mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -389,8 +389,7 @@ public class CMISScript extends BaseScopableProcessorExtension
|
||||
{
|
||||
try
|
||||
{
|
||||
CMISTypeId cmisTypeId = cmisDictionaryService.getTypeId(typeId);
|
||||
return cmisDictionaryService.getType(cmisTypeId);
|
||||
return cmisDictionaryService.findType(typeId);
|
||||
}
|
||||
catch(AlfrescoRuntimeException e)
|
||||
{
|
||||
@@ -409,8 +408,7 @@ public class CMISScript extends BaseScopableProcessorExtension
|
||||
try
|
||||
{
|
||||
QName typeQName = node.getQNameType();
|
||||
CMISTypeId cmisTypeId = cmisDictionaryService.getTypeId(typeQName, null);
|
||||
return cmisDictionaryService.getType(cmisTypeId);
|
||||
return cmisDictionaryService.findTypeForClass(typeQName);
|
||||
}
|
||||
catch(AlfrescoRuntimeException e)
|
||||
{
|
||||
|
@@ -28,7 +28,6 @@ import java.util.List;
|
||||
|
||||
import org.alfresco.cmis.dictionary.CMISDictionaryService;
|
||||
import org.alfresco.cmis.dictionary.CMISTypeDefinition;
|
||||
import org.alfresco.cmis.dictionary.CMISTypeId;
|
||||
import org.alfresco.repo.template.TemplateNode;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
@@ -89,11 +88,7 @@ public class CMISTypeDefinitionMethod implements TemplateMethodModelEx
|
||||
// convert to CMIS type
|
||||
if (nodeType != null)
|
||||
{
|
||||
CMISTypeId typeId = dictionaryService.getTypeId(nodeType, null);
|
||||
if (typeId != null)
|
||||
{
|
||||
result = dictionaryService.getType(typeId);
|
||||
}
|
||||
result = dictionaryService.findTypeForClass(nodeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -285,11 +285,11 @@ public class DMAbstractServicePort
|
||||
protected CmisPropertiesType getPropertiesType(Map<String, Serializable> alfrescoProperties, PropertyFilter filter)
|
||||
{
|
||||
String objectTypeId = (String) alfrescoProperties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID);
|
||||
CMISTypeId cmisTypeId = cmisDictionaryService.getTypeId(objectTypeId);
|
||||
CMISTypeDefinition cmisTypeDef = cmisDictionaryService.findType(objectTypeId);
|
||||
|
||||
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_LATEST_VERSION, alfrescoProperties);
|
||||
@@ -314,7 +314,7 @@ public class DMAbstractServicePort
|
||||
addStringProperty(properties, filter, CMISDictionaryModel.PROP_CHECKIN_COMMENT, 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_LAST_MODIFICATION_DATE, alfrescoProperties);
|
||||
@@ -326,7 +326,7 @@ public class DMAbstractServicePort
|
||||
addStringProperty(properties, filter, CMISDictionaryModel.PROP_CREATED_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);
|
||||
addIDProperty(properties, filter, CMISDictionaryModel.PROP_OBJECT_ID, alfrescoProperties);
|
||||
@@ -343,7 +343,7 @@ public class DMAbstractServicePort
|
||||
private Map<String, Serializable> createBaseRelationshipProperties(AssociationRef association)
|
||||
{
|
||||
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(BASE_TYPE_PROPERTY_NAME, CMISDictionaryModel.RELATIONSHIP_TYPE_ID.getId());
|
||||
result.put(CMISDictionaryModel.PROP_CREATED_BY, AuthenticationUtil.getFullyAuthenticatedUser());
|
||||
@@ -624,24 +624,11 @@ public class DMAbstractServicePort
|
||||
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
|
||||
{
|
||||
try
|
||||
{
|
||||
CMISTypeId cmisTypeId = cmisDictionaryService.getTypeId(typeId);
|
||||
return cmisDictionaryService.getType(cmisTypeId);
|
||||
return cmisDictionaryService.findType(typeId);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@@ -112,8 +112,8 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
Map<String, Serializable> propertiesMap = getPropertiesMap(properties);
|
||||
CMISTypeId cmisTypeId = getCmisTypeId(typeId);
|
||||
if (cmisTypeId.getScope() != CMISScope.DOCUMENT)
|
||||
CMISTypeDefinition typeDef = cmisDictionaryService.findType(typeId);
|
||||
if (typeDef.getTypeId().getScope() != CMISScope.DOCUMENT)
|
||||
{
|
||||
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");
|
||||
}
|
||||
|
||||
NodeRef newDocumentNodeRef = fileFolderService.create(parentNodeRef, documentName, cmisTypeId.getQName()).getNodeRef();
|
||||
NodeRef newDocumentNodeRef = fileFolderService.create(parentNodeRef, documentName, typeDef.getTypeId().getQName()).getNodeRef();
|
||||
ContentWriter writer = fileFolderService.getWriter(newDocumentNodeRef);
|
||||
String mimeType = (String) propertiesMap.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE);
|
||||
if (mimeType != null)
|
||||
@@ -286,13 +286,13 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
throw e;
|
||||
}
|
||||
|
||||
CMISTypeId relationshipTypeId = getCmisTypeId(typeId);
|
||||
if (relationshipTypeId.getScope() != CMISScope.RELATIONSHIP)
|
||||
CMISTypeDefinition relationshipType = cmisDictionaryService.findType(typeId);
|
||||
if (relationshipType == null || relationshipType.getTypeId().getScope() != CMISScope.RELATIONSHIP)
|
||||
{
|
||||
throw new TypeNotFoundException(typeId);
|
||||
}
|
||||
|
||||
QName relationshipTypeQName = relationshipTypeId.getQName();
|
||||
QName relationshipTypeQName = relationshipType.getTypeId().getQName();
|
||||
AssociationDefinition associationDef = dictionaryService.getAssociation(relationshipTypeQName);
|
||||
if (associationDef != null)
|
||||
{
|
||||
@@ -310,7 +310,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new TypeNotFoundException(relationshipTypeId.getQName() + " Relationship type not found");
|
||||
throw new TypeNotFoundException(relationshipType.getTypeId().getQName() + " Relationship type not found");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -29,6 +29,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.cmis.dictionary.CMISScope;
|
||||
import org.alfresco.cmis.dictionary.CMISTypeDefinition;
|
||||
import org.alfresco.cmis.dictionary.CMISTypeId;
|
||||
import org.alfresco.repo.cmis.PropertyFilter;
|
||||
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 maxItems = ((parameters.getMaxItems() != null) && (parameters.getMaxItems().getValue() != null)) ? parameters.getMaxItems().getValue() : BigInteger.ZERO;
|
||||
|
||||
CMISTypeId cmisTypeId = getCmisTypeId(typeId);
|
||||
QName associationType = cmisTypeId.getQName();
|
||||
CMISTypeDefinition cmisTypeDef = cmisDictionaryService.findType(typeId);
|
||||
QName associationType = cmisTypeDef.getTypeId().getQName();
|
||||
|
||||
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
|
||||
NodeRef objectNodeRef = (NodeRef) cmisObjectsUtils.getIdentifierInstance(parameters.getObjectId(), AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier();
|
||||
@@ -146,8 +147,8 @@ public class DMRelationshipServicePort extends DMAbstractServicePort implements
|
||||
}
|
||||
else
|
||||
{
|
||||
CMISTypeId typeId = cmisDictionaryService.getTypeId(qname, CMISScope.RELATIONSHIP);
|
||||
return typeId != null && relationshipType.equals(qname);
|
||||
CMISTypeDefinition typeDef = cmisDictionaryService.findTypeForClass(qname, CMISScope.RELATIONSHIP);
|
||||
return typeDef != null && relationshipType.equals(qname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -289,7 +289,7 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
wsPropertyDef.setPropertyType(propertyTypeEnumMapping.get(propertyDefinition.getDataType()));
|
||||
wsPropertyDef.setCardinality(cardinalityEnumMapping.get(propertyDefinition.getCardinality()));
|
||||
wsPropertyDef.setUpdateability(updatabilityEnumMapping.get(propertyDefinition.getUpdatability()));
|
||||
wsPropertyDef.setInherited(propertyDefinition.getOwningType().equals(typeDefinition));
|
||||
wsPropertyDef.setInherited(!typeDefinition.getOwnedPropertyDefinitions().containsKey(propertyDefinition.getPropertyId()));
|
||||
wsPropertyDef.setRequired(propertyDefinition.isRequired());
|
||||
wsPropertyDef.setQueryable(propertyDefinition.isQueryable());
|
||||
wsPropertyDef.setOrderable(propertyDefinition.isOrderable());
|
||||
@@ -410,7 +410,7 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
}
|
||||
else
|
||||
{
|
||||
CMISTypeDefinition typeDef = cmisDictionaryService.getType(cmisDictionaryService.getTypeId(parameters.getTypeId().getValue()));
|
||||
CMISTypeDefinition typeDef = cmisDictionaryService.findType(parameters.getTypeId().getValue());
|
||||
typeDefs = typeDef.getSubTypes(true);
|
||||
}
|
||||
|
||||
@@ -463,7 +463,7 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
|
||||
GetTypeDefinitionResponse response = new GetTypeDefinitionResponse();
|
||||
CMISTypeDefinition typeDef = cmisDictionaryService.getType(cmisDictionaryService.getTypeId(parameters.getTypeId()));
|
||||
CMISTypeDefinition typeDef = cmisDictionaryService.findType(parameters.getTypeId());
|
||||
response.setType(getCmisTypeDefinition(typeDef, true));
|
||||
return response;
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ import java.util.List;
|
||||
|
||||
import org.alfresco.cmis.dictionary.CMISDictionaryService;
|
||||
import org.alfresco.cmis.dictionary.CMISScope;
|
||||
import org.alfresco.cmis.dictionary.CMISTypeDefinition;
|
||||
import org.alfresco.cmis.dictionary.CMISTypeId;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.cmis.ws.EnumObjectType;
|
||||
@@ -219,8 +220,8 @@ public class CmisObjectsUtils
|
||||
return false;
|
||||
}
|
||||
QName typeQName = nodeService.getType(folderNodeRef);
|
||||
CMISTypeId typeId = cmisDictionaryService.getTypeId(typeQName, CMISScope.FOLDER);
|
||||
return typeId != null;
|
||||
CMISTypeDefinition typeDef = cmisDictionaryService.findTypeForClass(typeQName, CMISScope.FOLDER);
|
||||
return typeDef != null;
|
||||
}
|
||||
|
||||
public boolean isDocument(NodeRef documentNodeRef)
|
||||
@@ -230,8 +231,8 @@ public class CmisObjectsUtils
|
||||
return false;
|
||||
}
|
||||
QName typeQName = nodeService.getType(documentNodeRef);
|
||||
CMISTypeId typeId = cmisDictionaryService.getTypeId(typeQName, CMISScope.DOCUMENT);
|
||||
return typeId != null;
|
||||
CMISTypeDefinition typeDef = cmisDictionaryService.findTypeForClass(typeQName, CMISScope.DOCUMENT);
|
||||
return typeDef != null;
|
||||
}
|
||||
|
||||
public boolean isRelationship(String identifier)
|
||||
@@ -363,14 +364,14 @@ public class CmisObjectsUtils
|
||||
|
||||
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)
|
||||
&& typeId.getScope() == CMISScope.DOCUMENT)
|
||||
&& typeDef.getTypeId().getScope() == CMISScope.DOCUMENT)
|
||||
{
|
||||
return expectedType;
|
||||
}
|
||||
if ((expectedType == AlfrescoObjectType.FOLDER_OBJECT || expectedType == AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT)
|
||||
&& typeId.getScope() == CMISScope.FOLDER)
|
||||
&& typeDef.getTypeId().getScope() == CMISScope.FOLDER)
|
||||
{
|
||||
return expectedType;
|
||||
}
|
||||
|
Reference in New Issue
Block a user