public void export(String xmlPath, String outPath, boolean isZip) { String adminPath = rootPath + sep + "administrator" + sep; String outFolder = outPath + sep + MyCommonMethods.getFileName(xmlPath, "."); // copy the xml also to create the path MyCommonMethods.deleteDir(outFolder + sep, null); MyCommonMethods.copyFileOrFolder( xmlPath, outFolder + sep + MyCommonMethods.getFullFileName(xmlPath), ""); if ((new File(outFolder)).exists()) { if (extClient != null) { if (extClient.equalsIgnoreCase("administrator")) { processXml(adminPath, outFolder + sep, true); } else { processXml(rootPath + sep, outFolder + sep, false); } } else { processXml(adminPath, outFolder + sep, true); processXml(rootPath + sep, outFolder + sep, false); } } // XXX to speed up exportTables(outFolder + sep); if (isZip) { MyCommonMethods.zipFolder(outFolder, outFolder + ".zip"); MyCommonMethods.deleteDir(outFolder, null); } }
public void processXml(String basePath, String outPath, boolean isAdmin) { Element parentSection = isAdmin ? xml.getFirstElementByTag("administration", null) : null; Element fileSection = xml.getFirstElementByTag("files", parentSection); Element langSection = xml.getFirstElementByTag("languages", parentSection); Element mediaSection = xml.getFirstElementByTag("media", parentSection); String type = extType.getFolder(); if (isAdmin) { if (extVer == SharedDefines.emJava_ver.J_15) { Element instFile = xml.getFirstElementByTag("installfile", null); Element uninstFile = xml.getFirstElementByTag("uninstallfile", null); String file = null; if (instFile != null) { file = instFile.getValue(); MyCommonMethods.copyFileOrFolder( basePath + type + sep + extFolder + sep + file, outPath + file, ""); } if (uninstFile != null) { file = uninstFile.getValue(); MyCommonMethods.copyFileOrFolder( basePath + type + sep + extFolder + sep + file, outPath + file, ""); } } else { Element scriptFile = xml.getFirstElementByTag("uninstall", null); if (scriptFile != null) { String file = scriptFile.getValue(); MyCommonMethods.copyFileOrFolder( basePath + type + sep + extFolder + sep + file, outPath + file, ""); } } Element instSection = xml.getFirstElementByTag("sql", xml.getFirstElementByTag("install", null)); Element uninstSection = xml.getFirstElementByTag("sql", xml.getFirstElementByTag("uninstall", null)); if (instSection != null) { ArrayList<String> instFiles = xml.getElementsValues(xml.getElementsByTag("file", instSection), null); for (String F : instFiles) { MyCommonMethods.copyFileOrFolder( basePath + type + sep + extFolder + sep + F, outPath + F, ""); } } if (uninstSection != null) { ArrayList<String> uninstFiles = xml.getElementsValues(xml.getElementsByTag("file", uninstSection), null); for (String F : uninstFiles) { MyCommonMethods.copyFileOrFolder( basePath + type + sep + extFolder + sep + F, outPath + F, ""); } } } if (fileSection != null) { String filesPath = fileSection.getAttributeValue("folder") == null ? "" : fileSection.getAttributeValue("folder") + sep; ArrayList<String> folders = xml.getElementsValues(xml.getElementsByTag("folder", fileSection), null); ArrayList<Element> fElements = xml.getElementsByTag("filename", fileSection); if (fElements.isEmpty()) // XXX workaround { fElements = xml.getElementsByTag("file", fileSection); } ArrayList<String> files = xml.getElementsValues(fElements, null); // XXX message box if you want overwrite and remove try catch for (String F : folders) { MyCommonMethods.copyFileOrFolder( basePath + type + sep + extFolder + sep + F, outPath + filesPath + F, ""); } for (String F : files) { MyCommonMethods.copyFileOrFolder( basePath + type + sep + extFolder + sep + F, outPath + filesPath + F, ""); } } if (mediaSection != null) { String mediaPath = mediaSection.getAttributeValue("folder") == null ? "" : mediaSection.getAttributeValue("folder") + sep; String mediaDest = mediaSection.getAttributeValue("destination"); ArrayList<String> mediaFolders = xml.getElementsValues(xml.getElementsByTag("folder", mediaSection), null); ArrayList<Element> fElements = xml.getElementsByTag("filename", mediaSection); if (fElements.isEmpty()) // XXX workaround { fElements = xml.getElementsByTag("file", mediaSection); } ArrayList<String> mediaFiles = xml.getElementsValues(fElements, null); for (String F : mediaFolders) { MyCommonMethods.copyFileOrFolder( basePath + "media" + sep + mediaDest + sep + F, outPath + mediaPath + sep + F, ""); } for (String F : mediaFiles) { MyCommonMethods.copyFileOrFolder( basePath + "media" + sep + mediaDest + sep + F, outPath + mediaPath + sep + F, ""); } } if (langSection != null) { String langPath = langSection.getAttributeValue("folder") == null ? "" : langSection.getAttributeValue("folder") + sep; ArrayList<Element> langFiles = xml.getElementsByTag("language", langSection); for (Element E : langFiles) { String folder = E.getAttributeValue("tag"); String file = E.getValue(); MyCommonMethods.copyFileOrFolder( basePath + "language" + sep + folder + sep + file, outPath + langPath + sep + E.getValue(), ""); } } }