Add logs from external-repo-manager lib 72/113772/6
authorEdyta Krukowska <edyta.krukowska@nokia.com>
Mon, 12 Oct 2020 11:15:21 +0000 (13:15 +0200)
committerEdyta Krukowska <edyta.krukowska@nokia.com>
Fri, 16 Oct 2020 09:11:59 +0000 (09:11 +0000)
Issue-ID: DCAEGEN2-2478
Signed-off-by: Edyta Krukowska <edyta.krukowska@nokia.com>
Change-Id: If6f4ab2c8fd9a4bf14e2391acc54eb7b25689e21

Changelog.md
pom.xml
src/main/java/org/onap/dcae/common/validator/StndDefinedDataValidator.java
src/main/java/org/onap/dcae/restapi/EventValidatorException.java
src/main/java/org/onap/dcae/restapi/VesRestController.java
src/test/java/org/onap/dcae/restapi/VesRestControllerTest.java
version.properties

index 9d6192b..6fcb9bc 100644 (file)
@@ -35,4 +35,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
         - [DCAEGEN-2374](https://jira.onap.org/browse/DCAEGEN2-2374) - Fix an error reported by DMaapEventPublisher test when pk is not available.
         - [DCAEGEN2-2453](https://jira.onap.org/browse/DCAEGEN2-2453) - Fix VES problem with subsequent fetching from CBS.
 ## [1.7.7] - 29/09/2020
-         - [DCAEGEN2-2462](https://jira.onap.org/browse/DCAEGEN2-2462) - Adapt schema-map.json and test files to updated 3GPP repos 
\ No newline at end of file
+         - [DCAEGEN2-2462](https://jira.onap.org/browse/DCAEGEN2-2462) - Adapt schema-map.json and test files to updated 3GPP repos 
+## [1.7.8] - 13/10/2020
+          - [DCAEGEN2-2478](https://jira.onap.org/browse/DCAEGEN2-2478) - Add logs from external-repo-manager lib
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 9e11a33..d4875c4 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
   </parent>\r
   <groupId>org.onap.dcaegen2.collectors.ves</groupId>\r
   <artifactId>VESCollector</artifactId>\r
-  <version>1.7.7-SNAPSHOT</version>\r
+  <version>1.7.8-SNAPSHOT</version>\r
   <name>dcaegen2-collectors-ves</name>\r
   <description>VESCollector</description>\r
   <properties>\r
index d936f27..20890f0 100644 (file)
@@ -29,6 +29,8 @@ import org.onap.dcae.restapi.EventValidatorException;
 import org.onap.dcaegen2.services.sdk.services.external.schema.manager.exception.IncorrectInternalFileReferenceException;
 import org.onap.dcaegen2.services.sdk.services.external.schema.manager.exception.NoLocalReferenceException;
 import org.onap.dcaegen2.services.sdk.services.external.schema.manager.service.StndDefinedValidator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -39,6 +41,8 @@ public class StndDefinedDataValidator {
 
     private final StndDefinedValidator stndDefinedValidator;
 
+    public static final Logger log = LoggerFactory.getLogger(StndDefinedDataValidator.class);
+
     @Autowired
     public StndDefinedDataValidator(StndDefinedValidator validator) {
         this.stndDefinedValidator = validator;
@@ -56,7 +60,7 @@ public class StndDefinedDataValidator {
                 throw new EventValidatorException(ApiException.STND_DEFINED_VALIDATION_FAILED);
             }
         } catch (JsonProcessingException ex) {
-            throw new EventValidatorException(ApiException.INVALID_JSON_INPUT);
+            throw new EventValidatorException(ApiException.INVALID_JSON_INPUT, ex);
         }
     }
 
@@ -64,9 +68,9 @@ public class StndDefinedDataValidator {
         try {
             return stndDefinedValidator.validate(event);
         } catch (NoLocalReferenceException e) {
-            throw new EventValidatorException(ApiException.NO_LOCAL_SCHEMA_REFERENCE);
+            throw new EventValidatorException(ApiException.NO_LOCAL_SCHEMA_REFERENCE, e);
         } catch (IncorrectInternalFileReferenceException e) {
-            throw new EventValidatorException(ApiException.INCORRECT_INTERNAL_FILE_REFERENCE);
+            throw new EventValidatorException(ApiException.INCORRECT_INTERNAL_FILE_REFERENCE, e);
         }
     }
 
index 380694d..f477bc7 100644 (file)
@@ -22,6 +22,11 @@ package org.onap.dcae.restapi;
 public class EventValidatorException extends RuntimeException {
     private final ApiException apiException;
 
+    public EventValidatorException(ApiException apiException, Exception cause) {
+        super(cause);
+        this.apiException = apiException;
+    }
+
     public EventValidatorException(ApiException apiException) {
         this.apiException = apiException;
     }
index 0a5930f..93e428b 100644 (file)
@@ -61,6 +61,7 @@ public class VesRestController {
     private static final String EVENT = "event";
     private final ApplicationSettings settings;
     private final Logger requestLogger;
+    private final Logger logger;
     private EventSender eventSender;
     private final HeaderUtils headerUtils;
     private final GeneralEventValidator generalEventValidator;
@@ -69,10 +70,11 @@ public class VesRestController {
 
     @Autowired
     VesRestController(ApplicationSettings settings, @Qualifier("incomingRequestsLogger") Logger incomingRequestsLogger,
-                      @Qualifier("eventSender") EventSender eventSender, HeaderUtils headerUtils,
+                      @Qualifier("errorLog") Logger logger, @Qualifier("eventSender") EventSender eventSender, HeaderUtils headerUtils,
                       StndDefinedDataValidator stndDefinedDataValidator) {
         this.settings = settings;
         this.requestLogger = incomingRequestsLogger;
+        this.logger = logger;
         this.eventSender = eventSender;
         this.headerUtils = headerUtils;
         this.stndDefinedValidator = stndDefinedDataValidator;
@@ -113,6 +115,7 @@ public class VesRestController {
             executeStndDefinedValidation(vesEvents);
             eventSender.send(vesEvents);
         } catch (EventValidatorException e) {
+           logger.error(e.getMessage());
             return ResponseEntity.status(e.getApiException().httpStatusCode)
                     .body(e.getApiException().toJSON().toString());
         } catch (StndDefinedNamespaceParameterNotDefinedException e) {
index 5504ca8..a3c0628 100644 (file)
@@ -27,7 +27,6 @@ import com.networknt.schema.JsonSchema;
 import io.vavr.collection.HashMap;
 import org.apache.http.HttpStatus;
 import org.jetbrains.annotations.NotNull;
-import org.json.JSONObject;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -81,6 +80,9 @@ public class VesRestControllerTest {
     @Mock
     private Logger logger;
 
+    @Mock
+    private Logger errorLogger;
+
     @Mock
     private HeaderUtils headerUtils;
 
@@ -97,7 +99,7 @@ public class VesRestControllerTest {
                 "3GPP-FaultSupervision", new String[]{VES_3_GPP_FAULT_SUPERVISION_TOPIC}
         );
         this.vesRestController = new VesRestController(applicationSettings, logger,
-                new EventSender(eventPublisher, streamIds), headerUtils, stndDefinedDataValidator);
+                errorLogger, new EventSender(eventPublisher, streamIds), headerUtils, stndDefinedDataValidator);
     }
 
     @Test
index 976c443..6460498 100644 (file)
@@ -1,6 +1,6 @@
 major=1
 minor=7
-patch=7
+patch=8
 base_version=${major}.${minor}.${patch}
 release_version=${base_version}
 snapshot_version=${base_version}-SNAPSHOT