@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
StdMsgContext stdMsgContext = new StdMsgContext();
String cmdBpm = ServletRequestUtils.getStringParameter(request, "cmdBpm", null);
String returnEndpoint = null;
String returnInstanceId = null;
List<TaskInfo> taskInfoList = null;
ProcessManagerFactoryBean pmfb = new ProcessManagerFactoryBean();
ProcessManagerRemote pm = null;
try {
pm = pmfb.getProcessManager();
ProcessManagerService pms = new ProcessManagerService(pm, request);
if (StdMsgContext.CMD_PROCESS_START.equalsIgnoreCase(cmdBpm)) {
ProcessStartMsg psMsg = stdMsgContext.bindProcessStartMsg(request);
System.out.println(psMsg);
String newInstanceId = pms.processStart(psMsg);
returnEndpoint = psMsg.getInitiator();
returnInstanceId = newInstanceId;
} else if (StdMsgContext.CMD_ACTIVITY_COMPLETE.equalsIgnoreCase(cmdBpm)) {
ActivityCompleteMsg acMsg = stdMsgContext.bindActivityCompleteMsg(request);
System.out.println(acMsg);
pms.activityComplete(acMsg);
returnEndpoint = acMsg.getEndpoint();
returnInstanceId = acMsg.getInstanceId();
} else if (StdMsgContext.CMD_PROCESS_STOP.equalsIgnoreCase(cmdBpm)) {
ProcessStopMsg psMsg = stdMsgContext.bindProcessStopMsg(request);
System.out.println(psMsg);
pms.processStop(psMsg);
} else if (StdMsgContext.CMD_APPROVAL_DRAFT.equalsIgnoreCase(cmdBpm)) {
ApprovalDraftActivityCompleteMsg adacMsg = stdMsgContext.bindApprovalDraftMsg(request);
System.out.println(adacMsg);
pms.approvalDraftActivityComplete(adacMsg);
returnEndpoint = adacMsg.getEndpoint();
returnInstanceId = adacMsg.getInstanceId();
} else if (StdMsgContext.CMD_APPROVAL_COMPLETE.equalsIgnoreCase(cmdBpm)) {
ApprovalActivityCompleteMsg aacMsg = stdMsgContext.bindApprovalActivityCompleteMsg(request);
System.out.println(aacMsg);
pms.approvalActivityComplete(aacMsg);
returnEndpoint = aacMsg.getEndpoint();
returnInstanceId = aacMsg.getInstanceId();
} else if (StdMsgContext.CMD_APPROVAL_LINE_CHANGE.equalsIgnoreCase(cmdBpm)) {
ApprovalLineChangeMsg alcMsg = stdMsgContext.bindApprovalLineChangeMsg(request);
System.out.println(alcMsg);
pms.approvalLineChange(alcMsg);
} else if (StdMsgContext.CMD_TASK_INFO.equalsIgnoreCase(cmdBpm)) {
TaskInfoMsg tiMsg = stdMsgContext.bindTaskInfoMsg(request);
// System.out.println(tiMsg);
taskInfoList = pms.getTaskInfo(tiMsg);
} else if (StdMsgContext.CMD_INITIALIZE_PROCESS_INSTANCE.equalsIgnoreCase(cmdBpm)) {
InitializeProcessInstanceMsg ipiMsg = stdMsgContext.bindInitializeProcessInstanceMsg(request);
System.out.println(ipiMsg);
pms.initializeProcessInstance(ipiMsg);
} else if (StdMsgContext.CMD_WORKITEM_ACCEPT.equalsIgnoreCase(cmdBpm)) {
WorkItemAcceptMsg wiaMsg = stdMsgContext.bindWorkItemAcceptMsg(request);
System.out.println(wiaMsg);
pms.workItemAccept(wiaMsg);
} else if (StdMsgContext.CMD_DELEGATE_WORKITEM.equalsIgnoreCase(cmdBpm)) {
DelegateWorkItemMsg dwMsg = stdMsgContext.bindDelegateWorkItemMsg(request);
System.out.println(dwMsg);
pms.delegateWorkItem(dwMsg);
}