use of io.automatiko.engine.workflow.base.core.context.exception.ExceptionHandler in project automatiko-engine by automatiko-io.
the class CompensationScopeInstance method handleException.
public void handleException(io.automatiko.engine.api.runtime.process.NodeInstance nodeInstance, String activityRef, Object dunno) {
assert activityRef != null : "It should not be possible for the compensation activity reference to be null here.";
CompensationScope compensationScope = (CompensationScope) getExceptionScope();
// broadcast/general compensation in reverse order
if (activityRef.startsWith(IMPLICIT_COMPENSATION_PREFIX)) {
activityRef = activityRef.substring(IMPLICIT_COMPENSATION_PREFIX.length());
assert activityRef.equals(compensationScope.getContextContainerId()) : "Compensation activity ref [" + activityRef + "] does not match" + " Compensation Scope container id [" + compensationScope.getContextContainerId() + "]";
Map<String, ExceptionHandler> handlers = compensationScope.getExceptionHandlers();
List<String> completedNodeIds = ((WorkflowProcessInstanceImpl) getProcessInstance()).getCompletedNodeIds();
ListIterator<String> iter = completedNodeIds.listIterator(completedNodeIds.size());
while (iter.hasPrevious()) {
String completedId = iter.previous();
ExceptionHandler handler = handlers.get(completedId);
if (handler != null) {
handleException(nodeInstance, handler, completedId, null);
}
}
} else {
// Specific compensation
ExceptionHandler handler = compensationScope.getExceptionHandler(activityRef);
if (handler == null) {
throw new IllegalArgumentException("Could not find CompensationHandler for " + activityRef);
}
handleException(nodeInstance, handler, activityRef, null);
}
// Cancel all node instances created for compensation
while (!compensationInstances.isEmpty()) {
NodeInstance generatedInstance = compensationInstances.pop();
((NodeInstanceContainer) generatedInstance.getNodeInstanceContainer()).removeNodeInstance(generatedInstance);
}
}
use of io.automatiko.engine.workflow.base.core.context.exception.ExceptionHandler in project automatiko-engine by automatiko-io.
the class ExceptionScopeInstance method handleException.
public void handleException(NodeInstance nodeInstance, String exception, Object params) {
ExceptionHandler handler = getExceptionScope().getExceptionHandler(exception);
if (handler == null) {
throw new IllegalArgumentException("Could not find ExceptionHandler for " + exception);
}
handleException(nodeInstance, handler, exception, params);
}
use of io.automatiko.engine.workflow.base.core.context.exception.ExceptionHandler in project automatiko-engine by automatiko-io.
the class XmlWorkflowProcessDumper method visitExceptionHandlers.
public static void visitExceptionHandlers(Map<String, ExceptionHandler> exceptionHandlers, StringBuilder xmlDump) {
if (exceptionHandlers != null && exceptionHandlers.size() > 0) {
xmlDump.append(" <exceptionHandlers>" + EOL);
for (Map.Entry<String, ExceptionHandler> entry : exceptionHandlers.entrySet()) {
ExceptionHandler exceptionHandler = entry.getValue();
if (exceptionHandler instanceof ActionExceptionHandler) {
ActionExceptionHandler actionExceptionHandler = (ActionExceptionHandler) exceptionHandler;
xmlDump.append(" <exceptionHandler faultName=\"" + entry.getKey() + "\" type=\"action\" ");
String faultVariable = actionExceptionHandler.getFaultVariable();
if (faultVariable != null && faultVariable.length() > 0) {
xmlDump.append("faultVariable=\"" + faultVariable + "\" ");
}
xmlDump.append(">" + EOL);
ProcessAction action = actionExceptionHandler.getAction();
if (action != null) {
AbstractNodeHandler.writeAction(action, xmlDump);
}
xmlDump.append(" </exceptionHandler>" + EOL);
} else {
throw new IllegalArgumentException("Unknown exception handler type: " + exceptionHandler);
}
}
xmlDump.append(" </exceptionHandlers>" + EOL);
}
}
Aggregations