Example usage for org.dom4j Element addElement

List of usage examples for org.dom4j Element addElement

Introduction

In this page you can find the example usage for org.dom4j Element addElement.

Prototype

Element addElement(String name);

Source Link

Document

Adds a new Element node with the given name to this branch and returns a reference to the new node.

Usage

From source file:com.eurelis.opencms.ant.task.ManifestBuilderTask.java

License:Open Source License

public Document createDocument() {

    document = DocumentHelper.createDocument();
    document.setXMLEncoding("UTF-8");
    Element root = document.addElement("export");

    Element info = root.addElement("info");
    if (creator != null)
        info.addElement("creator").addText(creator);
    if (opencmsversion != null)
        info.addElement("opencms_version").addText(opencmsversion);
    info.addElement("createdate").addText(dateformat.format(new Date()));
    if (project != null)
        info.addElement("infoproject").addText(project);
    if (exportversion != null)
        info.addElement("export_version").addText(exportversion);

    Element module = root.addElement("module");

    if (name != null)
        module.addElement("name").addText(name);
    if (nicename != null)
        module.addElement("nicename").addText(nicename);
    if (group != null)
        module.addElement("group").addText(group);
    if (moduleclass != null)
        module.addElement("class").addText(moduleclass);
    if (moduledescription != null)
        module.addElement("description").add(new FlyweightCDATA(moduledescription));
    if (version != null)
        module.addElement("version").addText(version);
    if (authorname != null)
        module.addElement("authorname").add(new FlyweightCDATA(authorname));
    if (authoremail != null)
        module.addElement("authoremail").add(new FlyweightCDATA(authoremail));
    module.addElement("datecreated").addText(dateformat.format(new Date()));
    module.addElement("userinstalled").addText(userinstalled);
    module.addElement("dateinstalled").addText(dateinstalled);

    Element dependenciesBlock = module.addElement("dependencies");
    for (Dependency dep : dependencies) {
        dependenciesBlock.addElement("dependency").addAttribute("name", dep.getName()).addAttribute("version",
                dep.getVersion());/*from  ww  w.j a  va  2s  .com*/
    }

    Element exportPointsBlock = module.addElement("exportpoints");
    for (ExportPoint ep : exportpoints) {
        exportPointsBlock.addElement("exportpoint").addAttribute("uri", ep.getSrc()).addAttribute("destination",
                ep.getDst());
    }

    Element resourcesBlock = module.addElement("resources");
    for (Resource res : resources) {
        resourcesBlock.addElement("resource").addAttribute("uri", res.getUri());
    }

    Element parametersBlock = module.addElement("parameters");
    for (Parameter par : parameters) {
        parametersBlock.addElement("param").addAttribute("name", par.getName()).addText(par.getValue());
    }

    insertResourceTypes(module);
    insertExplorerTypes(module);

    if (!filesets.isEmpty()) {

        Element files = root.addElement("files");

        for (FileSet fileset : filesets) {
            DirectoryScanner ds = fileset.getDirectoryScanner(fileset.getProject());
            String[] dirs = ds.getIncludedDirectories();
            String[] filesColl = ds.getIncludedFiles();

            String[] excluDirsArray = ds.getExcludedDirectories();
            List<String> excluDirs = new ArrayList<String>();
            excluDirs.addAll(Arrays.asList(excluDirsArray));

            String[] excluFilesArray = ds.getExcludedFiles();
            List<String> excluFiles = new ArrayList<String>();
            excluFiles.addAll(Arrays.asList(excluFilesArray));

            CmsUUID.init("B4:B6:76:78:7F:3E");

            // FOLDERS MANAGEMENT
            for (int i = 0; i < dirs.length; i++) {
                String filepath = dirs[i];
                String filepathUnix = dirs[i].replace(SEPARATOR, "/");
                if (dirs[i] != "") {
                    Element tmpFile = files.addElement("file");
                    tmpFile.addElement("destination").addText(filepathUnix);

                    String folderPropertiesPath = getProject().getBaseDir() + SEPARATOR + srcfolder + SEPARATOR
                            + folderPropertiesPath(filepath);
                    String tmpType = getEurelisProperty("type", folderPropertiesPath);
                    if (null == tmpType) {
                        tmpType = "folder";
                    }
                    tmpFile.addElement("type").addText(tmpType);

                    if (generateuuids) {
                        Element uuidNode = tmpFile.addElement("uuidstructure");
                        String tmpUUID = getEurelisProperty("structureUUID", folderPropertiesPath);
                        if (null != tmpUUID)
                            uuidNode.addText(tmpUUID);
                        else
                            uuidNode.addText(new CmsUUID().toString());
                        // AJOUTER SAUVEGARDE DU NOUVEL UUID
                    }

                    long date = new File(
                            getProject().getBaseDir() + SEPARATOR + srcfolder + SEPARATOR + filepath)
                                    .lastModified();
                    if (0L == date)
                        date = new Date().getTime();
                    String formattedDate = dateformat.format(date);
                    tmpFile.addElement("datelastmodified").addText(formattedDate);
                    tmpFile.addElement("userlastmodified").addText("Admin");
                    // WARNING : CONSTANT VALUE
                    tmpFile.addElement("datecreated").addText(formattedDate);
                    // WARNING : CONSTANT VALUE
                    tmpFile.addElement("usercreated").addText("Admin");
                    tmpFile.addElement("flags").addText("0");

                    Element properties = tmpFile.addElement("properties");
                    // props detection and implementation
                    String tmpPropFile = folderPropertiesPath;
                    addPropertiesToTree(properties, tmpPropFile);

                    String tmpAccessFile = getProject().getBaseDir() + SEPARATOR + srcfolder + SEPARATOR
                            + folderAccessesPath(filepath);
                    addAccessesToTree(tmpFile, tmpAccessFile);
                }
            }
            // FILES MANAGEMENT
            for (int i = 0; i < filesColl.length; i++) {
                String filepath = filesColl[i];
                String filepathUnix = filesColl[i].replace(SEPARATOR, "/");
                if (filesColl[i] != "") {
                    Element tmpFile = files.addElement("file");
                    tmpFile.addElement("source").addText(filepathUnix);
                    tmpFile.addElement("destination").addText(filepathUnix);

                    String propertiesFilepath = getProject().getBaseDir() + SEPARATOR + srcfolder + SEPARATOR
                            + filePropertiesPath(filepath);
                    String tmpType = getEurelisProperty("type", propertiesFilepath);
                    if (null == tmpType) {
                        if (filepathUnix.endsWith(".config"))
                            tmpType = "module_config";
                        else if (filepathUnix.endsWith("main.jsp"))
                            tmpType = "containerpage_template";
                        else if (filepathUnix.endsWith(".jsp"))
                            tmpType = "jsp";
                        else if (filepathUnix.endsWith(".png") || filepathUnix.endsWith(".gif")
                                || filepathUnix.endsWith(".jpg") || filepathUnix.endsWith(".jpeg"))
                            tmpType = "image";
                        else if (filepathUnix.endsWith(".html") && filepathUnix.contains("/models/"))
                            tmpType = "containerpage";
                        else
                            tmpType = "plain";
                    }
                    tmpFile.addElement("type").addText(tmpType);

                    if (generateuuids) {
                        Element uuidNode = tmpFile.addElement("uuidresource");
                        Element uuidNode2 = tmpFile.addElement("uuidstructure");
                        String tmpUUID = getEurelisProperty("resourceUUID", propertiesFilepath);
                        if (null != tmpUUID)
                            uuidNode.addText(tmpUUID);
                        else
                            uuidNode.addText(new CmsUUID().toString());
                        tmpUUID = getEurelisProperty("structureUUID", propertiesFilepath);
                        if (null != tmpUUID)
                            uuidNode2.addText(tmpUUID);
                        else
                            uuidNode2.addText(new CmsUUID().toString());
                    }

                    long date = new File(
                            getProject().getBaseDir() + SEPARATOR + srcfolder + SEPARATOR + filepath)
                                    .lastModified();
                    if (0L == date)
                        date = new Date().getTime();
                    String formattedDate = dateformat.format(date);

                    tmpFile.addElement("datelastmodified").addText(formattedDate);
                    tmpFile.addElement("userlastmodified").addText("Admin");
                    tmpFile.addElement("datecreated").addText(formattedDate);
                    tmpFile.addElement("usercreated").addText("Admin");
                    tmpFile.addElement("flags").addText("0");
                    Element properties = tmpFile.addElement("properties");
                    String tmpPropFile = propertiesFilepath;
                    addPropertiesToTree(properties, tmpPropFile);

                    tmpFile.addElement("accesscontrol");

                }
            }
        }
    }

    return document;
}

