Example usage for org.apache.commons.lang StringUtils equalsIgnoreCase

List of usage examples for org.apache.commons.lang StringUtils equalsIgnoreCase

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils equalsIgnoreCase.

Prototype

public static boolean equalsIgnoreCase(String str1, String str2) 

Source Link

Document

Compares two Strings, returning true if they are equal ignoring the case.

Usage

From source file:hydrograph.ui.engine.converter.impl.SFTPConvertorHelper.java

/** 
 *  file operation details//from w w w . j a  v  a2s.c om
 * @param ftp
 */
private void addSFtpOperationDetails(SFTP sftp) {
    Map<String, FTPAuthOperationDetails> fileOperationDetaildetails = (Map<String, FTPAuthOperationDetails>) properties
            .get(PropertyNameConstants.FTP_OPERATION.value());
    FileOperationChoice fileOperationChoice = new FileOperationChoice();
    FTPAuthOperationDetails authOperationDetails = null;
    if (fileOperationDetaildetails != null && !fileOperationDetaildetails.isEmpty()) {
        for (Map.Entry<String, FTPAuthOperationDetails> map : fileOperationDetaildetails.entrySet()) {
            authOperationDetails = map.getValue();
            if (StringUtils.equalsIgnoreCase(map.getKey(), Constants.GET_FILE)) {
                fileOperationChoice.setDownload(map.getKey());
                sftp.setInputFilePath(authOperationDetails.getField2());
                sftp.setOutputFilePath(authOperationDetails.getField1());
            } else {
                fileOperationChoice.setUpload(map.getKey());
                sftp.setInputFilePath(authOperationDetails.getField1());
                sftp.setOutputFilePath(authOperationDetails.getField2());
            }
        }
        sftp.setFileOperation(fileOperationChoice);
        sftp.setOverwritemode(authOperationDetails.getField5());
    }
}

From source file:com.fiveamsolutions.nci.commons.ejb.AuthorizationInterceptor.java

/**
 * Ensures that the current authenticated user is associated with the current session so that security filtering is
 * correct./*from  w  w  w .ja va  2s  .  c o m*/
 *
 * @param invContext the method context
 * @return the method result
 * @throws Exception if invoking the method throws an exception.
 */
@AroundInvoke
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
// method invocation wrapper requires throws Exception
public Object prepareReturnValue(InvocationContext invContext) throws Exception {
    final String currentUser = UsernameHolder.getUser();
    if (StringUtils.equalsIgnoreCase(UsernameHolder.ANONYMOUS_USERNAME, currentUser)) {
        String username;
        try {
            username = sessionContext.getCallerPrincipal().getName();
        } catch (IllegalStateException e) {
            username = getUnknownUsername();
        }
        UsernameHolder.setUser(username);
    }
    try {
        return invContext.proceed();
    } finally {
        // See PO-6019. Username needs to be cleaned up after the thread is done.
        UsernameHolder.setUserCaseSensitive(currentUser);
    }
}

From source file:com.zg.action.admin.InstallAction.java

