Getting Extensions

CMIS 1.0 CMIS 1.1

OpenCMIS (Java)

CmisObject cmisObject = ...
String extensionValue = null;

// extensions can be attached to different levels
// in this example we get the extensions on the properties level
List<CmisExtensionElement> extensions = cmisObject.getExtensions(ExtensionLevel.PROPERTIES);

if (extensions != null) {
    // iterate through the extensions until we find the one we are looking for
    for (CmisExtensionElement ext: extensions) {
        if ("myExtension".equals(ext.getName())) {
            extensionValue = ext.getValue();
            break;
        }
    }
}

PortCMIS (C#)

ICmisObject cmisObject = ...
string extensionValue = null;

// extensions can be attached to different levels
// in this example we get the extensions on the properties level
IList<ICmisExtensionElement> extensions = cmisObject.GetExtensions(ExtensionLevel.Properties);

if (extensions != null) {
    // iterate through the extensions until we find the one we are looking for
    try {
        extensionValue = extensions.First(ext => ext.Name == "myExtension").Value;
    } catch (InvalidOperationException) {
        // not found
    }
}