aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-09-22 21:07:43 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-09-22 21:15:22 +0100
commit6973ec9109fd2651e2284663b6c8039bd830a677 (patch)
treef1f02ef9e5400805e6c2179dc539ad15c3ce5334 /client
parenta02548ec2e98a8a13cd76ecc83379b13cd26030b (diff)
Fix sonar problems in Apex
Fixed some easy to resolve Sonar issues. Issue-ID: POLICY-1034 Change-Id: Ia8e4606bd4307daca499b4a74c96135211e572fd Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'client')
-rw-r--r--client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ApexDeploymentRestMain.java27
-rw-r--r--client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ParameterCheck.java12
-rw-r--r--client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/handling/RestCommandHandler.java1
-rw-r--r--client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/handling/bean/BeanBase.java35
-rw-r--r--client/client-full/src/main/java/org/onap/policy/apex/client/full/rest/ApexServicesRestMain.java27
-rw-r--r--client/client-full/src/main/java/org/onap/policy/apex/client/full/rest/ParameterCheck.java12
-rw-r--r--client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ApexMonitoringRestMain.java27
-rw-r--r--client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ParameterCheck.java12
8 files changed, 80 insertions, 73 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 134914f11..8f6dcd089 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
@@ -54,20 +54,6 @@ public class ApexDeploymentRestMain {
private ApexDeploymentRest apexDeploymentRest = null;
/**
- * Main method, main entry point for command.
- *
- * @param args The command line arguments for the client
- */
- public static void main(final String[] args) {
- try {
- final ApexDeploymentRestMain restMain = new ApexDeploymentRestMain(args, System.out);
- restMain.init();
- } catch (final Exception e) {
- LOGGER.error("start failed", e);
- }
- }
-
- /**
* Constructor, kicks off the rest service.
*
* @param args The command line arguments for the RESTful service
@@ -201,4 +187,17 @@ public class ApexDeploymentRestMain {
}
}
+ /**
+ * Main method, main entry point for command.
+ *
+ * @param args The command line arguments for the client
+ */
+ public static void main(final String[] args) {
+ try {
+ final ApexDeploymentRestMain restMain = new ApexDeploymentRestMain(args, System.out);
+ restMain.init();
+ } catch (final Exception e) {
+ LOGGER.error("start failed", e);
+ }
+ }
}
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 5026c5162..4e75763db 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,6 +32,12 @@ import org.slf4j.ext.XLoggerFactory;
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public final class ParameterCheck {
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(ParameterCheck.class);
+
+ private static final String HOSTNAME_PAR = "hostname";
+ private static final String PORT_PAR = "port";
+ private static final String AXARTIFACTKEY_PAR = "AxArtifactKey";
+
// Recurring string constants
private static final String OF_PARAMETER = "\"of parameter \"";
private static final String VALUE = "value \"";
@@ -58,12 +64,6 @@ public final class ParameterCheck {
STOP
}
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ParameterCheck.class);
-
- private static final String HOSTNAME_PAR = "hostname";
- private static final String PORT_PAR = "port";
- private static final String AXARTIFACTKEY_PAR = "AxArtifactKey";
-
/**
* Gets the host name.
*
diff --git a/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/handling/RestCommandHandler.java b/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/handling/RestCommandHandler.java
index c4fd6d6f4..5921c8960 100644
--- a/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/handling/RestCommandHandler.java
+++ b/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/handling/RestCommandHandler.java
@@ -23,7 +23,6 @@ package org.onap.policy.apex.client.editor.rest.handling;
import org.onap.policy.apex.model.modelapi.ApexApiResult;
import org.onap.policy.apex.model.modelapi.ApexApiResult.Result;
-// TODO: Auto-generated Javadoc
/**
* This interface defines the methods that a REST handler must implement to handle REST editor commands.
*
diff --git a/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/handling/bean/BeanBase.java b/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/handling/bean/BeanBase.java
index 20f8d6f07..6ac5c48e1 100644
--- a/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/handling/bean/BeanBase.java
+++ b/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/handling/bean/BeanBase.java
@@ -31,6 +31,9 @@ public abstract class BeanBase {
private static final String PROBLEM_RETRIEVING_FIELD_PREFIX = "Problem retrieving field called ('";
private static final String JSON_BEAN_SUFFIX = "') from JSON bean ";
+ // Magic numbers
+ private static final int GET_LENGTH = 3;
+
/**
* Gets a named field from the bean.
*
@@ -38,20 +41,14 @@ public abstract class BeanBase {
* @return the value for the field
*/
public String get(final String field) {
- // CHECKSTYLE:OFF: MagicNumber
// use getter preferably
for (final Method method : this.getClass().getMethods()) {
- if ((method.getName().startsWith("get")) && (method.getName().length() == (field.length() + 3))) {
- if (method.getName().toLowerCase().endsWith(field.toLowerCase())) {
- try {
- return (String) method.invoke(this);
- } catch (final Exception e) {
- throw new IllegalArgumentException(
- PROBLEM_RETRIEVING_FIELD_PREFIX + field + JSON_BEAN_SUFFIX + this, e);
- }
- }
+ if (method.getName().startsWith("get") && method.getName().length() == (field.length() + GET_LENGTH)
+ && method.getName().toLowerCase().endsWith(field.toLowerCase())) {
+ return invokeGetterMethod(field, method);
}
}
+
// Use field approach
if (field != null) {
try {
@@ -61,10 +58,24 @@ public abstract class BeanBase {
return (String) (f.get(this));
}
} catch (final Exception e) {
- throw new IllegalArgumentException(
- PROBLEM_RETRIEVING_FIELD_PREFIX + field + JSON_BEAN_SUFFIX + this, e);
+ throw new IllegalArgumentException(PROBLEM_RETRIEVING_FIELD_PREFIX + field + JSON_BEAN_SUFFIX + this,
+ e);
}
}
throw new IllegalArgumentException(PROBLEM_RETRIEVING_FIELD_PREFIX + field + JSON_BEAN_SUFFIX + this);
}
+
+ /**
+ * Invoke a getter method on a bean.
+ *
+ * @param field the field that the getter gets a value for
+ * @param method the method to invoke
+ */
+ private String invokeGetterMethod(final String field, final Method method) {
+ try {
+ return (String) method.invoke(this);
+ } catch (final Exception e) {
+ throw new IllegalArgumentException(PROBLEM_RETRIEVING_FIELD_PREFIX + field + JSON_BEAN_SUFFIX + this, e);
+ }
+ }
}
diff --git a/client/client-full/src/main/java/org/onap/policy/apex/client/full/rest/ApexServicesRestMain.java b/client/client-full/src/main/java/org/onap/policy/apex/client/full/rest/ApexServicesRestMain.java
index b11cd7ff3..7b9f4187d 100644
--- a/client/client-full/src/main/java/org/onap/policy/apex/client/full/rest/ApexServicesRestMain.java
+++ b/client/client-full/src/main/java/org/onap/policy/apex/client/full/rest/ApexServicesRestMain.java
@@ -65,20 +65,6 @@ public class ApexServicesRestMain {
private final PrintStream outStream;
/**
- * Main method, main entry point for command.
- *
- * @param args The command line arguments for the editor
- */
- public static void main(final String[] args) {
- try {
- final ApexServicesRestMain editorMain = new ApexServicesRestMain(args, System.out);
- editorMain.init();
- } catch (final Exception e) {
- LOGGER.error("error starting REST client", e);
- }
- }
-
- /**
* Constructor, kicks off the editor.
*
* @param args The command line arguments for the editor
@@ -213,4 +199,17 @@ public class ApexServicesRestMain {
}
}
}
+ /**
+ * Main method, main entry point for command.
+ *
+ * @param args The command line arguments for the editor
+ */
+ public static void main(final String[] args) {
+ try {
+ final ApexServicesRestMain editorMain = new ApexServicesRestMain(args, System.out);
+ editorMain.init();
+ } catch (final Exception e) {
+ LOGGER.error("error starting REST client", e);
+ }
+ }
}
diff --git a/client/client-full/src/main/java/org/onap/policy/apex/client/full/rest/ParameterCheck.java b/client/client-full/src/main/java/org/onap/policy/apex/client/full/rest/ParameterCheck.java
index 301b19f38..9832f4317 100644
--- a/client/client-full/src/main/java/org/onap/policy/apex/client/full/rest/ParameterCheck.java
+++ b/client/client-full/src/main/java/org/onap/policy/apex/client/full/rest/ParameterCheck.java
@@ -32,6 +32,12 @@ import org.slf4j.ext.XLoggerFactory;
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public final class ParameterCheck {
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(ParameterCheck.class);
+
+ private static final String HOSTNAME_PAR = "hostname";
+ private static final String PORT_PAR = "port";
+ private static final String AXARTIFACTKEY_PAR = "AxArtifactKey";
+
// Recurring string constants
private static final String PARAMETER = "parameter \"";
private static final String NOT_FOUND = "\" not found";
@@ -56,12 +62,6 @@ public final class ParameterCheck {
STOP
}
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ParameterCheck.class);
-
- private static final String HOSTNAME_PAR = "hostname";
- private static final String PORT_PAR = "port";
- private static final String AXARTIFACTKEY_PAR = "AxArtifactKey";
-
/**
* Gets the host name.
*
diff --git a/client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ApexMonitoringRestMain.java b/client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ApexMonitoringRestMain.java
index e1b5a9174..523a6eebb 100644
--- a/client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ApexMonitoringRestMain.java
+++ b/client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ApexMonitoringRestMain.java
@@ -54,20 +54,6 @@ public class ApexMonitoringRestMain {
private ApexMonitoringRest apexMonitoringRest = null;
/**
- * Main method, main entry point for command.
- *
- * @param args The command line arguments for the client
- */
- public static void main(final String[] args) {
- try {
- final ApexMonitoringRestMain restMain = new ApexMonitoringRestMain(args, System.out);
- restMain.init();
- } catch (final Exception e) {
- LOGGER.error("start failed", e);
- }
- }
-
- /**
* Constructor, kicks off the rest service.
*
* @param args The command line arguments for the RESTful service
@@ -201,4 +187,17 @@ public class ApexMonitoringRestMain {
}
}
+ /**
+ * Main method, main entry point for command.
+ *
+ * @param args The command line arguments for the client
+ */
+ public static void main(final String[] args) {
+ try {
+ final ApexMonitoringRestMain restMain = new ApexMonitoringRestMain(args, System.out);
+ restMain.init();
+ } catch (final Exception e) {
+ LOGGER.error("start failed", e);
+ }
+ }
}
diff --git a/client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ParameterCheck.java b/client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ParameterCheck.java
index 46e1452a5..acaee5fdb 100644
--- a/client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ParameterCheck.java
+++ b/client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ParameterCheck.java
@@ -32,6 +32,12 @@ import org.slf4j.ext.XLoggerFactory;
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public final class ParameterCheck {
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(ParameterCheck.class);
+
+ private static final String HOSTNAME_PAR = "hostname";
+ private static final String PORT_PAR = "port";
+ private static final String AXARTIFACTKEY_PAR = "AxArtifactKey";
+
// Recurring string constants
private static final String PARAMETER = "parameter \"";
private static final String NOT_FOUND = "\" not found";
@@ -56,12 +62,6 @@ public final class ParameterCheck {
STOP
}
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ParameterCheck.class);
-
- private static final String HOSTNAME_PAR = "hostname";
- private static final String PORT_PAR = "port";
- private static final String AXARTIFACTKEY_PAR = "AxArtifactKey";
-
/**
* Gets the host name.
*