()
{
public Void doWork()
{
- final NodeRef sourceNode = renditionService.getSourceNode(renditionNodeRef).getParentRef();
- if (contentClassificationService.isClassified(sourceNode))
+ final ChildAssociationRef chAssRef = renditionService.getSourceNode(renditionNodeRef);
+ final NodeRef sourceNode = chAssRef.getParentRef();
+ if (contentClassificationService.isClassified(sourceNode) &&
+ referralAdminService.getAttachedReferralFrom(renditionNodeRef, ASPECT_CLASSIFIED) != null)
{
- // All renditions should be given the same classification as their source node
- servicesExtras.copyAspect(sourceNode, renditionNodeRef, ASPECT_CLASSIFIED);
+ referralAdminService.attachReferrer(renditionNodeRef, sourceNode, ASSOC_CLASSIFIED_RENDITION);
}
+
return null;
}
}, authenticationUtil.getSystemUserName());
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 97f71efddd..91cfee419a 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
@@ -20,17 +20,13 @@ package org.alfresco.module.org_alfresco_module_rm.model.clf.aspect;
import static org.alfresco.module.org_alfresco_module_rm.util.RMCollectionUtils.diffKey;
-import java.io.Serializable;
-import java.util.Date;
-import java.util.Map;
-
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.MissingDowngradeInstructions;
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevel;
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService;
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationSchemeService.Reclassification;
import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel;
+import org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferralAdminService;
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
-import org.alfresco.module.org_alfresco_module_rm.util.CoreServicesExtras;
import org.alfresco.module.org_alfresco_module_rm.util.RMCollectionUtils.Difference;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
@@ -44,10 +40,15 @@ import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
/**
* clf:classification behaviour bean
*
- * @since 3.0.a
+ * @since 2.4.a
*/
@BehaviourBean
(
@@ -58,31 +59,27 @@ public class ClassifiedAspect extends BaseBehaviourBean implements NodeServicePo
ClassifiedContentModel
{
private ClassificationSchemeService classificationSchemeService;
+ private ReferralAdminService referralAdminService;
private RenditionService renditionService;
- private CoreServicesExtras servicesExtras;
public void setClassificationSchemeService(ClassificationSchemeService service)
{
this.classificationSchemeService = service;
}
+ public void setReferralAdminService(ReferralAdminService service)
+ {
+ this.referralAdminService = service;
+ }
+
public void setRenditionService(RenditionService service)
{
this.renditionService = service;
}
- public void setCoreServicesExtras(CoreServicesExtras extras)
- {
- this.servicesExtras = extras;
- }
-
/**
* Behaviour associated with updating the classified aspect properties.
*
- * Ensures that on reclassification of content (in other words a change in the value of the
- * {@link ClassifiedContentModel#PROP_CURRENT_CLASSIFICATION clf:currentClassification} property)
- * that various metadata are correctly updated as a side-effect.
- *
* Validates the consistency of the properties.
*/
@Override
@@ -91,7 +88,7 @@ public class ClassifiedAspect extends BaseBehaviourBean implements NodeServicePo
kind = BehaviourKind.CLASS,
notificationFrequency = NotificationFrequency.EVERY_EVENT
)
- public void onUpdateProperties(final NodeRef nodeRef,
+ public void onUpdateProperties(final NodeRef classifiedNode,
final Map before,
final Map after)
{
@@ -101,7 +98,7 @@ public class ClassifiedAspect extends BaseBehaviourBean implements NodeServicePo
{
final Difference classificationChange = diffKey(before, after, PROP_CURRENT_CLASSIFICATION);
- if (classificationChange == Difference.CHANGED && nodeService.hasAspect(nodeRef, ASPECT_CLASSIFIED))
+ if (classificationChange == Difference.CHANGED && nodeService.hasAspect(classifiedNode, ASPECT_CLASSIFIED))
{
final String oldValue = (String)before.get(PROP_CURRENT_CLASSIFICATION);
final String newValue = (String)after.get(PROP_CURRENT_CLASSIFICATION);
@@ -113,14 +110,12 @@ public class ClassifiedAspect extends BaseBehaviourBean implements NodeServicePo
if (reclassification != null)
{
- nodeService.setProperty(nodeRef, PROP_LAST_RECLASSIFICATION_ACTION, reclassification.toModelString());
- nodeService.setProperty(nodeRef, PROP_LAST_RECLASSIFY_AT, new Date());
+ nodeService.setProperty(classifiedNode, PROP_LAST_RECLASSIFICATION_ACTION, reclassification.toModelString());
+ nodeService.setProperty(classifiedNode, PROP_LAST_RECLASSIFY_AT, new Date());
}
}
- checkConsistencyOfProperties(nodeRef);
-
- copyClassifiedPropertiesToRenditions(nodeRef);
+ checkConsistencyOfProperties(classifiedNode);
return null;
}
@@ -136,33 +131,33 @@ public class ClassifiedAspect extends BaseBehaviourBean implements NodeServicePo
@Behaviour
(
kind = BehaviourKind.CLASS,
- notificationFrequency = NotificationFrequency.EVERY_EVENT
+ notificationFrequency = NotificationFrequency.FIRST_EVENT
)
- public void onAddAspect(final NodeRef nodeRef, final QName aspectTypeQName)
+ public void onAddAspect(final NodeRef classifiedNode, final QName aspectTypeQName)
{
AuthenticationUtil.runAs(new RunAsWork()
{
public Void doWork()
{
- checkConsistencyOfProperties(nodeRef);
+ checkConsistencyOfProperties(classifiedNode);
- copyClassifiedPropertiesToRenditions(nodeRef);
+ // If this node has any renditions, we must ensure that they inherit the classification
+ // from their source node.
+ final List renditions = renditionService.getRenditions(classifiedNode);
+ for (ChildAssociationRef chAssRef : renditions)
+ {
+ final NodeRef renditionNode = chAssRef.getChildRef();
+ if (referralAdminService.getAttachedReferralFrom(renditionNode, ASPECT_CLASSIFIED_RENDITION) == null)
+ {
+ referralAdminService.attachReferrer(renditionNode, classifiedNode, ASSOC_CLASSIFIED_RENDITION);
+ }
+ }
return null;
}
}, AuthenticationUtil.getSystemUserName());
}
- private void copyClassifiedPropertiesToRenditions(NodeRef nodeRef)
- {
- // All renditions should be given the same classification as their source node
- for (final ChildAssociationRef chAssRef : renditionService.getRenditions(nodeRef))
- {
- final NodeRef renditionNode = chAssRef.getChildRef();
- servicesExtras.copyAspect(nodeRef, renditionNode, ASPECT_CLASSIFIED);
- }
- }
-
/**
* Check the consistency of the classification properties and throw an exception if they are invalid.
*
diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImplUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImplUnitTest.java
index bc141bcc5c..b708aeb96a 100644
--- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImplUnitTest.java
+++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImplUnitTest.java
@@ -45,6 +45,7 @@ import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationE
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.LevelIdNotFound;
import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel;
import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
+import org.alfresco.module.org_alfresco_module_rm.referredmetadata.ReferredMetadataService;
import org.alfresco.module.org_alfresco_module_rm.test.util.MockAuthenticationUtilHelper;
import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil;
import org.alfresco.repo.security.permissions.AccessDeniedException;
@@ -80,6 +81,7 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte
@Mock FreezeService mockFreezeService;
@Mock SecurityClearanceService mockSecurityClearanceService;
@Mock AuthenticationUtil mockAuthenticationUtil;
+ @Mock ReferredMetadataService mockReferredMetadataService;
@Mock ClassificationAspectProperties mockPropertiesDTO;
@Captor ArgumentCaptor