Merging /BRANCHES/DEV/BELARUS/HEAD-2010_03_09/ to HEAD:

19162: Bug related to properties receiving in PropertyUtil was fixed.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19164 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2010-03-09 17:22:22 +00:00
parent 5245d38b61
commit 67bda4baa6
2 changed files with 34 additions and 10 deletions

View File

@@ -37,6 +37,7 @@ import org.alfresco.cmis.CMISInvalidArgumentException;
import org.alfresco.cmis.CMISRenditionKind; import org.alfresco.cmis.CMISRenditionKind;
import org.alfresco.cmis.CMISScope; import org.alfresco.cmis.CMISScope;
import org.alfresco.cmis.CMISServiceException; import org.alfresco.cmis.CMISServiceException;
import org.alfresco.cmis.CMISServices;
import org.alfresco.cmis.CMISTypeDefinition; import org.alfresco.cmis.CMISTypeDefinition;
import org.alfresco.cmis.CMISVersioningStateEnum; import org.alfresco.cmis.CMISVersioningStateEnum;
import org.alfresco.repo.cmis.PropertyFilter; import org.alfresco.repo.cmis.PropertyFilter;
@@ -48,6 +49,7 @@ import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.model.FileExistsException; import org.alfresco.service.cmr.model.FileExistsException;
import org.alfresco.service.cmr.model.FileInfo; import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.model.FileNotFoundException; import org.alfresco.service.cmr.model.FileNotFoundException;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.FileTypeImageSize; import org.alfresco.service.cmr.repository.FileTypeImageSize;
@@ -320,8 +322,8 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
{ {
throw ExceptionUtil.createCmisException("Target object type isn't allowed as target type", EnumServiceException.CONSTRAINT); throw ExceptionUtil.createCmisException("Target object type isn't allowed as target type", EnumServiceException.CONSTRAINT);
} }
String createdId = nodeService.createAssociation(sourceNodeRef, targetNodeRef, relationshipTypeQName).toString(); AssociationRef assocRef = nodeService.createAssociation(sourceNodeRef, targetNodeRef, relationshipTypeQName);
objectId.value = createdId; objectId.value = CMISServices.ASSOC_ID_PREFIX + assocRef.getId();
} }
else else
{ {
@@ -428,7 +430,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
try try
{ {
NodeRef object = cmisService.getReadableObject(objectId, NodeRef.class); Object object = cmisService.getReadableObject(objectId, Object.class);
PropertyFilter propertyFilter = createPropertyFilter(filter); PropertyFilter propertyFilter = createPropertyFilter(filter);
CmisObjectType cmisObject = createCmisObject(object, propertyFilter, includeRelationships, CmisObjectType cmisObject = createCmisObject(object, propertyFilter, includeRelationships,
includeAllowableActions, renditionFilter); includeAllowableActions, renditionFilter);

View File

@@ -471,14 +471,14 @@ public class PropertyUtil
aspectProperties.putAll(cmisService.getProperties((NodeRef)object, typeDef)); aspectProperties.putAll(cmisService.getProperties((NodeRef)object, typeDef));
} }
CmisPropertiesType aspectResult = new CmisPropertiesType(); CmisPropertiesType aspectResult = new CmisPropertiesType();
convertToCmisProperties(aspectProperties, filter, aspectResult); convertToCmisProperties(object, aspectProperties, filter, aspectResult);
extension.setProperties(aspectResult); extension.setProperties(aspectResult);
} }
else else
{ {
properties = createBaseRelationshipProperties((AssociationRef) object); properties = createBaseRelationshipProperties((AssociationRef) object);
} }
convertToCmisProperties(properties, filter, result); convertToCmisProperties(object, properties, filter, result);
return result; return result;
} }
catch (CMISInvalidArgumentException e) catch (CMISInvalidArgumentException e)
@@ -491,7 +491,7 @@ public class PropertyUtil
{ {
Map<String, Serializable> result = new HashMap<String, Serializable>(); Map<String, Serializable> result = new HashMap<String, Serializable>();
result.put(CMISDictionaryModel.PROP_OBJECT_TYPE_ID, cmisDictionaryService.findTypeForClass(association.getTypeQName(), CMISScope.RELATIONSHIP).getTypeId()); 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, CMISServices.ASSOC_ID_PREFIX + association.getId());
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());
result.put(CMISDictionaryModel.PROP_CREATION_DATE, new Date()); result.put(CMISDictionaryModel.PROP_CREATION_DATE, new Date());
@@ -500,14 +500,36 @@ public class PropertyUtil
return result; return result;
} }
private void convertToCmisProperties(Map<String, Serializable> properties, PropertyFilter filter, CmisPropertiesType cmisProperties) throws CmisException private void convertToCmisProperties(Object object, Map<String, Serializable> properties, PropertyFilter filter, CmisPropertiesType cmisProperties) throws CmisException
{ {
String typeId = properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID) != null ? properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID).toString() : null; CMISTypeDefinition type = null;
CMISTypeDefinition type = cmisDictionaryService.findType(typeId); if (object instanceof NodeRef)
{
try
{
type = cmisService.getTypeDefinition((NodeRef) object);
}
catch (CMISInvalidArgumentException e)
{
throw ExceptionUtil.createCmisException(e.getMessage(), EnumServiceException.INVALID_ARGUMENT);
}
}
else
{
try
{
type = cmisService.getTypeDefinition((AssociationRef) object);
}
catch (CMISInvalidArgumentException e)
{
throw ExceptionUtil.createCmisException(e.getMessage(), EnumServiceException.INVALID_ARGUMENT);
}
}
if (null == type) if (null == type)
{ {
throw ExceptionUtil.createCmisException(("Type with " + typeId + " typeId was not found"), EnumServiceException.RUNTIME); throw ExceptionUtil.createCmisException(("Type for object " + object + " was not found"), EnumServiceException.RUNTIME);
} }
for (String propertyName : properties.keySet()) for (String propertyName : properties.keySet())