try{
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
jbpmContext = jbpmConfiguration.createJbpmContext();
String activityKeyIdStr = (String) request.getAttribute("ActivityKey");
long activityKeyId = Long.valueOf(activityKeyIdStr).longValue();
TaskInstance taskInstance = jbpmContext.getTaskInstance(activityKeyId);
ContextInstance contextInstance = taskInstance.getContextInstance();
ProcessInstance processInstance = contextInstance.getProcessInstance();
if (request.getAttribute("CompletedActivity") != null){
// Submit buttin named CompleteActivity is pressed
SpagoBITracer.info("Workflow", "CompleteOrRejectActivityModule", "service", "Completing Activity ["+ activityKeyId + "]");
taskInstance.end();
} else {
// Submit buttin named RejectActivity is pressed
SpagoBITracer.info("Workflow", "CompleteOrRejectActivityModule", "service", "Completing Activity ["+ activityKeyId + "]");
taskInstance.cancel();
}
jbpmContext.save(processInstance);
} catch (Exception e) {
SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(),
"service", "Error during the complete or reject workflow activity", e);