From source file:com.eurelis.opencms.ant.task.ManifestBuilderTask.java

License:Open Source License

private void insertExplorerTypes(Element module) {
    if (null != explorertypes) {
        File xml = new File(explorertypes);
        SAXReader reader = new SAXReader();
        Document doc;/*from ww w  .ja va2s.co m*/
        try {
            doc = reader.read(xml);
            Element root = doc.getRootElement();
            module.add(root);
        } catch (DocumentException e) {
            module.addElement("explorertypes");
        }

    }
}

From source file:com.eurelis.opencms.ant.task.ManifestBuilderTask.java

License:Open Source License

private void insertResourceTypes(Element module) {
    if (null != resourcetypes) {
        File xml = new File(resourcetypes);
        SAXReader reader = new SAXReader();
        Document doc;//from  w  w w.ja v  a2s.c om
        try {
            doc = reader.read(xml);
            Element root = doc.getRootElement();
            module.add(root);
        } catch (DocumentException e) {
            module.addElement("resourcetypes");
        }
    }

}

From source file:com.eurelis.opencms.ant.task.ManifestBuilderTask.java

License:Open Source License

private void addPropertiesToTree(Element root, String propFilePath) {
    try {/*from  ww  w  . j  a  v  a 2 s .  c  o  m*/
        Properties props = new Properties();
        if (new File(propFilePath).exists())
            props.load(new FileInputStream(propFilePath));
        if (!props.isEmpty()) {
            for (Object keyObject : props.keySet()) {
                try {
                    String key = (String) keyObject;
                    if (key == null)
                        continue;
                    String value = props.getProperty(key);
                    if (value == null)
                        continue;
                    if (value.length() > 0) {
                        if (key.contains("EurelisProperty")) {
                            continue;
                        }
                        Element property = root.addElement("property");
                        property.addElement("name")
                                .addText(key.matches("^.*\\.[is]$") ? key.substring(0, key.length() - 2) : key);
                        property.addElement("value").add(new FlyweightCDATA(value));
                        if (key.endsWith(".s"))
                            property.addAttribute("type", "shared");
                    }
                } catch (Exception e) {
                    log(e, Project.MSG_ERR);
                    e.printStackTrace();
                }
            }
        }

    } catch (Exception e) {
        log(e, Project.MSG_ERR);
        e.printStackTrace();
    }
}

