aboutsummaryrefslogtreecommitdiffstats
path: root/client/client-deployment/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'client/client-deployment/src/main')
-rw-r--r--client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ApexDeploymentRestMain.java23
-rw-r--r--client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ParameterCheck.java45
2 files changed, 39 insertions, 29 deletions
diff --git a/client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ApexDeploymentRestMain.java b/client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ApexDeploymentRestMain.java
index 73374053f..134914f11 100644
--- a/client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ApexDeploymentRestMain.java
+++ b/client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ApexDeploymentRestMain.java
@@ -85,21 +85,21 @@ public class ApexDeploymentRestMain {
parameters = parser.parse(args);
} catch (final ApexDeploymentRestParameterException e) {
throw new ApexDeploymentRestParameterException(
- REST_ENDPOINT_PREFIX + this.toString() + ") parameter error, " + e.getMessage() + '\n'
- + parser.getHelp(ApexDeploymentRestMain.class.getCanonicalName()));
+ REST_ENDPOINT_PREFIX + this.toString() + ") parameter error, " + e.getMessage() + '\n'
+ + parser.getHelp(ApexDeploymentRestMain.class.getCanonicalName()), e);
}
if (parameters.isHelpSet()) {
throw new ApexDeploymentRestParameterException(
- parser.getHelp(ApexDeploymentRestMain.class.getCanonicalName()));
+ parser.getHelp(ApexDeploymentRestMain.class.getCanonicalName()));
}
// Validate the parameters
final String validationMessage = parameters.validate();
if (validationMessage.length() > 0) {
throw new ApexDeploymentRestParameterException(
- REST_ENDPOINT_PREFIX + this.toString() + ") parameters invalid, " + validationMessage
- + '\n' + parser.getHelp(ApexDeploymentRestMain.class.getCanonicalName()));
+ REST_ENDPOINT_PREFIX + this.toString() + ") parameters invalid, " + validationMessage + '\n'
+ + parser.getHelp(ApexDeploymentRestMain.class.getCanonicalName()));
}
state = ServicesState.READY;
@@ -109,8 +109,8 @@ public class ApexDeploymentRestMain {
* Initialize the rest service.
*/
public void init() {
- outStream.println(REST_ENDPOINT_PREFIX + this.toString() + ") starting at "
- + parameters.getBaseUri().toString() + " . . .");
+ outStream.println(REST_ENDPOINT_PREFIX + this.toString() + ") starting at " + parameters.getBaseUri().toString()
+ + " . . .");
try {
state = ServicesState.INITIALIZING;
@@ -125,7 +125,7 @@ public class ApexDeploymentRestMain {
if (parameters.getTimeToLive() == ApexDeploymentRestParameters.INFINITY_TIME_TO_LIVE) {
outStream.println(REST_ENDPOINT_PREFIX + this.toString() + ") started at "
- + parameters.getBaseUri().toString());
+ + parameters.getBaseUri().toString());
} else {
outStream.println(REST_ENDPOINT_PREFIX + this.toString() + ") started");
}
@@ -142,8 +142,9 @@ public class ApexDeploymentRestMain {
Thread.sleep(1000);
}
} catch (final Exception e) {
- outStream.println(
- REST_ENDPOINT_PREFIX + this.toString() + ") failed at with error: " + e.getMessage());
+ String message = REST_ENDPOINT_PREFIX + this.toString() + ") failed at with error: " + e.getMessage();
+ outStream.println(message);
+ LOGGER.warn(message, e);
} finally {
if (apexDeploymentRest != null) {
apexDeploymentRest.shutdown();
@@ -167,7 +168,7 @@ public class ApexDeploymentRestMain {
public String toString() {
final StringBuilder ret = new StringBuilder();
ret.append(this.getClass().getSimpleName()).append(": Config=[").append(this.parameters).append("], State=")
- .append(this.getState());
+ .append(this.getState());
return ret.toString();
}
diff --git a/client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ParameterCheck.java b/client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ParameterCheck.java
index b68ffebcf..fb18a002f 100644
--- a/client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ParameterCheck.java
+++ b/client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ParameterCheck.java
@@ -32,12 +32,19 @@ import org.slf4j.ext.XLoggerFactory;
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public final class ParameterCheck {
+ // Recurring string constants
+ private static final String OF_PARAMETER = "\"of parameter \"";
+ private static final String VALUE = "value \"";
+ private static final String PARAMETER = "parameter \"";
+ private static final String NOT_FOUND = "\" not found";
+
private static final int MAX_PORT = 65535;
/**
* private constructor to prevent subclassing of this utility class.
*/
- private ParameterCheck() {}
+ private ParameterCheck() {
+ }
/**
* The Enum StartStop is used to hold.
@@ -65,14 +72,14 @@ public final class ParameterCheck {
*/
public static String getHostName(final Map<String, String[]> parameterMap) {
if (!parameterMap.containsKey(HOSTNAME_PAR)) {
- LOGGER.warn("parameter \"" + HOSTNAME_PAR + "\" not found");
+ LOGGER.warn(PARAMETER + HOSTNAME_PAR + NOT_FOUND);
return null;
}
final String[] hostNameValue = parameterMap.get(HOSTNAME_PAR);
if (hostNameValue.length == 0 || hostNameValue[0].trim().length() == 0) {
- LOGGER.warn("value of parameter \"" + HOSTNAME_PAR + "\" not found");
+ LOGGER.warn("value of parameter \"" + HOSTNAME_PAR + NOT_FOUND);
return null;
}
@@ -87,14 +94,14 @@ public final class ParameterCheck {
*/
public static int getPort(final Map<String, String[]> parameterMap) {
if (!parameterMap.containsKey(PORT_PAR)) {
- LOGGER.warn("parameter \"" + PORT_PAR + "\" not found");
+ LOGGER.warn(PARAMETER + PORT_PAR + NOT_FOUND);
return -1;
}
final String[] portValue = parameterMap.get(PORT_PAR);
if (portValue.length == 0 || portValue[0].trim().length() == 0) {
- LOGGER.warn("value of parameter \"" + PORT_PAR + "\" not found");
+ LOGGER.warn("value of parameter \"" + PORT_PAR + NOT_FOUND);
return -1;
}
@@ -102,13 +109,14 @@ public final class ParameterCheck {
try {
port = Integer.parseInt(portValue[0]);
} catch (final Exception e) {
- LOGGER.warn("value \"" + portValue[0] + "\"of parameter \"" + PORT_PAR + "\" not a valid integer", e);
+ LOGGER.warn(VALUE + portValue[0] + OF_PARAMETER + PORT_PAR + "\" not a valid integer", e);
return -1;
}
if (port <= 0 || port > MAX_PORT) {
- LOGGER.warn("value \"" + portValue[0] + "\"of parameter \"" + PORT_PAR
- + "\" not a valid port between 0 and 65535");
+ String message = VALUE + portValue[0] + OF_PARAMETER + PORT_PAR
+ + "\" not a valid port between 0 and 65535";
+ LOGGER.warn(message);
return -1;
}
@@ -131,14 +139,16 @@ public final class ParameterCheck {
}
}
if (artifactKeyParameter == null) {
- LOGGER.warn("parameter \"" + AXARTIFACTKEY_PAR + "\" not found");
+ LOGGER.warn(PARAMETER + AXARTIFACTKEY_PAR + NOT_FOUND);
return null;
}
final String[] axArtifactKeyArray = artifactKeyParameter.split("#");
if (axArtifactKeyArray.length != 2) {
- LOGGER.warn("value \"" + artifactKeyParameter + "\" of parameter \"" + AXARTIFACTKEY_PAR + "\" not valid");
+ String message = VALUE + artifactKeyParameter + "\" of parameter \"" + AXARTIFACTKEY_PAR
+ + "\" not valid";
+ LOGGER.warn(message);
return null;
}
@@ -153,17 +163,17 @@ public final class ParameterCheck {
* @return the start stop
*/
public static ParameterCheck.StartStop getStartStop(final Map<String, String[]> parameterMap,
- final AxArtifactKey engineKey) {
+ final AxArtifactKey engineKey) {
final String startStopPar = AXARTIFACTKEY_PAR + '#' + engineKey.getId();
if (!parameterMap.containsKey(startStopPar)) {
- LOGGER.warn("parameter \"" + startStopPar + "\" not found");
+ LOGGER.warn("parameter \"{}\" not found", startStopPar);
return null;
}
final String[] startStopValue = parameterMap.get(startStopPar);
if (startStopValue.length == 0 || startStopValue[0].trim().length() == 0) {
- LOGGER.warn("value of parameter \"" + startStopPar + "\" not found");
+ LOGGER.warn("value of parameter \"{}\" not found", startStopPar);
return null;
}
@@ -173,8 +183,7 @@ public final class ParameterCheck {
} else if (startStopValue[0].equalsIgnoreCase("stop")) {
startStop = ParameterCheck.StartStop.STOP;
} else {
- LOGGER.warn("value \"" + startStopValue[0] + "\"of parameter \"" + startStopPar
- + "\" not \"start\" or \"stop\"");
+ LOGGER.warn("value \"{}\"of parameter \"{}\" not \"start\" or \"stop\"", startStopValue[0], startStopPar);
return null;
}
@@ -190,21 +199,21 @@ public final class ParameterCheck {
*/
public static long getLong(final Map<String, String[]> parameterMap, final String longName) {
if (!parameterMap.containsKey(longName)) {
- LOGGER.warn("parameter \"" + longName + "\" not found");
+ LOGGER.warn("parameter \"{}\" not found", longName);
return -1;
}
final String[] longValue = parameterMap.get(longName);
if (longValue.length == 0 || longValue[0].trim().length() == 0) {
- LOGGER.warn("value of parameter \"" + longName + "\" not found");
+ LOGGER.warn("value of parameter \"{}\" not found", longName);
return -1;
}
try {
return Long.parseLong(longValue[0]);
} catch (final Exception e) {
- LOGGER.warn("value \"" + longValue[0] + "\"of parameter \"" + longName + "\" not a valid long", e);
+ LOGGER.warn(VALUE + longValue[0] + OF_PARAMETER + longName + "\" not a valid long", e);
return -1;
}
}