From 85fa078bfabea17ffdafcdf2748d1a877f00a3b0 Mon Sep 17 00:00:00 2001 From: awudzins Date: Thu, 28 Mar 2019 15:39:20 +0100 Subject: Fix sonar violation Fix sonar violation Change-Id: I72d7c4a7ac127b9ec89e8a144d934aa96884fc6a Issue-ID: DCAEGEN2-1016 Signed-off-by: Adam Wudzinski --- src/main/java/org/onap/dcae/common/EventSender.java | 7 +++++-- src/main/java/org/onap/dcae/common/VESLogger.java | 6 ------ src/main/java/org/onap/dcae/restapi/VesRestController.java | 7 ++++--- 3 files changed, 9 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/main/java/org/onap/dcae/common/EventSender.java b/src/main/java/org/onap/dcae/common/EventSender.java index 3c95315c..48268d6c 100644 --- a/src/main/java/org/onap/dcae/common/EventSender.java +++ b/src/main/java/org/onap/dcae/common/EventSender.java @@ -30,6 +30,7 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import org.json.JSONObject; +import org.onap.dcae.ApplicationException; import org.onap.dcae.ApplicationSettings; import org.onap.dcae.common.publishing.EventPublisher; import org.slf4j.Logger; @@ -37,11 +38,12 @@ import org.slf4j.LoggerFactory; public class EventSender { + private static final String COULD_NOT_FIND_FILE = "Couldn't find file ./etc/eventTransform.json"; private Map streamidHash; private ApplicationSettings properties; private EventPublisher eventPublisher; - static final Type EVENT_LIST_TYPE = new TypeToken>() {}.getType(); + private static final Type EVENT_LIST_TYPE = new TypeToken>() {}.getType(); private static final Logger log = LoggerFactory.getLogger(EventSender.class); private static final String EVENT_LITERAL = "event"; private static final String COMMON_EVENT_HEADER = "commonEventHeader"; @@ -79,7 +81,8 @@ public class EventSender { List events = new Gson().fromJson(fr, EVENT_LIST_TYPE); parseEventsJson(events, new ConfigProcessorAdapter(new ConfigProcessors(jsonObject))); } catch (IOException e) { - log.error("Couldn't find file ./etc/eventTransform.json" + e.toString()); + log.error(COULD_NOT_FIND_FILE, e); + throw new ApplicationException(COULD_NOT_FIND_FILE, e); } } if (jsonObject.has("VESversion")) diff --git a/src/main/java/org/onap/dcae/common/VESLogger.java b/src/main/java/org/onap/dcae/common/VESLogger.java index 79681484..1072fb54 100644 --- a/src/main/java/org/onap/dcae/common/VESLogger.java +++ b/src/main/java/org/onap/dcae/common/VESLogger.java @@ -25,12 +25,6 @@ import com.att.nsa.clock.SaClock; import com.att.nsa.logging.LoggingContext; import com.att.nsa.logging.LoggingContextFactory; import com.att.nsa.logging.log4j.EcompFields; -import jline.internal.Log; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.net.InetAddress; -import java.net.UnknownHostException; import java.util.UUID; public class VESLogger { diff --git a/src/main/java/org/onap/dcae/restapi/VesRestController.java b/src/main/java/org/onap/dcae/restapi/VesRestController.java index 510031df..3102c31c 100644 --- a/src/main/java/org/onap/dcae/restapi/VesRestController.java +++ b/src/main/java/org/onap/dcae/restapi/VesRestController.java @@ -53,11 +53,11 @@ import org.springframework.web.bind.annotation.RestController; @RestController public class VesRestController { - private static final Logger log = LoggerFactory.getLogger(VesRestController.class); + private static final Logger log = LoggerFactory.getLogger(VesRestController.class); + private static final String INVALID_JSON = ApiException.INVALID_JSON_INPUT.toJSON().toString(); private final ApplicationSettings applicationSettings; private final LinkedBlockingQueue inputQueue; - private final Logger metricsLog; private final Logger errorLog; private final Logger incomingRequestsLogger; @@ -101,7 +101,8 @@ public class VesRestController { try { jsonObject = new JSONObject(jsonPayload); } catch (Exception e) { - return ResponseEntity.badRequest().body(ApiException.INVALID_JSON_INPUT.toJSON().toString()); + log.error(INVALID_JSON); + return ResponseEntity.badRequest().body(INVALID_JSON); } String uuid = setUpECOMPLoggingForRequest(); -- cgit 1.2.3-korg