use of org.onap.so.apihandlerinfra.exceptions.BPMNFailureException in project so by onap.
the class CamundaClientTest method createBPMNFailureExceptionWithCamundaResponseTest.
@Test
public void createBPMNFailureExceptionWithCamundaResponseTest() throws IOException {
HttpClientErrorException e = new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR, null, inputStream("/CamundaFailure.json").getBytes(), null);
BPMNFailureException ex = client.createBPMNFailureException(e);
assertEquals(HttpStatus.BAD_GATEWAY.value(), ex.getHttpResponseCode());
assertEquals("Request Failed due to BPEL error with HTTP Status = 500 INTERNAL_SERVER_ERROR <aetgt:WorkflowException xmlns:aetgt=\"http://org.onap/so/workflow/schema/v1\"><aetgt:ErrorMessage>Exception in create execution list 500 </aetgt:ErrorMessage><aetgt:ErrorCode>7000</aetgt:ErrorCode></aetgt:WorkflowException>", ex.getMessage());
}
use of org.onap.so.apihandlerinfra.exceptions.BPMNFailureException 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.apihandlerinfra.exceptions.BPMNFailureException 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.apihandlerinfra.exceptions.BPMNFailureException in project so by onap.
the class ApiExceptionMapperTest method testBPMNFailureResponse.
@Test
public void testBPMNFailureResponse() {
BPMNFailureException bpmnException = new BPMNFailureException.Builder("Test Message", HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_BAD_PARAMETER).build();
Response resp = mapper.toResponse((ApiException) bpmnException);
assertEquals(resp.getStatus(), HttpStatus.SC_NOT_FOUND);
}
use of org.onap.so.apihandlerinfra.exceptions.BPMNFailureException 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