From 8711fde62fd65a745ddac7c82250e7c224f3c963 Mon Sep 17 00:00:00 2001 From: Sumapriya Sarvepalli Date: Fri, 27 Jul 2018 11:37:01 +0530 Subject: Sonar major issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This block of commented-out lines of code should be removed Sonar Link: https://sonar.onap.org/project/issues?fileUuids=AWHCr-EXEU5FCDfKtlqk&id=org.onap.so%3Aso&resolved=false&severities=MAJOR Location: src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java Line No: L39 L75 L112 L338 L473 L536 L555 L715 L736 L756 L794 L844 Change-Id: I6cbecd22eff2d86911405811686619771ac3f74e Issue-ID: SO-762 Signed-off-by: Sumapriya Sarvepalli --- .../openecomp/mso/bpmn/core/json/JsonUtils.java | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'bpmn/MSOCoreBPMN/src') diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java index 1869b930f0..01388352de 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java @@ -36,7 +36,7 @@ import org.json.JSONException; import org.json.JSONObject; import org.json.XML; import org.openecomp.mso.apihandler.common.ValidationException; -//import org.openecomp.mso.bpmn.core.BPMNLogger; + import org.openecomp.mso.bpmn.core.xml.XmlTool; import org.openecomp.mso.logger.MsoLogger; @@ -72,7 +72,7 @@ public class JsonUtils { * @return String containing the JSON translation */ public static String xml2json(String xml, Boolean pretty) { -// String isDebugLogEnabled = "true"; + try { // name spaces cause problems, so just remove them JSONObject jsonObj = XML.toJSONObject(XmlTool.removeNamespaces(xml)); @@ -109,7 +109,7 @@ public class JsonUtils { * @return String containing the XML translation */ public static String json2xml(String jsonStr, Boolean pretty) { -// String isDebugLogEnabled = "true"; + try { JSONObject jsonObj = new JSONObject(jsonStr); if (pretty) { @@ -335,7 +335,7 @@ public class JsonUtils { * @return String field value associated with keys */ public static String getJsonValue(String jsonStr, String keys) { -// String isDebugLogEnabled = "true"; + try { Object rawValue = getJsonRawValue(jsonStr, keys); if (rawValue == null) { @@ -470,7 +470,7 @@ public class JsonUtils { * @return String param value associated with field name */ public static String getJsonParamValue(String jsonStr, String keys, String name, int index) { -// String isDebugLogEnabled = "true"; + try { Object rawValue = getJsonRawValue(jsonStr, keys); if (rawValue == null) { @@ -533,7 +533,7 @@ public class JsonUtils { * @return String field value associated with key */ public static String getJsonValueForKey(String jsonStr, String key) { -// String isDebugLogEnabled = "true"; + try { JSONObject jsonObj = new JSONObject(jsonStr); return getJsonValueForKey(jsonObj, key); @@ -552,7 +552,7 @@ public class JsonUtils { * @return String field value associated with key */ public static String getJsonValueForKey(JSONObject jsonObj, String key) { -// String isDebugLogEnabled = "true"; + String keyValue = null; try { if (jsonObj.has(key)) { @@ -712,7 +712,7 @@ public class JsonUtils { * @return String containing the updated JSON doc */ public static String addJsonValue(String jsonStr, String keys, String value) { -// String isDebugLogEnabled = "true"; + // only attempt to insert the key/value pair if it does not exist if (!jsonValueExists(jsonStr, keys)) { return putJsonValue(jsonStr, keys, value); @@ -733,7 +733,7 @@ public class JsonUtils { * @return String containing the updated JSON doc */ public static String updJsonValue(String jsonStr, String keys, String newValue) { -// String isDebugLogEnabled = "true"; + // only attempt to modify the key/value pair if it exists if (jsonValueExists(jsonStr, keys)) { return putJsonValue(jsonStr, keys, newValue); @@ -753,7 +753,7 @@ public class JsonUtils { * @return String containing the updated JSON doc */ public static String delJsonValue(String jsonStr, String keys) { -// String isDebugLogEnabled = "true"; + // only attempt to remove the key/value pair if it exists if (jsonValueExists(jsonStr, keys)) { // passing a null value results in a delete @@ -791,7 +791,7 @@ public class JsonUtils { * @return Object field value associated with keys */ private static Object getJsonRawValue(String jsonStr, String keys, Boolean wrap) { -// String isDebugLogEnabled = "true"; + String keyStr = ""; try { JSONObject jsonObj = new JSONObject(jsonStr); @@ -841,7 +841,7 @@ public class JsonUtils { * @return String containing the updated JSON doc */ private static String putJsonValue(String jsonStr, String keys, String value) { -// String isDebugLogEnabled = "true"; + String keyStr = ""; try { JSONObject jsonObj = new JSONObject(jsonStr); -- cgit 1.2.3-korg