From fa36daa658a50d9ca2e57cae649d63c0e9e2882a Mon Sep 17 00:00:00 2001 From: "Smokowski, Steven" Date: Thu, 15 Aug 2019 21:40:16 -0400 Subject: Initial commit of validation framework to APIH Move ListenerRunner to common location Adjust request params name, update junit tests Update validations to work properly Properly escape period for the string split Issue-ID: SO-2232 Signed-off-by: Benjamin, Max (mb388a) Change-Id: Ia468cf7062cccf30e28afeb7a5cddc37ceb2e002 --- .../org/onap/so/apihandlerinfra/exceptions/ApiException.java | 11 ++++++++++- .../so/apihandlerinfra/exceptions/ApiExceptionMapper.java | 2 +- .../onap/so/apihandlerinfra/exceptions/ValidateException.java | 5 +++++ 3 files changed, 16 insertions(+), 2 deletions(-) (limited to 'mso-api-handlers/mso-api-handler-common/src') diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiException.java index c7f6459482..ab2ce10690 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiException.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiException.java @@ -29,7 +29,7 @@ public abstract class ApiException extends Exception { * */ private static final long serialVersionUID = 683162058616691134L; - private int httpResponseCode; + private int httpResponseCode = 500; private String messageID; private ErrorLoggerInfo errorLoggerInfo; @@ -49,6 +49,15 @@ public abstract class ApiException extends Exception { super(message, cause); } + public ApiException(String message, int httpResponseCode) { + super(message); + this.httpResponseCode = httpResponseCode; + } + + public ApiException(String message) { + super(message); + } + public String getMessageID() { return messageID; } diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiExceptionMapper.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiExceptionMapper.java index 66b86a6961..6a56b58f04 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiExceptionMapper.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiExceptionMapper.java @@ -70,7 +70,7 @@ public class ApiExceptionMapper implements ExceptionMapper { @Override public Response toResponse(ApiException exception) { - + logger.error("Error During API Call", exception); return Response.status(exception.getHttpResponseCode()).entity(buildErrorString(exception)).build(); } diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ValidateException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ValidateException.java index 372ed30d8e..ae8256e64f 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ValidateException.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ValidateException.java @@ -28,6 +28,11 @@ public class ValidateException extends ApiException { } + public ValidateException(String errorMessage, int httpResponseCode) { + super(errorMessage, httpResponseCode); + } + + public static class Builder extends ApiException.Builder { public Builder(String message, int httpResponseCode, String messageID) { -- cgit 1.2.3-korg