From 63f7887f80fb07d966a83cd8ca27288dcbfb7474 Mon Sep 17 00:00:00 2001 From: Raluca Munteanu Date: Tue, 6 Apr 2021 15:38:19 +0300 Subject: [PATCH] MNT22138: Document Filed to RM File Plan under categories with cut off retention schedule no longer accessible to non admin users in collab site - Added fix for issue cought by ui tests --- .../disposition/DispositionScheduleImpl.java | 9 ++- .../disposition/DispositionServiceImpl.java | 75 +++++++++++-------- 2 files changed, 53 insertions(+), 31 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionScheduleImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionScheduleImpl.java index fb3d654032..e18177b349 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionScheduleImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionScheduleImpl.java @@ -133,7 +133,14 @@ public class DispositionScheduleImpl implements DispositionSchedule, { if (this.actions == null) { - getDispositionActionsImpl(); + authenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() + { + public Void doWork() throws Exception + { + getDispositionActionsImpl(); + return null; + } + }); } DispositionActionDefinition actionDef = this.actionsById.get(id); diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java index 71261bb47f..fdc8a936dd 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java @@ -27,16 +27,6 @@ package org.alfresco.module.org_alfresco_module_rm.disposition; -import static org.apache.commons.lang3.BooleanUtils.isNotTrue; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies; @@ -73,6 +63,11 @@ import org.alfresco.util.ParameterCheck; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.Serializable; +import java.util.*; + +import static org.apache.commons.lang3.BooleanUtils.isNotTrue; + /** * Disposition service implementation. * @@ -439,26 +434,30 @@ public class DispositionServiceImpl extends ServiceBaseImpl */ private NodeRef getAssociatedDispositionScheduleImpl(NodeRef nodeRef) { - NodeRef result = null; ParameterCheck.mandatory("nodeRef", nodeRef); - // Make sure we are dealing with an RM node - if (!filePlanService.isFilePlanComponent(nodeRef)) + return authenticationUtil.runAsSystem(new RunAsWork() { - throw new AlfrescoRuntimeException("Can not find the associated retention schedule for a non records management component. (nodeRef=" + nodeRef.toString() + ")"); - } - - if (this.nodeService.hasAspect(nodeRef, ASPECT_SCHEDULED)) - { - List childAssocs = this.nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL); - if (!childAssocs.isEmpty()) + public NodeRef doWork() throws Exception { - ChildAssociationRef firstChildAssocRef = childAssocs.get(0); - result = firstChildAssocRef.getChildRef(); + NodeRef result = null; + // Make sure we are dealing with an RM node + if (!filePlanService.isFilePlanComponent(nodeRef)) + { + throw new AlfrescoRuntimeException("Can not find the associated retention schedule for a non records management component. (nodeRef=" + nodeRef.toString() + ")"); + } + if (nodeService.hasAspect(nodeRef, ASPECT_SCHEDULED)) + { + List childAssocs = nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL); + if (!childAssocs.isEmpty()) + { + ChildAssociationRef firstChildAssocRef = childAssocs.get(0); + result = firstChildAssocRef.getChildRef(); + } + } + return result; } - } - - return result; + }); } /** @@ -894,14 +893,15 @@ public class DispositionServiceImpl extends ServiceBaseImpl @Override public boolean isNextDispositionActionEligible(NodeRef nodeRef) { + // Get the disposition instructions + DispositionSchedule di = getDispositionSchedule(nodeRef); + DispositionAction nextDa = getNextDispositionAction(nodeRef); return authenticationUtil.runAsSystem(new RunAsWork() { public Boolean doWork() throws Exception { boolean result = false; - // Get the disposition instructions - DispositionSchedule di = getDispositionSchedule(nodeRef); - DispositionAction nextDa = getNextDispositionAction(nodeRef); + if (di != null && nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE) && nextDa != null) { @@ -1218,7 +1218,15 @@ public class DispositionServiceImpl extends ServiceBaseImpl public Date getDispositionActionDate(NodeRef record, NodeRef dispositionSchedule, String dispositionActionName) { DispositionSchedule ds = new DispositionScheduleImpl(serviceRegistry, nodeService, dispositionSchedule); - List assocs = nodeService.getChildAssocs(dispositionSchedule); + List assocs = AuthenticationUtil.runAsSystem(new RunAsWork >() + { + @Override + public List doWork() + { + return nodeService.getChildAssocs(dispositionSchedule); + } + }); + if (assocs != null && !assocs.isEmpty()) { for (ChildAssociationRef assoc : assocs) @@ -1226,7 +1234,14 @@ public class DispositionServiceImpl extends ServiceBaseImpl if (assoc != null && assoc.getQName().getLocalName().contains(dispositionActionName)) { DispositionActionDefinition actionDefinition = ds.getDispositionActionDefinition(assoc.getChildRef().getId()); - return calculateAsOfDate(record, actionDefinition); + + return authenticationUtil.runAsSystem(new RunAsWork() + { + public Date doWork() throws Exception + { + return calculateAsOfDate(record, actionDefinition); + } + }); } } }