@Override
public TypeDefinition getTypeDefinitionForObject(String objectId) {
TypeDefinition type = objectToTypeDefinitions.get(objectId);
if (type == null) {
ObjectData obj = service.getObject(repositoryId, objectId,
"cmis:objectId,cmis:objectTypeId,cmis:baseTypeId,cmis:secondaryObjectTypeIds", false,
IncludeRelationships.NONE, "cmis:none", false, false, null);
if (obj != null && obj.getProperties() != null) {
PropertyData<?> typeProp = obj.getProperties().getProperties().get(PropertyIds.OBJECT_TYPE_ID);
if (typeProp instanceof PropertyId) {
String typeId = ((PropertyId) typeProp).getFirstValue();
if (typeId != null) {
type = getTypeDefinition(typeId);
}
}
PropertyData<?> secTypeProp = obj.getProperties().getProperties()
.get(PropertyIds.SECONDARY_OBJECT_TYPE_IDS);
if ((secTypeProp instanceof PropertyId) && (secTypeProp.getValues() != null)) {
for (String secTypeId : ((PropertyId) secTypeProp).getValues()) {
if (secTypeId != null) {
getTypeDefinition(secTypeId);
}
}
}
}
objectToTypeDefinitions.put(objectId, type);
}
return type;
}