From source file:com.eurelis.opencms.ant.task.ManifestBuilderTask.java

License:Open Source License

private void addAccessesToTree(Element root, String propFilePath) {
    if (null != propFilePath) {
        File xml = new File(propFilePath);
        SAXReader reader = new SAXReader();
        Document doc;/*from   w  w  w. jav a  2 s .com*/
        try {
            doc = reader.read(xml);
            Element elem = doc.getRootElement();
            if (null != elem)
                root.add(elem);
            else
                root.addElement("accesscontrol");
        } catch (DocumentException e) {
            root.addElement("accesscontrol");
        }
    }
}

From source file:com.eurelis.opencms.workflows.workflows.A_OSWorkflowManager.java

License:Open Source License

/**
 * Get the OpenCMS RFS OSWorkflow configuration file and update it with the given filepath.
 * /*from  w ww  .  ja v  a2 s  .c  om*/
 * @param listOfWorkflowsFilepath
 *            the path of the file containing the list of available workflow descriptions
 * @return the path in RFS of the updated file
 * @throws DocumentException
 *             this exception is thrown if an error occurs during the parsing of the document
 * @throws IOException
 *             this exception is thrown if a problem occurs during overwriting of the config file
 */
private String updateOSWorkflowConfigFile(String listOfWorkflowsFilepath)
        throws CmsException, DocumentException, IOException {

    // get file path
    String configFilePath = this.getWebINFPath() + ModuleSharedVariables.SYSTEM_FILE_SEPARATOR
            + OSWORKFLOWCONFIGFILE_RFSFILEPATH;

    File listOfWorkflowsFile = new File(listOfWorkflowsFilepath);
    // Load Jdom parser
    SAXReader reader = new SAXReader();
    Document document = reader.read(configFilePath);
    Node propertyNode = document.selectSingleNode(OSWORKFLOWCONFIGFILE_PROPERTYTOUPDATE_XPATH);
    if (propertyNode != null) {
        if (propertyNode.getNodeType() == Node.ELEMENT_NODE) {
            // convert Node into element
            Element propertyElement = (Element) propertyNode;

            // update the Attribute
            Attribute valueAttribute = propertyElement
                    .attribute(OSWORKFLOWCONFIGFILE_PROPERTYTOUPDATE_ATTRIBUTNAME);

            valueAttribute.setValue(listOfWorkflowsFile.toURI().toString());

        } else {
            LOGGER.debug("the node with Xpath " + OSWORKFLOWCONFIGFILE_PROPERTYTOUPDATE_XPATH + " in the file "
                    + configFilePath + " doesn't correspond to an element");
        }

    } else {
        Node parentNode = document.selectSingleNode(OSWORKFLOWCONFIGFILE_PROPERTYTOUPDATE_PARENT_XPATH);
        if (parentNode != null) {

            if (parentNode.getNodeType() == Node.ELEMENT_NODE) {
                // convert Node into element
                Element parentElement = (Element) parentNode;

                // add new property
                Element propertyElement = parentElement.addElement("property");

                // add attributs
                propertyElement.addAttribute("key", "resource");
                propertyElement.addAttribute("value", listOfWorkflowsFile.toURI().toString());

            } else {
                LOGGER.debug("the node with Xpath " + OSWORKFLOWCONFIGFILE_PROPERTYTOUPDATE_XPATH
                        + " in the file " + configFilePath + " doesn't correspond to an element");
            }

        } else {
            LOGGER.debug("the node with Xpath " + OSWORKFLOWCONFIGFILE_PROPERTYTOUPDATE_PARENT_XPATH
                    + " in the file " + configFilePath + " has not been found.");
        }
    }

    /*
     * Get a string of the resulting file
     */

    // creating of a buffer that will collect result
    ByteArrayOutputStream xmlContent = new ByteArrayOutputStream();

    // Pretty print the document to xmlContent
    OutputFormat format = OutputFormat.createPrettyPrint();
    XMLWriter writer = new XMLWriter(xmlContent, format);
    writer.write(document);
    writer.flush();
    writer.close();

    // get the config file content as a String
    String documentContent = new String(xmlContent.toByteArray());

    /*
     * Overwrite the config file
     */
    FileWriter.writeFile(configFilePath, documentContent);

    return configFilePath;
}

