Addition of tidyup code for when clf:classified aspect is removed. Also added notes on what's to do if this ever becomes a core service.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/classified_renditions@111768 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Neil McErlean
2015-09-09 09:12:02 +00:00
parent 9ede2dfa5c
commit 10fdfcf078
2 changed files with 62 additions and 1 deletions

View File

@@ -56,6 +56,7 @@ import java.util.Map;
) )
public class ClassifiedAspect extends BaseBehaviourBean implements NodeServicePolicies.OnUpdatePropertiesPolicy, public class ClassifiedAspect extends BaseBehaviourBean implements NodeServicePolicies.OnUpdatePropertiesPolicy,
NodeServicePolicies.OnAddAspectPolicy, NodeServicePolicies.OnAddAspectPolicy,
NodeServicePolicies.OnRemoveAspectPolicy,
ClassifiedContentModel ClassifiedContentModel
{ {
private ClassificationSchemeService classificationSchemeService; 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.
* <p> * <p>
* Validates the consistency of the properties. * Validates the consistency of the properties.
*/ */
@@ -158,6 +159,37 @@ public class ClassifiedAspect extends BaseBehaviourBean implements NodeServicePo
}, AuthenticationUtil.getSystemUserName()); }, AuthenticationUtil.getSystemUserName());
} }
/**
* Behaviour associated with removing the classified aspect.
* <p>
* 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<Void>()
{
public Void doWork()
{
// If this node has any renditions, we should remove the metadata link
final List<ChildAssociationRef> 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. * Check the consistency of the classification properties and throw an exception if they are invalid.
* *

View File

@@ -37,6 +37,35 @@ import java.util.Set;
*/ */
public class ReferralAdminServiceImpl implements ReferralAdminService 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 ReferralRegistry registry;
private NodeService nodeService; private NodeService nodeService;