Refactor CMIS Dictionary part 2

- further simplification of CMISDictionaryService and fixup fallout
- added logging
- consolidate & fix property definition handling (only one definition per property)
- include support for aspect properties
- fix property.isInherited
- open up the door for types outside of CMIS doc, folder, rel & policy

Dictionary Service
- add isOverride() to PropertyDefinition

Invite Workflows
- ensure they create their own namespace for new types/props
- NOTE: the previous way uses a hole in the DictinaryService which has been there
        unnoticed for over 4 years, till now. At some point, the hole will be filled in.
        
Tests pass for CMIS REST / Web Services and Query.
Tests pass for Invitation Service.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13786 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2009-03-31 17:48:28 +00:00
parent 16b4fc701f
commit dbec12a9c7
8 changed files with 34 additions and 51 deletions

View File

@@ -388,8 +388,9 @@
<cmis:controllable>${typedef.controllable?string}</cmis:controllable> <cmis:controllable>${typedef.controllable?string}</cmis:controllable>
<cmis:includedInSupertypeQuery>${typedef.includeInSuperTypeQuery?string}</cmis:includedInSupertypeQuery> <cmis:includedInSupertypeQuery>${typedef.includeInSuperTypeQuery?string}</cmis:includedInSupertypeQuery>
[#if includeProperties] [#if includeProperties]
[#assign ownedprops = typedef.ownedPropertyDefinitions?keys]
[#list typedef.propertyDefinitions?values as propdef] [#list typedef.propertyDefinitions?values as propdef]
[#assign inherited = (propdef.owningType != typedef)] [#assign inherited = !ownedprops?seq_contains(propdef.propertyId)]
[#if includeInheritedProperties || !inherited] [#if includeInheritedProperties || !inherited]
[@propdefCMISProps propdef inherited/] [@propdefCMISProps propdef inherited/]
[/#if] [/#if]

View File

@@ -389,8 +389,7 @@ public class CMISScript extends BaseScopableProcessorExtension
{ {
try try
{ {
CMISTypeId cmisTypeId = cmisDictionaryService.getTypeId(typeId); return cmisDictionaryService.findType(typeId);
return cmisDictionaryService.getType(cmisTypeId);
} }
catch(AlfrescoRuntimeException e) catch(AlfrescoRuntimeException e)
{ {
@@ -409,8 +408,7 @@ public class CMISScript extends BaseScopableProcessorExtension
try try
{ {
QName typeQName = node.getQNameType(); QName typeQName = node.getQNameType();
CMISTypeId cmisTypeId = cmisDictionaryService.getTypeId(typeQName, null); return cmisDictionaryService.findTypeForClass(typeQName);
return cmisDictionaryService.getType(cmisTypeId);
} }
catch(AlfrescoRuntimeException e) catch(AlfrescoRuntimeException e)
{ {

View File

@@ -28,7 +28,6 @@ import java.util.List;
import org.alfresco.cmis.dictionary.CMISDictionaryService; import org.alfresco.cmis.dictionary.CMISDictionaryService;
import org.alfresco.cmis.dictionary.CMISTypeDefinition; import org.alfresco.cmis.dictionary.CMISTypeDefinition;
import org.alfresco.cmis.dictionary.CMISTypeId;
import org.alfresco.repo.template.TemplateNode; import org.alfresco.repo.template.TemplateNode;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
@@ -89,11 +88,7 @@ public class CMISTypeDefinitionMethod implements TemplateMethodModelEx
// convert to CMIS type // convert to CMIS type
if (nodeType != null) if (nodeType != null)
{ {
CMISTypeId typeId = dictionaryService.getTypeId(nodeType, null); result = dictionaryService.findTypeForClass(nodeType);
if (typeId != null)
{
result = dictionaryService.getType(typeId);
}
} }
} }
} }

View File

@@ -285,11 +285,11 @@ public class DMAbstractServicePort
protected CmisPropertiesType getPropertiesType(Map<String, Serializable> alfrescoProperties, PropertyFilter filter) protected CmisPropertiesType getPropertiesType(Map<String, Serializable> alfrescoProperties, PropertyFilter filter)
{ {
String objectTypeId = (String) alfrescoProperties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID); String objectTypeId = (String) alfrescoProperties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID);
CMISTypeId cmisTypeId = cmisDictionaryService.getTypeId(objectTypeId); CMISTypeDefinition cmisTypeDef = cmisDictionaryService.findType(objectTypeId);
CmisPropertiesType properties = new CmisPropertiesType(); CmisPropertiesType properties = new CmisPropertiesType();
if (cmisTypeId.getScope() == CMISScope.DOCUMENT) if (cmisTypeDef.getTypeId().getScope() == CMISScope.DOCUMENT)
{ {
addBooleanProperty(properties, filter, CMISDictionaryModel.PROP_IS_IMMUTABLE, alfrescoProperties); addBooleanProperty(properties, filter, CMISDictionaryModel.PROP_IS_IMMUTABLE, alfrescoProperties);
addBooleanProperty(properties, filter, CMISDictionaryModel.PROP_IS_LATEST_VERSION, alfrescoProperties); addBooleanProperty(properties, filter, CMISDictionaryModel.PROP_IS_LATEST_VERSION, alfrescoProperties);
@@ -314,7 +314,7 @@ public class DMAbstractServicePort
addStringProperty(properties, filter, CMISDictionaryModel.PROP_CHECKIN_COMMENT, alfrescoProperties); addStringProperty(properties, filter, CMISDictionaryModel.PROP_CHECKIN_COMMENT, alfrescoProperties);
addURIProperty(properties, filter, CMISDictionaryModel.PROP_CONTENT_STREAM_URI, alfrescoProperties); addURIProperty(properties, filter, CMISDictionaryModel.PROP_CONTENT_STREAM_URI, alfrescoProperties);
} }
else if (cmisTypeId.getScope() == CMISScope.FOLDER) else if (cmisTypeDef.getTypeId().getScope() == CMISScope.FOLDER)
{ {
addDateTimeProperty(properties, filter, CMISDictionaryModel.PROP_CREATION_DATE, alfrescoProperties); addDateTimeProperty(properties, filter, CMISDictionaryModel.PROP_CREATION_DATE, alfrescoProperties);
addDateTimeProperty(properties, filter, CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE, alfrescoProperties); addDateTimeProperty(properties, filter, CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE, alfrescoProperties);
@@ -326,7 +326,7 @@ public class DMAbstractServicePort
addStringProperty(properties, filter, CMISDictionaryModel.PROP_CREATED_BY, alfrescoProperties); addStringProperty(properties, filter, CMISDictionaryModel.PROP_CREATED_BY, alfrescoProperties);
addStringProperty(properties, filter, CMISDictionaryModel.PROP_LAST_MODIFIED_BY, alfrescoProperties); addStringProperty(properties, filter, CMISDictionaryModel.PROP_LAST_MODIFIED_BY, alfrescoProperties);
} }
else if (cmisTypeId.getScope() == CMISScope.RELATIONSHIP) else if (cmisTypeDef.getTypeId().getScope() == CMISScope.RELATIONSHIP)
{ {
addStringProperty(properties, filter, CMISDictionaryModel.PROP_OBJECT_TYPE_ID, alfrescoProperties); addStringProperty(properties, filter, CMISDictionaryModel.PROP_OBJECT_TYPE_ID, alfrescoProperties);
addIDProperty(properties, filter, CMISDictionaryModel.PROP_OBJECT_ID, alfrescoProperties); addIDProperty(properties, filter, CMISDictionaryModel.PROP_OBJECT_ID, alfrescoProperties);
@@ -343,7 +343,7 @@ public class DMAbstractServicePort
private Map<String, Serializable> createBaseRelationshipProperties(AssociationRef association) private Map<String, Serializable> createBaseRelationshipProperties(AssociationRef association)
{ {
Map<String, Serializable> result = new HashMap<String, Serializable>(); Map<String, Serializable> result = new HashMap<String, Serializable>();
result.put(CMISDictionaryModel.PROP_OBJECT_TYPE_ID, cmisDictionaryService.getTypeId(association.getTypeQName(), CMISScope.RELATIONSHIP)); result.put(CMISDictionaryModel.PROP_OBJECT_TYPE_ID, cmisDictionaryService.findTypeForClass(association.getTypeQName(), CMISScope.RELATIONSHIP).getTypeId());
result.put(CMISDictionaryModel.PROP_OBJECT_ID, association.toString()); result.put(CMISDictionaryModel.PROP_OBJECT_ID, association.toString());
result.put(BASE_TYPE_PROPERTY_NAME, CMISDictionaryModel.RELATIONSHIP_TYPE_ID.getId()); result.put(BASE_TYPE_PROPERTY_NAME, CMISDictionaryModel.RELATIONSHIP_TYPE_ID.getId());
result.put(CMISDictionaryModel.PROP_CREATED_BY, AuthenticationUtil.getFullyAuthenticatedUser()); result.put(CMISDictionaryModel.PROP_CREATED_BY, AuthenticationUtil.getFullyAuthenticatedUser());
@@ -624,24 +624,11 @@ public class DMAbstractServicePort
return checkOutCheckInService.checkout(documentNodeReference); return checkOutCheckInService.checkout(documentNodeReference);
} }
protected CMISTypeId getCmisTypeId(String typeId) throws InvalidArgumentException
{
try
{
return cmisDictionaryService.getTypeId(typeId);
}
catch (Exception e)
{
throw new InvalidArgumentException("Invalid typeId " + typeId);
}
}
protected CMISTypeDefinition getCmisTypeDefinition(String typeId) throws InvalidArgumentException protected CMISTypeDefinition getCmisTypeDefinition(String typeId) throws InvalidArgumentException
{ {
try try
{ {
CMISTypeId cmisTypeId = cmisDictionaryService.getTypeId(typeId); return cmisDictionaryService.findType(typeId);
return cmisDictionaryService.getType(cmisTypeId);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@@ -112,8 +112,8 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
checkRepositoryId(repositoryId); checkRepositoryId(repositoryId);
Map<String, Serializable> propertiesMap = getPropertiesMap(properties); Map<String, Serializable> propertiesMap = getPropertiesMap(properties);
CMISTypeId cmisTypeId = getCmisTypeId(typeId); CMISTypeDefinition typeDef = cmisDictionaryService.findType(typeId);
if (cmisTypeId.getScope() != CMISScope.DOCUMENT) if (typeDef.getTypeId().getScope() != CMISScope.DOCUMENT)
{ {
throw new ConstraintViolationException("Invalid document type " + typeId); throw new ConstraintViolationException("Invalid document type " + typeId);
} }
@@ -126,7 +126,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
throw new InvalidArgumentException("Name property not found"); throw new InvalidArgumentException("Name property not found");
} }
NodeRef newDocumentNodeRef = fileFolderService.create(parentNodeRef, documentName, cmisTypeId.getQName()).getNodeRef(); NodeRef newDocumentNodeRef = fileFolderService.create(parentNodeRef, documentName, typeDef.getTypeId().getQName()).getNodeRef();
ContentWriter writer = fileFolderService.getWriter(newDocumentNodeRef); ContentWriter writer = fileFolderService.getWriter(newDocumentNodeRef);
String mimeType = (String) propertiesMap.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE); String mimeType = (String) propertiesMap.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE);
if (mimeType != null) if (mimeType != null)
@@ -286,13 +286,13 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
throw e; throw e;
} }
CMISTypeId relationshipTypeId = getCmisTypeId(typeId); CMISTypeDefinition relationshipType = cmisDictionaryService.findType(typeId);
if (relationshipTypeId.getScope() != CMISScope.RELATIONSHIP) if (relationshipType == null || relationshipType.getTypeId().getScope() != CMISScope.RELATIONSHIP)
{ {
throw new TypeNotFoundException(typeId); throw new TypeNotFoundException(typeId);
} }
QName relationshipTypeQName = relationshipTypeId.getQName(); QName relationshipTypeQName = relationshipType.getTypeId().getQName();
AssociationDefinition associationDef = dictionaryService.getAssociation(relationshipTypeQName); AssociationDefinition associationDef = dictionaryService.getAssociation(relationshipTypeQName);
if (associationDef != null) if (associationDef != null)
{ {
@@ -310,7 +310,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
} }
else else
{ {
throw new TypeNotFoundException(relationshipTypeId.getQName() + " Relationship type not found"); throw new TypeNotFoundException(relationshipType.getTypeId().getQName() + " Relationship type not found");
} }
} }

View File

@@ -29,6 +29,7 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.alfresco.cmis.dictionary.CMISScope; import org.alfresco.cmis.dictionary.CMISScope;
import org.alfresco.cmis.dictionary.CMISTypeDefinition;
import org.alfresco.cmis.dictionary.CMISTypeId; import org.alfresco.cmis.dictionary.CMISTypeId;
import org.alfresco.repo.cmis.PropertyFilter; import org.alfresco.repo.cmis.PropertyFilter;
import org.alfresco.repo.cmis.ws.utils.AlfrescoObjectType; import org.alfresco.repo.cmis.ws.utils.AlfrescoObjectType;
@@ -83,8 +84,8 @@ public class DMRelationshipServicePort extends DMAbstractServicePort implements
BigInteger skipCount = ((parameters.getSkipCount() != null) && (parameters.getSkipCount().getValue() != null)) ? parameters.getSkipCount().getValue() : BigInteger.ZERO; BigInteger skipCount = ((parameters.getSkipCount() != null) && (parameters.getSkipCount().getValue() != null)) ? parameters.getSkipCount().getValue() : BigInteger.ZERO;
BigInteger maxItems = ((parameters.getMaxItems() != null) && (parameters.getMaxItems().getValue() != null)) ? parameters.getMaxItems().getValue() : BigInteger.ZERO; BigInteger maxItems = ((parameters.getMaxItems() != null) && (parameters.getMaxItems().getValue() != null)) ? parameters.getMaxItems().getValue() : BigInteger.ZERO;
CMISTypeId cmisTypeId = getCmisTypeId(typeId); CMISTypeDefinition cmisTypeDef = cmisDictionaryService.findType(typeId);
QName associationType = cmisTypeId.getQName(); QName associationType = cmisTypeDef.getTypeId().getQName();
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter()); PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
NodeRef objectNodeRef = (NodeRef) cmisObjectsUtils.getIdentifierInstance(parameters.getObjectId(), AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier(); NodeRef objectNodeRef = (NodeRef) cmisObjectsUtils.getIdentifierInstance(parameters.getObjectId(), AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier();
@@ -146,8 +147,8 @@ public class DMRelationshipServicePort extends DMAbstractServicePort implements
} }
else else
{ {
CMISTypeId typeId = cmisDictionaryService.getTypeId(qname, CMISScope.RELATIONSHIP); CMISTypeDefinition typeDef = cmisDictionaryService.findTypeForClass(qname, CMISScope.RELATIONSHIP);
return typeId != null && relationshipType.equals(qname); return typeDef != null && relationshipType.equals(qname);
} }
} }
} }

View File

@@ -289,7 +289,7 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
wsPropertyDef.setPropertyType(propertyTypeEnumMapping.get(propertyDefinition.getDataType())); wsPropertyDef.setPropertyType(propertyTypeEnumMapping.get(propertyDefinition.getDataType()));
wsPropertyDef.setCardinality(cardinalityEnumMapping.get(propertyDefinition.getCardinality())); wsPropertyDef.setCardinality(cardinalityEnumMapping.get(propertyDefinition.getCardinality()));
wsPropertyDef.setUpdateability(updatabilityEnumMapping.get(propertyDefinition.getUpdatability())); wsPropertyDef.setUpdateability(updatabilityEnumMapping.get(propertyDefinition.getUpdatability()));
wsPropertyDef.setInherited(propertyDefinition.getOwningType().equals(typeDefinition)); wsPropertyDef.setInherited(!typeDefinition.getOwnedPropertyDefinitions().containsKey(propertyDefinition.getPropertyId()));
wsPropertyDef.setRequired(propertyDefinition.isRequired()); wsPropertyDef.setRequired(propertyDefinition.isRequired());
wsPropertyDef.setQueryable(propertyDefinition.isQueryable()); wsPropertyDef.setQueryable(propertyDefinition.isQueryable());
wsPropertyDef.setOrderable(propertyDefinition.isOrderable()); wsPropertyDef.setOrderable(propertyDefinition.isOrderable());
@@ -410,7 +410,7 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
} }
else else
{ {
CMISTypeDefinition typeDef = cmisDictionaryService.getType(cmisDictionaryService.getTypeId(parameters.getTypeId().getValue())); CMISTypeDefinition typeDef = cmisDictionaryService.findType(parameters.getTypeId().getValue());
typeDefs = typeDef.getSubTypes(true); typeDefs = typeDef.getSubTypes(true);
} }
@@ -463,7 +463,7 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
checkRepositoryId(parameters.getRepositoryId()); checkRepositoryId(parameters.getRepositoryId());
GetTypeDefinitionResponse response = new GetTypeDefinitionResponse(); GetTypeDefinitionResponse response = new GetTypeDefinitionResponse();
CMISTypeDefinition typeDef = cmisDictionaryService.getType(cmisDictionaryService.getTypeId(parameters.getTypeId())); CMISTypeDefinition typeDef = cmisDictionaryService.findType(parameters.getTypeId());
response.setType(getCmisTypeDefinition(typeDef, true)); response.setType(getCmisTypeDefinition(typeDef, true));
return response; return response;
} }

