diff options
author | 2018-02-26 12:38:53 +0100 | |
---|---|---|
committer | 2018-02-26 19:11:11 +0000 | |
commit | 312e9f071ef0a8b3482278e8909f66f4c986ba89 (patch) | |
tree | 8aecf342768b9d86fb1f68bf107ef5c313b2c7f8 /appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/CheckDataTool.java | |
parent | 534f94b92547efab097040209e61fa06e07f6e43 (diff) |
appc-config-generator-provider sonar fixes part 2
Sonar fixes in whole module
Change-Id: I55856a6ce73a73098dadb2c5b9428437349ed8a8
Issue-ID: APPC-671
Signed-off-by: Jakub Dudycz <jakub.dudycz@nokia.com>
Diffstat (limited to 'appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/CheckDataTool.java')
-rw-r--r-- | appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/CheckDataTool.java | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/CheckDataTool.java b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/CheckDataTool.java index 4488e0be8..3895aa47f 100644 --- a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/CheckDataTool.java +++ b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/CheckDataTool.java @@ -24,6 +24,8 @@ package org.onap.sdnc.config.generator.tool; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import java.io.StringReader; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -31,11 +33,15 @@ import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; import org.onap.sdnc.config.generator.ConfigGeneratorConstant; -import org.w3c.dom.Document; import org.xml.sax.InputSource; public class CheckDataTool { + private static final EELFLogger logger = EELFManager.getInstance().getLogger(CheckDataTool.class); + private static final String STR_INPUT_DATA = "Input data: \n"; + + private CheckDataTool() {} + public static String checkData(String data) { boolean isJSON = isJSON(data); if (isJSON) { @@ -54,33 +60,26 @@ public class CheckDataTool { try { new JSONObject(data); } catch (JSONException ex) { + logger.error(STR_INPUT_DATA + data + "\n is not json object", ex); try { new JSONArray(data); } catch (JSONException ex1) { + logger.error(STR_INPUT_DATA + data + "\n is not json array", ex1); return false; } } return true; - - // try { - // final ObjectMapper mapper = new ObjectMapper(); - // mapper.readTree(data); - // return true; - // } catch (IOException e) { - // return false; - // } } public static boolean isXML(String data) { try { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); - Document doc = dBuilder.parse(new InputSource(new StringReader(data))); + dBuilder.parse(new InputSource(new StringReader(data))); return true; } catch (Exception ex) { + logger.error(STR_INPUT_DATA + data + "\n is not xml document", ex); return false; } - } - } |