Last active
January 16, 2024 10:45
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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....