Skip to content

Instantly share code, notes, and snippets.

@wk-j
Forked from jpotts/addSecondaryType.java
Created November 8, 2015 06:16
Show Gist options
  • Save wk-j/8a18f8e0ac3765535e4e to your computer and use it in GitHub Desktop.
Save wk-j/8a18f8e0ac3765535e4e 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());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment