mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
78747: Merged V4.2-BUG-FIX (4.2.4) to HEAD-BUG-FIX (5.0/Cloud) 78624: Merged V4.2.1 (4.2.1.10) to V4.2-BUG-FIX (4.2.4) 77969: MNT-11926: Unable to start a workflow from a taskListener When activity workflow is started suspend CommandContext propogation (if any exists) so that new ProcessInstance could be flushed and correctly converted to WorkflowPath. Add unit test. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@82635 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -52,9 +52,11 @@ import org.activiti.engine.impl.bpmn.behavior.ReceiveTaskActivityBehavior;
|
||||
import org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior;
|
||||
import org.activiti.engine.impl.bpmn.deployer.BpmnDeployer;
|
||||
import org.activiti.engine.impl.bpmn.diagram.ProcessDiagramGenerator;
|
||||
import org.activiti.engine.impl.context.Context;
|
||||
import org.activiti.engine.impl.form.DefaultTaskFormHandler;
|
||||
import org.activiti.engine.impl.form.TaskFormHandler;
|
||||
import org.activiti.engine.impl.identity.Authentication;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.TimerEntity;
|
||||
@@ -985,16 +987,35 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
}
|
||||
|
||||
// Start the process-instance
|
||||
ProcessInstance instance = runtimeService.startProcessInstanceById(processDefId, variables);
|
||||
if(instance.isEnded())
|
||||
CommandContext context = Context.getCommandContext();
|
||||
boolean isContextSuspended = false;
|
||||
if (context != null && context.getException() == null)
|
||||
{
|
||||
return typeConverter.buildCompletedPath(instance.getId(), instance.getId());
|
||||
}
|
||||
else
|
||||
// MNT-11926: push null context to stack to avoid context reusage when new instance is not flushed
|
||||
Context.setCommandContext(null);
|
||||
isContextSuspended = true;
|
||||
}
|
||||
try
|
||||
{
|
||||
WorkflowPath path = typeConverter.convert((Execution)instance);
|
||||
endStartTaskAutomatically(path, instance);
|
||||
return path;
|
||||
ProcessInstance instance = runtimeService.startProcessInstanceById(processDefId, variables);
|
||||
if (instance.isEnded())
|
||||
{
|
||||
return typeConverter.buildCompletedPath(instance.getId(), instance.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
WorkflowPath path = typeConverter.convert((Execution) instance);
|
||||
endStartTaskAutomatically(path, instance);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (isContextSuspended)
|
||||
{
|
||||
// pop null context out of stack
|
||||
Context.removeCommandContext();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ActivitiException ae)
|
||||
|
Reference in New Issue
Block a user