Skip to content

Instantly share code, notes, and snippets.

@jpotts
Last active January 16, 2024 10:45
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jpotts/7242070 to your computer and use it in GitHub Desktop.
Save jpotts/7242070 to your computer and use it in GitHub Desktop.
Adding an aspect (known in CMIS 1.1 as a "secondary type") by modifying cmis:secondaryObjectTypeIds. This requires that you connect using the CMIS 1.1 service URL. You do not need the Alfresco OpenCMIS Extension when using this approach. Works with Alfresco 4.2.e Community Edition and higher.
List<Object> aspects = doc.getProperty("cmis:secondaryObjectTypeIds").getValues();
if (!aspects.contains("P:cm:geographic")) {
aspects.add("P:cm:geographic");
HashMap<String, Object> props = new HashMap<String, Object>();
props.put("cmis:secondaryObjectTypeIds", aspects);
doc.updateProperties(props);
System.out.println("Added aspect");
} else {
System.out.println("Doc already had aspect");
}
HashMap<String, Object> props = new HashMap<String, Object>();
props.put("cm:latitude", 52.513871);
props.put("cm:longitude", 13.391106);
doc.updateProperties(props);
System.out.println("Latitude: " + doc.getProperty("cm:latitude").getValueAsString());
System.out.println("Longitude: " + doc.getProperty("cm:longitude").getValueAsString());
@aakashkumar2589
Copy link

what is this doc you are referring to ??
If possible please include some more lines

@nettree
Copy link

nettree commented Apr 6, 2016

This is about how to add a secondary aspect to your created alfresco document and update property of that aspect via cmis. Sometimes you may want to update the property of a secondary type (aspect) attached to a document, but these aspects may not be attached by default after you invoke the cmis API to create alfresco document, for example, the P:cm:titled, is a secondary type for a document, if you want to modify the title of the document after creation of document, you have to manually add the P:cm:titled to the cmis:secondaryObjectTypeIds, and then update the cm:title, otherwise you will receive the error saying that the cm:title is not a valid property something....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment