From a2df406852f02374c81afc8231639c7cb482f10e Mon Sep 17 00:00:00 2001 From: "rob.bog" Date: Tue, 28 May 2019 13:18:24 +0200 Subject: Cleaned up duplicated literals Cleaned up Sonar code smells related to the duplicated literals in loggers. Issue-ID: SO-1932 Signed-off-by: Robert Bogacki Change-Id: I58c48cec0012c42b7b892ae76c24c6a087c60c7e --- .../src/main/java/org/onap/so/apihandler/common/CamundaClient.java | 7 ++++--- .../src/main/java/org/onap/so/apihandler/common/XMLValidator.java | 5 +++-- .../org/onap/so/apihandlerinfra/exceptions/ApiExceptionMapper.java | 5 +++-- 3 files changed, 10 insertions(+), 7 deletions(-) (limited to 'mso-api-handlers/mso-api-handler-common/src/main/java/org/onap') diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java index 75fb00c7a6..eb4ba76530 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java @@ -27,6 +27,7 @@ package org.onap.so.apihandler.common; import java.io.IOException; import java.util.UUID; import javax.xml.bind.DatatypeConverter; +import com.google.common.base.Strings; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpPost; @@ -161,7 +162,7 @@ public class CamundaClient extends RequestClient { jsonReq = mapper.writeValueAsString(camundaRequest); logger.trace("request body is {}", jsonReq); } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.APIH_WARP_REQUEST.toString(), "Camunda", "wrapRequest", + logger.error(Strings.repeat("{} ", 5), MessageEnum.APIH_WARP_REQUEST.toString(), "Camunda", "wrapRequest", ErrorCode.BusinessProcesssError.getValue(), "Error in APIH Warp request", e); } return jsonReq; @@ -252,8 +253,8 @@ public class CamundaClient extends RequestClient { jsonReq = mapper.writeValueAsString(camundaRequest); logger.trace("request body is {}", jsonReq); } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.APIH_WARP_REQUEST.toString(), "Camunda", "wrapVIDRequest", - ErrorCode.BusinessProcesssError.getValue(), "Error in APIH Warp request", e); + logger.error(Strings.repeat("{} ", 5), MessageEnum.APIH_WARP_REQUEST.toString(), "Camunda", + "wrapVIDRequest", ErrorCode.BusinessProcesssError.getValue(), "Error in APIH Warp request", e); } return jsonReq; } diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/XMLValidator.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/XMLValidator.java index b972f7e1db..b9a06ac1d9 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/XMLValidator.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/XMLValidator.java @@ -31,6 +31,7 @@ import javax.xml.transform.stream.StreamSource; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; import javax.xml.validation.Validator; +import com.google.common.base.Strings; import org.apache.commons.io.IOUtils; import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; @@ -94,8 +95,8 @@ public class XMLValidator { return "ErrorDetails: " + e.getMessage(); } catch (Exception e) { - logger.error("{} {} {}", MessageEnum.APIH_CANNOT_READ_SCHEMA.toString(), ErrorCode.SchemaError.getValue(), - "APIH cannot read schema file", e); + logger.error(Strings.repeat("{} ", 3), MessageEnum.APIH_CANNOT_READ_SCHEMA.toString(), + ErrorCode.SchemaError.getValue(), "APIH cannot read schema file", e); return "ErrorDetails: " + "Unable to read the schema file"; } 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 3b977639fc..12379f9c1a 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 @@ -36,6 +36,7 @@ import javax.ws.rs.ext.Provider; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; +import com.google.common.base.Strings; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; @@ -134,8 +135,8 @@ public class ApiExceptionMapper implements ExceptionMapper { } catch (JsonProcessingException | JAXBException e) { String errorMsg = "Exception in buildServiceErrorResponse writing exceptionType to string " + e.getMessage(); - logger.error("{} {} {} {}", MessageEnum.GENERAL_EXCEPTION.toString(), "BuildServiceErrorResponse", - ErrorCode.DataError.getValue(), errorMsg, e); + logger.error(Strings.repeat("{} ", 4), MessageEnum.GENERAL_EXCEPTION.toString(), + "BuildServiceErrorResponse", ErrorCode.DataError.getValue(), errorMsg, e); return errorMsg; } -- cgit 1.2.3-korg