本文整理汇总了Java中org.apache.chemistry.opencmis.client.api.Session.getObjectByPath方法的典型用法代码示例。如果您正苦于以下问题:Java Session.getObjectByPath方法的具体用法?Java Session.getObjectByPath怎么用?Java Session.getObjectByPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.chemistry.opencmis.client.api.Session
的用法示例。
在下文中一共展示了Session.getObjectByPath方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateDescriptorFile
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
@Override
public void updateDescriptorFile(String tenantId, String uuid, CMISEvidenceFile cmisFile) {
Session session = createSession();
Folder multitenantRootFolder = (Folder) session.getObjectByPath("/" + tenantId);
Folder uuidFolder = getUuidFolder(session, uuid, multitenantRootFolder, repoFolderNestingLevels, true);
for (CmisObject cmisObject : uuidFolder.getChildren()) {
if (cmisObject.getType().getId().equals(CMISEvidenceFile.PROPERTY_DOC_ID)) {
Document doc = (Document) cmisObject;
if (doc.getName().equals(cmisFile.getFileName())) {
Map<String, String> newDocProps = new HashMap<String, String>();
newDocProps.put(CMISEvidenceFile.PROPERTY_TRANSACTION_STATUS, cmisFile.getTransactionStatus());
doc.updateProperties(newDocProps);
// Recover mime type from stored content
ContentStream contentStream = new ContentStreamImpl(cmisFile.getFileName(), null, doc.getContentStreamMimeType(), cmisFile.getInputStream());
doc.setContentStream(contentStream, true);
} else {
log.warn("Found unexpected CMIS object type in descriptor folder: " + cmisObject.getName() + " - " + cmisObject.getType().getId() +
" (expected " + cmisFile.getFileName() + ")");
}
}
}
}
示例2: getContentFiles
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
@Override
public List<CMISFile> getContentFiles(String uuid) {
Session session = createSession();
Folder multitenantRootFolder = (Folder) session.getObjectByPath("/" + multiTenantContextResolver.resolveCurrentTenantIdentifier());
Folder uuidFolder = getUuidFolder(session, uuid, multitenantRootFolder, repoFolderNestingLevels, false);
Folder contentsFolder = getFolderByPath(session, CONTENT_FOLDER_NAME, uuidFolder, true);
List<CMISFile> cmisFiles = new ArrayList<CMISFile>();
for (CmisObject cmisObject : contentsFolder.getChildren()) {
if (cmisObject.getType().isBaseType() && cmisObject.getType().getId().equals(CMIS_DOCUMENT)) {
Document doc = (Document) cmisObject;
CMISFileImpl file = new CMISFileImpl();
file.setFileName(doc.getName());
file.setMimeType(doc.getContentStreamMimeType());
file.setInputStream(doc.getContentStream().getStream());
cmisFiles.add(file);
} else {
log.warn("Found unexpected CMIS object type in contents folder: " + cmisObject.getName() + " - " +cmisObject.getType().getId());
}
}
return cmisFiles;
}
示例3: getCmisObjectByPath
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
public static CmisObject getCmisObjectByPath(final Session session,
final String path, final OperationContext context,
final String what) throws TheBlendException {
if (session == null) {
throw new IllegalArgumentException("Session must be set!");
}
if (path == null || !path.startsWith("/")) {
throw new TheBlendException("Invalid path to " + what + "!");
}
OperationContext oc = context;
if (oc == null) {
oc = session.getDefaultContext();
}
try {
return session.getObjectByPath(path, oc);
} catch (CmisObjectNotFoundException onfe) {
throw new TheBlendException("The " + what + " does not exist!",
onfe);
} catch (CmisBaseException cbe) {
throw new TheBlendException("Could not retrieve the " + what
+ ":" + cbe.getMessage(), cbe);
}
}
示例4: removePurgeableResources
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
@Override
// Asynchronous invocation - tenant and uuid required (!)
public void removePurgeableResources(String tenantId, String uuid) {
Session session = createSession();
Folder multitenantRootFolder = (Folder) session.getObjectByPath("/" + tenantId);
Folder uuidFolder = getPurgableUuidFolder(session, uuid, multitenantRootFolder, repoFolderNestingLevels, false);
uuidFolder.deleteTree(true, UnfileObject.DELETE, false);
}
示例5: removeResource
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
@Override
public void removeResource(String uuid) {
Session session = createSession();
Folder multitenantRootFolder = (Folder) session.getObjectByPath("/" + multiTenantContextResolver.resolveCurrentTenantIdentifier());
Folder uuidFolder = getUuidFolder(session, uuid, multitenantRootFolder, repoFolderNestingLevels, false);
uuidFolder.deleteTree(true, UnfileObject.DELETE, false);
}
示例6: getDescriptorFile
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
@Override
// Asynchronous invocation - tenant and uuid required (!)
public CMISEvidenceFile getDescriptorFile(String tenantId, String uuid, String descriptorFileName) {
Session session = createSession();
Folder multitenantRootFolder = (Folder) session.getObjectByPath("/" + tenantId);
return getDescriptorFile(multitenantRootFolder, session, uuid, descriptorFileName);
}
示例7: updateMimeTypeOnPurgeable
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
@Override
public void updateMimeTypeOnPurgeable(CMISFile cmisFile, String mimeType) {
Session session = createSession();
Folder multitenantRootFolder = getMultitenantRootFolder(session, true);
Folder uuidFolder = getPurgableUuidFolder(session, sessionResolver.resolveCurrentSessionIdentifier(), multitenantRootFolder, repoFolderNestingLevels, true);
Folder contentsFolder = getFolderByPath(session, CONTENT_FOLDER_NAME, uuidFolder, true);
Document document = (Document) session.getObjectByPath ("/" + contentsFolder.getPath() + "/" + cmisFile.getFileName());
Map<String, String> newDocProps = new HashMap<String, String>();
newDocProps.put(PropertyIds.CONTENT_STREAM_MIME_TYPE, mimeType);
document.updateProperties(newDocProps);
}
示例8: getSiteRoot
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
public static AlfrescoFolder getSiteRoot(Session session, String siteName)
{
String docLibPath = "/sites/" + siteName + "/documentLibrary";
CmisObject folder = session.getObjectByPath(docLibPath);
if (!(folder instanceof AlfrescoFolder))
{
throw new RuntimeException("Unable to get site root for site '" + siteName + "'");
}
return (AlfrescoFolder)folder;
}
示例9: createApplicationRootFolder
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
/**
* Gets the application root folder and if it doesn't exist, creates
* it.
*/
protected Folder createApplicationRootFolder(Session session,
String path) {
try {
// get the folder
return (Folder) session.getObjectByPath(path,
CMISHelper.LIGHT_OPERATION_CONTEXT);
} catch (CmisObjectNotFoundException nfe) {
// folder doesn't exist -> create it
int x = path.lastIndexOf('/');
Folder parent = null;
if (x == 0) {
parent = session.getRootFolder();
} else {
parent = createApplicationRootFolder(session,
path.substring(0, x));
}
// create folder
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
properties.put(PropertyIds.NAME, path.substring(x + 1));
return parent.createFolder(properties, null, null, null,
CMISHelper.LIGHT_OPERATION_CONTEXT);
}
}
示例10: doInBackground
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
@Override
protected String doInBackground(Void... arg0) {
// Initiates a Session Factory
SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
// Initiates connection session parameters.
Map<String, String> parameter = new HashMap<String, String>();
parameter.put(SessionParameter.USER, "admin");
parameter.put(SessionParameter.PASSWORD, "admin");
parameter.put(SessionParameter.ATOMPUB_URL, "http://192.168.1.36:8081/inmemory/atom/");
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
// Retrieves repository information and create the session object.
Repository repository = sessionFactory.getRepositories(parameter).get(0);
parameter.put(SessionParameter.REPOSITORY_ID, repository.getId());
Session session = sessionFactory.createSession(parameter);
// Retrieves media folder and list all this children.
String listChildren = "";
Folder mediaFolder = (Folder) session.getObjectByPath("/media");
ItemIterable<CmisObject> children = mediaFolder.getChildren();
for (CmisObject o : children) {
listChildren += o.getName() + " - " + o.getType().getDisplayName() + " - " + o.getCreatedBy() + "\b\n";
}
return listChildren;
}
示例11: run
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
@Override
public void run()
{
Session session = getSession(""+id+id+id, ""+id+id+id);
CmisObject object = session.getObjectByPath(path);
Map<String, Object> baseProps = new HashMap<String, Object>();
baseProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
baseProps.put(PropertyIds.NAME, "Thread"+id);
ObjectId base = session.createFolder(baseProps, object);
for(int i = 0; i < 100; i++)
{
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
properties.put(PropertyIds.NAME, "Folder-"+i);
ObjectId folder = session.createFolder(properties, base);
System.out.println("Thread "+id +" @Folder "+i);
for(int j = 0; j < 1000; j++)
{
Map<String, Object> folderProps = new HashMap<String, Object>();
folderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
folderProps.put(PropertyIds.NAME, "Folder-"+i);
ObjectId child = session.createFolder(folderProps, folder);
// Map<String, Object> docProps = new HashMap<String, Object>();
// docProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
// docProps.put(PropertyIds.NAME, "Doc-"+j);
//
// ContentStreamImpl contentSream = new ContentStreamImpl();
// contentSream.setFileName(GUID.generate());
// contentSream.setLength(BigInteger.valueOf(10));
// contentSream.setMimeType("text/plain");
// contentSream.setStream(new StringInputStream("abcdefghij"));
//
// ObjectId document = session.createDocument(docProps, folder, contentSream, VersioningState.MAJOR);
if(j % 20 == 0)
{
System.out.println(id+" @ "+j);
}
}
}
}