From 5cd7ee0c6e5e1e52577c399fd2a3da4da589f59b Mon Sep 17 00:00:00 2001 From: burdziak Date: Fri, 26 Jan 2018 13:54:34 +0100 Subject: Fixes in DGXMLGenerator Change-Id: I98821612d8a2ad0aea4484fbb12568301db70a37 Issue-ID: APPC-542 Signed-off-by: burdziak --- .../main/java/org/onap/sdnc/dg/loader/DGXMLGenerator.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'appc-directed-graph/dg-loader') diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLGenerator.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLGenerator.java index f9722a04d..b7ff22251 100644 --- a/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLGenerator.java +++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLGenerator.java @@ -25,6 +25,7 @@ package org.onap.sdnc.dg.loader; import java.io.File; +import java.security.InvalidParameterException; import java.util.ArrayList; import java.util.List; import javax.script.Invocable; @@ -39,13 +40,13 @@ import org.slf4j.LoggerFactory; public class DGXMLGenerator { private final static Logger logger = LoggerFactory.getLogger(DGXMLGenerator.class); - public static String STRING_ENCODING = "utf-8"; - public static String JS_INTERFACE_DG_CONVERTOR = "dgconverter"; - public static String JS_METHOD_GET_NODE_TO_XML = "getNodeToXml"; - public static String GENERATOR_TEMPLATE_FILE = "js/dg_xml2json.js"; + public static final String STRING_ENCODING = "utf-8"; + public static final String JS_INTERFACE_DG_CONVERTOR = "dgconverter"; + public static final String JS_METHOD_GET_NODE_TO_XML = "getNodeToXml"; + public static final String GENERATOR_TEMPLATE_FILE = "js/dg_xml2json.js"; public void generateXMLFromJSON(String jsonPath, String xmlpath, String propertyPath) - throws Exception { + throws InvalidParameterException { try { ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("JavaScript"); @@ -71,7 +72,7 @@ public class DGXMLGenerator { } else if (jsonPathFile.isFile()) { files.add(jsonPathFile); } else { - throw new Exception("Failed to get the nature of the JSON path :" + jsonPath); + throw new InvalidParameterException("Failed to get the nature of the JSON path :" + jsonPath); } logger.info("JSON Files identified " + files.size()); @@ -122,7 +123,7 @@ public class DGXMLGenerator { jsonPath = args[0]; xmlPath = args[1]; } else { - throw new Exception("Sufficient inputs are missing "); + throw new InvalidParameterException("Required inputs are missing "); } application.generateXMLFromJSON(jsonPath, xmlPath, propertyPath); -- cgit 1.2.3-korg