use of org.onap.so.apihandler.camundabeans.CamundaResponse in project so by onap.
the class CamundaClient method createBPMNFailureException.
protected BPMNFailureException createBPMNFailureException(HttpStatusCodeException e) {
ObjectMapper mapper = new ObjectMapper();
String responseText = null;
String message = null;
try {
CamundaResponse response = mapper.readValue(e.getResponseBodyAsString(), CamundaResponse.class);
responseText = response.getResponse();
} catch (IOException ex) {
responseText = e.getResponseBodyAsString();
}
message = String.valueOf(e.getStatusCode());
if (responseText != null && !responseText.isEmpty()) {
message = message + " " + responseText;
}
BPMNFailureException bpmnException = new BPMNFailureException.Builder(message, responseHandler.setStatus(e.getStatusCode().value()), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, e.getStatusCode()).build();
return bpmnException;
}
use of org.onap.so.apihandler.camundabeans.CamundaResponse in project so by onap.
the class ResponseHandler method getCamundaResponse.
public CamundaResponse getCamundaResponse(ResponseEntity<String> camundaResponse) throws ValidateException {
String responseBody = camundaResponse.getBody();
CamundaResponse response = null;
ObjectMapper mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
try {
response = mapper.readValue(responseBody, CamundaResponse.class);
} catch (IOException | NullPointerException e) {
logger.error("Cannot parse Camunda Response: ", e);
throw new ValidateException.Builder("Cannot parse Camunda ResponseBody. BPMN HTTP status: " + camundaResponse.getStatusCodeValue(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).build();
}
return response;
}
use of org.onap.so.apihandler.camundabeans.CamundaResponse in project so by onap.
the class ServiceIntentApiHandler method postBPELRequest.
private Response postBPELRequest(InfraActiveRequests currentActiveReq, RequestClientParameter parameter, String orchestrationURI, String requestScope) throws ApiException {
ResponseEntity<String> response = requestHandlerUtils.postRequest(currentActiveReq, parameter, orchestrationURI);
logger.debug("BPEL response : " + response);
int bpelStatus = responseHandler.setStatus(response.getStatusCodeValue());
String jsonResponse;
try {
responseHandler.acceptedResponse(response);
CamundaResponse camundaResponse = responseHandler.getCamundaResponse(response);
String responseBody = camundaResponse.getResponse();
if ("Success".equalsIgnoreCase(camundaResponse.getMessage())) {
jsonResponse = responseBody;
} else {
BPMNFailureException bpmnException = new BPMNFailureException.Builder(String.valueOf(bpelStatus) + responseBody, bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).build();
requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, bpmnException.getMessage());
throw bpmnException;
}
} catch (ApiException e) {
requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, e.getMessage());
throw e;
}
return builder.buildResponse(HttpStatus.SC_ACCEPTED, parameter.getRequestId(), jsonResponse, parameter.getApiVersion());
}
use of org.onap.so.apihandler.camundabeans.CamundaResponse in project so by onap.
the class E2EServiceInstances method bpelStatusUpdate.
private Response bpelStatusUpdate(ResponseEntity<String> responseEntity, String version) throws ApiException {
String apiVersion = version.substring(1);
responseHandler.acceptedResponse(responseEntity);
CamundaResponse camundaResponse = responseHandler.getCamundaResponse(responseEntity);
String response = camundaResponse.getResponse();
logger.debug(END_OF_THE_TRANSACTION + response);
return builder.buildResponse(HttpStatus.SC_ACCEPTED, null, response, apiVersion);
}
use of org.onap.so.apihandler.camundabeans.CamundaResponse in project so by onap.
the class Onap3gppServiceInstances method postBPELRequest.
private Response postBPELRequest(InfraActiveRequests currentActiveReq, RequestClientParameter parameter, String orchestrationURI, String requestScope) throws ApiException {
ResponseEntity<String> response = requestHandlerUtils.postRequest(currentActiveReq, parameter, orchestrationURI);
logger.debug("BPEL response : " + response);
int bpelStatus = responseHandler.setStatus(response.getStatusCodeValue());
String jsonResponse;
try {
responseHandler.acceptedResponse(response);
CamundaResponse camundaResponse = responseHandler.getCamundaResponse(response);
String responseBody = camundaResponse.getResponse();
if ("Success".equalsIgnoreCase(camundaResponse.getMessage())) {
jsonResponse = responseBody;
} else {
BPMNFailureException bpmnException = new BPMNFailureException.Builder(String.valueOf(bpelStatus) + responseBody, bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).build();
requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, bpmnException.getMessage());
throw bpmnException;
}
} catch (ApiException e) {
requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, e.getMessage());
throw e;
}
return builder.buildResponse(HttpStatus.SC_ACCEPTED, parameter.getRequestId(), jsonResponse, parameter.getApiVersion());
}
Aggregations