summaryrefslogtreecommitdiffstats
path: root/client/client-editor
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-09-16 02:03:12 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-09-16 02:04:11 +0100
commit952d4f5aab9913f961e77fa0457da5d38f31d94f (patch)
treed482ebae10ff11b3096dd85d927eca75825574d6 /client/client-editor
parenta65e4772f4557a109917532b2d9c49680ce3bb15 (diff)
Fix Sonar issues in apex
Fixing various Sonar issues in apex. Issue-ID: POLICY-1034 Change-Id: Ie693637d75bd7e38c71b7ba04886fb75636276ed Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'client/client-editor')
-rw-r--r--client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/ApexEditorMain.java28
-rw-r--r--client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/ApexEditorRestResource.java72
-rw-r--r--client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/RestUtils.java15
3 files changed, 57 insertions, 58 deletions
diff --git a/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/ApexEditorMain.java b/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/ApexEditorMain.java
index ea4f206ce..4d0959977 100644
--- a/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/ApexEditorMain.java
+++ b/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/ApexEditorMain.java
@@ -65,20 +65,6 @@ public class ApexEditorMain {
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 ApexEditorMain editorMain = new ApexEditorMain(args, System.out);
- editorMain.init();
- } catch (final Exception e) {
- LOGGER.error("start failed", e);
- }
- }
-
- /**
* Constructor, kicks off the editor.
*
* @param args The command line arguments for the editor
@@ -212,4 +198,18 @@ public class ApexEditorMain {
}
}
}
+
+ /**
+ * 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 ApexEditorMain editorMain = new ApexEditorMain(args, System.out);
+ editorMain.init();
+ } catch (final Exception e) {
+ LOGGER.error("start failed", e);
+ }
+ }
}
diff --git a/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/ApexEditorRestResource.java b/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/ApexEditorRestResource.java
index 72c294169..fed1a50ce 100644
--- a/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/ApexEditorRestResource.java
+++ b/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/ApexEditorRestResource.java
@@ -536,10 +536,10 @@ public class ApexEditorRestResource {
return ret;
}
- if (name1 == null || name1.equals("")) {
+ if (name1 == null || "".equals(name1)) {
name1 = null;
}
- if (version1 == null || version1.equals("")) {
+ if (version1 == null || "".equals(version1)) {
version1 = null;
}
@@ -646,10 +646,10 @@ public class ApexEditorRestResource {
return ret;
}
- if (name1 == null || name1.equals("")) {
+ if (name1 == null || "".equals(name1)) {
name1 = null;
}
- if (version1 == null || version1.equals("")) {
+ if (version1 == null || "".equals(version1)) {
version1 = null;
}
@@ -690,10 +690,10 @@ public class ApexEditorRestResource {
return ret;
}
- if (name1 == null || name1.equals("")) {
+ if (name1 == null || "".equals(name1)) {
name1 = null;
}
- if (version1 == null || version1.equals("")) {
+ if (version1 == null || "".equals(version1)) {
version1 = null;
}
@@ -728,10 +728,10 @@ public class ApexEditorRestResource {
String version1 = version;
LOGGER.entry(name1, version1);
try {
- if (name1 == null || name1.equals("")) {
+ if (name1 == null || "".equals(name1)) {
name1 = null;
}
- if (version1 == null || version1.equals("")) {
+ if (version1 == null || "".equals(version1)) {
version1 = null;
}
@@ -849,10 +849,10 @@ public class ApexEditorRestResource {
return ret;
}
- if (name1 == null || name1.equals("")) {
+ if (name1 == null || "".equals(name1)) {
name1 = null;
}
- if (version1 == null || version1.equals("")) {
+ if (version1 == null || "".equals(version1)) {
version1 = null;
}
@@ -893,10 +893,10 @@ public class ApexEditorRestResource {
return ret;
}
- if (name1 == null || name1.equals("")) {
+ if (name1 == null || "".equals(name1)) {
name1 = null;
}
- if (version1 == null || version1.equals("")) {
+ if (version1 == null || "".equals(version1)) {
version1 = null;
}
@@ -931,10 +931,10 @@ public class ApexEditorRestResource {
String version1 = version;
LOGGER.entry(name1, version1);
try {
- if (name1 == null || name1.equals("")) {
+ if (name1 == null || "".equals(name1)) {
name1 = null;
}
- if (version1 == null || version1.equals("")) {
+ if (version1 == null || "".equals(version1)) {
version1 = null;
}
@@ -1037,8 +1037,8 @@ public class ApexEditorRestResource {
final BeanEvent jsonbean = RestUtils.getJsonParameters(jsonString, BeanEvent.class);
- if (jsonbean.getName() == null || jsonbean.getName().equals("") || jsonbean.getVersion() == null
- || jsonbean.getVersion().equals("")) {
+ if (jsonbean.getName() == null || "".equals(jsonbean.getName()) || jsonbean.getVersion() == null
+ || "".equals(jsonbean.getVersion())) {
ret = new ApexApiResult(Result.FAILED, "Null/Empty event name/version (\"" + jsonbean.getName() + ":"
+ jsonbean.getVersion() + "\" passed to UpdateEvent");
return ret;
@@ -1085,10 +1085,10 @@ public class ApexEditorRestResource {
return ret;
}
- if (name1 == null || name1.equals("")) {
+ if (name1 == null || "".equals(name1)) {
name1 = null;
}
- if (version1 == null || version1.equals("")) {
+ if (version1 == null || "".equals(version1)) {
version1 = null;
}
@@ -1124,10 +1124,10 @@ public class ApexEditorRestResource {
String version1 = version;
LOGGER.entry(name1, version1);
try {
- if (name1 == null || name1.equals("")) {
+ if (name1 == null || "".equals(name1)) {
name1 = null;
}
- if (version1 == null || version1.equals("")) {
+ if (version1 == null || "".equals(version1)) {
version1 = null;
}
@@ -1171,10 +1171,10 @@ public class ApexEditorRestResource {
return ret;
}
- if (name1 == null || name1.equals("")) {
+ if (name1 == null || "".equals(name1)) {
name1 = null;
}
- if (version1 == null || version1.equals("")) {
+ if (version1 == null || "".equals(version1)) {
version1 = null;
}
@@ -1374,8 +1374,8 @@ public class ApexEditorRestResource {
final BeanTask jsonbean = RestUtils.getJsonParameters(jsonString, BeanTask.class);
- if (jsonbean.getName() == null || jsonbean.getName().equals("") || jsonbean.getVersion() == null
- || jsonbean.getVersion().equals("")) {
+ if (jsonbean.getName() == null || "".equals(jsonbean.getName()) || jsonbean.getVersion() == null
+ || "".equals(jsonbean.getVersion())) {
ret = new ApexApiResult(Result.FAILED, "Null/Empty task name/version (\"" + jsonbean.getName() + ":"
+ jsonbean.getVersion() + "\" passed to UpdateTask");
return ret;
@@ -1422,10 +1422,10 @@ public class ApexEditorRestResource {
return ret;
}
- if (name1 == null || name1.equals("")) {
+ if (name1 == null || "".equals(name1)) {
name1 = null;
}
- if (version1 == null || version1.equals("")) {
+ if (version1 == null || "".equals(version1)) {
version1 = null;
}
@@ -1466,10 +1466,10 @@ public class ApexEditorRestResource {
return ret;
}
- if (name1 == null || name1.equals("")) {
+ if (name1 == null || "".equals(name1)) {
name1 = null;
}
- if (version1 == null || version1.equals("")) {
+ if (version1 == null || "".equals(version1)) {
version1 = null;
}
@@ -1511,10 +1511,10 @@ public class ApexEditorRestResource {
return ret;
}
- if (name1 == null || name1.equals("")) {
+ if (name1 == null || "".equals(name1)) {
name1 = null;
}
- if (version1 == null || version1.equals("")) {
+ if (version1 == null || "".equals(version1)) {
version1 = null;
}
@@ -1777,8 +1777,8 @@ public class ApexEditorRestResource {
final BeanPolicy jsonbean = RestUtils.getJsonParameters(jsonString, BeanPolicy.class);
- if (jsonbean.getName() == null || jsonbean.getName().equals("") || jsonbean.getVersion() == null
- || jsonbean.getVersion().equals("")) {
+ if (jsonbean.getName() == null || "".equals(jsonbean.getName()) || jsonbean.getVersion() == null
+ || "".equals(jsonbean.getVersion())) {
ret = new ApexApiResult(Result.FAILED, "Null/Empty Policy name/version (\"" + jsonbean.getName() + ":"
+ jsonbean.getVersion() + "\" passed to UpdatePolicy");
return ret;
@@ -1839,10 +1839,10 @@ public class ApexEditorRestResource {
return ret;
}
- if (name1 == null || name1.equals("")) {
+ if (name1 == null || "".equals(name1)) {
name1 = null;
}
- if (version1 == null || version1.equals("")) {
+ if (version1 == null || "".equals(version1)) {
version1 = null;
}
@@ -1884,10 +1884,10 @@ public class ApexEditorRestResource {
return ret;
}
- if (name1 == null || name1.equals("")) {
+ if (name1 == null || "".equals(name1)) {
name1 = null;
}
- if (version1 == null || version1.equals("")) {
+ if (version1 == null || "".equals(version1)) {
version1 = null;
}
diff --git a/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/RestUtils.java b/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/RestUtils.java
index 2bd47238a..2888b0376 100644
--- a/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/RestUtils.java
+++ b/client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/RestUtils.java
@@ -49,6 +49,12 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public abstract class RestUtils {
+ // Regular expressions for checking input types
+ private static final String XML_INPUT_TYPE_REGEXP = "^\\s*<\\?xml.*>\\s*"; //starts with <?xml...>
+ /**
+ * starts with some kind of bracket [ or ( or {, then has something, then has bracket.
+ */
+ private static final String JSON_INPUT_TYPE_REGEXP = "^\\s*[\\(\\{\\[][\\s+\\S]*[\\)\\}\\]]";
/**
* Constructor, block inheritance.
@@ -77,7 +83,7 @@ public abstract class RestUtils {
}
if (val.isJsonPrimitive() && ((JsonPrimitive) val).isString()) {
final String v = ((JsonPrimitive) val).getAsString();
- if (v == null || v.equals("")) {
+ if (v == null || "".equals(v)) {
return JsonNull.INSTANCE;
}
}
@@ -137,13 +143,6 @@ public abstract class RestUtils {
return gb.create().fromJson(jsonObject, clz);
}
- // Regular expressions for checking input types
- private static final String XML_INPUT_TYPE_REGEXP = "^\\s*<\\?xml.*>\\s*"; //starts with <?xml...>
- /**
- * starts with some kind of bracket [ or ( or {, then has something, then has bracket.
- */
- private static final String JSON_INPUT_TYPE_REGEXP = "^\\s*[\\(\\{\\[][\\s+\\S]*[\\)\\}\\]]";
-
/**
* Gets the concept from JSON.
*