打开无法通过 CMIS 在存储库中创建文件夹



我是新手,并尝试在存储库中创建文件夹,但它显示一些异常。提前帮我解决这个问题。

这是我的代码

SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
Map<String, String> parameter = new HashMap<String, String>();
// ECM user credentials
parameter.put(SessionParameter.USER, "User");
parameter.put(SessionParameter.PASSWORD, "password");
parameter.put(SessionParameter.ATOMPUB_URL, "URL");
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
// Get a list of repositories retrieved by the atompub CMIS endpoint (for Alfresco there is only one element)
List<Repository> repositories = sessionFactory.getRepositories(parameter);
// Create CMIS session to the repository
Session session = repositories.get(0).createSession();
System.out.println("Root Folder Name: "+session.getRepositoryInfo().getRootFolderId());
Folder subFolder = null;
Folder parentFolder = session.getRootFolder();
try {
subFolder = (Folder) session.getObjectByPath(parentFolder.getPath() + "/" + "folderName");
System.out.println("Folder already existed!");
} catch (CmisObjectNotFoundException onfe) {
Map props = new HashMap();
props.put("cmis:objectTypeId",  "cmis:folder");
props.put("cmis:name", "folderName");
subFolder = parentFolder.createFolder(props);
String subFolderId = subFolder.getId();
System.out.println("Created new folder: " + subFolderId);
}

收到此错误----- 线程"main"中的异常 org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException: Conflict at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:482) at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.post(AbstractAtomPubService.java:629) at org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImpl.createFolder(ObjectServiceImpl.java:158) at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createFolder(SessionImpl.java:814) at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createFolder(FolderImpl.java:136) at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createFolder(FolderImpl.java:479) at com.reva.test.main(test.java:55)

根文件夹的路径/,您正在向其添加/folderName。因此,您发送到服务器的最终路径是//folderName,这是一个无效的路径。

使用方法getObjectByPath(String parentPath, String name)进行保存路径串联。

相关内容

  • 没有找到相关文章

最新更新