aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-09-13 15:25:32 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-09-13 15:26:47 +0100
commit4cfa2e2d98f6877d54da304ef17f096284430908 (patch)
treec9452d2bf6bb96fae9c1e8e2d8ce8f8d01e69d22 /plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main
parent0e23f7634e1e1fb31454c516974613335fcea1a4 (diff)
Sonar/Checkstyle in service/plugins
Sonar and Checkstyle changes in plugins and services, and knock on changes Issue-ID: POLICY-1034 Change-Id: Iff7df74e54fce2c661dcc2fae75ae93d4cacfe5b Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main')
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java28
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerProducer.java18
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParameters.java (renamed from plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java)6
-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.java20
4 files changed, 39 insertions, 33 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/ApexRestServerConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java
index 8cf0c8f9c..94063af20 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java
@@ -56,9 +56,6 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable {
// The amount of time to wait in milliseconds between checks that the consumer thread has stopped
private static final long REST_SERVER_CONSUMER_WAIT_SLEEP_TIME = 50;
- // The REST parameters read from the parameter service
- private RESTServerCarrierTechnologyParameters restConsumerProperties;
-
// The event receiver that will receive events from this consumer
private ApexEventReceiver eventReceiver;
@@ -84,7 +81,7 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable {
*
* @return the next candidate value for a Execution ID
*/
- private static synchronized long getNextExecutionID() {
+ private static synchronized long getNextExecutionId() {
return nextExecutionID.getAndIncrement();
}
@@ -102,14 +99,16 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable {
this.name = consumerName;
// Check and get the REST Properties
- if (!(consumerParameters.getCarrierTechnologyParameters() instanceof RESTServerCarrierTechnologyParameters)) {
+ if (!(consumerParameters.getCarrierTechnologyParameters() instanceof RestServerCarrierTechnologyParameters)) {
final String errorMessage =
"specified consumer properties are not applicable to REST Server consumer (" + this.name + ")";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
- restConsumerProperties =
- (RESTServerCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters();
+
+ // The REST parameters read from the parameter service
+ RestServerCarrierTechnologyParameters restConsumerProperties =
+ (RestServerCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters();
// Check if we are in synchronous mode
if (!consumerParameters.isPeeredMode(EventHandlerPeeredMode.SYNCHRONOUS)) {
@@ -131,12 +130,12 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable {
}
// Compose the URI for the standalone server
- final String baseURI = String.format(BASE_URI_TEMPLATE, restConsumerProperties.getHost(),
+ final String baseUrl = String.format(BASE_URI_TEMPLATE, restConsumerProperties.getHost(),
restConsumerProperties.getPort());
// Instantiate the standalone server
final ResourceConfig rc = new ResourceConfig(RestServerEndpoint.class, AccessControlFilter.class);
- server = GrizzlyHttpServerFactory.createHttpServer(URI.create(baseURI), rc);
+ server = GrizzlyHttpServerFactory.createHttpServer(URI.create(baseUrl), rc);
while (!server.isStarted()) {
ThreadUtilities.sleep(REST_SERVER_CONSUMER_WAIT_SLEEP_TIME);
@@ -201,10 +200,11 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable {
*/
public Response receiveEvent(final String event) {
// Get an execution ID for the event
- final long executionId = getNextExecutionID();
+ final long executionId = getNextExecutionId();
if (LOGGER.isDebugEnabled()) {
- LOGGER.debug(name + ": sending event " + name + '_' + executionId + " to Apex, event=" + event);
+ String message = name + ": sending event " + name + '_' + executionId + " to Apex, event=" + event;
+ LOGGER.debug(message);
}
try {
@@ -222,7 +222,8 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable {
// Wait until the event is in the cache of events sent to apex
do {
ThreadUtilities.sleep(REST_SERVER_CONSUMER_WAIT_SLEEP_TIME);
- } while (!synchronousEventCache.existsEventToApex(executionId));
+ }
+ while (!synchronousEventCache.existsEventToApex(executionId));
// Now wait for the reply or for the event to time put
do {
@@ -238,7 +239,8 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable {
// Return the event as a response to the call
return Response.status(Response.Status.OK.getStatusCode()).entity(responseEvent.toString()).build();
}
- } while (synchronousEventCache.existsEventToApex(executionId));
+ }
+ while (synchronousEventCache.existsEventToApex(executionId));
// The event timed out
final String errorMessage = "processing of event on event consumer " + name + " timed out, event=" + event;
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerProducer.java
index e51482ce4..cacdb3408 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerProducer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerProducer.java
@@ -41,9 +41,6 @@ import org.slf4j.LoggerFactory;
public class ApexRestServerProducer implements ApexEventProducer {
private static final Logger LOGGER = LoggerFactory.getLogger(ApexRestServerProducer.class);
- // The REST carrier properties
- private RESTServerCarrierTechnologyParameters restProducerProperties;
-
// The name for this producer
private String name = null;
@@ -62,14 +59,16 @@ public class ApexRestServerProducer implements ApexEventProducer {
this.name = producerName;
// Check and get the REST Properties
- if (!(producerParameters.getCarrierTechnologyParameters() instanceof RESTServerCarrierTechnologyParameters)) {
+ if (!(producerParameters.getCarrierTechnologyParameters() instanceof RestServerCarrierTechnologyParameters)) {
final String errorMessage =
"specified producer properties are not applicable to REST Server producer (" + this.name + ")";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
- restProducerProperties =
- (RESTServerCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
+
+ // The REST carrier properties
+ RestServerCarrierTechnologyParameters restProducerProperties =
+ (RestServerCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
// Check if host and port are defined
if (restProducerProperties.getHost() != null || restProducerProperties.getPort() != -1
@@ -131,7 +130,8 @@ public class ApexRestServerProducer implements ApexEventProducer {
@Override
public void sendEvent(final long executionId, final String eventName, final Object event) {
if (LOGGER.isDebugEnabled()) {
- LOGGER.debug(name + ": event " + executionId + ':' + eventName + " recevied from Apex, event=" + event);
+ String message = name + ": event " + executionId + ':' + eventName + " recevied from Apex, event=" + event;
+ LOGGER.debug(message);
}
// If we are not synchronized, then exit
@@ -163,5 +163,7 @@ public class ApexRestServerProducer implements ApexEventProducer {
* @see org.onap.policy.apex.service.engine.event.ApexEventProducer#stop()
*/
@Override
- public void stop() {}
+ public void stop() {
+ // Implementation not required on this class
+ }
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParameters.java
index cd7f388f2..76ec577b8 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParameters.java
@@ -27,7 +27,7 @@ import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for REST as an event carrier technology with Apex as a REST client.
*
- * The parameters for this plugin are:
+ * <p>The parameters for this plugin are:
* <ol>
* <li>standalone: A flag indicating if APEX should start a standalone HTTP server to process REST requests (true) or
* whether it should use an underlying servlet infrastructure such as Apache Tomcat (False). This parameter is legal
@@ -40,7 +40,7 @@ import org.onap.policy.common.parameters.ValidationStatus;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class RESTServerCarrierTechnologyParameters extends CarrierTechnologyParameters {
+public class RestServerCarrierTechnologyParameters extends CarrierTechnologyParameters {
// @formatter:off
private static final int MIN_USER_PORT = 1024;
private static final int MAX_USER_PORT = 65535;
@@ -64,7 +64,7 @@ public class RESTServerCarrierTechnologyParameters extends CarrierTechnologyPara
* Constructor to create a REST carrier technology parameters instance and register the instance with the parameter
* service.
*/
- public RESTServerCarrierTechnologyParameters() {
+ public RestServerCarrierTechnologyParameters() {
super();
// Set the carrier technology properties for the web socket carrier technology
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 beee10fd0..f8524fcfd 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
@@ -57,21 +57,21 @@ 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<String, ApexRestServerConsumer>();
+ new LinkedHashMap<>();
// The ID of this event input. This gets injected from the URL.
@PathParam("eventInput")
- private String eventInputID = null;
+ private String eventInputId = null;
/**
* Register an Apex consumer with the REST server end point.
*
- * @param consumerEventInputID The event input ID that indicates this consumer shoud be used
+ * @param consumerEventInputId The event input ID that indicates this consumer shoud be used
* @param consumer The consumer to register
*/
- public static void registerApexRestServerConsumer(final String consumerEventInputID,
+ public static void registerApexRestServerConsumer(final String consumerEventInputId,
final ApexRestServerConsumer consumer) {
- consumerMap.put(consumerEventInputID, consumer);
+ consumerMap.put(consumerEventInputId, consumer);
}
/**
@@ -102,7 +102,8 @@ public class RestServerEndpoint {
postEventMessagesReceived++;
if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("event input " + eventInputID + ", received POST of event \"" + jsonString + "\"");
+ String message = "event input " + eventInputId + ", received POST of event \"" + jsonString + "\"";
+ LOGGER.debug(message);
}
// Common handler method for POST and PUT requests
@@ -121,7 +122,8 @@ public class RestServerEndpoint {
putEventMessagesReceived++;
if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("event input \"" + eventInputID + "\", received PUT of event \"" + jsonString + "\"");
+ String message = "event input \"" + eventInputId + "\", received PUT of event \"" + jsonString + "\"";
+ LOGGER.debug(message);
}
// Common handler method for POST and PUT requests
@@ -136,10 +138,10 @@ public class RestServerEndpoint {
*/
private Response handleEvent(final String jsonString) {
// Find the correct consumer for this REST message
- final ApexRestServerConsumer eventConsumer = consumerMap.get(eventInputID);
+ final ApexRestServerConsumer eventConsumer = consumerMap.get(eventInputId);
if (eventConsumer == null) {
final String errorMessage =
- "event input " + eventInputID + " is not defined in the Apex configuration file";
+ "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();