cancel
Showing results for 
Search instead for 
Did you mean: 

CMIS - Data List

baaka
Champ in-the-making
Champ in-the-making
Hello there,

Can anyone give me an example/reference, how to create data list item via CMIS from Java?

Thanks
2 REPLIES 2

cpaul
Champ on-the-rise
Champ on-the-rise
You can do this with the Alfresco OpenCMIS extensions like so:


Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:my:customDataListItem");
properties.put(PropertyIds.NAME, "my custom item name");
ObjectId newItemId = session.createItem(properties, dataListContainer);


The key to this is using the "D:…" qualifier on the data list item type name.

For more information on setting up and using the Alfresco OpenCMIS extension, see:
https://code.google.com/a/apache-extras.org/p/alfresco-opencmis-extension/

kaynezhang
World-Class Innovator
World-Class Innovator
If you are using existing data list type,you can skip step a) and e).
If you want to create your own custom data list types follow all steps:
a)   Define and deploy a custom content model for your new Data List type, making sure it inherits from dl:dataListItem.
b)   Get your site dataLists folder:
   
      
   AlfrescoFolder dataLists = (AlfrescoFolder) session.getObjectByPath("/sites/{site short name}/dataLists");
   

c)   Iterate dataLists's children to get dataList that you want to operate;
   

         java.util.Iterator<CmisObject> it = dataLists.getChildren().iterator();
         AlfrescoFolder dataList = null;
         while (it.hasNext()) {
            CmisObject obj = it.next();
            if(***){
               dataList = (AlfrescoFolder)obj;
            }
            System.out.println(obj.getName());
         }
   

d) add item as cpaul said
   

   Map<String, Object> properties = new HashMap<String, Object>();
   properties.put(PropertyIds.OBJECT_TYPE_ID, "D:item type");
   properties.put(PropertyIds.NAME, item name");
   ObjectId newItemId = session.createItem(properties, dataList);

e)   Configure the Alfresco Form Service in the Alfresco Share application to display your custom Data List.