use of io.automatiko.engine.workflow.process.instance.WorkflowRuntimeException in project automatiko-engine by automatiko-io.
the class ActionNodeInstance method internalTrigger.
public void internalTrigger(final NodeInstance from, String type) {
triggerTime = new Date();
if (!io.automatiko.engine.workflow.process.core.Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
throw new IllegalArgumentException("An ActionNode only accepts default incoming connections!");
}
Action action = (Action) getActionNode().getAction().getMetaData("Action");
try {
ProcessContext context = new ProcessContext(getProcessInstance().getProcessRuntime());
context.setNodeInstance(this);
executeAction(action);
} catch (WorkflowRuntimeException wre) {
throw wre;
} catch (Exception e) {
// - or context.setNodeInstance(this)
throw new WorkflowRuntimeException(this, getProcessInstance(), "Unable to execute Action: " + e.getMessage(), e);
}
triggerCompleted();
}
use of io.automatiko.engine.workflow.process.instance.WorkflowRuntimeException in project automatiko-engine by automatiko-io.
the class WorkItemNodeInstance method handleException.
protected void handleException(String exceptionName, Exception e) {
ExceptionScopeInstance exceptionScopeInstance = (ExceptionScopeInstance) resolveContextInstance(ExceptionScope.EXCEPTION_SCOPE, exceptionName);
if (exceptionScopeInstance == null) {
if (e instanceof WorkItemExecutionError) {
throw (WorkItemExecutionError) e;
}
throw new WorkflowRuntimeException(this, getProcessInstance(), "Unable to execute Action: " + e.getMessage(), e);
}
// workItemId must be set otherwise cancel activity will not find the right work
// item
this.workItemId = workItem.getId();
Object param = e;
if (e instanceof WorkItemExecutionError) {
param = ((WorkItemExecutionError) e).getErrorData();
}
exceptionScopeInstance.handleException(this, exceptionName, param != null ? param : e);
}
use of io.automatiko.engine.workflow.process.instance.WorkflowRuntimeException in project automatiko-engine by automatiko-io.
the class RuleSetNodeInstance method handleException.
private void handleException(Throwable e) {
String exceptionName = e.getClass().getName();
Object param = e;
if (e instanceof WorkItemExecutionError) {
param = ((WorkItemExecutionError) e).getErrorData();
exceptionName = ((WorkItemExecutionError) e).getErrorCode();
}
ExceptionScopeInstance exceptionScopeInstance = getExceptionScopeInstance(exceptionName);
if (exceptionScopeInstance != null) {
exceptionScopeInstance.handleException(this, exceptionName, param != null ? param : e);
} else {
Throwable rootCause = getRootException(e);
if (rootCause != null) {
exceptionName = rootCause.getClass().getName();
param = rootCause;
if (rootCause instanceof WorkItemExecutionError) {
param = ((WorkItemExecutionError) rootCause).getErrorData();
exceptionName = ((WorkItemExecutionError) rootCause).getErrorCode();
}
exceptionScopeInstance = getExceptionScopeInstance(exceptionName);
if (exceptionScopeInstance != null) {
exceptionScopeInstance.handleException(this, exceptionName, param != null ? param : e);
return;
}
}
if (e instanceof WorkItemExecutionError) {
throw (WorkItemExecutionError) e;
}
throw new WorkflowRuntimeException(this, getProcessInstance(), "Unable to execute Action: " + e.getMessage(), e);
}
}
use of io.automatiko.engine.workflow.process.instance.WorkflowRuntimeException in project automatiko-engine by automatiko-io.
the class SplitInstance method internalTrigger.
public void internalTrigger(final NodeInstance from, String type) {
if (!io.automatiko.engine.workflow.process.core.Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
throw new IllegalArgumentException("A Split only accepts default incoming connections!");
}
triggerTime = new Date();
final Split split = getSplit();
try {
executeStrategy(split, type);
} catch (WorkflowRuntimeException wre) {
throw wre;
} catch (Exception e) {
throw new WorkflowRuntimeException(this, getProcessInstance(), "Unable to execute Split: " + e.getMessage(), e);
}
}
use of io.automatiko.engine.workflow.process.instance.WorkflowRuntimeException in project automatiko-engine by automatiko-io.
the class WorkItemNodeInstance method exceptionHandlingCompleted.
private void exceptionHandlingCompleted(ProcessInstance processInstance, ProcessWorkItemHandlerException handlerException) {
if (handlerException == null) {
handlerException = (ProcessWorkItemHandlerException) ((WorkflowProcessInstance) processInstance).getVariable("Error");
}
switch(handlerException.getStrategy()) {
case ABORT:
getProcessInstance().getProcessRuntime().getWorkItemManager().abortWorkItem(getWorkItem().getId());
break;
case RETHROW:
String exceptionName = handlerException.getCause().getClass().getName();
ExceptionScopeInstance exceptionScopeInstance = (ExceptionScopeInstance) resolveContextInstance(ExceptionScope.EXCEPTION_SCOPE, exceptionName);
if (exceptionScopeInstance == null) {
throw new WorkflowRuntimeException(this, getProcessInstance(), "Unable to execute work item " + handlerException.getMessage(), handlerException.getCause());
}
exceptionScopeInstance.handleException(this, exceptionName, handlerException.getCause());
break;
case RETRY:
Map<String, Object> parameters = new HashMap<>(getWorkItem().getParameters());
parameters.putAll(processInstance.getVariables());
((DefaultWorkItemManager) getProcessInstance().getProcessRuntime().getWorkItemManager()).retryWorkItem(getWorkItem().getId(), parameters);
break;
case COMPLETE:
getProcessInstance().getProcessRuntime().getWorkItemManager().completeWorkItem(getWorkItem().getId(), processInstance.getVariables());
break;
default:
break;
}
}
Aggregations