import org.json.JSONObject;\r
import org.json.XML;\r
import org.openecomp.mso.apihandler.common.ValidationException;\r
-//import org.openecomp.mso.bpmn.core.BPMNLogger;\r
+\r
import org.openecomp.mso.bpmn.core.xml.XmlTool;\r
import org.openecomp.mso.logger.MsoLogger;\r
\r
* @return String containing the JSON translation\r
*/\r
public static String xml2json(String xml, Boolean pretty) {\r
-// String isDebugLogEnabled = "true";\r
+\r
try {\r
// name spaces cause problems, so just remove them\r
JSONObject jsonObj = XML.toJSONObject(XmlTool.removeNamespaces(xml));\r
* @return String containing the XML translation\r
*/\r
public static String json2xml(String jsonStr, Boolean pretty) {\r
-// String isDebugLogEnabled = "true";\r
+\r
try {\r
JSONObject jsonObj = new JSONObject(jsonStr);\r
if (pretty) {\r
* @return String field value associated with keys\r
*/\r
public static String getJsonValue(String jsonStr, String keys) {\r
-// String isDebugLogEnabled = "true";\r
+\r
try {\r
Object rawValue = getJsonRawValue(jsonStr, keys);\r
if (rawValue == null) {\r
* @return String param value associated with field name\r
*/\r
public static String getJsonParamValue(String jsonStr, String keys, String name, int index) {\r
-// String isDebugLogEnabled = "true";\r
+\r
try {\r
Object rawValue = getJsonRawValue(jsonStr, keys);\r
if (rawValue == null) {\r
* @return String field value associated with key\r
*/\r
public static String getJsonValueForKey(String jsonStr, String key) {\r
-// String isDebugLogEnabled = "true";\r
+\r
try {\r
JSONObject jsonObj = new JSONObject(jsonStr);\r
return getJsonValueForKey(jsonObj, key);\r
* @return String field value associated with key\r
*/\r
public static String getJsonValueForKey(JSONObject jsonObj, String key) {\r
-// String isDebugLogEnabled = "true";\r
+\r
String keyValue = null;\r
try {\r
if (jsonObj.has(key)) {\r
* @return String containing the updated JSON doc\r
*/\r
public static String addJsonValue(String jsonStr, String keys, String value) {\r
-// String isDebugLogEnabled = "true";\r
+\r
// only attempt to insert the key/value pair if it does not exist\r
if (!jsonValueExists(jsonStr, keys)) {\r
return putJsonValue(jsonStr, keys, value);\r
* @return String containing the updated JSON doc\r
*/\r
public static String updJsonValue(String jsonStr, String keys, String newValue) {\r
-// String isDebugLogEnabled = "true";\r
+\r
// only attempt to modify the key/value pair if it exists\r
if (jsonValueExists(jsonStr, keys)) {\r
return putJsonValue(jsonStr, keys, newValue);\r
* @return String containing the updated JSON doc\r
*/\r
public static String delJsonValue(String jsonStr, String keys) {\r
-// String isDebugLogEnabled = "true";\r
+\r
// only attempt to remove the key/value pair if it exists\r
if (jsonValueExists(jsonStr, keys)) {\r
// passing a null value results in a delete\r
* @return Object field value associated with keys\r
*/\r
private static Object getJsonRawValue(String jsonStr, String keys, Boolean wrap) {\r
-// String isDebugLogEnabled = "true";\r
+\r
String keyStr = "";\r
try {\r
JSONObject jsonObj = new JSONObject(jsonStr);\r
* @return String containing the updated JSON doc\r
*/\r
private static String putJsonValue(String jsonStr, String keys, String value) {\r
-// String isDebugLogEnabled = "true";\r
+\r
String keyStr = "";\r
try {\r
JSONObject jsonObj = new JSONObject(jsonStr);\r