无法通过 CMIS 在存储库中创建文件夹
Unable to create folder in repositry through CMIS
我是新手,正在尝试在存储库中创建文件夹,但它向我展示了一些 exception.Help 提前感谢。
这是我的代码
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 中的异常:冲突
在 org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:482)
在 org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.post(AbstractAtomPubService.java:629)
在 org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImpl.createFolder(ObjectServiceImpl.java:158)
在 org.apache.chemistry.opencmis.client.runtime.SessionImpl.createFolder(SessionImpl.java:814)
在 org.apache.chemistry.opencmis.client.runtime.FolderImpl.createFolder(FolderImpl.java:136)
在 org.apache.chemistry.opencmis.client.runtime.FolderImpl.createFolder(FolderImpl.java:479)
在 com.reva.test.main(test.java:55)
根文件夹的路径是 /
,您正在向其中添加 /folderName
。因此,您发送到服务器的最终路径是 //folderName
,这是一个无效路径。
使用方法getObjectByPath(String parentPath, String name)
进行保存路径连接。
我是新手,正在尝试在存储库中创建文件夹,但它向我展示了一些 exception.Help 提前感谢。
这是我的代码
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 中的异常:冲突 在 org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:482) 在 org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.post(AbstractAtomPubService.java:629) 在 org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImpl.createFolder(ObjectServiceImpl.java:158) 在 org.apache.chemistry.opencmis.client.runtime.SessionImpl.createFolder(SessionImpl.java:814) 在 org.apache.chemistry.opencmis.client.runtime.FolderImpl.createFolder(FolderImpl.java:136) 在 org.apache.chemistry.opencmis.client.runtime.FolderImpl.createFolder(FolderImpl.java:479) 在 com.reva.test.main(test.java:55)
根文件夹的路径是 /
,您正在向其中添加 /folderName
。因此,您发送到服务器的最终路径是 //folderName
,这是一个无效路径。
使用方法getObjectByPath(String parentPath, String name)
进行保存路径连接。