use of io.automatiko.engine.workflow.base.instance.context.exception.ExceptionScopeInstance in project automatiko-engine by automatiko-io.
the class LambdaSubProcessNodeInstance method processInstanceCompleted.
public void processInstanceCompleted(ProcessInstance processInstance) {
removeEventListeners();
String parentInstanceId = getProcessInstance().getId();
if (getProcessInstance().getParentProcessInstanceId() != null && !getProcessInstance().getParentProcessInstanceId().isEmpty()) {
parentInstanceId = getProcessInstance().getParentProcessInstanceId() + ":" + parentInstanceId;
}
((ProcessInstanceImpl) getProcessInstance()).removeChild(processInstance.getProcess().getId(), parentInstanceId + ":" + processInstance.getId());
handleOutMappings(processInstance);
if (processInstance.getState() == ProcessInstance.STATE_ABORTED) {
String faultName = processInstance.getOutcome() == null ? "" : processInstance.getOutcome();
// handle exception as sub process failed with error code
ExceptionScopeInstance exceptionScopeInstance = (ExceptionScopeInstance) resolveContextInstance(ExceptionScope.EXCEPTION_SCOPE, faultName);
if (exceptionScopeInstance != null) {
exceptionScopeInstance.handleException(this, faultName, processInstance.getFaultData());
if (getSubProcessNode() != null && !getSubProcessNode().isIndependent() && getSubProcessNode().isAbortParent()) {
cancel();
}
return;
} else if (getSubProcessNode() != null && !getSubProcessNode().isIndependent() && getSubProcessNode().isAbortParent()) {
getProcessInstance().setState(ProcessInstance.STATE_ABORTED, faultName);
return;
}
}
// handle dynamic subprocess
if (getNode() == null) {
setMetaData("NodeType", "SubProcessNode");
}
// if there were no exception proceed normally
triggerCompleted();
if (getProcessInstance().getProcess().getType().equals(Process.FUNCTION_FLOW_TYPE)) {
processInstance.getMetaData().put("ATK_FUNC_FLOW_NEXT", getProcessInstance().getMetaData().get("ATK_FUNC_FLOW_NEXT"));
processInstance.getMetaData().put("ATK_FUNC_FLOW_ID", getProcessInstance().getId());
}
}
use of io.automatiko.engine.workflow.base.instance.context.exception.ExceptionScopeInstance in project automatiko-engine by automatiko-io.
the class SubProcessNodeInstance method processInstanceCompleted.
public void processInstanceCompleted(ProcessInstance processInstance) {
removeEventListeners();
((ProcessInstanceImpl) getProcessInstance()).removeChild(processInstance.getProcessId(), processInstance.getId());
handleOutMappings(processInstance);
if (processInstance.getState() == ProcessInstance.STATE_ABORTED) {
String faultName = processInstance.getOutcome() == null ? "" : processInstance.getOutcome();
// handle exception as sub process failed with error code
ExceptionScopeInstance exceptionScopeInstance = (ExceptionScopeInstance) resolveContextInstance(ExceptionScope.EXCEPTION_SCOPE, faultName);
if (exceptionScopeInstance != null) {
exceptionScopeInstance.handleException(this, faultName, processInstance.getFaultData());
if (getSubProcessNode() != null && !getSubProcessNode().isIndependent() && getSubProcessNode().isAbortParent()) {
cancel();
}
return;
} else if (getSubProcessNode() != null && !getSubProcessNode().isIndependent() && getSubProcessNode().isAbortParent()) {
((ProcessInstance) getProcessInstance()).setState(ProcessInstance.STATE_ABORTED, faultName);
return;
}
}
// handle dynamic subprocess
if (getNode() == null) {
setMetaData("NodeType", "SubProcessNode");
}
// if there were no exception proceed normally
triggerCompleted();
}
use of io.automatiko.engine.workflow.base.instance.context.exception.ExceptionScopeInstance in project automatiko-engine by automatiko-io.
the class NodeInstanceImpl method executeAction.
/**
* This method is used in both instances of the {@link ExtendedNodeInstanceImpl}
* and {@link ActionNodeInstance} instances in order to handle exceptions thrown
* when executing actions.
*
* @param action An {@link Action} instance.
*/
protected void executeAction(Action action) {
ProcessContext context = new ProcessContext(getProcessInstance().getProcessRuntime());
context.setNodeInstance(this);
context.setProcessInstance(getProcessInstance());
try {
action.execute(context);
} catch (Exception e) {
String exceptionName = e.getClass().getName();
ExceptionScopeInstance exceptionScopeInstance = (ExceptionScopeInstance) resolveContextInstance(ExceptionScope.EXCEPTION_SCOPE, exceptionName);
if (exceptionScopeInstance == null) {
throw new WorkflowRuntimeException(this, getProcessInstance(), "Unable to execute Action: " + e.getMessage(), e);
}
exceptionScopeInstance.handleException(this, exceptionName, e);
cancel();
}
}
Aggregations