cancel
Showing results for 
Search instead for 
Did you mean: 

CMIS - Create a new list inside a Site

dmralfing
Champ in-the-making
Champ in-the-making
Somebody knows what I´m doing wrong in this function?.

    public void createListInsideSite ()
    {
       Map<String, Object> props = new HashMap<String, Object>();
       props.put(PropertyIds.OBJECT_TYPE_ID, "F:dl:dataList");
       props.put("dl:dataListItemType", "dl:eventAgenda");
       props.put("cm:title", "HELLO");
       AlfrescoFolder fold=(AlfrescoFolder)(Folder)session.getObjectByPath("/Sites/mysite/dataLists");
       session.createFolder(props,fold);

}//void

This is the exception:

Exception in thread "main" java.lang.IllegalArgumentException: Property 'cm:title' is neither an object type property nor an aspect property!
   at org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl.convertProperties(AlfrescoObjectFactoryImpl.java:181)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createFolder(SessionImpl.java:769)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createFolder(SessionImpl.java:828)
   at otro.cmis.Controller.crearListaSitio2(Controller.java:199)
   at pruebas.cmis.Main.crearListaSitio(Main.java:29)
   at pruebas.cmis.Main.main(Main.java:23)

I have tryed also setting the object type id like this:
newDocProps.put(PropertyIds.OBJECT_TYPE_ID, "F:dl:dataList,P:cm:titled");
..but it doesn´t work anyway..
Thank you so much!
4 REPLIES 4

jpotts
World-Class Innovator
World-Class Innovator
I am not sure why you are trying to set a title on the data list folder. You can do it, but I don't think it displays anywhere. Perhaps you instead need to set the cmis:name property?

When I run this code against 4.2.d Community Edition using OpenCMIS 0.10.0 it works fine:


Map<String, Object> props = new HashMap<String, Object>();
   
props.put(PropertyIds.OBJECT_TYPE_ID, "F:dl:dataList,P:cm:titled");
   
props.put("dl:dataListItemType", "dl:eventAgenda");
props.put("cmis:name", "Test CMIS Data List");
props.put("cm:title", "HELLO");
   
AlfrescoFolder fold=(AlfrescoFolder)session.getObjectByPath("/Sites/test-site-1/dataLists");
   
session.createFolder(props,fold);


The difference between mine and yours is that I am setting the cmis:name and I am not doing a double typecast (I removed the cast to Folder).

Jeff

dobrolub
Champ in-the-making
Champ in-the-making
Hi, your code is working for me and data list is created. But only if I manually add DataLists from Customize site / Add DataLists from Available site pages (If i dont do this, cmis will throw error "Datalists" not found). Then DataLists folder is created and I can add new data lists like contacts and so on.
Is it somehow possible to create "DataLists" folder via CMIS ?

Thank you very much.

Lubomir

jpotts
World-Class Innovator
World-Class Innovator
If you go into the Node Browser in Share and navigate to the dataLists folder, you'll see that it is just an instance of cm:folder with several aspects applied. The two that are the most important to data lists are: st:siteContainer and cm:titled. So you should be okay if you create an instance of cm:folder, add those aspects, and set the following properties:

st:componentId : "dataLists"
cm:name : "dataLists"
cm:description : "Data Lists"

Jeff

dmralfing
Champ in-the-making
Champ in-the-making
I´m trying to put it because I think it is a compulsory attribute for this kind of element: If you go to Alfresco Share, you go to any site and you create a new list, I see in the interface that it has the * symbol that indicates you must fill the title.
  Anyway, I don´t know what I did wrong last time, I have tryed now and it works fine, thank you so much Jeff!