Search code examples
alfrescocmis

Issues in setting secondary properties to a document using cmis 1.1


I am trying to add the secondary properties (title,description) programmatically to a document in Alfresco using CMIS 1.1.

code snippet:

properties.put(PropertyIds.NAME, fileName);
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document,P:cm:titled"); 
properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, "P:cm:titled");
properties.put("cm:title", "test title");
properties.put("cm:description", "description of document");

The code results in successful upload of the document to the Alfresco site without any issues,but the title and description are empty in Alfresco UI.

I also tried setting the tags to a document as well. Tags were also empty in alfresco site.

The code snippet

document = parentFolder.createDocument(properties, contentStream, null);
AlfrescoDocument alfDoc = (AlfrescoDocument) document;
Map<String, Object> properties1 = new HashMap<String, Object>();
List<String> tags = new ArrayList<String>();
tags.add("cmisTag");
tags.add("testTag");
properties1.put("cm:taggable",tags);
alfDoc.updateProperties(properties1);

Solution

  • On first look I thought it might be that you are setting your secondary object type IDs property to a single value instead of an array, but then I looked at my gist on this and I am also using a String instead of an array of Strings.

    Now I notice that you are using AlfrescoDocument which means you are using the OpenCMIS Extension. If you are using CMIS 1.1 you do NOT want to use the OpenCMIS extension. Just use the regular OpenCMIS library without it. Use Document instead of AlfrescoDocument.