summaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java
diff options
context:
space:
mode:
authorshrikantawachar <shrikant.awachar@amdocs.com>2018-01-04 19:57:04 +0530
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>2018-01-04 18:37:31 +0000
commit386af7e65bbc73f50f0c78b3a745c8c81ecad288 (patch)
tree312b7eb9f6dfa5761e36daa5dde3b4eb75fa8959 /openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java
parentde50de7a41451d7b2ef4c5dae8c8c7d511e1a097 (diff)
Fixing sonar qube issues
Refactored the code as per review comment in DefaultExceptionMapper.java file. Change-Id: I23c43e52e444cbd26b9c6bcf1c060f0f8b8f8204 Issue-ID: SDC-343 Signed-off-by: shrikantawachar <shrikant.awachar@amdocs.com>
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java
index 2f6d298f01..28917b9fb7 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java
@@ -50,11 +50,12 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> {
private static final String ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE =
"errorCodesToResponseStatusMapping.json";
@SuppressWarnings("unchecked")
- private static Map<String, String> errorCodeToResponseStatus =
+ private static final Map<String, String> ERROR_CODE_TO_RESPONSE_STATUS =
FileUtils.readViaInputStream(ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE,
- stream -> JsonUtil.json2Object(stream, Map.class));
+ stream -> JsonUtil.json2Object(stream, Map.class));
- private static Logger logger = (Logger) LoggerFactory.getLogger(DefaultExceptionMapper.class);
+ private static final Logger LOGGER = (Logger) LoggerFactory.getLogger(DefaultExceptionMapper
+ .class);
@Override
public Response toResponse(Exception exception) {
@@ -80,16 +81,16 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> {
private Response transform(CoreException coreException) {
Response response;
ErrorCode code = coreException.code();
- logger.error(code.message(), coreException);
+ LOGGER.error(code.message(), coreException);
if (coreException.code().category().equals(ErrorCategory.APPLICATION)) {
- if (Response.Status.NOT_FOUND.name().equals(errorCodeToResponseStatus.get(code.id()))) {
+ if (Response.Status.NOT_FOUND.name().equals(ERROR_CODE_TO_RESPONSE_STATUS.get(code.id()))) {
response = Response
.status(Response.Status.NOT_FOUND)
.entity(toEntity(Response.Status.NOT_FOUND, code))
.build();
} else if (Response.Status.BAD_REQUEST.name()
- .equals(errorCodeToResponseStatus.get(code.id()))) {
+ .equals(ERROR_CODE_TO_RESPONSE_STATUS.get(code.id()))) {
response = Response
.status(Response.Status.BAD_REQUEST)
.entity(toEntity(Response.Status.BAD_REQUEST, code))
@@ -129,7 +130,7 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> {
ErrorCode validationErrorCode = new ValidationErrorBuilder(message, fieldName).build();
- logger.error(validationErrorCode.message(), validationException);
+ LOGGER.error(validationErrorCode.message(), validationException);
return Response
.status(Response.Status.EXPECTATION_FAILED) //error 417
.entity(toEntity(Response.Status.EXPECTATION_FAILED, validationErrorCode))
@@ -138,7 +139,7 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> {
private Response transform(JsonMappingException jsonMappingException) {
ErrorCode jsonMappingErrorCode = new JsonMappingErrorBuilder().build();
- logger.error(jsonMappingErrorCode.message(), jsonMappingException);
+ LOGGER.error(jsonMappingErrorCode.message(), jsonMappingException);
return Response
.status(Response.Status.EXPECTATION_FAILED) //error 417
.entity(toEntity(Response.Status.EXPECTATION_FAILED, jsonMappingErrorCode))
@@ -147,7 +148,7 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> {
private Response transform(Exception exception) {
ErrorCode generalErrorCode = new GeneralErrorBuilder(exception.getMessage()).build();
- logger.error(generalErrorCode.message(), exception);
+ LOGGER.error(generalErrorCode.message(), exception);
return Response
.status(Response.Status.INTERNAL_SERVER_ERROR)
.entity(toEntity(Response.Status.INTERNAL_SERVER_ERROR, generalErrorCode))