2013-07-26 68 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,這可能無法正常工作,但大多數最新的安裝都可以使用。

相關問題