mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
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:
@@ -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)
|
||||
{
|
||||
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
|
||||
// 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));
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user