use of org.openecomp.mso.bpmn.common.workflow.service.WorkflowProcessorException in project so by onap.
the class WorkflowAsyncResource method startProcessInstanceByKey.
/**
* Asynchronous JAX-RS method that starts a process instance.
*
* @param processKey the process key
* @param variableMap input variables to the process
* @return
*/
@POST
@Path("/services/{processKey}")
@Operation(description = "Starts a new process with the appropriate process Key. Aysnc fall outs are only logged")
@Produces("application/json")
@Consumes("application/json")
public Response startProcessInstanceByKey(@PathParam("processKey") String processKey, VariableMapImpl variableMap) {
Map<String, Object> inputVariables = getInputVariables(variableMap);
try {
MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, getRequestId(inputVariables));
processor.startProcess(processKey, variableMap);
WorkflowResponse response = waitForResponse(inputVariables);
if (response.getMessageCode() == 500) {
return Response.status(500).entity(response).build();
} else {
return Response.status(202).entity(response).build();
}
} catch (WorkflowProcessorException e) {
WorkflowResponse response = e.getWorkflowResponse();
return Response.status(500).entity(response).build();
} catch (Exception e) {
WorkflowResponse response = buildUnkownError(getRequestId(inputVariables), e.getMessage());
return Response.status(500).entity(response).build();
}
}
use of org.openecomp.mso.bpmn.common.workflow.service.WorkflowProcessorException in project so by onap.
the class WorkflowProcessor method startProcess.
@Async
public void startProcess(String processKey, VariableMapImpl variableMap) {
Map<String, Object> inputVariables;
String processInstanceId = null;
try {
inputVariables = getInputVariables(variableMap);
// This variable indicates that the flow was invoked asynchronously
inputVariables.put("isAsyncProcess", "true");
// Note: this creates a random businessKey if it wasn't specified.
String businessKey = getBusinessKey(inputVariables);
logger.debug("***Received MSO startProcessInstanceByKey with processKey: {} and variables: {}", processKey, inputVariables);
RuntimeService runtimeService = getProcessEngineServices().getRuntimeService();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processKey, businessKey, inputVariables);
processInstanceId = processInstance.getId();
logger.debug(logMarker + "Process " + processKey + ":" + processInstanceId + " " + (processInstance.isEnded() ? "ENDED" : "RUNNING"));
} catch (Exception e) {
WorkflowResponse workflowResponse = new WorkflowResponse();
workflowResponse.setResponse("Error occurred while executing the process: " + e);
workflowResponse.setProcessInstanceID(processInstanceId);
workflowResponse.setMessageCode(500);
workflowResponse.setMessage("Fail");
throw new WorkflowProcessorException(workflowResponse);
}
}
Aggregations