List of usage examples for org.apache.commons.lang StringUtils equalsIgnoreCase
public static boolean equalsIgnoreCase(String str1, String str2)
Compares two Strings, returning true
if they are equal ignoring the case.
From source file:hydrograph.ui.propertywindow.widgets.utility.SchemaRowValidation.java
private void executeIfObjectIsFixedWidthRow(GridRow gridRow, String componentType, TableItem tableItem) { if (StringUtils.equalsIgnoreCase(gridRow.getDataTypeValue(), JAVA_MATH_BIG_DECIMAL)) { if (validationCheckForBigDecimalDatatype(gridRow, componentType, tableItem)) return; } else if (StringUtils.equalsIgnoreCase(gridRow.getDataTypeValue(), JAVA_UTIL_DATE)) { validationCheckForDateDatatype(gridRow, tableItem); return;// ww w . j a va2s. c om } FixedWidthGridRow fixedWidthGridRow = (FixedWidthGridRow) gridRow; if (fixedWidthGridRow instanceof MixedSchemeGridRow) { if ((StringUtils.isBlank(fixedWidthGridRow.getDelimiter()) && StringUtils.isBlank(fixedWidthGridRow.getLength())) || (StringUtils.isNotBlank(fixedWidthGridRow.getDelimiter()) && StringUtils.isNotBlank(fixedWidthGridRow.getLength())) || (StringUtils.isNotBlank(fixedWidthGridRow.getLength()) && (fixedWidthGridRow.getLength().equals("0"))) || (StringUtils.isNotBlank(fixedWidthGridRow.getLength()) && !(fixedWidthGridRow.getLength().matches(REGULAR_EXPRESSION_FOR_NUMBER)))) { setRedColor(tableItem); invalidLength = true; } else { setBlackColor(tableItem); invalidLength = false; } } else { if (StringUtils.isBlank(fixedWidthGridRow.getLength()) || !(fixedWidthGridRow.getLength().matches(REGULAR_EXPRESSION_FOR_NUMBER)) || (fixedWidthGridRow.getLength().equals("0"))) { setRedColor(tableItem); invalidLength = true; } else { setBlackColor(tableItem); invalidLength = false; } } }
From source file:hydrograph.ui.propertywindow.widgets.customwidgets.secondarykeys.SecondaryColumnKeysWidget.java
private List<String> getPropagatedSchema() { List<String> propogatedFields = new ArrayList<>(); if (StringUtils.equalsIgnoreCase(getComponent().getComponentName(), Constants.AGGREGATE) || StringUtils.equalsIgnoreCase(getComponent().getComponentName(), Constants.CUMULATE) || StringUtils.equalsIgnoreCase(getComponent().getComponentName(), Constants.GROUP_COMBINE)) { TransformWidget transformWidget = null; for (AbstractWidget abstractWidget : widgets) { if (abstractWidget instanceof TransformWidget) { transformWidget = (TransformWidget) abstractWidget; break; }/*from w ww .j ava 2 s . c o m*/ } if (transformWidget != null) { TransformMapping transformMapping = (TransformMapping) transformWidget.getProperties() .get(Constants.OPERATION); for (InputField inputField : transformMapping.getInputFields()) { propogatedFields.add(inputField.getFieldName()); } } return propogatedFields; } else if (StringUtils.equalsIgnoreCase(getComponent().getComponentName(), Constants.FILTER) || StringUtils.equalsIgnoreCase(getComponent().getCategory(), Constants.STRAIGHTPULL)) { ELTSchemaGridWidget schemaWidget = null; for (AbstractWidget abstractWidget : widgets) { if (abstractWidget instanceof ELTSchemaGridWidget) { schemaWidget = (ELTSchemaGridWidget) abstractWidget; break; } } if (schemaWidget != null) { schemaWidget.refresh(); List<GridRow> gridRowList = (List<GridRow>) schemaWidget.getTableViewer().getInput(); for (GridRow gridRow : gridRowList) { propogatedFields.add(gridRow.getFieldName()); } } return propogatedFields; } else if (StringUtils.equalsIgnoreCase(getComponent().getComponentName(), Constants.OUTPUT_EXCEL)) { List<String> list = new ArrayList<String>(); Schema schema = (Schema) getComponent().getProperties().get(Constants.SCHEMA_PROPERTY_NAME); if (schema != null && schema.getGridRow() != null) { List<GridRow> gridRows = schema.getGridRow(); if (gridRows != null) { for (GridRow gridRow : gridRows) { list.add(gridRow.getFieldName()); } } } return list; } return SchemaPropagationHelper.INSTANCE.getFieldsForFilterWidget(getComponent()) .get(Constants.INPUT_SOCKET_TYPE + 0); }
From source file:gov.nih.nci.cabig.caaers.tools.configuration.Configuration.java
public boolean isAuthenticationModeWebSSO() { return StringUtils.equalsIgnoreCase("webSSO", authenticationMode); }
From source file:hydrograph.ui.propertywindow.ftp.FTPAuthenticEditorDialog.java
private void populateWidget(Composite stackComposite, StackLayout stackLayout) { String comboText1;// w w w .j a v a2s . c o m String ComboText2; if (StringUtils.equalsIgnoreCase(protocolText, "AWS S3 HTTPS")) { comboText1 = "AWS S3 Access Key"; ComboText2 = "AWS S3 Property File"; } else { comboText1 = Constants.STAND_AUTH; ComboText2 = "User ID and Key"; } for (Map.Entry<String, FTPAuthOperationDetails> map : authOperationSelectionMap.entrySet()) { authenticationModeCombo.setText(map.getKey()); if (StringUtils.equalsIgnoreCase(comboText1, map.getKey())) { authenticationModeCombo.select(0); basicAuthComposite = (Composite) addBasicAuthenticationComposite(stackComposite); stackLayout.topControl = basicAuthComposite; FTPAuthOperationDetails authOperationDetails = map.getValue(); text1.setText(authOperationDetails.getField1()); Utils.INSTANCE.addMouseMoveListener(text1, cursor); if (text2 != null) { text2.setText(authOperationDetails.getField2()); Utils.INSTANCE.addMouseMoveListener(text2, cursor); } } else if (StringUtils.equalsIgnoreCase(ComboText2, map.getKey())) { authenticationModeCombo.select(1); keyFileComposite = (Composite) addIdKeyComposite(stackComposite); stackLayout.topControl = keyFileComposite; FTPAuthOperationDetails authOperationDetails = map.getValue(); if (text1 != null && authOperationDetails.getField1() != null) { text1.setText(authOperationDetails.getField1()); Utils.INSTANCE.addMouseMoveListener(text1, cursor); } text2.setText(authOperationDetails.getField2()); Utils.INSTANCE.addMouseMoveListener(text2, cursor); } } }
From source file:com.sfs.whichdoctor.analysis.GroupAnalysisDAOImpl.java
/** * Load reference objects./*from w ww . j av a 2 s. c o m*/ * * @param referenceGUIDs the reference gui ds * @param loadDetails the load details * @param user the user * @param groupClass the group class * * @return the tree map< integer, object> * * @throws WhichDoctorSearchDaoException the which doctor search dao * exception */ private TreeMap<Integer, Object> loadReferenceObjects(final TreeMap<Integer, ArrayList<Integer>> referenceGUIDs, final BuilderBean loadDetails, final UserBean user, final String groupClass) throws WhichDoctorSearchDaoException { TreeMap<Integer, Object> referenceObjects = new TreeMap<Integer, Object>(); Collection<Object> searchGUIDs = new ArrayList<Object>(); for (Integer referenceGUID : referenceGUIDs.keySet()) { searchGUIDs.add(String.valueOf(referenceGUID)); } dataLogger .info("Loading reference objects for: " + groupClass + ", with a size of: " + searchGUIDs.size()); if (StringUtils.equalsIgnoreCase(groupClass, "people") || StringUtils.equalsIgnoreCase(groupClass, "members")) { referenceObjects = loadPeople(searchGUIDs, loadDetails, user); } if (StringUtils.equalsIgnoreCase(groupClass, "organisations")) { referenceObjects = loadOrganisations(searchGUIDs, loadDetails, user); } if (StringUtils.equalsIgnoreCase(groupClass, "debits")) { referenceObjects = loadDebits(searchGUIDs, loadDetails, user); } if (StringUtils.equalsIgnoreCase(groupClass, "credits")) { referenceObjects = loadCredits(searchGUIDs, loadDetails, user); } if (StringUtils.equalsIgnoreCase(groupClass, "receipts")) { referenceObjects = loadReceipts(searchGUIDs, loadDetails, user); } if (StringUtils.equalsIgnoreCase(groupClass, "reimbursements")) { referenceObjects = loadReimbursements(searchGUIDs, loadDetails, user); } if (StringUtils.equalsIgnoreCase(groupClass, "rotations")) { referenceObjects = loadRotations(searchGUIDs, loadDetails, user); } return referenceObjects; }
From source file:com.sfs.whichdoctor.search.http.OrganisationInputHandler.java
/** * Process the incoming HttpRequest for search parameters. * * @param request the request//from www. j a v a 2 s . c o m * @param user the user * * @return the search bean */ public final SearchBean process(final HttpServletRequest request, final UserBean user) { SearchBean search = organisationSqlHandler.initiate(user); OrganisationBean searchCriteria = (OrganisationBean) search.getSearchCriteria(); OrganisationBean searchConstraints = (OrganisationBean) search.getSearchConstraints(); /* Process search form */ String strGUIDList = DataFilter.getHtml(request.getParameter("guidList")); String strIncludeGUIDList = DataFilter.getHtml(request.getParameter("includeGUIDList")); String strName = DataFilter.getHtml(request.getParameter("name")); String strType = DataFilter.getHtml(request.getParameter("type")); String strTrainingOrganisation = DataFilter.getHtml(request.getParameter("trainingOrganisation")); String strTrainingProgram = DataFilter.getHtml(request.getParameter("trainingProgram")); String strSpecialtyStatus = DataFilter.getHtml(request.getParameter("specialtyStatus")); String strRegion = DataFilter.getHtml(request.getParameter("region")); String strAddressClass = DataFilter.getHtml(request.getParameter("addressClass")); String strAddressType = DataFilter.getHtml(request.getParameter("addressType")); String strAddressReturnedMail = DataFilter.getHtml(request.getParameter("addressReturnedMail")); String strAddressRequestNoMail = DataFilter.getHtml(request.getParameter("addressRequestNoMail")); String strCountry = DataFilter.getHtml(request.getParameter("country")); String strCity = DataFilter.getHtml(request.getParameter("city")); String strEmailType = DataFilter.getHtml(request.getParameter("emailType")); String strEmailReturnedMail = DataFilter.getHtml(request.getParameter("emailReturnedMail")); String strEmailRequestNoMail = DataFilter.getHtml(request.getParameter("emailRequestNoMail")); String strClosingBalanceA = DataFilter.getHtml(request.getParameter("closingBalanceA")); String strClosingBalanceB = DataFilter.getHtml(request.getParameter("closingBalanceB")); String strCreatedA = DataFilter.getHtml(request.getParameter("createdA")); String strCreatedB = DataFilter.getHtml(request.getParameter("createdB")); String strUpdatedA = DataFilter.getHtml(request.getParameter("updatedA")); String strUpdatedB = DataFilter.getHtml(request.getParameter("updatedB")); if (StringUtils.isNotBlank(strGUIDList)) { // Parse the GUID list string into a collection of strings searchCriteria.setGUIDList(DataFilter.parseTextDataToCollection(strGUIDList)); } if (StringUtils.isNotBlank(strIncludeGUIDList)) { // Parse the GUID list string into a collection of strings searchCriteria.setIncludeGUIDList(DataFilter.parseTextDataToCollection(strIncludeGUIDList)); } /* Set first and last name requirements */ if (StringUtils.isNotBlank(strName)) { searchCriteria.setName(strName.trim()); } /* Set type requirements */ if (StringUtils.isNotBlank(strType) && !StringUtils.equals(strType, "Null")) { searchCriteria.setType(strType.trim()); } /* Tag searches */ searchCriteria.setTags(this.setTagArray(request, user)); /* Check if specialtyAge or Type was set */ boolean specialty = false; SpecialtyBean specialtyCriteria = new SpecialtyBean(); if (StringUtils.isNotBlank(strTrainingOrganisation) && !StringUtils.equals(strTrainingOrganisation, "Null")) { specialtyCriteria.setTrainingOrganisation(strTrainingOrganisation); specialty = true; } if (StringUtils.isNotBlank(strTrainingProgram) && !StringUtils.equals(strTrainingProgram, "Null")) { specialtyCriteria.setTrainingProgram(strTrainingProgram); specialty = true; } if (StringUtils.isNotBlank(strSpecialtyStatus) && !StringUtils.equals(strSpecialtyStatus, "Null")) { specialtyCriteria.setStatus(strSpecialtyStatus); specialty = true; } if (specialty) { Collection<SpecialtyBean> specialties = new ArrayList<SpecialtyBean>(); specialties.add(specialtyCriteria); searchCriteria.setSpecialtyList(specialties); } /* Set organisation region */ if (StringUtils.isNotBlank(strRegion) && !StringUtils.equals(strRegion, "Null")) { searchCriteria.setRegion(strRegion); } // Check if Address details have been submitted boolean address = false; AddressBean addressCriteria = new AddressBean(); AddressBean addressConstraints = new AddressBean(); // Address defaults addressCriteria.setReturnedMail(false); addressConstraints.setReturnedMail(true); addressCriteria.setRequestNoMail(false); addressConstraints.setRequestNoMail(true); // Set the address class and type - but don't set the address flag yet if (StringUtils.isNotBlank(strAddressClass)) { if (StringUtils.equalsIgnoreCase(strAddressClass, "Preferred")) { // Set the primary flag to true addressCriteria.setPrimary(true); addressConstraints.setPrimary(true); } else { // Set the address class addressCriteria.setContactClass(strAddressClass); } } if (StringUtils.isNotBlank(strAddressType)) { // Set the address type addressCriteria.setContactType(strAddressType); } // Set the address city if (StringUtils.isNotBlank(strCity)) { addressCriteria.setAddressField(strCity); address = true; } // Set the address country if (StringUtils.isNotBlank(strCountry)) { addressCriteria.setCountry(strCountry); address = true; } // Set the returned mail if (StringUtils.equals(strAddressReturnedMail, "true")) { addressCriteria.setReturnedMail(true); addressConstraints.setReturnedMail(true); address = true; } if (StringUtils.equals(strAddressReturnedMail, "false")) { addressCriteria.setReturnedMail(false); addressConstraints.setReturnedMail(false); address = true; } // Set the request mail if (StringUtils.equals(strAddressRequestNoMail, "true")) { addressCriteria.setRequestNoMail(true); addressConstraints.setRequestNoMail(true); address = true; } if (StringUtils.equals(strAddressRequestNoMail, "false")) { addressCriteria.setRequestNoMail(false); addressConstraints.setRequestNoMail(false); address = true; } if (address) { Collection<AddressBean> addresses = new ArrayList<AddressBean>(); Collection<AddressBean> addresses2 = new ArrayList<AddressBean>(); addresses.add(addressCriteria); addresses2.add(addressConstraints); searchCriteria.setAddress(addresses); searchConstraints.setAddress(addresses2); } // Check if Email details have been submitted boolean email = false; EmailBean emailCriteria = new EmailBean(); EmailBean emailConstraints = new EmailBean(); // Email defaults emailCriteria.setReturnedMail(true); emailConstraints.setReturnedMail(false); emailCriteria.setRequestNoMail(true); emailConstraints.setRequestNoMail(false); emailCriteria.setEmailQuestions(true); emailConstraints.setEmailQuestions(false); // Set the email type - but don't set the address flag yet if (StringUtils.isNotBlank(strEmailType)) { if (StringUtils.equalsIgnoreCase(strEmailType, "Preferred")) { // Set the primary flag to true emailCriteria.setPrimary(true); emailConstraints.setPrimary(true); } else { // Set the email type emailCriteria.setContactType(strEmailType); } } if (StringUtils.equals(strEmailReturnedMail, "true")) { emailCriteria.setReturnedMail(true); emailConstraints.setReturnedMail(true); email = true; } if (StringUtils.equals(strEmailReturnedMail, "false")) { emailCriteria.setReturnedMail(false); emailConstraints.setReturnedMail(false); email = true; } if (StringUtils.equals(strEmailRequestNoMail, "true")) { emailCriteria.setRequestNoMail(true); emailConstraints.setRequestNoMail(true); email = true; } if (StringUtils.equals(strEmailRequestNoMail, "false")) { emailCriteria.setRequestNoMail(false); emailConstraints.setRequestNoMail(false); email = true; } if (email) { Collection<EmailBean> emails = new ArrayList<EmailBean>(); Collection<EmailBean> emails2 = new ArrayList<EmailBean>(); emails.add(emailCriteria); emails2.add(emailConstraints); searchCriteria.setEmail(emails); searchConstraints.setEmail(emails2); } if (StringUtils.isNotBlank(strClosingBalanceA) && !StringUtils.equals(strClosingBalanceA, "Null")) { // Something has been defined for this field double closingBalanceA = 0; double closingBalanceB = 0; try { closingBalanceA = Double.parseDouble(strClosingBalanceA); } catch (NumberFormatException nfe) { closingBalanceA = 0; } try { closingBalanceB = Double.parseDouble(strClosingBalanceB); } catch (NumberFormatException nfe) { closingBalanceB = 0; } if (StringUtils.equals(strClosingBalanceB, "-")) { closingBalanceB = -100000000; } if (StringUtils.equals(strClosingBalanceB, "+")) { closingBalanceB = 100000000; } FinancialSummaryBean financialSummaryCriteria = new FinancialSummaryBean(); // This is a unique id to indicate the financial summary has been set financialSummaryCriteria.setId(1); financialSummaryCriteria.setClosingBalance(closingBalanceA); searchCriteria.setFinancialSummary(financialSummaryCriteria); if (closingBalanceB != 0) { FinancialSummaryBean financialSummaryConstraints = new FinancialSummaryBean(); financialSummaryConstraints.setClosingBalance(closingBalanceB); searchConstraints.setFinancialSummary(financialSummaryConstraints); } } if (StringUtils.isNotBlank(strCreatedA)) { searchCriteria.setCreatedDate(DataFilter.parseDate(strCreatedA, false)); } if (StringUtils.isNotBlank(strCreatedB)) { searchConstraints.setCreatedDate(DataFilter.parseDate(strCreatedB, false)); if (StringUtils.equals(strCreatedB, "+")) { /* All dates above Date A requested */ searchConstraints.setCreatedDate(getMaximumDate()); } if (StringUtils.equals(strCreatedB, "-")) { /* Add dates below Date A requested */ searchConstraints.setCreatedDate(getMinimumDate()); } } if (StringUtils.isNotBlank(strUpdatedA)) { searchCriteria.setModifiedDate(DataFilter.parseDate(strUpdatedA, false)); } if (StringUtils.isNotBlank(strUpdatedB)) { searchConstraints.setModifiedDate(DataFilter.parseDate(strUpdatedB, false)); if (StringUtils.equals(strUpdatedB, "+")) { /* All dates above Date A requested */ searchConstraints.setModifiedDate(getMaximumDate()); } if (StringUtils.equals(strUpdatedB, "-")) { /* Add dates below Date A requested */ searchConstraints.setModifiedDate(getMinimumDate()); } } search.setSearchCriteria(searchCriteria); search.setSearchConstraints(searchConstraints); return search; }
From source file:info.magnolia.cms.security.MgnlGroup.java
/** * adds a new node under specified node collection *///w w w . j ava2 s . c o m private void add(String name, String nodeName) { try { HierarchyManager hm; if (StringUtils.equalsIgnoreCase(nodeName, NODE_ROLES)) hm = MgnlContext.getHierarchyManager(ContentRepository.USER_ROLES); else hm = MgnlContext.getHierarchyManager(ContentRepository.USER_GROUPS); if (!this.hasAny(name, nodeName)) { Content node = groupNode.getContent(nodeName); // add corresponding ID try { String value = hm.getContent("/" + name).getUUID(); // assuming that there is a flat hierarchy // used only to get the unique label HierarchyManager usersHM = ContentRepository.getHierarchyManager(ContentRepository.USERS); String newName = Path.getUniqueLabel(usersHM, node.getHandle(), "0"); node.createNodeData(newName).setValue(value); groupNode.save(); } catch (PathNotFoundException e) { if (log.isDebugEnabled()) log.debug("Role [ " + name + " ] does not exist in the ROLES repository"); } } } catch (RepositoryException e) { log.error("failed to add " + name + " to user [" + this.getName() + "]", e); } }
From source file:com.aliyun.odps.flume.sink.OdpsWriter.java
private void setField(Record record, String field, String fieldValue, OdpsType odpsType) { if (StringUtils.isNotEmpty(field) && StringUtils.isNotEmpty(fieldValue)) { switch (odpsType) { case STRING: record.setString(field, fieldValue); break; case BIGINT: record.setBigint(field, Long.parseLong(fieldValue)); break; case DATETIME: if (dateFormat != null) { try { record.setDatetime(field, dateFormat.parse(fieldValue)); } catch (ParseException e) { logger.error("OdpsWriter parse date error. Date value = " + fieldValue, e); }/* www .j ava 2 s .c o m*/ } break; case DOUBLE: record.setDouble(field, Double.parseDouble(fieldValue)); break; case BOOLEAN: if (StringUtils.equalsIgnoreCase(fieldValue, "true")) { record.setBoolean(field, true); } else if (StringUtils.equalsIgnoreCase(fieldValue, "false")) { record.setBoolean(field, false); } break; case DECIMAL: record.setDecimal(field, new BigDecimal(fieldValue)); default: throw new RuntimeException("Unknown column type: " + odpsType); } } }
From source file:net.shopxx.action.admin.InstallAction.java
public String save() throws URISyntaxException, IOException, DocumentException { if (isInstalled()) { return ajaxJsonErrorMessage("SHOP++?????"); }// www.ja v 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("[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() + 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("SHOP++?????"); }
From source file:com.adobe.acs.commons.forms.helpers.impl.PostRedirectGetFormHelperImpl.java
/** * Checks if this Form Manager should handle this request as a GET request. * * @param formName/* ww w . ja v a 2s . c o m*/ * @param request * @return */ protected boolean doHandleGet(final String formName, final SlingHttpServletRequest request) { //noinspection SimplifiableIfStatement if (StringUtils.equalsIgnoreCase("GET", request.getMethod())) { return (StringUtils.isNotBlank(request.getParameter(this.getGetLookupKey(formName)))); } else { return false; } }