3

我有一个存储库,通过 alfresco 网站,我可以在存储库中创建文件夹时设置名称、标题和描述。

但是,如果我尝试通过 opencmis java 创建相同的内容,我会收到错误消息“Property 'cmis:title' 对于这种类型或次要类型之一无效!”

这是我的代码:

Map<String, String> newFolderProps = new HashMap<String, String>();
newFolderProps.put(PropertyIds.NAME, "this is my new folder");
newFolderProps.put("cmis:description", "this is my description");  //this doesn't work.
newFolderProps.put("cmis:title", "this is my title"); //this doesn't work.

//I also tried this too:

newFolderProps.put(PropertyIds.DESCRIPTION, "this is my description");  //this doesn't work either.
newFolderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");  //this works!
Folder newFolderObject=rootfolder.createFolder(newFolderProps);

我也尝试过“cm:description”,但这也不起作用。

在 Alfresco 中创建新文件夹时如何设置标题和描述?

4

2 回答 2

3

这两个特定属性在称为 cm:titled 的方面中定义。CMIS 本身不支持方面。为了使用在方面中定义的方面和属性,您必须使用Alfresco OpenCMIS 扩展

我创建了一个gist,它是一个可以编译和运行的工作类,它将创建一个文件夹(如果它不存在),设置描述和标题,然后在该文件夹中创建一个文档并设置描述和标题在上面。

关键位是您使用 Alfresco 对象工厂建立会话的位置:

parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");

然后在指定类型时,还必须指定方面:

properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder, P:cm:titled");

其余属性的工作方式与您的一样,但请注意 cm:description 和 cm:title 的属性名称:

properties.put(PropertyIds.NAME, folderName);
properties.put("cm:description", TEST_DESCRIPTION);
properties.put("cm:title", TEST_TITLE);
于 2013-08-02T00:59:27.423 回答
2

您不再需要使用自定义 Alfresco 类来设置辅助属性。使用 Apache Chemistry CMIS 1.1.0 客户端;

Map<String, Object> props = new HashMap<>();
props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
props.put(PropertyIds.NAME, "my-doc.txt");
List<String> secondary = new ArrayList<>();
secondary.add("P:cm:titled");
props.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondary);
props.put("cm:title", "My Very Fancy Document");
props.put("cm:description", "This document was generated by me!");

无需进一步更改代码。如果您使用的是较旧的 Alfresco,这可能无法正常工作,但大多数当前安装都可以开箱即用。

于 2017-05-11T15:07:52.123 回答