diff options
author | Edyta Krukowska <edyta.krukowska@nokia.com> | 2020-10-12 13:15:21 +0200 |
---|---|---|
committer | Edyta Krukowska <edyta.krukowska@nokia.com> | 2020-10-16 09:11:59 +0000 |
commit | 4846c92177fb3e437e678c4abdf4733ab0b7a0f2 (patch) | |
tree | f98b7970b90f13ae5c0edefaac473e66668d193f /src/main | |
parent | 72c913d96d76ecce08a92e3794b22e4e6e88a85f (diff) |
Add logs from external-repo-manager lib
Issue-ID: DCAEGEN2-2478
Signed-off-by: Edyta Krukowska <edyta.krukowska@nokia.com>
Change-Id: If6f4ab2c8fd9a4bf14e2391acc54eb7b25689e21
Diffstat (limited to 'src/main')
3 files changed, 16 insertions, 4 deletions
diff --git a/src/main/java/org/onap/dcae/common/validator/StndDefinedDataValidator.java b/src/main/java/org/onap/dcae/common/validator/StndDefinedDataValidator.java index d936f272..20890f01 100644 --- a/src/main/java/org/onap/dcae/common/validator/StndDefinedDataValidator.java +++ b/src/main/java/org/onap/dcae/common/validator/StndDefinedDataValidator.java @@ -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); } } diff --git a/src/main/java/org/onap/dcae/restapi/EventValidatorException.java b/src/main/java/org/onap/dcae/restapi/EventValidatorException.java index 380694d1..f477bc7c 100644 --- a/src/main/java/org/onap/dcae/restapi/EventValidatorException.java +++ b/src/main/java/org/onap/dcae/restapi/EventValidatorException.java @@ -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; } diff --git a/src/main/java/org/onap/dcae/restapi/VesRestController.java b/src/main/java/org/onap/dcae/restapi/VesRestController.java index 0a5930f6..93e428b4 100644 --- a/src/main/java/org/onap/dcae/restapi/VesRestController.java +++ b/src/main/java/org/onap/dcae/restapi/VesRestController.java @@ -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) { |