in kogito-quarkus-examples/process-error-handling/src/main/java/org/acme/wih/CustomTaskWorkItemHandler.java [39:67]
public Optional<WorkItemTransition> activateWorkItemHandler(KogitoWorkItemManager manager, KogitoWorkItemHandler handler, KogitoWorkItem workItem, WorkItemTransition transition) {
LOG.debug("start");
LOG.debug("Passed parameters:");
// Printing task’s parameters, it will also print
// our value we pass to the task from the process
for (String parameter : workItem.getParameters().keySet()) {
LOG.debug(parameter + " = " + workItem.getParameters().get(parameter));
}
String input = (String) workItem.getParameter("Input");
Map<String, Object> results = new HashMap<String, Object>();
results.put("Result", "Hello " + input);
if (input.matches("(RETRY|COMPLETE|RETHROW)")) {
handleError(input);
} else if (input.contentEquals("ABORT")) {
return Optional.of(handler.abortTransition(workItem.getPhaseStatus()));
} else {
// Don’t forget to finish the work item otherwise the process
// will be active infinitely and never will pass the flow
// to the next node.
return Optional.of(handler.completeTransition(workItem.getPhaseStatus(), results));
}
LOG.debug("end");
return Optional.empty();
}