AnsweredAssumed Answered

Get hold of aspect properties with OpenCMIS

Question asked by fmui Employee on Oct 22, 2010
Latest reply on Oct 25, 2010 by fmui
At DevCon in Paris we have been asked how aspects can be access through OpenCMIS. Here is a code snippet. Please note that this requires OpenCMIS 0.2.x.


CmisObject object = …

List<CmisExtensionElement> extensions = object.getExtensions(ExtensionLevel.PROPERTIES);

if(extensions != null && !extensions.isEmpty()) {
    List<CmisExtensionElement> alfrescoExtensions = extensions.get(0).getChildren();

    // applied aspects
    for(CmisExtensionElement extension: alfrescoExtensions) {
        if(extension.getName().equals("appliedAspects")) {
            String aspect = extension.getValue().substring(2);
           
            System.out.println(aspect);
        }
    }
   
    // aspect properties
    for(CmisExtensionElement extension: alfrescoExtensions) {
        if(extension.getName().equals("properties")) {
            for(CmisExtensionElement property: extension.getChildren()) {
                String id = property.getAttributes().get("propertyDefinitionId");
               
                List<String> values = new ArrayList();
                for(CmisExtensionElement propertyValues: property.getChildren()) {
                    values.add(propertyValues.getValue());
                }
               
                System.out.println(id + " = " + values);
            }
        }
    }
}


Florian

Outcomes