View File

@@ -29,6 +29,7 @@ import java.util.List;
import org.alfresco.cmis.dictionary.CMISDictionaryService; import org.alfresco.cmis.dictionary.CMISDictionaryService;
import org.alfresco.cmis.dictionary.CMISScope; import org.alfresco.cmis.dictionary.CMISScope;
import org.alfresco.cmis.dictionary.CMISTypeDefinition;
import org.alfresco.cmis.dictionary.CMISTypeId; import org.alfresco.cmis.dictionary.CMISTypeId;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.cmis.ws.EnumObjectType; import org.alfresco.repo.cmis.ws.EnumObjectType;
@@ -219,8 +220,8 @@ public class CmisObjectsUtils
return false; return false;
} }
QName typeQName = nodeService.getType(folderNodeRef); QName typeQName = nodeService.getType(folderNodeRef);
CMISTypeId typeId = cmisDictionaryService.getTypeId(typeQName, CMISScope.FOLDER); CMISTypeDefinition typeDef = cmisDictionaryService.findTypeForClass(typeQName, CMISScope.FOLDER);
return typeId != null; return typeDef != null;
} }
public boolean isDocument(NodeRef documentNodeRef) public boolean isDocument(NodeRef documentNodeRef)
@@ -230,8 +231,8 @@ public class CmisObjectsUtils
return false; return false;
} }
QName typeQName = nodeService.getType(documentNodeRef); QName typeQName = nodeService.getType(documentNodeRef);
CMISTypeId typeId = cmisDictionaryService.getTypeId(typeQName, CMISScope.DOCUMENT); CMISTypeDefinition typeDef = cmisDictionaryService.findTypeForClass(typeQName, CMISScope.DOCUMENT);
return typeId != null; return typeDef != null;
} }
public boolean isRelationship(String identifier) public boolean isRelationship(String identifier)
@@ -363,14 +364,14 @@ public class CmisObjectsUtils
private AlfrescoObjectType determineActualObjectType(AlfrescoObjectType expectedType, QName objectType) private AlfrescoObjectType determineActualObjectType(AlfrescoObjectType expectedType, QName objectType)
{ {
CMISTypeId typeId = cmisDictionaryService.getTypeId(objectType, null); CMISTypeDefinition typeDef = cmisDictionaryService.findTypeForClass(objectType);
if ((expectedType == AlfrescoObjectType.DOCUMENT_OBJECT || expectedType == AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT) if ((expectedType == AlfrescoObjectType.DOCUMENT_OBJECT || expectedType == AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT)
&& typeId.getScope() == CMISScope.DOCUMENT) && typeDef.getTypeId().getScope() == CMISScope.DOCUMENT)
{ {
return expectedType; return expectedType;
} }
if ((expectedType == AlfrescoObjectType.FOLDER_OBJECT || expectedType == AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT) if ((expectedType == AlfrescoObjectType.FOLDER_OBJECT || expectedType == AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT)
&& typeId.getScope() == CMISScope.FOLDER) && typeDef.getTypeId().getScope() == CMISScope.FOLDER)
{ {
return expectedType; return expectedType;
} }