diff options
author | Kuleshov, Elena <evn@att.com> | 2020-08-31 15:19:05 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@att.com> | 2020-08-31 15:19:06 -0400 |
commit | db89a3e8ed8af0c8fc25c8b288f527bd63e34fc2 (patch) | |
tree | d4e49371bbc562e57823f747a5ef64dd40d53ed8 /mso-api-handlers/mso-api-handler-infra/src/main | |
parent | d2857ab5a83fe6485083d7af121e5b788ea25c13 (diff) |
Set serviceInstanceId on failed validation
Set serviceInstanceId on failed validation requests in the DB.
Issue-ID: SO-3211
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: Ie4232dfd7caa2cc2661ce56b1b14863ac02628fc
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main')
4 files changed, 23 insertions, 10 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) { |