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:cn.com.xdays.xshop.action.admin.InstallAction.java
public String save() throws URISyntaxException, IOException, DocumentException { if (isInstalled()) { return ajaxJsonErrorMessage("SHOP++?????"); }//from www . ja v a 2s. c om 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 { Class.forName("com.mysql.jdbc.Driver"); // ? 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 (Exception 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.sfs.whichdoctor.dao.onlineapplication.BasicTrainingOnlineApplicationHandler.java
/** * Gets the JSP key for the next step./*w ww.j a va 2 s . c o m*/ * An error is thrown if the user does not have the privileges to access this step. * * @param application the online application * @param user the user * @param privileges the privileges * @return the next step * @throws WhichDoctorDaoException the which doctor dao exception */ public final String getNextJSPKey(final OnlineApplicationBean application, final UserBean user, final PrivilegesBean privileges) throws WhichDoctorDaoException { if (user == null) { throw new WhichDoctorDaoException("The user cannot be null"); } if (privileges == null) { throw new WhichDoctorDaoException("The privileges cannot be null"); } String key = ""; String status = application.getStatus(); if (StringUtils.contains(status, " )")) { status = StringUtils.substringBefore(status, " ("); } if (StringUtils.equalsIgnoreCase(status, "Unprocessed")) { if (privileges.getPrivilege(user, "people", "create")) { key = "PEOPLE_DATAENTRY"; } else { throw new WhichDoctorDaoException("Insufficient permissions to confirm membership details"); } } if (StringUtils.equalsIgnoreCase(status, "Confirm email address")) { if (privileges.getPrivilege(user, "emails", "create")) { key = "EMAIL_DATAENTRY"; } else { throw new WhichDoctorDaoException("Insufficient permissions to confirm email details"); } } if (StringUtils.equalsIgnoreCase(status, "Confirm address")) { if (privileges.getPrivilege(user, "addresses", "create")) { key = "ADDRESS_DATAENTRY"; } else { throw new WhichDoctorDaoException("Insufficient permissions to confirm address details"); } } if (StringUtils.containsIgnoreCase(status, " phone") || StringUtils.containsIgnoreCase(status, " fax")) { if (privileges.getPrivilege(user, "phones", "create")) { key = "PHONE_DATAENTRY"; } else { throw new WhichDoctorDaoException("Insufficient permissions to confirm phone details"); } } if (StringUtils.equalsIgnoreCase(status, "Confirm secondary qualifications")) { if (privileges.getPrivilege(user, "qualifications", "create")) { key = "QUALIFICATION_DATAENTRY"; } else { throw new WhichDoctorDaoException("Insufficient permissions to confirm qualifications details"); } } if (StringUtils.equalsIgnoreCase(status, "Confirm rotation details")) { if (privileges.getPrivilege(user, "rotations", "create")) { key = "ROTATIONS_DATAENTRY"; } else { throw new WhichDoctorDaoException("Insufficient permissions to confirm rotation details"); } } if (StringUtils.equalsIgnoreCase(status, "Issue invoice")) { if (privileges.getPrivilege(user, "invoices", "create")) { key = "DEBITS_DATAENTRY"; } else { throw new WhichDoctorDaoException("Insufficient permissions to issue invoice"); } } return key; }
From source file:com.tesora.dve.db.mysql.MysqlNative.java
private String getDataTypeForQuery(UserColumn uc, boolean extras) throws PEException { MysqlNativeType typeInfo = (MysqlNativeType) findType(uc.getTypeName()); String typeName = typeInfo.getTypeName(); // DAS - HACK - we need to remove the "ALT" from the 3 BLOB types if (typeName.startsWith("alt")) { typeName = typeName.substring(3); // remove the "ALT" }/*from ww w . ja va 2 s. c om*/ StringBuilder sb = new StringBuilder(typeName); if (MysqlType.ENUM.equals(typeInfo.getMysqlType())) { // with enum, use the full type, including values sb = new StringBuilder(uc.getTypeName()); } else if (!typeInfo.getSupportsPrecision()) { // type requires neither precision nor scale, so we're done } else if (typeInfo.getSupportsPrecision() && !typeInfo.getSupportsScale()) { // type has precision String precision = Long.toString(uc.getSize()); if (uc.getSize() == 0) { // the uc has a size of 0 which means the user probably specified it like integer instead of integer(n) // grab the default precision from the type info instead precision = Long.toString(typeInfo.getPrecision()); } sb.append('(').append(precision).append(')'); } else { // type has precision and scale MysqlType mysqlType = typeInfo.getMysqlType(); // don't output precision and scale if precision is 0 if (uc.getPrecision() > 0) { // handle special case for MYSQL - DOUBLE with no (p,s) comes back as (22,31) which is invalid if ((MysqlType.DOUBLE.equals(mysqlType) || MysqlType.DOUBLE_PRECISION.equals(mysqlType) || MysqlType.FLOAT.equals(mysqlType)) && uc.getScale() == 31) { // do nothing } else { sb.append('(').append(uc.getPrecision()).append(',').append(uc.getScale()).append(')'); } } else { // special case for decimal and numeric if 0 is specified // for precision // if ((MysqlType.DECIMAL.equals(mysqlType) || MysqlType.NUMERIC.equals(mysqlType)) if ((MysqlType.DECIMAL.equals(mysqlType)) && uc.getScale() == 0) { if (uc.getSize() > 0) { // can specify the size without scale - make sure it isn't larger than max for create table (see PE-1232) sb.append('(').append(uc.getSize()).append(",0)"); } else { // figure out the default size sb.append('(').append(typeInfo.getPrecision()).append(",0)"); } } } } if (uc.getESUniverse() != null) sb.append("(").append(uc.getESUniverse()).append(")"); if (extras && typeInfo.isStringType()) { if (uc.getCharset() != null && !StringUtils.equalsIgnoreCase(MysqlNativeConstants.DB_CHAR_SET, uc.getCharset())) { sb.append(" CHARACTER SET ").append(uc.getCharset()); } if (uc.getCollation() != null) { sb.append(" COLLATE ").append(uc.getCollation()); } } // add any type modifiers to the end if (uc.isUnsigned()) sb.append(" unsigned"); if (uc.isZerofill()) sb.append(" zerofill"); return sb.toString(); }
From source file:com.baifendian.swordfish.common.storm.StormRestUtil.java
/** * ??//w w w .ja v a2 s . c o m */ public static void topologyActivate(String topologyId) throws Exception { String res = Request.Post(getTopologyActivateUrl(topologyId)).execute().returnContent().toString(); TopologyOperationDto topologyOperation = JsonUtil.parseObject(res, TopologyOperationDto.class); if (topologyOperation == null) { throw new Exception("Activate not result return!"); } if (!StringUtils.equalsIgnoreCase(topologyOperation.getStatus(), "success")) { String msg = MessageFormat.format("Activate status not equal success: {0}", topologyOperation.getStatus()); throw new Exception(msg); } }
From source file:com.sfs.whichdoctor.beans.BulkContactBean.java
/** * Gets the action url./*from www. j a v a 2s . c om*/ * * @param preferences the preferences * * @return the action url */ public final String getActionUrl(final PreferencesBean preferences) { String url = ""; if (StringUtils.equalsIgnoreCase(getType(), "export")) { url = preferences.buildUrl("save", getObjectType().toLowerCase() + "_export", "existing", getReferenceId(), "Type=" + getSecondaryType()); } if (StringUtils.equalsIgnoreCase(getType(), "search")) { url = preferences.buildUrl("read", getObjectType().toLowerCase() + "_search", "search"); } if (StringUtils.equalsIgnoreCase(getType(), "group")) { url = preferences.buildUrl("read", "groups", "guid", getReferenceId(), "StartDate=" + Formatter.conventionalDate(getStartDate()) + "&EndDate=" + Formatter.conventionalDate(getEndDate())); } if (StringUtils.equalsIgnoreCase(getType(), "ledger")) { url = preferences.buildUrl("read", "ledger", "search"); } if (StringUtils.equalsIgnoreCase(getType(), "ageddebtors")) { url = preferences.buildUrl("read", "ledger", "search"); } return url; }
From source file:au.edu.anu.portal.portlets.basiclti.BasicLTIPortlet.java
/** * Process any portlet actions.//w ww. j a v a 2 s. c o m */ public void processAction(ActionRequest request, ActionResponse response) { log.info("Basic LTI processAction()"); //check mode and delegate if (StringUtils.equalsIgnoreCase(request.getPortletMode().toString(), "CONFIG")) { processConfigAction(request, response); } else if (StringUtils.equalsIgnoreCase(request.getPortletMode().toString(), "EDIT")) { processEditAction(request, response); } else { log.error("No handler for PortletMode: " + request.getPortletMode().toString()); } }
From source file:ddf.catalog.source.solr.RemoteSolrCatalogProvider.java
/** * Updates the configuration of Solr if necessary * * @param urlValue - url to Solr/* w w w . j a v a 2s .co m*/ */ public void updateClient(String urlValue) { LOGGER.debug("New url {}", urlValue); if (urlValue != null) { if (!StringUtils.equalsIgnoreCase(urlValue.trim(), url) || getClient() == null) { url = urlValue.trim(); if (getClient() != null) { LOGGER.debug("Shutting down the connection manager to Solr and releasing allocated resources."); closeSolrClient(); LOGGER.debug("Shutdown complete."); } updateClient(); } } else { url = null; } }
From source file:com.alibaba.otter.manager.biz.common.DataSourceCreator.java
private DataSource createDataSource(String url, String userName, String password, String driverClassName, DataMediaType dataMediaType, String encoding) { BasicDataSource dbcpDs = new BasicDataSource(); dbcpDs.setInitialSize(initialSize);// ? dbcpDs.setMaxActive(maxActive);// ????? dbcpDs.setMaxIdle(maxIdle);// ?? dbcpDs.setMinIdle(minIdle);// ?0? dbcpDs.setMaxWait(maxWait);// ??-1? dbcpDs.setRemoveAbandoned(true);// ??removeAbandonedTimeout dbcpDs.setLogAbandoned(true);// ?? dbcpDs.setRemoveAbandonedTimeout(removeAbandonedTimeout); // ? dbcpDs.setNumTestsPerEvictionRun(numTestsPerEvictionRun);// ?? dbcpDs.setTestOnBorrow(false);// ?? dbcpDs.setTestOnReturn(false);// ?? dbcpDs.setTestWhileIdle(true);// ???? dbcpDs.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); // ???????? dbcpDs.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); // ??????? // ??//from www .jav a2 s . c om dbcpDs.setDriverClassName(driverClassName); dbcpDs.setUrl(url); dbcpDs.setUsername(userName); dbcpDs.setPassword(password); if (dataMediaType.isOracle()) { dbcpDs.addConnectionProperty("restrictGetTables", "true"); // dbcpDs.setValidationQuery("select 1 from dual"); } else if (dataMediaType.isMysql()) { // open the batch mode for mysql since 5.1.8 dbcpDs.addConnectionProperty("useServerPrepStmts", "false"); dbcpDs.addConnectionProperty("rewriteBatchedStatements", "true"); dbcpDs.addConnectionProperty("zeroDateTimeBehavior", "convertToNull");// 0000-00-00null dbcpDs.addConnectionProperty("yearIsDateType", "false");// ??year?date? dbcpDs.addConnectionProperty("noDatetimeStringSync", "true");// ,??? if (StringUtils.isNotEmpty(encoding)) { if (StringUtils.equalsIgnoreCase(encoding, "utf8mb4")) { dbcpDs.addConnectionProperty("characterEncoding", "utf8"); dbcpDs.setConnectionInitSqls(Arrays.asList("set names utf8mb4")); } else { dbcpDs.addConnectionProperty("characterEncoding", encoding); } } // dbcpDs.setValidationQuery("select 1"); } else { logger.error("ERROR ## Unknow database type"); } return dbcpDs; }
From source file:com.sammyun.service.impl.MemberServiceImpl.java
/** * ??/*from w w w . jav a 2s .co m*/ * * @param previousVipCodel * @param vipCode * @return */ @Override @Transactional(readOnly = true) public boolean vipCodeUnique(String previousVipCodel, String vipCode) { if (StringUtils.equalsIgnoreCase(previousVipCodel, vipCode)) { return true; } else { if (memberDao.vipCodeUnique(vipCode)) { return false; } else { return true; } } }
From source file:com.smartitengineering.cms.type.xml.XmlParser.java
public Collection<MutableContentType> parse() { ContentTypeId contentTypeId = null;/*from w ww . j av a2 s.c o m*/ Collection<FieldDef> fieldDefs = new ArrayList<FieldDef>(); Collection<MutableContentType> contentTypes = new ArrayList<MutableContentType>(); Collection<RepresentationDef> representationDefs = new ArrayList<RepresentationDef>(); Collection<ContentStatus> statuses = new ArrayList<ContentStatus>(); String displayName = null; try { Builder builder = new Builder(false); Document document = builder.build(this.source); Element rootElement = document.getRootElement(); Elements childRootElements = rootElement.getChildElements(); for (int j = 0; j < childRootElements.size(); j++) { final MutableContentType mutableContent = introspector.createMutableContentType(); final Element contentTypeElement = childRootElements.get(j); Elements childElements = contentTypeElement.getChildElements(); String name = parseMandatoryStringElement(contentTypeElement, NAME); //max=1,min=1 String namespace = parseAttribute(contentTypeElement, ATTR_NAMESPACE); if (logger.isDebugEnabled()) { logger.debug(new StringBuilder("Iterating over ").append(j).toString()); logger.debug(new StringBuilder("Namespace ").append(namespace).toString()); logger.debug(new StringBuilder("Name ").append(name).toString()); } contentTypeId = getContentTypeId(workspaceId, namespace, name); mutableContent.setContentTypeID(contentTypeId); displayName = parseOptionalStringElement(contentTypeElement, DISPLAY_NAME); //min=0,max=1 mutableContent .setParameterizedDisplayNames(parseParams(contentTypeElement, PARAMETERIZED_DISPLAY_NAMES)); for (int child = 0; child < childElements.size(); child++) {//fields min=1,max=unbounted if (StringUtils.equalsIgnoreCase(childElements.get(child).getLocalName(), FIELDS)) { fieldDefs.addAll(parseFieldDefs(childElements.get(child), null)); } } statuses = parseContentStatuses(contentTypeElement, STATUS); representationDefs = parseRepresentations(contentTypeElement, REPRESENTATIONS); Map<ContentType.ContentProcessingPhase, List<MutableContentCoProcessorDef>> ccpDefs = parseContentCoProcessorDefs( contentTypeElement, CONTENT_CO_PROCESSOR_DEFS); for (Entry<ContentProcessingPhase, List<MutableContentCoProcessorDef>> entry : ccpDefs.entrySet()) { for (MutableContentCoProcessorDef def : entry.getValue()) { def.setPhase(entry.getKey()); if (logger.isDebugEnabled()) { logger.debug("^^^^^^^^^^^^^^ Adding content co processor to " + contentTypeId); } mutableContent.addContentCoProcessorDef(def); } } contentTypeId = parseContentTypeId(contentTypeElement, PARENT, workspaceId); String primaryFieldName = parseOptionalStringElement(contentTypeElement, PRIMARY_FIELD); if (logger.isDebugEnabled()) { logger.debug("Primary field parsed: " + primaryFieldName); } if (StringUtils.isNotBlank(primaryFieldName)) { mutableContent.setPrimaryFieldName(primaryFieldName); } String defType = parseOptionalStringElement(contentTypeElement, DEF_TYPE); if (logger.isDebugEnabled()) { logger.debug("Def type parsed: " + defType); } if (StringUtils.isNotBlank(defType)) { mutableContent.setDefinitionType(ContentType.DefinitionType.valueOf(defType)); } mutableContent.setDisplayName(displayName); mutableContent.setParent(contentTypeId); mutableContent.getMutableFieldDefs().addAll(fieldDefs); if (representationDefs != null) { mutableContent.getMutableRepresentationDefs().addAll(representationDefs); } mutableContent.getMutableStatuses().addAll(statuses); contentTypes.add(mutableContent); introspector.processMutableContentType(mutableContent, contentTypeElement); fieldDefs.clear(); } } catch (Exception e) { logger.warn(e.getMessage(), e); } return contentTypes; }