Merged DEV/JASONH to HEAD

12565: JCR - fix ALFCOM-1655 (supercedes part of r12170)
  12644: JCR - fix extra testcase for ALFCOM-1655


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12650 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2009-01-09 12:43:46 +00:00
parent 2c3c766028
commit 4c800c25c5
4 changed files with 231 additions and 5 deletions

View File

@@ -241,22 +241,48 @@ public class NodeImpl extends ItemImpl implements Node
Set<QName> aspects = nodeService.getAspects(nodeRef);
ClassDefinition classDef = dictionaryService.getAnonymousType(type, aspects);
Map<QName, ChildAssociationDefinition> childAssocs = classDef.getChildAssociations();
for (ChildAssociationDefinition childAssocDef : childAssocs.values())
{
QName targetClass = childAssocDef.getTargetClass().getName();
if (dictionaryService.isSubClass(nodeType, targetClass))
if (nodeType.equals(targetClass))
{
if (nodeTypeChildAssocDef != null)
{
throw new AlfrescoRuntimeException("Cannot determine child association for node type '" + nodeType + " within parent " + nodeRef);
}
// exact match
nodeTypeChildAssocDef = childAssocDef;
break;
}
}
if (nodeTypeChildAssocDef == null)
{
for (ChildAssociationDefinition childAssocDef : childAssocs.values())
{
QName targetClass = childAssocDef.getTargetClass().getName();
if (dictionaryService.isSubClass(nodeType, targetClass))
{
if (childAssocDef.getSourceClass().getName().equals(type))
{
// matching parent type
nodeTypeChildAssocDef = childAssocDef;
break;
}
if (nodeTypeChildAssocDef != null)
{
// more than one match
throw new AlfrescoRuntimeException("Cannot determine child association for node type '" + nodeType + " within parent " + nodeRef);
}
nodeTypeChildAssocDef = childAssocDef;
}
}
}
if (nodeTypeChildAssocDef == null)
{
throw new AlfrescoRuntimeException("Cannot determine child association for node type '" + nodeType + " within parent " + nodeRef);
}
return nodeTypeChildAssocDef;
}