cancel
Showing results for 
Search instead for 
Did you mean: 

How to set metadata using OpenCMIS createDocument ?

invantix
Champ in-the-making
Champ in-the-making
The document I am creating is actually a datalist item which has no content and only metadata.  I can create the item but I am not sure how to set the metadata.  I get an error when I try.


Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.NAME, name);
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:mc:maintChit");

//*****************************************************         
properties.put("cm:description",description);
//*****************************************************         
         
ObjectId docId = session.createDocument(properties,   
   session.createObjectId("workspace://SpacesStore/8097bc61-da49-4f2f-aee2-1ecefc58977e"),       
   null,
   VersioningState.MAJOR);


When I add the line properties.put("cm:description",description);  I get this error:


java.lang.IllegalArgumentException: Property 'cm:description' 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.createDocument(SessionImpl.java:716)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createDocument(SessionImpl.java:819)

Thanks in advance to anyone who knows how to set metadata properties in OpenCmis.
1 REPLY 1

invantix
Champ in-the-making
Champ in-the-making
OK I figured this out.  For those who might find this post in a search here is how it works.  In order to set the description the object has to have the "titled" aspect.  I was not setting that correctly. I needed to add P:cm:titled to the OBJECT_TYPE_ID property.


It turns out the OBJECT_TYPE_ID  can be set with a comma delimited list that starts with the object type and includes any aspects

properties.put(PropertyIds.OBJECT_TYPE_ID, "D:mc:maintChit,P:cm:titled");



Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.NAME, name);
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:mc:maintChit,P:cm:titled");
properties.put("cm:description",description);

ObjectId docId = session.createDocument(properties,   
   session.createObjectId("workspace://SpacesStore/8097bc61-da49-4f2f-aee2-1ecefc58977e"),       
   null,
   VersioningState.MAJOR);

That was all that was missing…