diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/clf/aspect/ClassifiedAspect.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/clf/aspect/ClassifiedAspect.java
index 91cfee419a..7730f82875 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/clf/aspect/ClassifiedAspect.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/clf/aspect/ClassifiedAspect.java
@@ -56,6 +56,7 @@ import java.util.Map;
)
public class ClassifiedAspect extends BaseBehaviourBean implements NodeServicePolicies.OnUpdatePropertiesPolicy,
NodeServicePolicies.OnAddAspectPolicy,
+ NodeServicePolicies.OnRemoveAspectPolicy,
ClassifiedContentModel
{
private ClassificationSchemeService classificationSchemeService;
@@ -123,7 +124,7 @@ public class ClassifiedAspect extends BaseBehaviourBean implements NodeServicePo
}
/**
- * Behaviour associated with updating the classified aspect properties.
+ * Behaviour associated with adding the classified aspect.
*
* Validates the consistency of the properties.
*/
@@ -158,6 +159,37 @@ public class ClassifiedAspect extends BaseBehaviourBean implements NodeServicePo
}, AuthenticationUtil.getSystemUserName());
}
+ /**
+ * Behaviour associated with removing the classified aspect.
+ *
+ * Validates the consistency of the properties.
+ */
+ @Override
+ @Behaviour
+ (
+ kind = BehaviourKind.CLASS,
+ notificationFrequency = NotificationFrequency.FIRST_EVENT
+ )
+ public void onRemoveAspect(final NodeRef classifiedNode, final QName aspectTypeQName)
+ {
+ AuthenticationUtil.runAs(new RunAsWork()
+ {
+ public Void doWork()
+ {
+ // If this node has any renditions, we should remove the metadata link
+ final List renditions = renditionService.getRenditions(classifiedNode);
+ for (ChildAssociationRef chAssRef : renditions)
+ {
+ // In RM, renditions are only attached to one metadata referent - the source node.
+ // Therefore it is safe to (and we must) remove the aspect from the rendition node.
+ nodeService.removeAspect(chAssRef.getChildRef(), ASPECT_CLASSIFIED_RENDITION);
+ }
+
+ return null;
+ }
+ }, AuthenticationUtil.getSystemUserName());
+ }
+
/**
* Check the consistency of the classification properties and throw an exception if they are invalid.
*
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferralAdminServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferralAdminServiceImpl.java
index 117261b990..f2b43b1dc9 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferralAdminServiceImpl.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/referredmetadata/ReferralAdminServiceImpl.java
@@ -37,6 +37,35 @@ import java.util.Set;
*/
public class ReferralAdminServiceImpl implements ReferralAdminService
{
+ // Author's implementation note
+ // ----------------------------
+ //
+ // I can imagine that these services would be potentially useful in core Alfresco.
+ // However they are not yet full services and couldn't be moved as is into core.
+ // They solve a very specific RM problem in a fairly generic way that should allow
+ // someone to use them as the basis for fuller services within core.
+ //
+ // The problem they solve is that of 'classified renditions' whereby the classification
+ // metadata on a node should appear to be on its renditions as well. This particular problem
+ // is simplified by the fact that renditions are not 'normal' nodes, as they are usually
+ // not accessed directly. This implementation also relies on the fact that RM already
+ // has interceptors for checking content classification and we can programmatically add
+ // the calls to metadata referral within the ContentClassificationService.
+ //
+ // To solve the problem of Metadata Referral in a general way would require the provision
+ // of 'MetadataReferral' interceptors that could sit in front of the NodeService. Only in this
+ // way could the services be used declaratively, thus minimising their impact on calling code.
+ // To add these to core would require careful assessment of their impact, not least in
+ // performance terms. This work is beyond RM's scope at this stage.
+ // The addition of such interceptors to the NodeService would also ensure that any metadata
+ // returned to e.g. Share for a particular node could automatically include 'linked' metadata
+ // which would be important.
+ //
+ // There are further enhancements that should be considered if these were developed into
+ // fuller services including the automatic registration of behaviours (onAddAspect, onRemoveAspect)
+ // for the aspect types which are linked. Currently these behaviours need to be hand-coded.
+ // See ClassifiedAspect.java for an example.
+
private ReferralRegistry registry;
private NodeService nodeService;