CMIS Dictionary Refactor

- follows pattern of Alfresco Dictionary
- simplified and much reduced DictionaryService interface
- model now compiled and cached (no more lots of small continuous object creations)
- walk model via simple getters
- validated (no dangling references)
- fix up property inheritance
- fix up sub-types for all types
- implements strict mode only for now (i.e. doesn't go outside of CMIS doc, folder, rel and policy)
- abstract helper for building other CMIS dictionaries (e.g. mapping all types in Alfresco)

Alfresco Dictionary:
- add event for initialized or re-initialized

Fix up usage in CMIS REST, Web Services and query. Tests pass.

REST support for custom sub-types and properties now reliable as constrained by validated CMIS model.

TODO:
- hook property value accessors into CMIS Dictionary

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13768 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2009-03-27 23:13:29 +00:00
parent b4aa000b9f
commit 509708b273
23 changed files with 423 additions and 484 deletions

View File

@@ -24,7 +24,6 @@
*/
package org.alfresco.repo.cmis.rest;
import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
@@ -51,7 +50,6 @@ import org.alfresco.repo.web.util.paging.Paging;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.mozilla.javascript.Scriptable;
/**
@@ -331,21 +329,21 @@ public class CMISScript extends BaseScopableProcessorExtension
*/
public PagedResults queryTypes(Page page)
{
Collection<CMISTypeId> typeIds = cmisDictionaryService.getAllObjectTypeIds();
Cursor cursor = paging.createCursor(typeIds.size(), page);
Collection<CMISTypeDefinition> typeDefs = cmisDictionaryService.getAllTypes();
Cursor cursor = paging.createCursor(typeDefs.size(), page);
// skip
Iterator<CMISTypeId> iterTypeIds = typeIds.iterator();
Iterator<CMISTypeDefinition> iterTypeDefs = typeDefs.iterator();
for (int i = 0; i < cursor.getStartRow(); i++)
{
iterTypeIds.next();
iterTypeDefs.next();
}
// get types for page
CMISTypeDefinition[] types = new CMISTypeDefinition[cursor.getRowCount()];
for (int i = cursor.getStartRow(); i <= cursor.getEndRow(); i++)
{
types[i - cursor.getStartRow()] = cmisDictionaryService.getType(iterTypeIds.next());
types[i - cursor.getStartRow()] = iterTypeDefs.next();
}
PagedResults results = paging.createPagedResults(types, cursor);
@@ -358,23 +356,23 @@ public class CMISScript extends BaseScopableProcessorExtension
* @param page
* @return paged result set of types
*/
public PagedResults queryTypeHierarchy(CMISTypeDefinition typedef, boolean descendants, Page page)
public PagedResults queryTypeHierarchy(CMISTypeDefinition typeDef, boolean descendants, Page page)
{
Collection<CMISTypeId> typeIds = cmisDictionaryService.getChildTypeIds(typedef.getObjectTypeId(), descendants);
Cursor cursor = paging.createCursor(typeIds.size(), page);
Collection<CMISTypeDefinition> subTypes = typeDef.getSubTypes(descendants);
Cursor cursor = paging.createCursor(subTypes.size(), page);
// skip
Iterator<CMISTypeId> iterTypeIds = typeIds.iterator();
Iterator<CMISTypeDefinition> iterSubTypes = subTypes.iterator();
for (int i = 0; i < cursor.getStartRow(); i++)
{
iterTypeIds.next();
iterSubTypes.next();
}
// get types for page
CMISTypeDefinition[] types = new CMISTypeDefinition[cursor.getRowCount()];
for (int i = cursor.getStartRow(); i <= cursor.getEndRow(); i++)
{
types[i - cursor.getStartRow()] = cmisDictionaryService.getType(iterTypeIds.next());
types[i - cursor.getStartRow()] = iterSubTypes.next();
}
PagedResults results = paging.createPagedResults(types, cursor);
@@ -391,7 +389,7 @@ public class CMISScript extends BaseScopableProcessorExtension
{
try
{
CMISTypeId cmisTypeId = cmisDictionaryService.getCMISMapping().getCmisTypeId(typeId);
CMISTypeId cmisTypeId = cmisDictionaryService.getTypeId(typeId);
return cmisDictionaryService.getType(cmisTypeId);
}
catch(AlfrescoRuntimeException e)
@@ -411,7 +409,7 @@ public class CMISScript extends BaseScopableProcessorExtension
try
{
QName typeQName = node.getQNameType();
CMISTypeId cmisTypeId = cmisDictionaryService.getCMISMapping().getCmisTypeId(typeQName);
CMISTypeId cmisTypeId = cmisDictionaryService.getTypeId(typeQName, null);
return cmisDictionaryService.getType(cmisTypeId);
}
catch(AlfrescoRuntimeException e)

View File

@@ -26,7 +26,8 @@ package org.alfresco.repo.cmis.rest;
import java.util.List;
import org.alfresco.cmis.dictionary.CMISMapping;
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;
@@ -38,23 +39,23 @@ import freemarker.template.TemplateModelException;
/**
* Custom FreeMarker Template language method.
* <p>
* Retrieve the CMIS Type Id for an Alfresco node
* Retrieve the CMIS Type Definition for an Alfresco node
* <p>
* Usage: cmistypeid(TemplateNode node)
* cmistypeid(QName nodeType)
* Usage: cmistype(TemplateNode node)
* cmistype(QName nodeType)
*
* @author davidc
*/
public class CMISTypeIdMethod implements TemplateMethodModelEx
public class CMISTypeDefinitionMethod implements TemplateMethodModelEx
{
private CMISMapping mappingService;
private CMISDictionaryService dictionaryService;
/**
* Construct
*/
public CMISTypeIdMethod(CMISMapping mappingService)
public CMISTypeDefinitionMethod(CMISDictionaryService dictionaryService)
{
this.mappingService = mappingService;
this.dictionaryService = dictionaryService;
}
/**
@@ -63,7 +64,7 @@ public class CMISTypeIdMethod implements TemplateMethodModelEx
@SuppressWarnings("unchecked")
public Object exec(List args) throws TemplateModelException
{
CMISTypeId result = null;
CMISTypeDefinition result = null;
if (args.size() == 1)
{
@@ -85,10 +86,14 @@ public class CMISTypeIdMethod implements TemplateMethodModelEx
}
}
// convert to CMIS type id
// convert to CMIS type
if (nodeType != null)
{
result = mappingService.getCmisTypeId(nodeType);
CMISTypeId typeId = dictionaryService.getTypeId(nodeType, null);
if (typeId != null)
{
result = dictionaryService.getType(typeId);
}
}
}
}

View File

@@ -1,71 +0,0 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.repo.cmis.rest;
import java.util.List;
import org.alfresco.cmis.dictionary.CMISDictionaryService;
import org.alfresco.cmis.dictionary.CMISTypeId;
import freemarker.template.TemplateModelException;
/**
* Custom FreeMarker Template language method.
* <p>
* Retrieve the CMIS Type for an Alfresco node
* <p>
* Usage: cmistype(TemplateNode node)
* cmistype(QName nodeType)
*
* @author davidc
*/
public class CMISTypeMethod extends CMISTypeIdMethod
{
private CMISDictionaryService dictionaryService;
/**
* Construct
*/
public CMISTypeMethod(CMISDictionaryService dictionaryService)
{
super(dictionaryService.getCMISMapping());
this.dictionaryService = dictionaryService;
}
/**
* @see freemarker.template.TemplateMethodModel#exec(java.util.List)
*/
@SuppressWarnings("unchecked")
public Object exec(List args) throws TemplateModelException
{
Object result = null;
Object typeId = super.exec(args);
if (typeId != null)
{
result = dictionaryService.getType((CMISTypeId)typeId);
}
return result;
}
}

View File

@@ -67,8 +67,8 @@ public class CMISTest extends BaseCMISWebScriptTest
// setRemoteServer(server);
// setArgsAsHeaders(false);
// setValidateResponse(false);
// setListener(new CMISTestListener(System.out));
// setTraceReqRes(true);
setListener(new CMISTestListener(System.out));
setTraceReqRes(true);
super.setUp();
}

View File

@@ -40,8 +40,11 @@ import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import org.alfresco.cmis.CMISService;
import org.alfresco.cmis.dictionary.CMISDictionaryModel;
import org.alfresco.cmis.dictionary.CMISDictionaryService;
import org.alfresco.cmis.dictionary.CMISMapping;
import org.alfresco.cmis.dictionary.CMISScope;
import org.alfresco.cmis.dictionary.CMISTypeDefinition;
import org.alfresco.cmis.dictionary.CMISTypeId;
import org.alfresco.cmis.property.CMISPropertyService;
import org.alfresco.cmis.search.CMISQueryService;
import org.alfresco.model.ContentModel;
@@ -63,7 +66,6 @@ import org.alfresco.service.cmr.version.VersionHistory;
import org.alfresco.service.cmr.version.VersionService;
import org.alfresco.service.cmr.version.VersionType;
import org.alfresco.service.descriptor.DescriptorService;
import org.alfresco.service.namespace.QName;
/**
* Base class for all CMIS web services
@@ -282,58 +284,57 @@ public class DMAbstractServicePort
protected CmisPropertiesType getPropertiesType(Map<String, Serializable> alfrescoProperties, PropertyFilter filter)
{
CMISMapping cmisMapping = cmisDictionaryService.getCMISMapping();
String objectTypeId = (String) alfrescoProperties.get(CMISMapping.PROP_OBJECT_TYPE_ID);
QName cmisType = cmisMapping.getCmisTypeId(objectTypeId).getQName();
String objectTypeId = (String) alfrescoProperties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID);
CMISTypeId cmisTypeId = cmisDictionaryService.getTypeId(objectTypeId);
CmisPropertiesType properties = new CmisPropertiesType();
if (cmisMapping.isValidCmisDocument(cmisType))
if (cmisTypeId.getScope() == CMISScope.DOCUMENT)
{
addBooleanProperty(properties, filter, CMISMapping.PROP_IS_IMMUTABLE, alfrescoProperties);
addBooleanProperty(properties, filter, CMISMapping.PROP_IS_LATEST_VERSION, alfrescoProperties);
addBooleanProperty(properties, filter, CMISMapping.PROP_IS_MAJOR_VERSION, alfrescoProperties);
addBooleanProperty(properties, filter, CMISMapping.PROP_IS_LATEST_MAJOR_VERSION, alfrescoProperties);
addBooleanProperty(properties, filter, CMISMapping.PROP_IS_VERSION_SERIES_CHECKED_OUT, alfrescoProperties);
addDateTimeProperty(properties, filter, CMISMapping.PROP_CREATION_DATE, alfrescoProperties);
addDateTimeProperty(properties, filter, CMISMapping.PROP_LAST_MODIFICATION_DATE, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_OBJECT_ID, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_VERSION_SERIES_ID, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_VERSION_SERIES_CHECKED_OUT_ID, alfrescoProperties);
addIntegerProperty(properties, filter, CMISMapping.PROP_CONTENT_STREAM_LENGTH, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_NAME, alfrescoProperties);
addBooleanProperty(properties, filter, CMISDictionaryModel.PROP_IS_IMMUTABLE, alfrescoProperties);
addBooleanProperty(properties, filter, CMISDictionaryModel.PROP_IS_LATEST_VERSION, alfrescoProperties);
addBooleanProperty(properties, filter, CMISDictionaryModel.PROP_IS_MAJOR_VERSION, alfrescoProperties);
addBooleanProperty(properties, filter, CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION, alfrescoProperties);
addBooleanProperty(properties, filter, CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT, alfrescoProperties);
addDateTimeProperty(properties, filter, CMISDictionaryModel.PROP_CREATION_DATE, alfrescoProperties);
addDateTimeProperty(properties, filter, CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE, alfrescoProperties);
addIDProperty(properties, filter, CMISDictionaryModel.PROP_OBJECT_ID, alfrescoProperties);
addIDProperty(properties, filter, CMISDictionaryModel.PROP_VERSION_SERIES_ID, alfrescoProperties);
addIDProperty(properties, filter, CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID, alfrescoProperties);
addIntegerProperty(properties, filter, CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH, alfrescoProperties);
addStringProperty(properties, filter, CMISDictionaryModel.PROP_NAME, alfrescoProperties);
addStringProperty(properties, filter, BASE_TYPE_PROPERTY_NAME, "document");
addStringProperty(properties, filter, CMISMapping.PROP_OBJECT_TYPE_ID, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_CREATED_BY, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_LAST_MODIFIED_BY, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_CONTENT_STREAM_MIME_TYPE, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_CONTENT_STREAM_FILENAME, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_VERSION_LABEL, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_VERSION_SERIES_CHECKED_OUT_BY, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_CHECKIN_COMMENT, alfrescoProperties);
addURIProperty(properties, filter, CMISMapping.PROP_CONTENT_STREAM_URI, alfrescoProperties);
addStringProperty(properties, filter, CMISDictionaryModel.PROP_OBJECT_TYPE_ID, alfrescoProperties);
addStringProperty(properties, filter, CMISDictionaryModel.PROP_CREATED_BY, alfrescoProperties);
addStringProperty(properties, filter, CMISDictionaryModel.PROP_LAST_MODIFIED_BY, alfrescoProperties);
addStringProperty(properties, filter, CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE, alfrescoProperties);
addStringProperty(properties, filter, CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME, alfrescoProperties);
addStringProperty(properties, filter, CMISDictionaryModel.PROP_VERSION_LABEL, alfrescoProperties);
addStringProperty(properties, filter, CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY, alfrescoProperties);
addStringProperty(properties, filter, CMISDictionaryModel.PROP_CHECKIN_COMMENT, alfrescoProperties);
addURIProperty(properties, filter, CMISDictionaryModel.PROP_CONTENT_STREAM_URI, alfrescoProperties);
}
else if (cmisMapping.isValidCmisFolder(cmisType))
else if (cmisTypeId.getScope() == CMISScope.FOLDER)
{
addDateTimeProperty(properties, filter, CMISMapping.PROP_CREATION_DATE, alfrescoProperties);
addDateTimeProperty(properties, filter, CMISMapping.PROP_LAST_MODIFICATION_DATE, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_OBJECT_ID, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_PARENT_ID, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_NAME, alfrescoProperties);
addDateTimeProperty(properties, filter, CMISDictionaryModel.PROP_CREATION_DATE, alfrescoProperties);
addDateTimeProperty(properties, filter, CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE, alfrescoProperties);
addIDProperty(properties, filter, CMISDictionaryModel.PROP_OBJECT_ID, alfrescoProperties);
addIDProperty(properties, filter, CMISDictionaryModel.PROP_PARENT_ID, alfrescoProperties);
addStringProperty(properties, filter, CMISDictionaryModel.PROP_NAME, alfrescoProperties);
addStringProperty(properties, filter, BASE_TYPE_PROPERTY_NAME, "folder");
addStringProperty(properties, filter, CMISMapping.PROP_OBJECT_TYPE_ID, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_CREATED_BY, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_LAST_MODIFIED_BY, alfrescoProperties);
addStringProperty(properties, filter, CMISDictionaryModel.PROP_OBJECT_TYPE_ID, alfrescoProperties);
addStringProperty(properties, filter, CMISDictionaryModel.PROP_CREATED_BY, alfrescoProperties);
addStringProperty(properties, filter, CMISDictionaryModel.PROP_LAST_MODIFIED_BY, alfrescoProperties);
}
else if (cmisMapping.isValidCmisRelationship(cmisType))
else if (cmisTypeId.getScope() == CMISScope.RELATIONSHIP)
{
addStringProperty(properties, filter, CMISMapping.PROP_OBJECT_TYPE_ID, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_OBJECT_ID, alfrescoProperties);
addStringProperty(properties, filter, CMISDictionaryModel.PROP_OBJECT_TYPE_ID, alfrescoProperties);
addIDProperty(properties, filter, CMISDictionaryModel.PROP_OBJECT_ID, alfrescoProperties);
addStringProperty(properties, filter, BASE_TYPE_PROPERTY_NAME, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_CREATED_BY, alfrescoProperties);
addDateTimeProperty(properties, filter, CMISMapping.PROP_CREATION_DATE, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_SOURCE_ID, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_TARGET_ID, alfrescoProperties);
addStringProperty(properties, filter, CMISDictionaryModel.PROP_CREATED_BY, alfrescoProperties);
addDateTimeProperty(properties, filter, CMISDictionaryModel.PROP_CREATION_DATE, alfrescoProperties);
addIDProperty(properties, filter, CMISDictionaryModel.PROP_SOURCE_ID, alfrescoProperties);
addIDProperty(properties, filter, CMISDictionaryModel.PROP_TARGET_ID, alfrescoProperties);
}
return properties;
@@ -342,13 +343,13 @@ public class DMAbstractServicePort
private Map<String, Serializable> createBaseRelationshipProperties(AssociationRef association)
{
Map<String, Serializable> result = new HashMap<String, Serializable>();
result.put(CMISMapping.PROP_OBJECT_TYPE_ID, cmisDictionaryService.getCMISMapping().getCmisType(association.getTypeQName()));
result.put(CMISMapping.PROP_OBJECT_ID, association.toString());
result.put(BASE_TYPE_PROPERTY_NAME, CMISMapping.RELATIONSHIP_TYPE_ID.getTypeId());
result.put(CMISMapping.PROP_CREATED_BY, AuthenticationUtil.getFullyAuthenticatedUser());
result.put(CMISMapping.PROP_CREATION_DATE, new Date());
result.put(CMISMapping.PROP_SOURCE_ID, association.getSourceRef());
result.put(CMISMapping.PROP_TARGET_ID, association.getTargetRef());
result.put(CMISDictionaryModel.PROP_OBJECT_TYPE_ID, cmisDictionaryService.getTypeId(association.getTypeQName(), CMISScope.RELATIONSHIP));
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());
result.put(CMISDictionaryModel.PROP_CREATION_DATE, new Date());
result.put(CMISDictionaryModel.PROP_SOURCE_ID, association.getSourceRef());
result.put(CMISDictionaryModel.PROP_TARGET_ID, association.getTargetRef());
return result;
}
@@ -570,7 +571,7 @@ public class DMAbstractServicePort
{
// TODO: properties setting
String name = (String) PropertyUtil.getProperty(properties, CMISMapping.PROP_NAME);
String name = (String) PropertyUtil.getProperty(properties, CMISDictionaryModel.PROP_NAME);
if (name != null)
{
nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, name);
@@ -622,5 +623,30 @@ 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);
}
catch (Exception e)
{
throw new InvalidArgumentException("Invalid typeId " + typeId);
}
}
}

View File

@@ -27,7 +27,7 @@ package org.alfresco.repo.cmis.ws;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.cmis.CMISPropertyTypeEnum;
import org.alfresco.cmis.CMISDataTypeEnum;
import org.alfresco.cmis.search.CMISQueryOptions;
import org.alfresco.cmis.search.CMISResultSet;
import org.alfresco.cmis.search.CMISResultSetColumn;
@@ -91,41 +91,41 @@ public class DMDiscoveryServicePort extends DMAbstractServicePort implements Dis
// for each column...
for (CMISResultSetColumn column : columns)
{
CMISPropertyTypeEnum type = column.getPropertyType();
if (type == CMISPropertyTypeEnum.BOOLEAN)
CMISDataTypeEnum type = column.getPropertyType();
if (type == CMISDataTypeEnum.BOOLEAN)
{
addBooleanProperty(properties, filter, column.getName(), values);
}
else if (type == CMISPropertyTypeEnum.DATETIME)
else if (type == CMISDataTypeEnum.DATETIME)
{
addDateTimeProperty(properties, filter, column.getName(), values);
}
else if (type == CMISPropertyTypeEnum.DECIMAL)
else if (type == CMISDataTypeEnum.DECIMAL)
{
addDecimalProperty(properties, filter, column.getName(), values);
}
else if (type == CMISPropertyTypeEnum.ID)
else if (type == CMISDataTypeEnum.ID)
{
addIDProperty(properties, filter, column.getName(), values);
}
else if (type == CMISPropertyTypeEnum.INTEGER)
else if (type == CMISDataTypeEnum.INTEGER)
{
addIntegerProperty(properties, filter, column.getName(), values);
}
else if (type == CMISPropertyTypeEnum.STRING)
else if (type == CMISDataTypeEnum.STRING)
{
addStringProperty(properties, filter, column.getName(), values);
}
else if (type == CMISPropertyTypeEnum.URI)
else if (type == CMISDataTypeEnum.URI)
{
addURIProperty(properties, filter, column.getName(), values);
}
else if (type == CMISPropertyTypeEnum.XML)
else if (type == CMISDataTypeEnum.XML)
{
// TODO:
throw new UnsupportedOperationException();
}
else if (type == CMISPropertyTypeEnum.HTML)
else if (type == CMISDataTypeEnum.HTML)
{
// TODO:
throw new UnsupportedOperationException();

View File

@@ -34,8 +34,9 @@ import java.util.Map;
import javax.activation.DataHandler;
import javax.xml.ws.Holder;
import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.cmis.dictionary.CMISMapping;
import org.alfresco.cmis.dictionary.CMISDictionaryModel;
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.PropertyFilter;
@@ -43,6 +44,7 @@ import org.alfresco.repo.cmis.ws.DeleteTreeResponse.FailedToDelete;
import org.alfresco.repo.cmis.ws.utils.AlfrescoObjectType;
import org.alfresco.repo.cmis.ws.utils.CmisObjectsUtils;
import org.alfresco.repo.cmis.ws.utils.CmisObjectsUtils.IdentifierConversionResults;
import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.lock.NodeLockedException;
@@ -110,25 +112,23 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
checkRepositoryId(repositoryId);
Map<String, Serializable> propertiesMap = getPropertiesMap(properties);
CMISMapping cmisMapping = cmisDictionaryService.getCMISMapping();
CMISTypeId cmisTypeId = cmisMapping.getCmisTypeId(typeId);
if (cmisMapping.getCmisTypeId(typeId).equals(CMISMapping.DOCUMENT_TYPE_ID) == false)
CMISTypeId cmisTypeId = getCmisTypeId(typeId);
if (cmisTypeId.getScope() != CMISScope.DOCUMENT)
{
throw new ConstraintViolationException("Invalid document type " + typeId);
}
NodeRef parentNodeRef = safeGetFolderNodeRef(folderId);
String documentName = (String) propertiesMap.get(CMISMapping.PROP_NAME);
String documentName = (String) propertiesMap.get(CMISDictionaryModel.PROP_NAME);
if (documentName == null)
{
throw new InvalidArgumentException("Name property not found");
}
NodeRef newDocumentNodeRef = fileFolderService.create(parentNodeRef, documentName, cmisMapping.getAlfrescoType(cmisTypeId.getQName())).getNodeRef();
NodeRef newDocumentNodeRef = fileFolderService.create(parentNodeRef, documentName, cmisTypeId.getQName()).getNodeRef();
ContentWriter writer = fileFolderService.getWriter(newDocumentNodeRef);
String mimeType = (String) propertiesMap.get(CMISMapping.PROP_CONTENT_STREAM_MIME_TYPE);
String mimeType = (String) propertiesMap.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE);
if (mimeType != null)
{
writer.setMimetype(mimeType);
@@ -165,7 +165,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
break;
}
String versionLabel = (String) cmisPropertyService.getProperty(newDocumentNodeRef, CMISMapping.PROP_VERSION_LABEL);
String versionLabel = (String) cmisPropertyService.getProperty(newDocumentNodeRef, CMISDictionaryModel.PROP_VERSION_LABEL);
return versionLabel != null && versionLabel.contains(VERSION_DELIMETER) ?
newDocumentNodeRef.toString() + CmisObjectsUtils.NODE_REFERENCE_ID_DELIMETER + versionLabel :
newDocumentNodeRef.toString();
@@ -194,17 +194,14 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
checkRepositoryId(repositoryId);
NodeRef folderNodeRef = cmisObjectsUtils.getIdentifierInstance(folderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
CMISTypeId cmisTypeId = getCmisTypeId(typeId);
assertTypeExists(cmisTypeId);
CMISMapping cmisMapping = cmisDictionaryService.getCMISMapping();
if (cmisMapping.isValidCmisFolder(cmisTypeId.getQName()) == false)
CMISTypeDefinition type = getCmisTypeDefinition(typeId);
if (type == null || type.getTypeId().getScope() != CMISScope.FOLDER)
{
throw new InvalidArgumentException(typeId + " isn't a folder type");
throw new TypeNotFoundException(typeId);
}
Map<String, Serializable> propertiesMap = getPropertiesMap(properties);
String name = (String) propertiesMap.get(CMISMapping.PROP_NAME);
String name = (String) propertiesMap.get(CMISDictionaryModel.PROP_NAME);
if (name == null)
{
throw new InvalidArgumentException("Name property not found");
@@ -214,10 +211,10 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
try
{
NodeRef newFolderNodeRef = fileFolderService.create(folderNodeRef, name, cmisMapping.getAlfrescoType(cmisTypeId.getQName())).getNodeRef();
NodeRef newFolderNodeRef = fileFolderService.create(folderNodeRef, name, type.getTypeId().getQName()).getNodeRef();
// TODO:
// cmisPropertyService.setProperties(newFolderNodeRef, propertiesMap);
return (String) cmisPropertyService.getProperty(newFolderNodeRef, CMISMapping.PROP_OBJECT_ID);
return (String) cmisPropertyService.getProperty(newFolderNodeRef, CMISDictionaryModel.PROP_OBJECT_ID);
}
catch (FileExistsException e)
{
@@ -289,17 +286,13 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
throw e;
}
CMISTypeId relationshipTypeId;
try
CMISTypeId relationshipTypeId = getCmisTypeId(typeId);
if (relationshipTypeId.getScope() != CMISScope.RELATIONSHIP)
{
relationshipTypeId = cmisDictionaryService.getCMISMapping().getCmisTypeId(typeId);
}
catch (Exception e)
{
throw new InvalidArgumentException("Invalid typeId format: " + typeId);
throw new TypeNotFoundException(typeId);
}
QName relationshipTypeQName = cmisDictionaryService.getCMISMapping().getAlfrescoType(relationshipTypeId.getQName());
QName relationshipTypeQName = relationshipTypeId.getQName();
AssociationDefinition associationDef = dictionaryService.getAssociation(relationshipTypeQName);
if (associationDef != null)
{
@@ -365,7 +358,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
NodeRef objectNodeReference = cmisObjectsUtils.getIdentifierInstance(objectId, AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier();
checkForRootObject(repositoryId, objectId);
checkObjectTypeAndAppropriateStates(objectNodeReference, this.cmisDictionaryService.getCMISMapping().getCmisType(this.nodeService.getType(objectNodeReference)));
checkObjectTypeAndAppropriateStates(objectNodeReference, nodeService.getType(objectNodeReference));
if (!cmisObjectsUtils.deleteObject(objectNodeReference))
{
throw new PermissionDeniedException("Currently authenticated User has no appropriate Permissions to delete specified Object");
@@ -451,7 +444,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
response.setLength(BigInteger.valueOf(reader.getSize()));
response.setMimeType(reader.getMimetype());
String filename = (String) cmisPropertyService.getProperty(nodeRef, CMISMapping.PROP_NAME);
String filename = (String) cmisPropertyService.getProperty(nodeRef, CMISDictionaryModel.PROP_NAME);
response.setFilename(filename);
response.setStream(new DataHandler(new ContentReaderDataSource(reader, filename)));
@@ -568,7 +561,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
// TODO: change token
// no new version
objectId.value = (String) cmisPropertyService.getProperty(objectNodeRef, CMISMapping.PROP_OBJECT_ID);
objectId.value = (String) cmisPropertyService.getProperty(objectNodeRef, CMISDictionaryModel.PROP_OBJECT_ID);
}
/**
@@ -636,26 +629,6 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
return properties;
}
private void assertTypeExists(CMISTypeId cmisTypeId) throws TypeNotFoundException
{
if (cmisDictionaryService.getCMISMapping().isValidCmisType(cmisTypeId.getQName()) == false)
{
throw new TypeNotFoundException(cmisTypeId.toString());
}
}
private CMISTypeId getCmisTypeId(String typeId) throws InvalidArgumentException
{
try
{
return cmisDictionaryService.getCMISMapping().getCmisTypeId(typeId);
}
catch (Exception e)
{
throw new InvalidArgumentException("Invalid typeId " + typeId);
}
}
private boolean changeObjectParentAssociation(NodeRef objectNodeRef, NodeRef targetFolderNodeRef, NodeRef sourceFolderNodeReference)
throws UpdateConflictException, PermissionDeniedException
{
@@ -726,7 +699,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
throw new InvalidArgumentException("Specified Object has invalid Object Type");
}
if (objectType.equals(CMISMapping.FOLDER_QNAME) && (nodeService.getChildAssocs(objectNodeReference).size() > 0))
if (objectType.equals(ContentModel.TYPE_FOLDER) && (nodeService.getChildAssocs(objectNodeReference).size() > 0))
{
throw new ConstraintViolationException("Could not delete folder with at least one Child");
}

View File

@@ -28,6 +28,8 @@ import java.math.BigInteger;
import java.util.LinkedList;
import java.util.List;
import org.alfresco.cmis.dictionary.CMISScope;
import org.alfresco.cmis.dictionary.CMISTypeId;
import org.alfresco.repo.cmis.PropertyFilter;
import org.alfresco.repo.cmis.ws.utils.AlfrescoObjectType;
import org.alfresco.repo.web.util.paging.Cursor;
@@ -81,7 +83,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;
QName associationType = cmisDictionaryService.getCMISMapping().getAlfrescoType(cmisDictionaryService.getCMISMapping().getCmisTypeId(typeId).getQName());
CMISTypeId cmisTypeId = getCmisTypeId(typeId);
QName associationType = cmisTypeId.getQName();
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
NodeRef objectNodeRef = (NodeRef) cmisObjectsUtils.getIdentifierInstance(parameters.getObjectId(), AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier();
@@ -143,7 +146,8 @@ public class DMRelationshipServicePort extends DMAbstractServicePort implements
}
else
{
return cmisDictionaryService.getCMISMapping().isValidCmisRelationship(qname) && relationshipType.equals(qname);
CMISTypeId typeId = cmisDictionaryService.getTypeId(qname, CMISScope.RELATIONSHIP);
return typeId != null && relationshipType.equals(qname);
}
}
}

View File

@@ -38,15 +38,14 @@ import javax.xml.bind.JAXBElement;
import org.alfresco.cmis.CMISCardinalityEnum;
import org.alfresco.cmis.CMISContentStreamAllowedEnum;
import org.alfresco.cmis.CMISDataTypeEnum;
import org.alfresco.cmis.CMISFullTextSearchEnum;
import org.alfresco.cmis.CMISJoinEnum;
import org.alfresco.cmis.CMISPropertyTypeEnum;
import org.alfresco.cmis.CMISUpdatabilityEnum;
import org.alfresco.cmis.dictionary.CMISChoice;
import org.alfresco.cmis.dictionary.CMISMapping;
import org.alfresco.cmis.dictionary.CMISDictionaryModel;
import org.alfresco.cmis.dictionary.CMISPropertyDefinition;
import org.alfresco.cmis.dictionary.CMISTypeDefinition;
import org.alfresco.cmis.dictionary.CMISTypeId;
import org.alfresco.repo.web.util.paging.Cursor;
import org.alfresco.service.descriptor.Descriptor;
@@ -63,7 +62,7 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
private static Map<CMISContentStreamAllowedEnum, EnumContentStreamAllowed> contentStreamAllowedEnumMapping;
private static Map<CMISUpdatabilityEnum, EnumUpdateability> updatabilityEnumMapping;
private static Map<CMISCardinalityEnum, EnumCardinality> cardinalityEnumMapping;
private static Map<CMISPropertyTypeEnum, EnumPropertyType> propertyTypeEnumMapping;
private static Map<CMISDataTypeEnum, EnumPropertyType> propertyTypeEnumMapping;
static
{
@@ -91,16 +90,16 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
cardinalityEnumMapping.put(CMISCardinalityEnum.MULTI_VALUED, EnumCardinality.MULTI);
cardinalityEnumMapping.put(CMISCardinalityEnum.SINGLE_VALUED, EnumCardinality.SINGLE);
propertyTypeEnumMapping = new HashMap<CMISPropertyTypeEnum, EnumPropertyType>();
propertyTypeEnumMapping.put(CMISPropertyTypeEnum.BOOLEAN, EnumPropertyType.BOOLEAN);
propertyTypeEnumMapping.put(CMISPropertyTypeEnum.DATETIME, EnumPropertyType.DATETIME);
propertyTypeEnumMapping.put(CMISPropertyTypeEnum.DECIMAL, EnumPropertyType.DECIMAL);
propertyTypeEnumMapping.put(CMISPropertyTypeEnum.HTML, EnumPropertyType.HTML);
propertyTypeEnumMapping.put(CMISPropertyTypeEnum.ID, EnumPropertyType.ID);
propertyTypeEnumMapping.put(CMISPropertyTypeEnum.INTEGER, EnumPropertyType.INTEGER);
propertyTypeEnumMapping.put(CMISPropertyTypeEnum.STRING, EnumPropertyType.STRING);
propertyTypeEnumMapping.put(CMISPropertyTypeEnum.URI, EnumPropertyType.URI);
propertyTypeEnumMapping.put(CMISPropertyTypeEnum.XML, EnumPropertyType.XML);
propertyTypeEnumMapping = new HashMap<CMISDataTypeEnum, EnumPropertyType>();
propertyTypeEnumMapping.put(CMISDataTypeEnum.BOOLEAN, EnumPropertyType.BOOLEAN);
propertyTypeEnumMapping.put(CMISDataTypeEnum.DATETIME, EnumPropertyType.DATETIME);
propertyTypeEnumMapping.put(CMISDataTypeEnum.DECIMAL, EnumPropertyType.DECIMAL);
propertyTypeEnumMapping.put(CMISDataTypeEnum.HTML, EnumPropertyType.HTML);
propertyTypeEnumMapping.put(CMISDataTypeEnum.ID, EnumPropertyType.ID);
propertyTypeEnumMapping.put(CMISDataTypeEnum.INTEGER, EnumPropertyType.INTEGER);
propertyTypeEnumMapping.put(CMISDataTypeEnum.STRING, EnumPropertyType.STRING);
propertyTypeEnumMapping.put(CMISDataTypeEnum.URI, EnumPropertyType.URI);
propertyTypeEnumMapping.put(CMISDataTypeEnum.XML, EnumPropertyType.XML);
}
/**
@@ -147,7 +146,7 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
repositoryInfoType.setRepositoryName(serverDescriptor.getName());
repositoryInfoType.setRepositoryRelationship("self");
repositoryInfoType.setRepositoryDescription("");
repositoryInfoType.setRootFolderId((String) cmisPropertyService.getProperty(cmisService.getDefaultRootNodeRef(), CMISMapping.PROP_OBJECT_ID));
repositoryInfoType.setRootFolderId((String) cmisPropertyService.getProperty(cmisService.getDefaultRootNodeRef(), CMISDictionaryModel.PROP_OBJECT_ID));
repositoryInfoType.setVendorName("Alfresco");
repositoryInfoType.setProductName("Alfresco Repository (" + serverDescriptor.getEdition() + ")");
repositoryInfoType.setProductVersion(serverDescriptor.getVersion());
@@ -173,7 +172,7 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
* @param propertyType type of property
* @return web service choice
*/
private JAXBElement<? extends CmisChoiceType> getCmisChoiceType(CMISChoice choice, CMISPropertyTypeEnum propertyType)
private JAXBElement<? extends CmisChoiceType> getCmisChoiceType(CMISChoice choice, CMISDataTypeEnum propertyType)
{
JAXBElement<? extends CmisChoiceType> result = null;
@@ -239,7 +238,7 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
* @param choices repository choice object
* @param cmisChoices web service choice object
*/
private void addChoiceChildrens(CMISPropertyTypeEnum propertyType, Collection<CMISChoice> choices, List<JAXBElement<? extends CmisChoiceType>> cmisChoices)
private void addChoiceChildrens(CMISDataTypeEnum propertyType, Collection<CMISChoice> choices, List<JAXBElement<? extends CmisChoiceType>> cmisChoices)
{
for (CMISChoice choice : choices)
{
@@ -260,7 +259,7 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
* @param choices repository choice object
* @param cmisChoices web service choice object
*/
private void addChoices(CMISPropertyTypeEnum propertyType, Collection<CMISChoice> choices, List<CmisChoiceType> cmisChoices)
private void addChoices(CMISDataTypeEnum propertyType, Collection<CMISChoice> choices, List<CmisChoiceType> cmisChoices)
{
for (CMISChoice choice : choices)
{
@@ -280,21 +279,21 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
* @param propertyDefinition repository property definition
* @param wsPropertyDefs web service property definition
*/
private void addPropertyDefs(CMISPropertyDefinition propertyDefinition, List<CmisPropertyDefinitionType> wsPropertyDefs)
private void addPropertyDefs(CMISTypeDefinition typeDefinition, CMISPropertyDefinition propertyDefinition, List<CmisPropertyDefinitionType> wsPropertyDefs)
{
CmisPropertyDefinitionType wsPropertyDef = new CmisPropertyDefinitionType();
wsPropertyDef.setName(propertyDefinition.getPropertyName());
wsPropertyDef.setId(propertyDefinition.getPropertyId());
wsPropertyDef.setName(propertyDefinition.getPropertyId().getName());
wsPropertyDef.setId(propertyDefinition.getPropertyId().getId());
wsPropertyDef.setDisplayName(propertyDefinition.getDisplayName());
wsPropertyDef.setDescription(propertyDefinition.getDescription());
wsPropertyDef.setPropertyType(propertyTypeEnumMapping.get(propertyDefinition.getPropertyType()));
wsPropertyDef.setPropertyType(propertyTypeEnumMapping.get(propertyDefinition.getDataType()));
wsPropertyDef.setCardinality(cardinalityEnumMapping.get(propertyDefinition.getCardinality()));
wsPropertyDef.setUpdateability(updatabilityEnumMapping.get(propertyDefinition.getUpdatability()));
wsPropertyDef.setInherited(propertyDefinition.isInherited());
wsPropertyDef.setInherited(propertyDefinition.getOwningType().equals(typeDefinition));
wsPropertyDef.setRequired(propertyDefinition.isRequired());
wsPropertyDef.setQueryable(propertyDefinition.isQueryable());
wsPropertyDef.setOrderable(propertyDefinition.isOrderable());
addChoices(propertyDefinition.getPropertyType(), propertyDefinition.getChoices(), wsPropertyDef.getChoice());
addChoices(propertyDefinition.getDataType(), propertyDefinition.getChoices(), wsPropertyDef.getChoice());
wsPropertyDef.setOpenChoice(propertyDefinition.isOpenChoice());
wsPropertyDefs.add(wsPropertyDef);
@@ -309,25 +308,25 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
*/
private void setCmisTypeDefinitionProperties(CmisTypeDefinitionType cmisTypeDefinition, CMISTypeDefinition typeDefinition, boolean includeProperties)
{
cmisTypeDefinition.setTypeId(typeDefinition.getObjectTypeId().getTypeId());
cmisTypeDefinition.setQueryName(typeDefinition.getObjectTypeQueryName());
cmisTypeDefinition.setDisplayName(typeDefinition.getObjectTypeDisplayName());
cmisTypeDefinition.setBaseType(EnumObjectType.fromValue(typeDefinition.getRootTypeId().getTypeId()));
cmisTypeDefinition.setParentId(typeDefinition.getParentTypeId().getTypeId());
cmisTypeDefinition.setBaseTypeQueryName(typeDefinition.getRootTypeQueryName());
cmisTypeDefinition.setTypeId(typeDefinition.getTypeId().getId());
cmisTypeDefinition.setQueryName(typeDefinition.getQueryName());
cmisTypeDefinition.setDisplayName(typeDefinition.getDisplayName());
cmisTypeDefinition.setBaseType(EnumObjectType.fromValue(typeDefinition.getRootType().getTypeId().getId()));
cmisTypeDefinition.setParentId(typeDefinition.getParentType().getTypeId().getId());
cmisTypeDefinition.setBaseTypeQueryName(typeDefinition.getRootType().getQueryName());
cmisTypeDefinition.setDescription(typeDefinition.getDescription());
cmisTypeDefinition.setCreatable(typeDefinition.isCreatable());
cmisTypeDefinition.setFileable(typeDefinition.isFileable());
cmisTypeDefinition.setQueryable(typeDefinition.isQueryable());
cmisTypeDefinition.setControllable(typeDefinition.isControllable());
cmisTypeDefinition.setIncludedInSupertypeQuery(typeDefinition.isIncludedInSupertypeQuery());
cmisTypeDefinition.setIncludedInSupertypeQuery(typeDefinition.isIncludeInSuperTypeQuery());
if (includeProperties)
{
List<CmisPropertyDefinitionType> propertyDefs = cmisTypeDefinition.getPropertyDefinition();
for (CMISPropertyDefinition cmisPropDef : cmisDictionaryService.getPropertyDefinitions(typeDefinition.getObjectTypeId()).values())
for (CMISPropertyDefinition cmisPropDef : typeDefinition.getPropertyDefinitions().values())
{
addPropertyDefs(cmisPropDef, propertyDefs);
addPropertyDefs(typeDefinition, cmisPropDef, propertyDefs);
}
}
}
@@ -340,45 +339,42 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
* @return web service type definition
* @throws ObjectNotFoundException if type id not found
*/
private JAXBElement<? extends CmisTypeDefinitionType> getCmisTypeDefinition(String typeId, boolean includeProperties) throws ObjectNotFoundException
private JAXBElement<? extends CmisTypeDefinitionType> getCmisTypeDefinition(CMISTypeDefinition typeDef, boolean includeProperties) throws ObjectNotFoundException
{
CMISTypeId cmisTypeId = cmisDictionaryService.getCMISMapping().getCmisTypeId(typeId);
CMISTypeDefinition typeDefinition = cmisDictionaryService.getType(cmisTypeId);
if (typeDefinition.getParentTypeId() == null)
if (typeDef.getParentType() == null)
{
return null;
}
if (typeDefinition == null)
if (typeDef == null)
{
throw new ObjectNotFoundException("Type not found");
}
JAXBElement<? extends CmisTypeDefinitionType> result = null;
switch (cmisTypeId.getScope())
switch (typeDef.getTypeId().getScope())
{
case DOCUMENT:
CmisTypeDocumentDefinitionType documentDefinitionType = new CmisTypeDocumentDefinitionType();
setCmisTypeDefinitionProperties(documentDefinitionType, typeDefinition, includeProperties);
documentDefinitionType.setVersionable(typeDefinition.isVersionable());
documentDefinitionType.setContentStreamAllowed(contentStreamAllowedEnumMapping.get(typeDefinition.getContentStreamAllowed()));
setCmisTypeDefinitionProperties(documentDefinitionType, typeDef, includeProperties);
documentDefinitionType.setVersionable(typeDef.isVersionable());
documentDefinitionType.setContentStreamAllowed(contentStreamAllowedEnumMapping.get(typeDef.getContentStreamAllowed()));
result = cmisObjectFactory.createDocumentType(documentDefinitionType);
break;
case FOLDER:
CmisTypeFolderDefinitionType folderDefinitionType = new CmisTypeFolderDefinitionType();
setCmisTypeDefinitionProperties(folderDefinitionType, typeDefinition, includeProperties);
setCmisTypeDefinitionProperties(folderDefinitionType, typeDef, includeProperties);
result = cmisObjectFactory.createFolderType(folderDefinitionType);
break;
case POLICY:
CmisTypePolicyDefinitionType policyDefinitionType = new CmisTypePolicyDefinitionType();
setCmisTypeDefinitionProperties(policyDefinitionType, typeDefinition, includeProperties);
setCmisTypeDefinitionProperties(policyDefinitionType, typeDef, includeProperties);
result = cmisObjectFactory.createPolicyType(policyDefinitionType);
break;
case RELATIONSHIP:
CmisTypeRelationshipDefinitionType relationshipDefinitionType = new CmisTypeRelationshipDefinitionType();
setCmisTypeDefinitionProperties(relationshipDefinitionType, typeDefinition, includeProperties);
setCmisTypeDefinitionProperties(relationshipDefinitionType, typeDef, includeProperties);
result = cmisObjectFactory.createRelationshipType(relationshipDefinitionType);
break;
case UNKNOWN:
@@ -407,28 +403,29 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
{
checkRepositoryId(parameters.getRepositoryId());
Collection<CMISTypeId> typeIds;
Collection<CMISTypeDefinition> typeDefs;
if (parameters.getTypeId() == null)
{
typeIds = cmisDictionaryService.getAllObjectTypeIds();
typeDefs = cmisDictionaryService.getAllTypes();
}
else
{
typeIds = cmisDictionaryService.getChildTypeIds(cmisDictionaryService.getCMISMapping().getCmisTypeId(parameters.getTypeId().getValue()), true);
CMISTypeDefinition typeDef = cmisDictionaryService.getType(cmisDictionaryService.getTypeId(parameters.getTypeId().getValue()));
typeDefs = typeDef.getSubTypes(true);
}
GetTypesResponse response = new GetTypesResponse();
if (parameters.getMaxItems() != null)
{
response.setHasMoreItems(parameters.getMaxItems().getValue().intValue() < typeIds.size());
response.setHasMoreItems(parameters.getMaxItems().getValue().intValue() < typeDefs.size());
}
// skip
Cursor cursor = createCursor(typeIds.size(), parameters.getSkipCount() != null ? parameters.getSkipCount().getValue() : null, parameters.getMaxItems() != null ? parameters.getMaxItems().getValue() : null);
Iterator<CMISTypeId> iterTypeIds = typeIds.iterator();
Cursor cursor = createCursor(typeDefs.size(), parameters.getSkipCount() != null ? parameters.getSkipCount().getValue() : null, parameters.getMaxItems() != null ? parameters.getMaxItems().getValue() : null);
Iterator<CMISTypeDefinition> iterTypeDefs = typeDefs.iterator();
for (int i = 0; i < cursor.getStartRow(); i++)
{
iterTypeIds.next();
iterTypeDefs.next();
}
boolean returnPropertyDefinitions = parameters.getReturnPropertyDefinitions() == null ? false : parameters.getReturnPropertyDefinitions().getValue();
@@ -436,7 +433,7 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
List<JAXBElement<? extends CmisTypeDefinitionType>> types = response.getType();
for (int i = cursor.getStartRow(); i <= cursor.getEndRow(); i++)
{
JAXBElement<? extends CmisTypeDefinitionType> element = getCmisTypeDefinition(iterTypeIds.next().getTypeId(), returnPropertyDefinitions);
JAXBElement<? extends CmisTypeDefinitionType> element = getCmisTypeDefinition(iterTypeDefs.next(), returnPropertyDefinitions);
if (element != null)
{
types.add(element);
@@ -466,7 +463,8 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
checkRepositoryId(parameters.getRepositoryId());
GetTypeDefinitionResponse response = new GetTypeDefinitionResponse();
response.setType(getCmisTypeDefinition(parameters.getTypeId(), true));
CMISTypeDefinition typeDef = cmisDictionaryService.getType(cmisDictionaryService.getTypeId(parameters.getTypeId()));
response.setType(getCmisTypeDefinition(typeDef, true));
return response;
}

View File

@@ -28,7 +28,7 @@ import java.util.List;
import javax.xml.ws.Holder;
import org.alfresco.cmis.dictionary.CMISMapping;
import org.alfresco.cmis.dictionary.CMISDictionaryModel;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.cmis.PropertyFilter;
import org.alfresco.repo.cmis.ws.utils.AlfrescoObjectType;
@@ -125,7 +125,7 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
}
NodeRef nodeRef = checkOutCheckInService.checkin(workingCopyNodeRef, createVersionProperties(checkinComment, major != null && major ? VersionType.MAJOR : VersionType.MINOR));
documentId.value = (String) cmisPropertyService.getProperty(nodeRef, CMISMapping.PROP_OBJECT_ID);
documentId.value = (String) cmisPropertyService.getProperty(nodeRef, CMISDictionaryModel.PROP_OBJECT_ID);
}
/**
@@ -157,7 +157,7 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
}
NodeRef pwcNodeRef = checkoutNode(documentNodeRef);
documentId.value = (String) cmisPropertyService.getProperty(pwcNodeRef, CMISMapping.PROP_OBJECT_ID);
documentId.value = (String) cmisPropertyService.getProperty(pwcNodeRef, CMISDictionaryModel.PROP_OBJECT_ID);
contentCopied.value = true;
}

View File

@@ -28,7 +28,7 @@ import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.cmis.dictionary.CMISMapping;
import org.alfresco.cmis.dictionary.CMISDictionaryModel;
import org.alfresco.util.Pair;
/**
@@ -44,29 +44,29 @@ public class PropertyUtil
static
{
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_IS_IMMUTABLE, new Pair<String, Boolean>("IsImmutable", true));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_IS_LATEST_VERSION, new Pair<String, Boolean>("IsLatestVersion", true));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_IS_MAJOR_VERSION, new Pair<String, Boolean>("IsMajorVersion", true));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_IS_LATEST_MAJOR_VERSION, new Pair<String, Boolean>("IsLatestMajorVersion", true));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_IS_VERSION_SERIES_CHECKED_OUT, new Pair<String, Boolean>("IsVersionSeriesCheckedOut", true));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_CREATION_DATE, new Pair<String, Boolean>("CreationDate", true));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_LAST_MODIFICATION_DATE, new Pair<String, Boolean>("LastModificationDate", true));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_OBJECT_ID, new Pair<String, Boolean>("ObjectId", true));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_VERSION_SERIES_ID, new Pair<String, Boolean>("VersionSeriesId", true));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_VERSION_SERIES_CHECKED_OUT_ID, new Pair<String, Boolean>("VersionSeriesCheckedOutId", true));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_CONTENT_STREAM_LENGTH, new Pair<String, Boolean>("ContentStreamLength", true));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_NAME, new Pair<String, Boolean>("Name", false));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_OBJECT_TYPE_ID, new Pair<String, Boolean>("ObjectTypeId", true));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_CREATED_BY, new Pair<String, Boolean>("CreatedBy", true));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_LAST_MODIFIED_BY, new Pair<String, Boolean>("LastModifiedBy", true));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_CONTENT_STREAM_MIME_TYPE, new Pair<String, Boolean>("ContentStreamMimeType", true));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_CONTENT_STREAM_FILENAME, new Pair<String, Boolean>("ContentStreamFilename", true));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_VERSION_LABEL, new Pair<String, Boolean>("VersionLabel", true));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_CHECKIN_COMMENT, new Pair<String, Boolean>("checkinComment", false));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_CONTENT_STREAM_URI, new Pair<String, Boolean>("contentStreamUri", true));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_VERSION_SERIES_CHECKED_OUT_BY, new Pair<String, Boolean>("VersionSeriesCheckedOutBy", true));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_PARENT_ID, new Pair<String, Boolean>("ParentId", true));
cmisToRepoPropertiesNamesMapping.put(CMISMapping.PROP_CONTENT_STREAM_ALLOWED, new Pair<String, Boolean>("ContentStreamAllowed", true));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_IS_IMMUTABLE, new Pair<String, Boolean>("IsImmutable", true));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_IS_LATEST_VERSION, new Pair<String, Boolean>("IsLatestVersion", true));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_IS_MAJOR_VERSION, new Pair<String, Boolean>("IsMajorVersion", true));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION, new Pair<String, Boolean>("IsLatestMajorVersion", true));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT, new Pair<String, Boolean>("IsVersionSeriesCheckedOut", true));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_CREATION_DATE, new Pair<String, Boolean>("CreationDate", true));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE, new Pair<String, Boolean>("LastModificationDate", true));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_OBJECT_ID, new Pair<String, Boolean>("ObjectId", true));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_VERSION_SERIES_ID, new Pair<String, Boolean>("VersionSeriesId", true));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID, new Pair<String, Boolean>("VersionSeriesCheckedOutId", true));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH, new Pair<String, Boolean>("ContentStreamLength", true));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_NAME, new Pair<String, Boolean>("Name", false));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_OBJECT_TYPE_ID, new Pair<String, Boolean>("ObjectTypeId", true));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_CREATED_BY, new Pair<String, Boolean>("CreatedBy", true));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_LAST_MODIFIED_BY, new Pair<String, Boolean>("LastModifiedBy", true));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE, new Pair<String, Boolean>("ContentStreamMimeType", true));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME, new Pair<String, Boolean>("ContentStreamFilename", true));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_VERSION_LABEL, new Pair<String, Boolean>("VersionLabel", true));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_CHECKIN_COMMENT, new Pair<String, Boolean>("checkinComment", false));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_CONTENT_STREAM_URI, new Pair<String, Boolean>("contentStreamUri", true));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY, new Pair<String, Boolean>("VersionSeriesCheckedOutBy", true));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_PARENT_ID, new Pair<String, Boolean>("ParentId", true));
cmisToRepoPropertiesNamesMapping.put(CMISDictionaryModel.PROP_CONTENT_STREAM_ALLOWED, new Pair<String, Boolean>("ContentStreamAllowed", true));
for (Map.Entry<String, Pair<String, Boolean>> entry : cmisToRepoPropertiesNamesMapping.entrySet())
{

View File

@@ -28,7 +28,6 @@ import java.util.LinkedList;
import java.util.List;
import org.alfresco.cmis.dictionary.CMISDictionaryService;
import org.alfresco.cmis.dictionary.CMISMapping;
import org.alfresco.cmis.dictionary.CMISScope;
import org.alfresco.cmis.dictionary.CMISTypeId;
import org.alfresco.model.ContentModel;
@@ -73,7 +72,6 @@ public class CmisObjectsUtils
private AuthorityService authorityService;
private NodeService nodeService;
private LockService lockService;
private CMISMapping cmisMapping;
private Throwable lastOperationException;
@@ -81,7 +79,6 @@ public class CmisObjectsUtils
public void setCmisDictionaryService(CMISDictionaryService cmisDictionaryService)
{
this.cmisDictionaryService = cmisDictionaryService;
this.cmisMapping = this.cmisDictionaryService.getCMISMapping();
}
public void setNodeService(NodeService nodeService)
@@ -217,12 +214,24 @@ public class CmisObjectsUtils
public boolean isFolder(NodeRef folderNodeRef)
{
return (folderNodeRef != null) && cmisMapping.isValidCmisFolder(cmisMapping.getCmisType(nodeService.getType(folderNodeRef)));
if (folderNodeRef == null)
{
return false;
}
QName typeQName = nodeService.getType(folderNodeRef);
CMISTypeId typeId = cmisDictionaryService.getTypeId(typeQName, CMISScope.FOLDER);
return typeId != null;
}
public boolean isDocument(NodeRef documentNodeRef)
{
return (documentNodeRef != null) && cmisMapping.isValidCmisDocument(cmisMapping.getCmisType(nodeService.getType(documentNodeRef)));
if (documentNodeRef == null)
{
return false;
}
QName typeQName = nodeService.getType(documentNodeRef);
CMISTypeId typeId = cmisDictionaryService.getTypeId(typeQName, CMISScope.DOCUMENT);
return typeId != null;
}
public boolean isRelationship(String identifier)
@@ -354,7 +363,7 @@ public class CmisObjectsUtils
private AlfrescoObjectType determineActualObjectType(AlfrescoObjectType expectedType, QName objectType)
{
CMISTypeId typeId = cmisMapping.getCmisTypeId(objectType);
CMISTypeId typeId = cmisDictionaryService.getTypeId(objectType, null);
if ((expectedType == AlfrescoObjectType.DOCUMENT_OBJECT || expectedType == AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT)
&& typeId.getScope() == CMISScope.DOCUMENT)
{