From source file:com.ewcms.content.particular.service.ProjectBasicService.java

License:Open Source License

public Document exportXml(List<Long> projectBasicIds) {
    Document document = DocumentHelper.createDocument();

    Element root = document.addElement("MetaDatas");
    Element metaViewData = root.addElement("MetaViewData");

    if (projectBasicIds.isEmpty())
        return document;

    for (Long projectBasicId : projectBasicIds) {
        ProjectBasic projectBasic = projectBasicDAO.get(projectBasicId);

        Element projects = metaViewData.addElement("PROPERTIES");

        Element code = projects.addElement("?");
        code.addText(projectBasic.getCode() == null ? "" : projectBasic.getCode());

        Element name = projects.addElement("??");
        name.addText(projectBasic.getName() == null ? "" : projectBasic.getName());

        Element buildTime = projects.addElement("");
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        if (projectBasic.getBuildTime() != null) {
            buildTime.addText(dateFormat.format(projectBasic.getBuildTime()));
        } else {//from   w  w w .  java2  s .c  om
            buildTime.addText("");
        }

        Element investmentScale = projects.addElement("");
        investmentScale
                .addText(projectBasic.getInvestmentScale() == null ? "" : projectBasic.getInvestmentScale());

        Element overview = projects.addElement("");
        overview.addText(projectBasic.getOverview() == null ? "" : projectBasic.getOverview());

        Element buildUnit = projects.addElement("??");
        buildUnit.addText(projectBasic.getBuildUnit() == null ? "" : projectBasic.getBuildUnit());

        Element unitPhone = projects.addElement("????");
        unitPhone.addText(projectBasic.getUnitPhone() == null ? "" : projectBasic.getUnitPhone());

        Element unitAddress = projects.addElement("???");
        unitAddress.addText(projectBasic.getUnitAddress() == null ? "" : projectBasic.getUnitAddress());

        Element zoningCode_code = projects.addElement("?");
        if (projectBasic.getZoningCode() != null)
            zoningCode_code.addText(projectBasic.getZoningCode().getCode() == null ? ""
                    : projectBasic.getZoningCode().getCode());
        else
            zoningCode_code.addText("");

        Element organizationCode = projects.addElement("?");
        organizationCode
                .addText(projectBasic.getOrganizationCode() == null ? "" : projectBasic.getOrganizationCode());

        Element industryCode_code = projects.addElement("?");
        if (projectBasic.getIndustryCode() != null)
            industryCode_code.addText(projectBasic.getIndustryCode().getCode() == null ? ""
                    : projectBasic.getIndustryCode().getCode());
        else
            industryCode_code.addText("");

        Element category = projects.addElement("");
        category.addText(projectBasic.getCategory() == null ? "" : projectBasic.getCategory());

        Element unitId = projects.addElement("???");
        unitId.addText(projectBasic.getUnitId() == null ? "" : projectBasic.getUnitId());

        Element approvalRecord_code = projects.addElement("?");
        if (projectBasic.getApprovalRecord() != null)
            approvalRecord_code.addText(projectBasic.getApprovalRecord().getCode() == null ? ""
                    : projectBasic.getApprovalRecord().getCode());
        else
            approvalRecord_code.addText("");

        Element address = projects.addElement("?");
        address.addText(projectBasic.getAddress() == null ? "" : projectBasic.getAddress());

        Element bildNature = projects.addElement("");
        if (projectBasic.getBildNature() != null)
            bildNature.addText(projectBasic.getBildNature().getDescription() == null ? ""
                    : projectBasic.getBildNature().getDescription());
        else
            bildNature.addText("");

        Element contact = projects.addElement("?");
        contact.addText(projectBasic.getContact() == null ? "" : projectBasic.getContact());

        Element phone = projects.addElement("??");
        phone.addText(projectBasic.getPhone() == null ? "" : projectBasic.getPhone());

        Element email = projects.addElement("??");
        email.addText(projectBasic.getEmail() == null ? "" : projectBasic.getEmail());
    }
    return document;
}

