mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix ALF-2332: getRelationships fails for associations whose source or target types are not mapped to the CMIS domain model
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19747 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -655,9 +655,13 @@ public class CMISServicesImpl implements CMISServices, ApplicationContextAware,
|
||||
{
|
||||
// by the spec. if typeId=null then it is necessary return ALL associated Relationship objects!
|
||||
// establish relationship type to filter on
|
||||
if ((relDef != null) && !relDef.getBaseType().getTypeId().equals(CMISDictionaryModel.RELATIONSHIP_TYPE_ID))
|
||||
if (relDef == null)
|
||||
{
|
||||
throw new CMISInvalidArgumentException("Type Id " + relDef.getTypeId() + " is not a relationship type");
|
||||
relDef = cmisDictionaryService.findType(CMISDictionaryModel.RELATIONSHIP_TYPE_ID);
|
||||
}
|
||||
if (!relDef.getBaseType().getTypeId().equals(CMISDictionaryModel.RELATIONSHIP_TYPE_ID))
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Type Id " + relDef.getTypeId() + " is not a relationship type");
|
||||
}
|
||||
|
||||
// retrieve associations
|
||||
@@ -671,29 +675,22 @@ public class CMISServicesImpl implements CMISServices, ApplicationContextAware,
|
||||
assocs.addAll(nodeService.getSourceAssocs(node, RegexQNamePattern.MATCH_ALL));
|
||||
}
|
||||
|
||||
List<AssociationRef> filteredAssocs = new ArrayList<AssociationRef>(assocs.size());
|
||||
if (null != relDef)
|
||||
{
|
||||
// filter association by type
|
||||
// NOTE: even if typeId = null, we still filter out relationships that do not map to CMIS domain model e.g.
|
||||
// relationships whose source or target are not folders or documents
|
||||
Collection<CMISTypeDefinition> subRelDefs = (includeSubTypes ? relDef.getSubTypes(true) : null);
|
||||
List<AssociationRef> filteredAssocs = new ArrayList<AssociationRef>(assocs.size());
|
||||
for (AssociationRef assoc : assocs)
|
||||
{
|
||||
CMISTypeDefinition assocTypeDef = cmisDictionaryService.findTypeForClass(assoc.getTypeQName(), CMISScope.RELATIONSHIP);
|
||||
if (assocTypeDef == null)
|
||||
if (assocTypeDef != null)
|
||||
{
|
||||
throw new CMISInvalidArgumentException("Association Type QName " + assoc.getTypeQName() + " does not map to a CMIS Relationship Type");
|
||||
}
|
||||
|
||||
if (assocTypeDef.equals(relDef) || (subRelDefs != null && subRelDefs.contains(assocTypeDef)))
|
||||
{
|
||||
filteredAssocs.add(assoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
filteredAssocs = assocs;
|
||||
}
|
||||
|
||||
AssociationRef[] assocArray = new AssociationRef[filteredAssocs.size()];
|
||||
filteredAssocs.toArray(assocArray);
|
||||
|
Reference in New Issue
Block a user