Remove now unessesary checks from rule execution (RM-3148)

This commit is contained in:
Roy Wetherall
2016-03-15 11:59:13 +11:00
parent 1c6e95efe8
commit 44a188dabf
2 changed files with 32 additions and 74 deletions

View File

@@ -171,8 +171,7 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
if (nodeService.exists(nodeRef))
{
QName typeQName = nodeService.getType(nodeRef);
if (shouldRuleBeAppliedToNode(rule, nodeRef, typeQName))
{
// check if this is a rm rule on a rm artifact
if (filePlanService.isFilePlanComponent(nodeRef) &&
isFilePlanComponentRule(rule))
@@ -206,7 +205,6 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
}
}
}
}
/**
* Indicates whether the rule is a file plan component
@@ -228,44 +226,4 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
{
return ignoredTypes.contains(typeQName);
}
/**
* Check if the rule is associated with the file plan component that the node it is being
* applied to isn't a hold container, a hold, a transfer container, a transfer, an unfiled
* record container, an unfiled record folder or unfiled content
*
* @param rule
* @param nodeRef
* @param typeQName
* @return
*/
private boolean shouldRuleBeAppliedToNode(final Rule rule, final NodeRef nodeRef, final QName typeQName)
{
return AuthenticationUtil.runAsSystem(new RunAsWork<Boolean>()
{
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;
}
});
}
}

View File

@@ -66,10 +66,10 @@ public class FilePlanRuleInheritanceTest extends BaseRMTestCase
}
/**
* Given that a singel rule is set on the parent folder of the file plan root
* Given that a single rule is set on the parent folder of the file plan root
* And that it is configured to apply to children
* When we ask for the rules on the file plan, inclusing those inherited
* Then it will not include thos defined on the parent folder
* When we ask for the rules on the file plan, including those inherited
* Then it will not include those defined on the parent folder
*/
public void testFilePlanDoesNotInheritRulesFromParentFolder()
{