From source file:com.ewcms.util.XMLUtil.java

License:Open Source License

/**
 * ?/*from   w  ww  . j a  v  a 2s  .com*/
 * 
 * @param parentElement
 * @param elementName
 * @return
 */
public Element addNode(Element parentElement, String elementName) {
    Element node = parentElement.addElement(elementName);
    return node;
}

From source file:com.example.sample.pMainActivity.java

License:Apache License

public Document createXMLDocument() {
    Document doc = null;//from w  w w  .  j  a va 2 s  .c  o  m
    doc = DocumentHelper.createDocument();
    doc.addComment("edited with XMLSpy v2005 rel. 3 U (http://www.altova.com) by  ()");
    //  doc.addDocType("class","//By Jack Chen","saveXML.xsd");
    Element root = doc.addElement("class");
    Element company = root.addElement("company");
    Element person = company.addElement("person");
    person.addAttribute("id", "11");
    person.addElement("name").setText("Jack Chen");
    person.addElement("sex").setText("");
    person.addElement("date").setText("2001-04-01");
    person.addElement("email").setText("chen@163.com");
    person.addElement("QQ").setText("2366001");
    return doc;
}

From source file:com.faithbj.shop.action.admin.InstallAction.java

public String save() throws URISyntaxException, IOException, DocumentException {
    if (isInstalled()) {
        return ajaxJsonErrorMessage("CAIJINGLING?????");
    }//  ww w  .j a  v a2s.c  o  m
    if (StringUtils.isEmpty(databaseHost)) {
        return ajaxJsonErrorMessage("?!");
    }
    if (StringUtils.isEmpty(databasePort)) {
        return ajaxJsonErrorMessage("??!");
    }
    if (StringUtils.isEmpty(databaseUsername)) {
        return ajaxJsonErrorMessage("???!");
    }
    if (StringUtils.isEmpty(databasePassword)) {
        return ajaxJsonErrorMessage("??!");
    }
    if (StringUtils.isEmpty(databaseName)) {
        return ajaxJsonErrorMessage("???!");
    }
    if (StringUtils.isEmpty(adminUsername)) {
        return ajaxJsonErrorMessage("???!");
    }
    if (StringUtils.isEmpty(adminPassword)) {
        return ajaxJsonErrorMessage("??!");
    }
    if (StringUtils.isEmpty(installStatus)) {
        Map<String, String> jsonMap = new HashMap<String, String>();
        jsonMap.put(STATUS, "requiredCheckFinish");
        return ajaxJson(jsonMap);
    }

    String jdbcUrl = "jdbc:mysql://" + databaseHost + ":" + databasePort + "/" + databaseName
            + "?useUnicode=true&characterEncoding=UTF-8";
    Connection connection = null;
    PreparedStatement preparedStatement = null;
    ResultSet resultSet = null;
    try {
        // ?
        connection = DriverManager.getConnection(jdbcUrl, databaseUsername, databasePassword);
        DatabaseMetaData databaseMetaData = connection.getMetaData();
        String[] types = { "TABLE" };
        resultSet = databaseMetaData.getTables(null, databaseName, "%", types);
        if (StringUtils.equalsIgnoreCase(installStatus, "databaseCheck")) {
            Map<String, String> jsonMap = new HashMap<String, String>();
            jsonMap.put(STATUS, "databaseCheckFinish");
            return ajaxJson(jsonMap);
        }

        // ?
        if (StringUtils.equalsIgnoreCase(installStatus, "databaseCreate")) {
            StringBuffer stringBuffer = new StringBuffer();
            BufferedReader bufferedReader = null;
            String sqlFilePath = Thread.currentThread().getContextClassLoader().getResource("").toURI()
                    .getPath() + SQL_INSTALL_FILE_NAME;
            bufferedReader = new BufferedReader(
                    new InputStreamReader(new FileInputStream(sqlFilePath), "UTF-8"));
            String line = "";
            while (null != line) {
                line = bufferedReader.readLine();
                stringBuffer.append(line);
                if (null != line && line.endsWith(";")) {
                    System.out.println("[CAIJINGLING?]SQL: " + line);
                    preparedStatement = connection.prepareStatement(stringBuffer.toString());
                    preparedStatement.executeUpdate();
                    stringBuffer = new StringBuffer();
                }
            }
            String insertAdminSql = "INSERT INTO `admin` VALUES ('402881862bec2a21012bec2bd8de0003','2010-10-10 0:0:0','2010-10-10 0:0:0','','admin@shopxx.net',b'1',b'0',b'0',b'0',NULL,NULL,0,NULL,'?','"
                    + DigestUtils.md5Hex(adminPassword) + "','" + adminUsername + "');";
            String insertAdminRoleSql = "INSERT INTO `admin_role` VALUES ('402881862bec2a21012bec2bd8de0003','402881862bec2a21012bec2b70510002');";
            preparedStatement = connection.prepareStatement(insertAdminSql);
            preparedStatement.executeUpdate();
            preparedStatement = connection.prepareStatement(insertAdminRoleSql);
            preparedStatement.executeUpdate();
        }
    } catch (SQLException e) {
        e.printStackTrace();
        return ajaxJsonErrorMessage("???!");
    } finally {
        try {
            if (resultSet != null) {
                resultSet.close();
                resultSet = null;
            }
            if (preparedStatement != null) {
                preparedStatement.close();
                preparedStatement = null;
            }
            if (connection != null) {
                connection.close();
                connection = null;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    // ???
    String configFilePath = Thread.currentThread().getContextClassLoader().getResource("").toURI().getPath()
            + JDBC_CONFIG_FILE_NAME;
    Properties properties = new Properties();
    properties.put("jdbc.driver", "com.mysql.jdbc.Driver");
    properties.put("jdbc.url", jdbcUrl);
    properties.put("jdbc.username", databaseUsername);
    properties.put("jdbc.password", databasePassword);
    properties.put("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
    properties.put("hibernate.show_sql", "false");
    properties.put("hibernate.format_sql", "false");
    OutputStream outputStream = new FileOutputStream(configFilePath);
    properties.store(outputStream, JDBC_CONFIG_FILE_DESCRIPTION);
    outputStream.close();

    // ??
    String backupWebConfigFilePath = Thread.currentThread().getContextClassLoader().getResource("").toURI()
            .getPath() + BACKUP_WEB_CONFIG_FILE_NAME;
    String backupApplicationContextConfigFilePath = Thread.currentThread().getContextClassLoader()
            .getResource("").toURI().getPath() + BACKUP_APPLICATION_CONTEXT_CONFIG_FILE_NAME;
    String backupCompassApplicationContextConfigFilePath = Thread.currentThread().getContextClassLoader()
            .getResource("").toURI().getPath() + BACKUP_COMPASS_APPLICATION_CONTEXT_CONFIG_FILE_NAME;
    String backupSecurityApplicationContextConfigFilePath = Thread.currentThread().getContextClassLoader()
            .getResource("").toURI().getPath() + BACKUP_SECURITY_APPLICATION_CONTEXT_CONFIG_FILE_NAME;

    String webConfigFilePath = new File(
            Thread.currentThread().getContextClassLoader().getResource("").toURI().getPath()).getParent() + "/"
            + WEB_CONFIG_FILE_NAME;
    String applicationContextConfigFilePath = Thread.currentThread().getContextClassLoader().getResource("")
            .toURI().getPath() + APPLICATION_CONTEXT_CONFIG_FILE_NAME;
    String compassApplicationContextConfigFilePath = Thread.currentThread().getContextClassLoader()
            .getResource("").toURI().getPath() + COMPASS_APPLICATION_CONTEXT_CONFIG_FILE_NAME;
    String securityApplicationContextConfigFilePath = Thread.currentThread().getContextClassLoader()
            .getResource("").toURI().getPath() + SECURITY_APPLICATION_CONTEXT_CONFIG_FILE_NAME;

    FileUtils.copyFile(new File(backupWebConfigFilePath), new File(webConfigFilePath));
    FileUtils.copyFile(new File(backupApplicationContextConfigFilePath),
            new File(applicationContextConfigFilePath));
    FileUtils.copyFile(new File(backupCompassApplicationContextConfigFilePath),
            new File(compassApplicationContextConfigFilePath));
    FileUtils.copyFile(new File(backupSecurityApplicationContextConfigFilePath),
            new File(securityApplicationContextConfigFilePath));

    // ??
    String systemConfigFilePath = Thread.currentThread().getContextClassLoader().getResource("").toURI()
            .getPath() + SystemConfigUtil.CONFIG_FILE_NAME;
    File systemConfigFile = new File(systemConfigFilePath);
    SAXReader saxReader = new SAXReader();
    Document document = saxReader.read(systemConfigFile);
    Element rootElement = document.getRootElement();
    Element systemConfigElement = rootElement.element("systemConfig");
    Node isInstalledNode = document.selectSingleNode("/shopxx/systemConfig/isInstalled");
    if (isInstalledNode == null) {
        isInstalledNode = systemConfigElement.addElement("isInstalled");
    }
    isInstalledNode.setText("true");
    try {
        OutputFormat outputFormat = OutputFormat.createPrettyPrint();// XML?
        outputFormat.setEncoding("UTF-8");// XML?
        outputFormat.setIndent(true);// ?
        outputFormat.setIndent("   ");// TAB?
        outputFormat.setNewlines(true);// ??
        XMLWriter xmlWriter = new XMLWriter(new FileOutputStream(systemConfigFile), outputFormat);
        xmlWriter.write(document);
        xmlWriter.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return ajaxJsonSuccessMessage("CAIJINGLING?????");
}