summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-09-13 23:48:50 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-09-13 23:49:32 +0100
commitcd68fc9bae7d6258f77ff59c1431e4f925f61a4c (patch)
tree53054a7c8e8738644785039c3a200c6b23d4b3ed /plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver
parent4cfa2e2d98f6877d54da304ef17f096284430908 (diff)
Address sonar/Checkstyle Issues
Sweep through Apex codebase to fix most ceheckstyle and straightforward sonar issues. Issue-ID: POLICY-1034 Change-Id: I149d9a94ad893affc93573e8de5e3304b6bdde2d Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver')
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerEndpoint.java52
1 files changed, 37 insertions, 15 deletions
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerEndpoint.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerEndpoint.java
index f8524fcfd..ca2d797b9 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerEndpoint.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerEndpoint.java
@@ -43,8 +43,10 @@ import org.slf4j.LoggerFactory;
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
@Path("/{eventInput}")
-@Produces({ MediaType.APPLICATION_JSON })
-@Consumes({ MediaType.APPLICATION_JSON })
+@Produces(
+ { MediaType.APPLICATION_JSON })
+@Consumes(
+ { MediaType.APPLICATION_JSON })
public class RestServerEndpoint {
// Get a reference to the logger
private static final Logger LOGGER = LoggerFactory.getLogger(RestServerEndpoint.class);
@@ -56,8 +58,7 @@ public class RestServerEndpoint {
// This map is used to hold all the REST server event inputs. This is used to determine which consumer to send input
// events to
- private static Map<String, ApexRestServerConsumer> consumerMap =
- new LinkedHashMap<>();
+ private static Map<String, ApexRestServerConsumer> consumerMap = new LinkedHashMap<>();
// The ID of this event input. This gets injected from the URL.
@PathParam("eventInput")
@@ -70,7 +71,7 @@ public class RestServerEndpoint {
* @param consumer The consumer to register
*/
public static void registerApexRestServerConsumer(final String consumerEventInputId,
- final ApexRestServerConsumer consumer) {
+ final ApexRestServerConsumer consumer) {
consumerMap.put(consumerEventInputId, consumer);
}
@@ -82,12 +83,12 @@ public class RestServerEndpoint {
@Path("/Status")
@GET
public Response serviceGetStats() {
- getMessagesReceived++;
+ incrementGetMessages();
return Response.status(Response.Status.OK.getStatusCode())
- .entity("{\n" + "\"INPUTS\": \"" + consumerMap.keySet() + "\",\n" + "\"STAT\": " + getMessagesReceived
- + ",\n" + "\"POST\": " + postEventMessagesReceived + ",\n" + "\"PUT\": "
- + putEventMessagesReceived + "\n}")
- .build();
+ .entity("{\n" + "\"INPUTS\": \"" + consumerMap.keySet() + "\",\n" + "\"STAT\": "
+ + getMessagesReceived + ",\n" + "\"POST\": " + postEventMessagesReceived + ",\n"
+ + "\"PUT\": " + putEventMessagesReceived + "\n}")
+ .build();
}
/**
@@ -99,7 +100,7 @@ public class RestServerEndpoint {
@Path("/EventIn")
@POST
public Response servicePostRequest(final String jsonString) {
- postEventMessagesReceived++;
+ incrementPostEventMessages();
if (LOGGER.isDebugEnabled()) {
String message = "event input " + eventInputId + ", received POST of event \"" + jsonString + "\"";
@@ -119,7 +120,7 @@ public class RestServerEndpoint {
@Path("/EventIn")
@PUT
public Response servicePutRequest(final String jsonString) {
- putEventMessagesReceived++;
+ incrementPutEventMessages();
if (LOGGER.isDebugEnabled()) {
String message = "event input \"" + eventInputId + "\", received PUT of event \"" + jsonString + "\"";
@@ -140,13 +141,34 @@ public class RestServerEndpoint {
// Find the correct consumer for this REST message
final ApexRestServerConsumer eventConsumer = consumerMap.get(eventInputId);
if (eventConsumer == null) {
- final String errorMessage =
- "event input " + eventInputId + " is not defined in the Apex configuration file";
+ final String errorMessage = "event input " + eventInputId
+ + " is not defined in the Apex configuration file";
LOGGER.warn(errorMessage);
return Response.status(Response.Status.BAD_REQUEST.getStatusCode())
- .entity("{'errorMessage', '" + errorMessage + "'}").build();
+ .entity("{'errorMessage', '" + errorMessage + "'}").build();
}
return eventConsumer.receiveEvent(jsonString);
}
+
+ /**
+ * Increment number of get messages received.
+ */
+ private static void incrementGetMessages() {
+ getMessagesReceived++;
+ }
+
+ /**
+ * Increment number of get messages received.
+ */
+ private static void incrementPutEventMessages() {
+ putEventMessagesReceived++;
+ }
+
+ /**
+ * Increment number of get messages received.
+ */
+ private static void incrementPostEventMessages() {
+ postEventMessagesReceived++;
+ }
}