From de5b68397c2e54c22e500f1f70ca3d7ca7c75150 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Tue, 9 Jul 2019 08:47:49 +0530 Subject: Sonar fix in RestMusicHealthCheckAPI.java Fixed sonar issues in this file Issue-ID: MUSIC-429 Change-Id: If56fa1064651e6df2c49fc5835efdd310ead5bbe Signed-off-by: Arundathi Patil --- .../java/org/onap/music/rest/RestMusicHealthCheckAPI.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/onap/music/rest/RestMusicHealthCheckAPI.java b/src/main/java/org/onap/music/rest/RestMusicHealthCheckAPI.java index 73afe6a1..eef3aa3a 100644 --- a/src/main/java/org/onap/music/rest/RestMusicHealthCheckAPI.java +++ b/src/main/java/org/onap/music/rest/RestMusicHealthCheckAPI.java @@ -67,6 +67,8 @@ public class RestMusicHealthCheckAPI { private static final String INVALID_MESSAGE = "Consistency level is invalid..."; private static final String INACTIVE_MESSAGE = "One or more nodes in the Cluster is/are down or not responding."; private static final String ACTIVE_MESSAGE = "Cassandra Running and Listening to requests"; + private static final String STATUS_KEY = "status"; + private static final String MESSAGE_KEY = "message"; @GET @Path("/pingCassandra/{consistency}") @@ -80,21 +82,21 @@ public class RestMusicHealthCheckAPI { Map resultMap = new HashMap<>(); if(ConsistencyLevel.valueOf(consistency) == null) { - resultMap.put("status",INVALID_STATUS); - resultMap.put("message", INVALID_MESSAGE); + resultMap.put(STATUS_KEY,INVALID_STATUS); + resultMap.put(MESSAGE_KEY, INVALID_MESSAGE); resultMap.put(INVALID_STATUS, INVALID_STATUS); return Response.status(Status.BAD_REQUEST).entity(resultMap).build(); } MusicHealthCheck cassHealthCheck = new MusicHealthCheck(); String status = cassHealthCheck.getCassandraStatus(consistency); if(status.equals(ACTIVE_STATUS)) { - resultMap.put("status",ACTIVE_STATUS); - resultMap.put("message", ACTIVE_MESSAGE); + resultMap.put(STATUS_KEY,ACTIVE_STATUS); + resultMap.put(MESSAGE_KEY, ACTIVE_MESSAGE); resultMap.put(ACTIVE_STATUS, ACTIVE_MESSAGE); return Response.status(Status.OK).entity(resultMap).build(); } else { - resultMap.put("status",INACTIVE_STATUS); - resultMap.put("message", INACTIVE_MESSAGE); + resultMap.put(STATUS_KEY,INACTIVE_STATUS); + resultMap.put(MESSAGE_KEY, INACTIVE_MESSAGE); resultMap.put(INACTIVE_STATUS, INACTIVE_MESSAGE); return Response.status(Status.BAD_REQUEST).entity(resultMap).build(); } -- cgit 1.2.3-korg