Add missing fields to the validation error record. 05/113505/2
authorKuleshov, Elena <evn@att.com>
Sat, 3 Oct 2020 15:15:17 +0000 (11:15 -0400)
committerBenjamin, Max (mb388a) <mb388a@att.com>
Wed, 7 Oct 2020 14:01:54 +0000 (10:01 -0400)
Add missing fields to the validation error record.
Fix the variable name for service scope check.
Correct the usage of the requestInfo variable.

Issue-ID: SO-3286
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: I67f5dd043c0ab8ee879a9e2e43f5544bb49ea275

mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java

index b09d676..7ed6038 100644 (file)
@@ -403,7 +403,7 @@ public class E2EServiceInstances {
 
             msoRequest.createErrorRequestRecord(Status.FAILED, requestId,
                     "Exception while communciate with " + "Catalog DB", action, ModelType.service.name(), requestJSON,
-                    null);
+                    null, null);
             logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
             return response;
         }
@@ -415,7 +415,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, null);
+                    ModelType.service.name(), requestJSON, null, null);
             logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
             return response;
         }
@@ -493,7 +493,7 @@ public class E2EServiceInstances {
 
             msoRequest.createErrorRequestRecord(Status.FAILED, requestId,
                     "Exception while communciate with " + "Catalog DB", action, ModelType.service.name(), requestJSON,
-                    null);
+                    null, null);
             logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
             return response;
         }
@@ -505,7 +505,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, null);
+                    ModelType.service.name(), requestJSON, null, null);
             logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
             return response;
         }
@@ -725,7 +725,7 @@ public class E2EServiceInstances {
 
             msoRequest.createErrorRequestRecord(Status.FAILED, requestId,
                     "No communication to catalog DB " + e.getMessage(), action, ModelType.service.name(), requestJSON,
-                    null);
+                    null, null);
             logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
             return response;
         }
@@ -737,7 +737,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, null);
+                    ModelType.service.name(), requestJSON, null, null);
             logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
             return response;
         }
@@ -958,7 +958,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, null);
+                    ModelType.service.name(), requestJSON, null, null);
 
             throw validateException;
         }
index bf76cd3..64c42a0 100644 (file)
@@ -451,7 +451,7 @@ public class MsoRequest {
     }
 
     public void createErrorRequestRecord(Status status, String requestId, String errorMessage, Actions action,
-            String requestScope, String requestJSON, String serviceInstanceId) {
+            String requestScope, String requestJSON, String serviceInstanceId, ServiceInstancesRequest sir) {
         try {
             InfraActiveRequests request = new InfraActiveRequests(requestId);
             Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis());
@@ -469,6 +469,17 @@ public class MsoRequest {
             Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis());
             request.setEndTime(endTimeStamp);
             request.setRequestUrl(MDC.get(LogConstants.HTTP_URL));
+            if (sir != null) {
+                if (sir.getRequestDetails() != null && sir.getRequestDetails().getRequestInfo() != null) {
+                    request.setRequestorId(sir.getRequestDetails().getRequestInfo().getRequestorId());
+                    request.setSource(sir.getRequestDetails().getRequestInfo().getSource());
+                    if (ModelType.service.name().equalsIgnoreCase(requestScope)) {
+                        if (sir.getRequestDetails().getRequestInfo().getInstanceName() != null) {
+                            request.setServiceInstanceName(sir.getRequestDetails().getRequestInfo().getInstanceName());
+                        }
+                    }
+                }
+            }
             requestsDbClient.save(request);
         } catch (Exception e) {
             logger.error("Exception when updating record in DB", e);
@@ -476,7 +487,6 @@ public class MsoRequest {
         }
     }
 
-
     public Response buildResponse(int httpResponseCode, String errorCode, InfraActiveRequests inProgress) {
         return buildResponseWithError(httpResponseCode, errorCode, inProgress, null);
     }
index 60e9c3b..cddb1ad 100644 (file)
@@ -326,7 +326,7 @@ public class RequestHandlerUtils extends AbstractRestHandler {
             String requestScope = requestScopeFromUri(requestUri);
 
             msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action,
-                    requestScope, requestJSON, null);
+                    requestScope, requestJSON, null, null);
 
             throw validateException;
         }
index 2c8e926..7924ca3 100644 (file)
@@ -830,7 +830,8 @@ public class ServiceInstances extends AbstractRestHandler {
         } catch (ApiException e) {
             msoRequest.createErrorRequestRecord(Status.FAILED, requestId, e.getMessage(), action, requestScope,
                     requestJSON, requestHandlerUtils
-                            .getServiceInstanceIdForValidationError(sir, instanceIdMap, requestScope).orElse(null));
+                            .getServiceInstanceIdForValidationError(sir, instanceIdMap, requestScope).orElse(null),
+                    sir);
             throw e;
         }