public String save() throws URISyntaxException, IOException, DocumentException {
    if (isInstalled()) {
        return ajaxJsonErrorMessage("SHOP++?????");
    }/*from   www  .  j ava  2s . com*/
    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("[SHOP++?]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() + SystemConfigUtils.CONFIG_FILE_NAME;
    File systemConfigFile = new File(
            ConfigurationManager.getConfigProperties(SystemConfigUtils.CONFIG_FILE_PATH_NAME));
    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("SHOP++?????");
}

From source file:com.baifendian.swordfish.common.storm.StormRestUtil.java

/**
 * ?//from w  ww.  j  a  v  a  2s  .c  o  m
 */
public static void topologyDeactivate(String topologyId) throws Exception {
    String res = Request.Post(getTopologyDeactivateUrl(topologyId)).execute().returnContent().toString();

    TopologyOperationDto topologyOperation = JsonUtil.parseObject(res, TopologyOperationDto.class);

    if (topologyOperation == null) {
        throw new Exception("Deactivate not result return!");
    }

    if (!StringUtils.equalsIgnoreCase(topologyOperation.getStatus(), "success")) {
        String msg = MessageFormat.format("Deactivate status not equal success: {0}",
                topologyOperation.getStatus());
        throw new Exception(msg);
    }
}

From source file:hydrograph.ui.engine.ui.converter.impl.JoinComponentUiConverter.java

protected void getOutPort(TypeOperationsComponent operationsComponent) {
    LOGGER.debug("Generating OutPut Ports for -{}", componentName);
    if (operationsComponent.getOutSocket() != null) {
        for (TypeOperationsOutSocket outSocket : operationsComponent.getOutSocket()) {

            if (StringUtils.equalsIgnoreCase(Constants.UNUSED_SOCKET_TYPE, outSocket.getType())) {
                unusedPortCounter++;/*from   ww w.  ja  v  a2  s  .  c o  m*/
            }

            uiComponent.engageOutputPort(outSocket.getId());
            if (outSocket.getPassThroughFieldOrOperationFieldOrExpressionField() != null
                    && !outSocket.getPassThroughFieldOrOperationFieldOrExpressionField().isEmpty()) {
                propertyMap.put(Constants.JOIN_MAP_FIELD, getJoinMappingGrid(outSocket));
                createPassThroughAndMappingFieldsForSchemaPropagation(outSocket);

            } else if (outSocket.getCopyOfInsocket() != null
                    && StringUtils.equalsIgnoreCase(outSocket.getType(), Constants.OUTPUT_SOCKET_TYPE)) {
                JoinMappingGrid joinMappingGrid = new JoinMappingGrid();
                joinMappingGrid.setButtonText(Constants.COPY_FROM_INPUT_PORT_PROPERTY
                        + outSocket.getCopyOfInsocket().getInSocketId());
                joinMappingGrid.setIsSelected(true);
                propertyMap.put(Constants.JOIN_MAP_FIELD, joinMappingGrid);
                copySchemaFromInputPort(outSocket.getCopyOfInsocket().getInSocketId());
            }
        }

    }
    if (unusedPortCounter > inPortCounter) {
        inPortCounter = unusedPortCounter;
        incrementPort();
    }

}

From source file:de.hybris.platform.accountsummaryaddon.document.dao.impl.DefaultPagedB2BDocumentDao.java

protected String formatField(final String fieldName) {
    if (StringUtils.equalsIgnoreCase(B2BDocumentModel.DOCUMENTTYPE, fieldName)) {
        return " {" + B2BDocumentTypeModel._TYPECODE + ":" + B2BDocumentTypeModel.CODE + " } ";
    } else if (StringUtils.equalsIgnoreCase(B2BDocumentModel.UNIT, fieldName)) {
        return " {" + B2BUnitModel._TYPECODE + ":" + B2BUnitModel.UID + " } ";
    } else {//from  w  ww  .  jav  a 2s  .c om
        return " {" + B2BDocumentModel._TYPECODE + ":" + getFiedName(fieldName) + "} ";
    }
}

From source file:com.dgq.utils.Struts2Utils.java

/**
 * ?contentTypeheaders./* w  w  w  . j a v a  2s  .c  o  m*/
 */
private static HttpServletResponse initResponseHeader(final String contentType, final String... headers) {
    // ?headers?
    String encoding = DEFAULT_ENCODING;
    boolean noCache = DEFAULT_NOCACHE;
    for (String header : headers) {
        String headerName = StringUtils.substringBefore(header, ":");
        String headerValue = StringUtils.substringAfter(header, ":");

        if (StringUtils.equalsIgnoreCase(headerName, HEADER_ENCODING)) {
            encoding = headerValue;
        } else if (StringUtils.equalsIgnoreCase(headerName, HEADER_NOCACHE)) {
            noCache = Boolean.parseBoolean(headerValue);
        } else {
            throw new IllegalArgumentException(headerName + "??header");
        }
    }

    HttpServletResponse response = getResponse();

    // headers?
    String fullContentType = contentType + ";charset=" + encoding;
    response.setContentType(fullContentType);
    if (noCache) {
        ServletUtils.setNoCacheHeader(response);
    }

    return response;
}

From source file:com.gcrm.action.crm.EditAccountAction.java

/**
 * Saves the entity./* ww  w .ja  v a2  s .c o  m*/
 * 
 * @return the SUCCESS result
 */
public String save() throws Exception {
    String validateStr = validateAccountForm();
    if (StringUtils.isNotEmpty(validateStr)) {
        response2Json(null, false, validateStr);
        return null;
    }
    // ?????
    if (account == null) {
        return null;
    }
    String hql = "from Contact where account = " + this.getId() + " AND contact_default = 1";
    mainContactList = contactService.findByHQL(hql);
    boolean flag = true;// 
    if (account.getId() == null) {
        if (!StringUtils.equalsIgnoreCase(goon, "true")) {
            // ?
            String existhql = "from Account where name = '" + account.getName() + "' or address = '"
                    + account.getAddress() + "'";
            List<Account> accountList1 = baseService.findByHQL(existhql);
            if (!accountList1.isEmpty()) {
                String msg = String.format(
                        "?%s??%s?",
                        accountList1.get(0).getName(), accountList1.get(0).getAddress());
                response2Json("exist", false, msg);
                return null;
            }
        }
    } else {
        flag = false;
    }

    final Account originalAccount = saveEntity();
    String recordText = "";
    // 
    Record record1 = null;
    Record record2 = null;
    if (account.getId() == null) {
        recordText = String.format("?%s%s", account.getName(),
                account.getAssigned_to().getLast_name());
        record1 = getRecordOjb(RecordTypeEnum.ADD_ACCOUNT, null, null, null, 0, 0, 0, null, "account",
                recordText);
    } else {
        if (!originalAccount.getAssigned_to().getId().equals(account.getAssigned_to().getId())) {
            recordText = String.format("%s?%s",
                    originalAccount.getAssigned_to().getName(), account.getAssigned_to().getName());
            record2 = getRecordOjb(RecordTypeEnum.ASSIGN_CHANGE, account.getId(), null, null,
                    account.getAccountIntent(), account.getAccountVisit(), 0, account.getAssigned_date(),
                    "account", recordText);
        } else {

            Account oldaccount = baseService.getEntityById(Account.class, account.getId());
            Account oldaccountEntry = oldaccount.clone();
            Map<String, Map<String, String>> resultMap = compareAccount(account, oldaccountEntry);
            StringBuffer changeValueSb = new StringBuffer();
            Map<String, String> newOldMap = new HashMap<String, String>();
            for (Entry<String, Map<String, String>> maps : resultMap.entrySet()) {
                changeValueSb.append("");
                changeValueSb.append("?" + maps.getKey() + "");
                changeValueSb.append(":");
                newOldMap = maps.getValue();
                for (Entry<String, String> subMap : newOldMap.entrySet()) {
                    changeValueSb.append(subMap.getValue());
                    changeValueSb.append("=>");
                    changeValueSb.append(subMap.getKey());
                }
                changeValueSb.append(",");

            }

            recordText = String.format("?%s?" + changeValueSb.toString(),
                    account.getName());
            record2 = getRecordOjb(RecordTypeEnum.UPDATE_ACCOUNT, account.getId(), null, null,
                    account.getAccountIntent(), account.getAccountVisit(), 0, account.getAssigned_date(),
                    "account", recordText);

        }
    }
    User loginUser = this.getLoginUser();
    final Collection<ChangeLog> changeLogs = changeLog(originalAccount, account, loginUser);
    account = baseService.makePersistent(account);
    this.setId(account.getId());
    this.setSaveFlag("true");
    if (record1 != null) {
        record1.setOuterId(account.getId());
        recordService.makePersistent(record1);
    }
    if (record2 != null) {
        recordService.makePersistent(record2);
    }
    if (originalAccount != null) {
        taskExecutor.execute(new Runnable() {

            public void run() {
                batchInserChangeLogs(changeLogs);
            }
        });
    }
    if (flag) {
        response2Json(account.getId(), true, "?!");
    } else {
        response2Json(account.getId(), true, "?!");
    }
    return null;
}

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

public String save() throws URISyntaxException, IOException, DocumentException {
    if (isInstalled()) {
        return ajaxJsonErrorMessage("CAIJINGLING?????");
    }//from w w w  .jav a 2s.  co 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?????");
}

From source file:com.sfs.whichdoctor.importer.Importer.java

/**
 * Process data./*from w  ww . ja  v a  2 s .  c o m*/
 *
 * @param type the type
 * @param data the data
 * @param columns the columns
 * @param applicationContext the application context
 *
 * @throws IOException Signals that an I/O exception has occurred.
 */
public final void processData(final String type, final TreeMap<Integer, TreeMap<Integer, String>> data,
        final TreeMap<Integer, String> columns, final ApplicationContext applicationContext)
        throws IOException {
    HashMap<String, List<String>> dataMap = new HashMap<String, List<String>>();

    if (data != null && columns != null) {
        // Iterate through the columns assigning values to the dataMap
        for (Integer columnNumber : columns.keySet()) {
            String columnField = columns.get(columnNumber);

            if (StringUtils.isNotBlank(columnField)) {
                // The column has been associated to some data
                ArrayList<String> dataValues = new ArrayList<String>();

                for (Integer rowNumber : data.keySet()) {
                    TreeMap<Integer, String> rowData = data.get(rowNumber);
                    if (rowData.containsKey(columnNumber)) {
                        // Get the value of the column and add it array
                        String dataField = rowData.get(columnNumber);
                        dataValues.add(dataField);
                    }
                }
                // Add the data name and array to the dataMap
                dataMap.put(columnField, dataValues);
            }
        }
        // Store the completed dataMap
        setDataMap(dataMap);
    }

    // Take the dataMap and load the relevant objects into the bean map
    if (StringUtils.equalsIgnoreCase(type, "exam")) {
        importLogger.debug("Processing exam import");
        try {
            ExamImporter examImporter = new ExamImporter();
            examImporter.setDataMap(getDataMap());

            /* Process the data map and turn it into a bean map */
            final PersonDAO personDAO = (PersonDAO) applicationContext.getBean("personDAO");

            setBeanMap(examImporter.assignData(personDAO));
            setDescriptionMap(examImporter.getDescriptionMap());
            setImportMessage(examImporter.getImportMessage());

        } catch (Exception e) {
            importLogger.error("Error processing exam import: " + e.getMessage());
            throw new IOException("Error processing exam import: " + e.getMessage());
        }
    }
}