diff options
Diffstat (limited to 'mso-api-handlers')
5 files changed, 23 insertions, 13 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java index 665fa547cc..c7692cb2cc 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java @@ -396,7 +396,8 @@ public class E2EServiceInstances { ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, - "Exception while communciate with " + "Catalog DB", action, ModelType.service.name(), requestJSON); + "Exception while communciate with " + "Catalog DB", action, ModelType.service.name(), requestJSON, + null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -408,7 +409,7 @@ public class E2EServiceInstances { ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "Recipe does not exist in catalog DB", action, - ModelType.service.name(), requestJSON); + ModelType.service.name(), requestJSON, null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -484,7 +485,8 @@ public class E2EServiceInstances { ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, - "Exception while communciate with " + "Catalog DB", action, ModelType.service.name(), requestJSON); + "Exception while communciate with " + "Catalog DB", action, ModelType.service.name(), requestJSON, + null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -496,7 +498,7 @@ public class E2EServiceInstances { ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "Recipe does not exist in catalog DB", action, - ModelType.service.name(), requestJSON); + ModelType.service.name(), requestJSON, null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -715,7 +717,8 @@ public class E2EServiceInstances { ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, - "No communication to catalog DB " + e.getMessage(), action, ModelType.service.name(), requestJSON); + "No communication to catalog DB " + e.getMessage(), action, ModelType.service.name(), requestJSON, + null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -727,7 +730,7 @@ public class E2EServiceInstances { MsoException.ServiceException, "Recipe does not exist in catalog DB", ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "No recipe found in DB", action, - ModelType.service.name(), requestJSON); + ModelType.service.name(), requestJSON, null); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -948,7 +951,7 @@ public class E2EServiceInstances { ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, - ModelType.service.name(), requestJSON); + ModelType.service.name(), requestJSON, null); throw validateException; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java index 4ac8b73698..bf76cd3174 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java @@ -451,7 +451,7 @@ public class MsoRequest { } public void createErrorRequestRecord(Status status, String requestId, String errorMessage, Actions action, - String requestScope, String requestJSON) { + String requestScope, String requestJSON, String serviceInstanceId) { try { InfraActiveRequests request = new InfraActiveRequests(requestId); Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis()); @@ -463,6 +463,9 @@ public class MsoRequest { request.setRequestAction(action.toString()); request.setRequestScope(requestScope); request.setRequestBody(requestJSON); + if (serviceInstanceId != null) { + request.setServiceInstanceId(serviceInstanceId); + } Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis()); request.setEndTime(endTimeStamp); request.setRequestUrl(MDC.get(LogConstants.HTTP_URL)); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java index a68309f199..87e5a2f23e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java @@ -326,7 +326,7 @@ public class RequestHandlerUtils extends AbstractRestHandler { String requestScope = requestScopeFromUri(requestUri); msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, - requestScope, requestJSON); + requestScope, requestJSON, null); throw validateException; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index 418ba05abf..107aa57974 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -823,9 +823,16 @@ public class ServiceInstances extends AbstractRestHandler { sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, requestId, requestUri); action = handleReplaceInstance(action, sir); - requestValidatorListenerRunner.runValidations(requestUri, instanceIdMap, sir, queryParams, action); String requestScope = requestHandlerUtils.deriveRequestScope(action, sir, requestUri); + try { + requestValidatorListenerRunner.runValidations(requestUri, instanceIdMap, sir, queryParams, action); + } catch (ApiException e) { + msoRequest.createErrorRequestRecord(Status.FAILED, requestId, e.getMessage(), action, requestScope, + requestJSON, sir.getServiceInstanceId()); + throw e; + } + InfraActiveRequests currentActiveReq = msoRequest.createRequestObject(sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope); if (sir.getRequestDetails().getRequestParameters() != null) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java index 7711608288..1f944da7ba 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java @@ -335,7 +335,6 @@ public class OrchestrationRequestsTest extends BaseTest { Map<String, List<String>> orchestrationMap = new HashMap<>(); orchestrationMap.put("modelType", values); - List<GetOrchestrationResponse> testResponses = new ArrayList<>(); List<InfraActiveRequests> requests = requestsDbClient.getOrchestrationFiltersFromInfraActive(orchestrationMap); HttpHeaders headers = new HttpHeaders(); @@ -427,7 +426,6 @@ public class OrchestrationRequestsTest extends BaseTest { public void testUnlockOrchestrationRequest_Valid_Status() throws JsonParseException, JsonMappingException, IOException, ValidationException { setupTestUnlockOrchestrationRequest_Valid_Status("5ffbabd6-b793-4377-a1ab-082670fbc7ac", "PENDING"); - ObjectMapper mapper = new ObjectMapper(); String requestJSON = new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/Request.json"))); HttpHeaders headers = new HttpHeaders(); @@ -481,7 +479,6 @@ public class OrchestrationRequestsTest extends BaseTest { assertThat(actualProcessingData, sameBeanAs(expectedDataList)); } - public void setupTestGetOrchestrationRequest() throws Exception { // For testGetOrchestrationRequest wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-1a18-42e5-965d-8ea592502018")) |