CommonjWorkContainer container=(CommonjWorkContainer)o;
WorkManager wm=container.getWm();
Work workToDo=container.getWork();
CommonjWorkListener listener=container.getListener();
FooRemoteWorkItem fooRemoteWorkItem=wm.buildFooRemoteWorkItem(workToDo, listener);
int statusWI;
// Check if work was accepted
if(fooRemoteWorkItem.getStatus()==WorkEvent.WORK_ACCEPTED){
container.setFooRemoteWorkItem(fooRemoteWorkItem);
// run work!
WorkItem workItem=(WorkItem)wm.runWithReturnWI(workToDo, listener);
container.setWorkItem(workItem);
statusWI=workItem.getStatus();
// put new Object in singleton!!!
processesStatusContainer.getPidContainerMap().put(pId, container);
//session.setAttribute("SBI_PROCESS_"+document_id, container);
// if not in action mode don't send the response
if(actionMode){
try {
info=GeneralUtils.buildJSONObject(pId,statusWI);
writeBackToClient( new JSONSuccess(info));
} catch (IOException e) {
String message = "Impossible to write back the responce to the client";
throw new SpagoBIEngineServiceException(getActionName(), message, e);
}
}
}
else{ // WORK is rejected
if(actionMode){
try {
statusWI=fooRemoteWorkItem.getStatus();
info=GeneralUtils.buildJSONObject(pId,statusWI);
writeBackToClient( new JSONSuccess(info));
} catch (IOException e) {
String message = "Impossible to write back the responce to the client";
throw new SpagoBIEngineServiceException(getActionName(), message, e);