Merge pull request #1398 from Alfresco/feature/MNT-22138_fixAfterFailingTests

feature/MNT-22138_fixAfterFailingTests
This commit is contained in:
ramunteanu
2021-04-27 08:35:55 +03:00
committed by GitHub
3 changed files with 43 additions and 29 deletions

View File

@@ -132,8 +132,15 @@ public class DispositionScheduleImpl implements DispositionSchedule,
public DispositionActionDefinition getDispositionActionDefinition(String id) public DispositionActionDefinition getDispositionActionDefinition(String id)
{ {
if (this.actions == null) if (this.actions == null)
{
authenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork<Void>()
{
public Void doWork() throws Exception
{ {
getDispositionActionsImpl(); getDispositionActionsImpl();
return null;
}
});
} }
DispositionActionDefinition actionDef = this.actionsById.get(id); DispositionActionDefinition actionDef = this.actionsById.get(id);

View File

@@ -447,10 +447,9 @@ public class DispositionServiceImpl extends ServiceBaseImpl
{ {
throw new AlfrescoRuntimeException("Can not find the associated retention schedule for a non records management component. (nodeRef=" + nodeRef.toString() + ")"); throw new AlfrescoRuntimeException("Can not find the associated retention schedule for a non records management component. (nodeRef=" + nodeRef.toString() + ")");
} }
if (getInternalNodeService().hasAspect(nodeRef, ASPECT_SCHEDULED))
if (this.nodeService.hasAspect(nodeRef, ASPECT_SCHEDULED))
{ {
List<ChildAssociationRef> childAssocs = this.nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL); List<ChildAssociationRef> childAssocs = getInternalNodeService().getChildAssocs(nodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL);
if (!childAssocs.isEmpty()) if (!childAssocs.isEmpty())
{ {
ChildAssociationRef firstChildAssocRef = childAssocs.get(0); ChildAssociationRef firstChildAssocRef = childAssocs.get(0);
@@ -898,25 +897,27 @@ public class DispositionServiceImpl extends ServiceBaseImpl
// Get the disposition instructions // Get the disposition instructions
DispositionSchedule di = getDispositionSchedule(nodeRef); DispositionSchedule di = getDispositionSchedule(nodeRef);
DispositionAction nextDa = getNextDispositionAction(nodeRef); DispositionAction nextDa = getNextDispositionAction(nodeRef);
if (di != null && if (di != null &&
this.nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE) && nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE) &&
nextDa != null) nextDa != null)
{ {
// for accession step we can have also AND between step conditions // for accession step we can have also AND between step conditions
Boolean combineSteps = false; boolean combineSteps = false;
if (nextDa.getName().equals("accession")) if (nextDa.getName().equals("accession"))
{ {
NodeRef accessionNodeRef = di.getDispositionActionDefinitionByName("accession").getNodeRef(); NodeRef accessionNodeRef = di.getDispositionActionDefinitionByName("accession").getNodeRef();
if (accessionNodeRef != null) { if (accessionNodeRef != null)
Boolean combineStepsProp = (Boolean)this.nodeService.getProperty(accessionNodeRef, PROP_COMBINE_DISPOSITION_STEP_CONDITIONS); {
Boolean combineStepsProp = (Boolean) getInternalNodeService().getProperty(accessionNodeRef, PROP_COMBINE_DISPOSITION_STEP_CONDITIONS);
if (combineStepsProp != null) if (combineStepsProp != null)
{ {
combineSteps = combineStepsProp; combineSteps = combineStepsProp;
} }
} }
} }
Date asOf = (Date)this.nodeService.getProperty(nextDa.getNodeRef(), PROP_DISPOSITION_AS_OF); Date asOf = (Date) getInternalNodeService().getProperty(nextDa.getNodeRef(), PROP_DISPOSITION_AS_OF);
Boolean asOfDateInPast = false; boolean asOfDateInPast = false;
if (asOf != null) if (asOf != null)
{ {
asOfDateInPast = asOf.before(new Date()); asOfDateInPast = asOf.before(new Date());
@@ -933,13 +934,14 @@ public class DispositionServiceImpl extends ServiceBaseImpl
DispositionActionDefinition dad = da.getDispositionActionDefinition(); DispositionActionDefinition dad = da.getDispositionActionDefinition();
if (dad != null) if (dad != null)
{ {
boolean firstComplete = dad.eligibleOnFirstCompleteEvent(); boolean firstComplete = authenticationUtil.runAsSystem(() -> dad.eligibleOnFirstCompleteEvent());
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(nextDa.getNodeRef(), ASSOC_EVENT_EXECUTIONS, RegexQNamePattern.MATCH_ALL); List<ChildAssociationRef> assocs = getInternalNodeService().getChildAssocs(nextDa.getNodeRef(), ASSOC_EVENT_EXECUTIONS,
RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef assoc : assocs) for (ChildAssociationRef assoc : assocs)
{ {
NodeRef eventExecution = assoc.getChildRef(); NodeRef eventExecution = assoc.getChildRef();
Boolean isCompleteValue = (Boolean)this.nodeService.getProperty(eventExecution, PROP_EVENT_EXECUTION_COMPLETE); Boolean isCompleteValue = (Boolean) getInternalNodeService().getProperty(eventExecution, PROP_EVENT_EXECUTION_COMPLETE);
boolean isComplete = false; boolean isComplete = false;
if (isCompleteValue != null) if (isCompleteValue != null)
{ {
@@ -1227,7 +1229,8 @@ public class DispositionServiceImpl extends ServiceBaseImpl
public Date getDispositionActionDate(NodeRef record, NodeRef dispositionSchedule, String dispositionActionName) public Date getDispositionActionDate(NodeRef record, NodeRef dispositionSchedule, String dispositionActionName)
{ {
DispositionSchedule ds = new DispositionScheduleImpl(serviceRegistry, nodeService, dispositionSchedule); DispositionSchedule ds = new DispositionScheduleImpl(serviceRegistry, nodeService, dispositionSchedule);
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(dispositionSchedule); List<ChildAssociationRef> assocs = getInternalNodeService().getChildAssocs(dispositionSchedule);
if (assocs != null && !assocs.isEmpty()) if (assocs != null && !assocs.isEmpty())
{ {
for (ChildAssociationRef assoc : assocs) for (ChildAssociationRef assoc : assocs)
@@ -1235,7 +1238,8 @@ public class DispositionServiceImpl extends ServiceBaseImpl
if (assoc != null && assoc.getQName().getLocalName().contains(dispositionActionName)) if (assoc != null && assoc.getQName().getLocalName().contains(dispositionActionName))
{ {
DispositionActionDefinition actionDefinition = ds.getDispositionActionDefinition(assoc.getChildRef().getId()); DispositionActionDefinition actionDefinition = ds.getDispositionActionDefinition(assoc.getChildRef().getId());
return calculateAsOfDate(record, actionDefinition);
return authenticationUtil.runAsSystem(() -> calculateAsOfDate(record, actionDefinition));
} }
} }
} }

View File

@@ -513,7 +513,7 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JS
// Set the actions array // Set the actions array
setActions(rmNodeValues, nodeRef); setActions(rmNodeValues, nodeRef);
AuthenticationUtil.runAsSystem((RunAsWork<Void>) () -> {
//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)
{ {
@@ -521,14 +521,17 @@ 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;
} }
} }
} }
return null;
});
return rmNodeValues; return rmNodeValues;
} }