diff options
author | awudzins <adam.wudzinski@nokia.com> | 2019-03-28 15:39:20 +0100 |
---|---|---|
committer | awudzins <adam.wudzinski@nokia.com> | 2019-04-05 11:08:59 +0200 |
commit | 85fa078bfabea17ffdafcdf2748d1a877f00a3b0 (patch) | |
tree | e13d757f1d1f4d47cd24b45e7cee4e4ecad2c015 | |
parent | d4766e8b38e68ddb97a91c4646455b1340d5acba (diff) |
Fix sonar violation
Fix sonar violation
Change-Id: I72d7c4a7ac127b9ec89e8a144d934aa96884fc6a
Issue-ID: DCAEGEN2-1016
Signed-off-by: Adam Wudzinski <adam.wudzinski@nokia.com>
-rw-r--r-- | src/main/java/org/onap/dcae/common/EventSender.java | 7 | ||||
-rw-r--r-- | src/main/java/org/onap/dcae/common/VESLogger.java | 6 | ||||
-rw-r--r-- | src/main/java/org/onap/dcae/restapi/VesRestController.java | 7 |
3 files changed, 9 insertions, 11 deletions
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<String, String[]> streamidHash; private ApplicationSettings properties; private EventPublisher eventPublisher; - static final Type EVENT_LIST_TYPE = new TypeToken<List<Event>>() {}.getType(); + private static final Type EVENT_LIST_TYPE = new TypeToken<List<Event>>() {}.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<Event> 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<JSONObject> 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(); |