Merge branch 'feature-2.4/RM-2996_UploadUnfiledReacordsWithRuleOnFilePlan' into 'release/V2.4'

Feature 2.4/rm 2996 upload unfiled reacords with rule on file plan

RM-2996 - Files can not be uploaded in Unfiled Records if the File Plan has rules defined applying to sub-folders

The execution of rules as well as RM's RecordsManagementContainer.onCreateChildAssociation behavior fire before transaction commit and is unpredictable which one will run first. If the rule runs first the newly uploaded node doesn't have rma:filePlanComponent set at the time the method shouldRuleBeAppliedToNode executes. Calling recordService.isFiled(nodeRef)) will trigger capability check among which ViewRecordsCapability will check if the record has the rma:filePlanComponent aspect.

As a fix I ran the code from shouldRuleBeAppliedToNode method as system to avoid capability check.

I am aware the fix is a workaround but I think this is part of a bigger problem. The rules are fired before transaction commit and may conflict with other behaviors registered on transaction commit. However, we cannot add the aspect earlier in RM.

See merge request !37
This commit is contained in:
Ana Bozianu
2016-02-22 08:54:59 +00:00

View File

@@ -228,24 +228,33 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
* @param typeQName * @param typeQName
* @return * @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; return AuthenticationUtil.runAsSystem(new RunAsWork<Boolean>()
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 public Boolean doWork() throws Exception
// it to holds/transfers/unfiled content... {
result = !(RecordsManagementModel.TYPE_HOLD.equals(typeQName) || boolean result = true;
RecordsManagementModel.TYPE_HOLD_CONTAINER.equals(typeQName) || NodeRef ruleNodeRef = getOwningNodeRef(rule);
RecordsManagementModel.TYPE_TRANSFER.equals(typeQName) || if (filePlanService.isFilePlan(ruleNodeRef))
RecordsManagementModel.TYPE_TRANSFER_CONTAINER.equals(typeQName) || {
RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER.equals(typeQName) || // if this rule is defined at the root of the file plan then
RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER.equals(typeQName) || // we do not want to apply
nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_TRANSFERRING) || // it to holds/transfers/unfiled content...
nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FROZEN) || result = !(RecordsManagementModel.TYPE_HOLD.equals(typeQName)
!recordService.isFiled(nodeRef)); || RecordsManagementModel.TYPE_HOLD_CONTAINER.equals(typeQName)
} || RecordsManagementModel.TYPE_TRANSFER.equals(typeQName)
return result; || 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;
}
});
} }
} }