Select all properties of a cmis type

474 Views Asked by At

I'd like to list all properties attached to a cmis object such as cmis:document. The idea is to return properties name, id, description just like it is done in opencmis-workbench

enter image description here

Any idea I could get the same result?

UPDATE: Thanks to @Florian Müller, I found a solution:

String myType = "cmis:document";
ObjectType type = session.getTypeDefinition(myType);
Map<String, PropertyDefinition<?>> propertyDefinitions = type.getPropertyDefinitions();
propertyDefinitions.each { name, value ->
    println "name = ${name}, value = ${value.getDisplayName()}"
}
1

There are 1 best solutions below

4
On

Here is a simple code sample:

Document doc = ...
ObjectType type = doc.getType();

for(String propId: type.getPropertyDefinitions().keySet()) {
    System.out.println(propId + ": " + doc.getPropertyValue(propId));
}

It only covers the primary type. If you want all properties, you have to iterate over secondary types as well.