MNT-22138: Document Filed to RM File Plan under categories with cut off retention schedule no longer accessible to non admin users in collab site

- Limited to certain code blocks to run as system.
This commit is contained in:
Raluca Munteanu
2021-04-02 17:23:23 +03:00
parent 14ab9ee541
commit a6aa711657
2 changed files with 66 additions and 73 deletions

View File

@@ -894,79 +894,70 @@ public class DispositionServiceImpl extends ServiceBaseImpl
@Override @Override
public boolean isNextDispositionActionEligible(NodeRef nodeRef) public boolean isNextDispositionActionEligible(NodeRef nodeRef)
{ {
boolean result = false; return authenticationUtil.runAsSystem(new RunAsWork<Boolean>()
// Get the disposition instructions
DispositionSchedule di = getDispositionSchedule(nodeRef);
DispositionAction nextDa = getNextDispositionAction(nodeRef);
if (di != null &&
this.nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE) &&
nextDa != null)
{ {
// for accession step we can have also AND between step conditions public Boolean doWork() throws Exception
Boolean combineSteps = false;
if (nextDa.getName().equals("accession"))
{ {
NodeRef accessionNodeRef = di.getDispositionActionDefinitionByName("accession").getNodeRef(); boolean result = false;
if (accessionNodeRef != null) { // Get the disposition instructions
Boolean combineStepsProp = (Boolean)this.nodeService.getProperty(accessionNodeRef, PROP_COMBINE_DISPOSITION_STEP_CONDITIONS); DispositionSchedule di = getDispositionSchedule(nodeRef);
if (combineStepsProp != null) DispositionAction nextDa = getNextDispositionAction(nodeRef);
{ if (di != null &&
combineSteps = combineStepsProp; nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE) &&
} nextDa != null) {
} // for accession step we can have also AND between step conditions
} Boolean combineSteps = false;
Date asOf = (Date)this.nodeService.getProperty(nextDa.getNodeRef(), PROP_DISPOSITION_AS_OF); if (nextDa.getName().equals("accession")) {
Boolean asOfDateInPast = false; NodeRef accessionNodeRef = di.getDispositionActionDefinitionByName("accession").getNodeRef();
if (asOf != null) if (accessionNodeRef != null) {
{ Boolean combineStepsProp = (Boolean) nodeService.getProperty(accessionNodeRef, PROP_COMBINE_DISPOSITION_STEP_CONDITIONS);
asOfDateInPast = asOf.before(new Date()); if (combineStepsProp != null) {
} combineSteps = combineStepsProp;
if (asOfDateInPast && !combineSteps)
{
return true;
}
else if(!asOfDateInPast && combineSteps)
{
return false;
}
DispositionAction da = new DispositionActionImpl(serviceRegistry, nextDa.getNodeRef());
DispositionActionDefinition dad = da.getDispositionActionDefinition();
if (dad != null)
{
boolean firstComplete = dad.eligibleOnFirstCompleteEvent();
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(nextDa.getNodeRef(), ASSOC_EVENT_EXECUTIONS, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef assoc : assocs)
{
NodeRef eventExecution = assoc.getChildRef();
Boolean isCompleteValue = (Boolean)this.nodeService.getProperty(eventExecution, PROP_EVENT_EXECUTION_COMPLETE);
boolean isComplete = false;
if (isCompleteValue != null)
{
isComplete = isCompleteValue.booleanValue();
// implement AND and OR combination of event completions
if (isComplete)
{
result = true;
if (firstComplete)
{
break;
} }
} }
else }
{ Date asOf = (Date) nodeService.getProperty(nextDa.getNodeRef(), PROP_DISPOSITION_AS_OF);
result = false; Boolean asOfDateInPast = false;
if (!firstComplete) if (asOf != null) {
{ asOfDateInPast = asOf.before(new Date());
break; }
if (asOfDateInPast && !combineSteps) {
return true;
} else if (!asOfDateInPast && combineSteps) {
return false;
}
DispositionAction da = new DispositionActionImpl(serviceRegistry, nextDa.getNodeRef());
DispositionActionDefinition dad = da.getDispositionActionDefinition();
if (dad != null) {
boolean firstComplete = dad.eligibleOnFirstCompleteEvent();
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(nextDa.getNodeRef(), ASSOC_EVENT_EXECUTIONS, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef assoc : assocs) {
NodeRef eventExecution = assoc.getChildRef();
Boolean isCompleteValue = (Boolean) nodeService.getProperty(eventExecution, PROP_EVENT_EXECUTION_COMPLETE);
boolean isComplete = false;
if (isCompleteValue != null) {
isComplete = isCompleteValue.booleanValue();
// implement AND and OR combination of event completions
if (isComplete) {
result = true;
if (firstComplete) {
break;
}
} else {
result = false;
if (!firstComplete) {
break;
}
}
} }
} }
} }
} }
return result;
} }
} });
return result;
} }
/** /**

View File

@@ -510,12 +510,13 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JS
// Set the indicators array // Set the indicators array
setIndicators(rmNodeValues, nodeRef); setIndicators(rmNodeValues, nodeRef);
AuthenticationUtil.runAsSystem(new RunAsWork<Void>() { // Set the actions array
@Override setActions(rmNodeValues, nodeRef);
public Void doWork() {
// Set the actions array AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
setActions(rmNodeValues, nodeRef); {
public Void doWork() throws Exception
{
//Add details of the next incomplete event in the disposition schedule //Add details of the next incomplete event in the disposition schedule
if (dispositionService.getNextDispositionAction(nodeRef) != null) if (dispositionService.getNextDispositionAction(nodeRef) != null)
@@ -525,9 +526,10 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JS
if (!details.isEventComplete()) if (!details.isEventComplete())
{ {
HashMap properties = ((HashMap) rmNodeValues.get("properties")); HashMap properties = ((HashMap) rmNodeValues.get("properties"));
properties.put("combineDispositionStepConditions", nodeService.getProperty(dispositionService.getNextDispositionAction(nodeRef).getDispositionActionDefinition().getNodeRef(), PROP_COMBINE_DISPOSITION_STEP_CONDITIONS)); properties.put("combineDispositionStepConditions", nodeService.getProperty(dispositionService.getNextDispositionAction(nodeRef).getDispositionActionDefinition().getNodeRef(), PROP_COMBINE_DISPOSITION_STEP_CONDITIONS));
properties.put("incompleteDispositionEvent", details.getEventName()); properties.put("incompleteDispositionEvent", details.getEventName());
properties.put("dispositionEventCombination", nodeService.getProperty(dispositionService.getNextDispositionAction(nodeRef).getDispositionActionDefinition().getNodeRef(), PROP_DISPOSITION_EVENT_COMBINATION)); properties.put("dispositionEventCombination", nodeService.getProperty(dispositionService.getNextDispositionAction(nodeRef).getDispositionActionDefinition().getNodeRef(), PROP_DISPOSITION_EVENT_COMBINATION));
break; break;
} }
} }