2013-07-26 67 views
2

我有一个存储库,并且通过露天网站,我可以在存储库中创建文件夹时设置名称,标题和说明。但是,如果我尝试通过opencmis java创建相同的错误,则会出现错误“Property'cmis:title'对此类型或其中一种辅助类型无效!”如何在社区Alfresco中设置标题和描述?

这里是我的代码:

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:说明”,但也不起作用。

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

+0

此代码基于GettingStarted.java示例代码,位于http://chemistry.apache.org/java/developing/guide.html#getting-started-with-opencmis – user2624246

回答

3

这两个特定属性是在称为cm:标题的方面定义的。 CMIS本质上不支持这些方面。为了处理方面中定义的方面和属性,您必须使用Alfresco OpenCMIS Extension

我创建了一个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"); 

休息的物业的工作,因为你有他们,但要注意属性名称是厘米:描述和厘米:标题:

properties.put(PropertyIds.NAME, folderName); 
properties.put("cm:description", TEST_DESCRIPTION); 
properties.put("cm:title", TEST_TITLE); 
+0

如果您使用的是Alfresco版本支持CMIS 1.1,您不使用Alfresco对象工厂,而是使用CMIS对方面的本地支持,称为辅助对象类型。查看其他答案的例子。 –

1

您不再需要使用自定义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,这可能无法正常工作,但大多数最新的安装都可以使用。

相关问题