+ private void generateXmls(String xmlpath, Invocable inv, Object dgconverter, List<File> files)
+ throws IOException, ScriptException, NoSuchMethodException {
+ for (File file : files) {
+ String dgJson = FileUtils.readFileToString(file, STRING_ENCODING);
+ logger.info("Generating XML from :" + file.getName());
+ String xmlFileName =
+ xmlpath + "/" + file.getName().replace(".json", ".xml");
+
+ Object dgXMl =
+ inv.invokeMethod(dgconverter, JS_METHOD_GET_NODE_TO_XML, dgJson);
+ tryWriteXml(xmlFileName, dgXMl);
+ }
+ }
+
+ private void tryWriteXml(String xmlFileName, Object dgXMl) throws IOException {
+ if (dgXMl != null) {
+ File xmlFile = new File(xmlFileName);
+ FileUtils.writeStringToFile(xmlFile, dgXMl.toString(), STRING_ENCODING);
+ logger.info("Generated XML File under :" + xmlFile.getCanonicalPath());
+ }
+ }