RM-3030 - added filePlan aspect for every thumbnail from renditions

This commit is contained in:
Roxana Lucanu
2016-04-06 16:49:42 +03:00
parent 6486923ca8
commit 1de1bcf5f4
2 changed files with 26 additions and 0 deletions

View File

@@ -46,6 +46,7 @@ import org.alfresco.repo.policy.annotation.BehaviourBean;
import org.alfresco.repo.policy.annotation.BehaviourKind;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.service.cmr.rendition.RenditionService;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.ScriptService;
@@ -82,6 +83,9 @@ public class FilePlanComponentAspect extends BaseBehaviourBean
/** file plan service */
private FilePlanService filePlanService;
/** rendition service */
private RenditionService renditionService;
/**
* @param scriptService set script service
*/
@@ -106,6 +110,14 @@ public class FilePlanComponentAspect extends BaseBehaviourBean
this.filePlanService = filePlanService;
}
/**
* @param renditionService rendition service
*/
public void setRenditionService(RenditionService service)
{
this.renditionService = service;
}
/**
* @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map)
*/
@@ -220,6 +232,19 @@ public class FilePlanComponentAspect extends BaseBehaviourBean
{
nodeService.setProperty(nodeRef, PROP_ROOT_NODEREF, root);
}
// If the node has any renditions, they inherit the file plan from their source node.
List<ChildAssociationRef> renditions = renditionService.getRenditions(nodeRef);
NodeRef thumbnail;
for (ChildAssociationRef chAssRef : renditions)
{
thumbnail = chAssRef.getChildRef();
if (nodeService.exists(thumbnail))
{
// Apply file plan component aspect to thumbnail
nodeService.addAspect(thumbnail, ASPECT_FILE_PLAN_COMPONENT, null);
}
}
}
return null;