From 3700a455c931e9badd767811ff18bb009b106caa Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Wed, 17 Feb 2016 15:37:19 +0200 Subject: [PATCH] RM-2996 - Files can not be uploaded in Unfiled Records if the File Plan has rules defined applying to sub-folders. - recordService.isFiled(nodeRef) fires capability check which conflicts with RM behavior so I run shouldRuleBeAppliedToNode code as system to skip capability check - this approach is a workaround --- .../repo/rule/ExtendedRuleServiceImpl.java | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/rule/ExtendedRuleServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/rule/ExtendedRuleServiceImpl.java index db0fd4d67e..b53b82e9dc 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/rule/ExtendedRuleServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/rule/ExtendedRuleServiceImpl.java @@ -228,24 +228,33 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl * @param typeQName * @return */ - private boolean shouldRuleBeAppliedToNode(Rule rule, NodeRef nodeRef, QName typeQName) + private boolean shouldRuleBeAppliedToNode(final Rule rule, final NodeRef nodeRef, final QName typeQName) { - boolean result = true; - NodeRef ruleNodeRef = getOwningNodeRef(rule); - if(filePlanService.isFilePlan(ruleNodeRef)) + return AuthenticationUtil.runAsSystem(new RunAsWork() { - // if this rule is defined at the root of the file plan then we do not want to apply - // it to holds/transfers/unfiled content... - result = !(RecordsManagementModel.TYPE_HOLD.equals(typeQName) || - RecordsManagementModel.TYPE_HOLD_CONTAINER.equals(typeQName) || - RecordsManagementModel.TYPE_TRANSFER.equals(typeQName) || - RecordsManagementModel.TYPE_TRANSFER_CONTAINER.equals(typeQName) || - RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER.equals(typeQName) || - RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER.equals(typeQName) || - nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_TRANSFERRING) || - nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FROZEN) || - !recordService.isFiled(nodeRef)); - } - return result; + public Boolean doWork() throws Exception + { + boolean result = true; + NodeRef ruleNodeRef = getOwningNodeRef(rule); + if (filePlanService.isFilePlan(ruleNodeRef)) + { + // if this rule is defined at the root of the file plan then + // we do not want to apply + // it to holds/transfers/unfiled content... + result = !(RecordsManagementModel.TYPE_HOLD.equals(typeQName) + || RecordsManagementModel.TYPE_HOLD_CONTAINER.equals(typeQName) + || RecordsManagementModel.TYPE_TRANSFER.equals(typeQName) + || RecordsManagementModel.TYPE_TRANSFER_CONTAINER.equals(typeQName) + || RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER + .equals(typeQName) + || RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER.equals(typeQName) + || nodeService.hasAspect(nodeRef, + RecordsManagementModel.ASPECT_TRANSFERRING) + || nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FROZEN) + || !recordService.isFiled(nodeRef)); + } + return result; + } + }); } }