mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <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.
|
||||
*
|
||||
|
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user