diff --git a/source/java/org/alfresco/repo/node/BaseNodeServiceTest.java b/source/java/org/alfresco/repo/node/BaseNodeServiceTest.java
index f54fd49123..92b5643cc5 100644
--- a/source/java/org/alfresco/repo/node/BaseNodeServiceTest.java
+++ b/source/java/org/alfresco/repo/node/BaseNodeServiceTest.java
@@ -736,14 +736,18 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
ContentModel.TYPE_CMOBJECT).getChildRef();
assertTrue("Aspect not automatically added by child association during 'createNode'",
nodeService.hasAspect(nodeRef, BaseNodeServiceTest.ASPECT_WITH_ASSOCIATIONS));
+ assertFalse("Unexpected 'aspect' added by child association during 'createNode'",
+ nodeService.hasAspect(nodeRef, BaseNodeServiceTest.ASSOC_ASPECT_CHILD_ASSOC));
nodeService.removeAspect(nodeRef, BaseNodeServiceTest.ASPECT_WITH_ASSOCIATIONS);
assertFalse("Child node should have been deleted", nodeService.exists(childNodeRef));
// Check that normal association creation adds the aspect to the source
nodeService.createAssociation(nodeRef, rootNodeRef, BaseNodeServiceTest.ASSOC_ASPECT_NORMAL_ASSOC);
- assertTrue("Aspect not automatically added by child association during 'createAssociation'",
+ assertTrue("Aspect not automatically added by peer association during 'createAssociation'",
nodeService.hasAspect(nodeRef, BaseNodeServiceTest.ASPECT_WITH_ASSOCIATIONS));
+ assertFalse("Unexpected aspect added by peer association during 'createAssociation'",
+ nodeService.hasAspect(nodeRef, BaseNodeServiceTest.ASSOC_ASPECT_NORMAL_ASSOC));
}
public void testAspectRemoval() throws Exception
diff --git a/source/java/org/alfresco/repo/node/BaseNodeServiceTest_model.xml b/source/java/org/alfresco/repo/node/BaseNodeServiceTest_model.xml
index 504bbff993..a33fe8f0f1 100644
--- a/source/java/org/alfresco/repo/node/BaseNodeServiceTest_model.xml
+++ b/source/java/org/alfresco/repo/node/BaseNodeServiceTest_model.xml
@@ -379,6 +379,16 @@
+
+
+
+ Aspect ANO1
+
+
+
+
+ Aspect ANO2
+
Aspect for Hanging Renditions Off
diff --git a/source/java/org/alfresco/repo/node/db/DbNodeServiceImpl.java b/source/java/org/alfresco/repo/node/db/DbNodeServiceImpl.java
index 89aa20a0c8..610ba64301 100644
--- a/source/java/org/alfresco/repo/node/db/DbNodeServiceImpl.java
+++ b/source/java/org/alfresco/repo/node/db/DbNodeServiceImpl.java
@@ -320,6 +320,7 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
addAspectsAndProperties(
childNodePair,
nodeTypeQName,
+ null,
Collections.emptySet(),
Collections.emptyMap(),
Collections.emptySet(),
@@ -348,7 +349,7 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
nodeIndexer.indexCreateNode(childAssocRef);
// Ensure that the parent node has the required aspects
- addAspectsAndProperties(parentNodePair, assocTypeQName, null, null, null, null, false);
+ addAspectsAndPropertiesAssoc(parentNodePair, assocTypeQName, null, null, null, null, false);
// done
return childAssocRef;
@@ -416,9 +417,8 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
*
* @param nodePair the node to which the details apply
* @param classQName the type or aspect QName for which the defaults must be applied.
- * This may also be an association type. If this is null
- * then properties and aspects are only applied for 'extra' aspects
- * and 'extra' properties.
+ * If this is null then properties and aspects are only applied
+ * for 'extra' aspects and 'extra' properties.
* @param existingAspects the existing aspects or null to have them fetched
* @param existingProperties the existing properties or null to have them fetched
* @param extraAspects any aspects that should be added to the 'missing' set (may be null)
@@ -436,12 +436,25 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
Map extraProperties,
boolean overwriteExistingProperties)
{
- return addAspectsAndProperties(nodePair, classQName, existingAspects, existingProperties, extraAspects, extraProperties, overwriteExistingProperties, true);
+ return addAspectsAndProperties(nodePair, classQName, null, existingAspects, existingProperties, extraAspects, extraProperties, overwriteExistingProperties, true);
+ }
+
+ private boolean addAspectsAndPropertiesAssoc(
+ Pair nodePair,
+ QName assocTypeQName,
+ Set existingAspects,
+ Map existingProperties,
+ Set extraAspects,
+ Map extraProperties,
+ boolean overwriteExistingProperties)
+ {
+ return addAspectsAndProperties(nodePair, null, assocTypeQName, existingAspects, existingProperties, extraAspects, extraProperties, overwriteExistingProperties, true);
}
private boolean addAspectsAndProperties(
Pair nodePair,
QName classQName,
+ QName assocTypeQName,
Set existingAspects,
Map existingProperties,
Set extraAspects,
@@ -491,6 +504,12 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
// Get the 'missing' aspects and append the 'extra' aspects
Set missingAspects = getMissingAspects(existingAspects, allProperties, classQName);
missingAspects.addAll(extraAspects);
+
+ if (assocTypeQName != null)
+ {
+ missingAspects.addAll(getMissingAspectsAssoc(existingAspects, allProperties, assocTypeQName));
+ }
+
// Notify 'before' adding aspect
for (QName missingAspect : missingAspects)
{
@@ -535,6 +554,20 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
return changedAspects || changedProperties;
}
+ private Set getMissingAspectsAssoc(
+ Set existingAspects,
+ Map existingProperties,
+ QName assocTypeQName)
+ {
+ AssociationDefinition assocDef = dictionaryService.getAssociation(assocTypeQName);
+ if (assocDef == null)
+ {
+ return Collections.emptySet();
+ }
+ ClassDefinition classDefinition = assocDef.getSourceClass();
+ return getMissingAspects(existingAspects, existingProperties, classDefinition.getName());
+ }
+
/**
* Get any aspects that should be added given the type, properties and existing aspects.
* Note that this does not included a search for properties required for the missing
@@ -554,13 +587,7 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
ClassDefinition classDefinition = dictionaryService.getClass(classQName);
if (classDefinition == null)
{
- AssociationDefinition assocDef = dictionaryService.getAssociation(classQName);
- if (assocDef == null)
- {
- return Collections.emptySet();
- }
- classDefinition = assocDef.getSourceClass();
- classQName = classDefinition.getName();
+ return Collections.emptySet();
}
Set missingAspects = new HashSet(7);
@@ -1103,7 +1130,7 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
// The association may be sourced on an aspect, which may itself mandate further aspects
for (Pair parentNodePair : parentNodePairs)
{
- addAspectsAndProperties(parentNodePair, assocTypeQName, null, null, null, null, false);
+ addAspectsAndPropertiesAssoc(parentNodePair, assocTypeQName, null, null, null, null, false);
}
// Index
@@ -1760,7 +1787,7 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
invokeOnCreateAssociation(assocRef);
// Add missing aspects
- addAspectsAndProperties(sourceNodePair, assocTypeQName, null, null, null, null, false);
+ addAspectsAndPropertiesAssoc(sourceNodePair, assocTypeQName, null, null, null, null, false);
return assocRef;
}