List of usage examples for org.apache.commons.lang StringUtils contains
public static boolean contains(String str, String searchStr)
Checks if String contains a search String, handling null
.
From source file:edu.ku.brc.specify.ui.db.AskForNumbersDlg.java
/** * @return// w w w .ja v a 2 s . c o m */ protected boolean processNumbers() { dataObjsIds.clear(); numbersList.clear(); numErrorList.clear(); numMissingList.clear(); errorPanel.setNumbers(null); missingPanel.setNumbers(null); DBTableInfo ti = DBTableIdMgr.getInstance().getByClassName(dataClass.getName()); DBFieldInfo fi = ti.getFieldByName(fieldName); boolean hasColMemID = ti.getFieldByColumnName("CollectionMemberID", true) != null; UIFieldFormatterIFace formatter = fi.getFormatter(); // Check for a dash in the format char rangeSeparator = formatter != null ? formatter.hasDash() ? '/' : '-' : ' '; boolean isOK = true; String fieldStr = textArea.getText().trim(); if (formatter != null && formatter.isNumeric() && ti.getTableId() == 1 && fieldName.equals("catalogNumber")) { fieldStr = CatalogNumberFormatter.preParseNumericCatalogNumbers(fieldStr, formatter); } if (StringUtils.isNotEmpty(fieldStr)) { DataProviderSessionIFace session = null; try { session = DataProviderFactory.getInstance().createSession(); String[] toks = StringUtils.split(fieldStr, ','); for (String fldStr : toks) { String numToken = fldStr.trim(); if (formatter != null && formatter.isNumeric() && StringUtils.contains(numToken, rangeSeparator)) { String fldNum = null; String endFldNum = null; String[] tokens = StringUtils.split(numToken, rangeSeparator); if (tokens.length == 2) { try { if (formatter.isNumeric()) { if (!StringUtils.isNumeric(fldNum) || !StringUtils.isNumeric(endFldNum)) { numErrorList.add(fldStr.trim()); isOK = false; continue; } } fldNum = (String) formatter.formatFromUI(tokens[0].trim()); endFldNum = (String) formatter.formatFromUI(tokens[1].trim()); } catch (java.lang.NumberFormatException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(AskForNumbersDlg.class, ex); numErrorList.add(numToken); isOK = false; } String sql = String.format("SELECT id FROM %s WHERE %s >= '%s' AND %s <= '%s' %s", ti.getClassName(), fieldName, fldNum, fieldName, endFldNum, (hasColMemID ? AND_COLLID : "")); sql = QueryAdjusterForDomain.getInstance().adjustSQL(sql); List<?> list = session.getDataList(sql); for (Object obj : list) { dataObjsIds.add((Integer) obj); } numbersList.add(numToken); } else { numErrorList.add(numToken); isOK = false; } continue; } String fldValForDB = numToken; try { if (formatter != null) { if (formatter.isNumeric()) { if (!StringUtils.isNumeric(numToken)) { numErrorList.add(numToken); isOK = false; continue; } } fldValForDB = (String) formatter.formatFromUI(numToken); } else { fldValForDB = numToken; } } catch (java.lang.NumberFormatException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(AskForNumbersDlg.class, ex); numErrorList.add(numToken); isOK = false; } if (StringUtils.isNotEmpty(fldValForDB)) { String sql = String.format("SELECT id FROM %s WHERE %s = '%s' %s", ti.getClassName(), fieldName, fldValForDB, (hasColMemID ? AND_COLLID : "")); sql = QueryAdjusterForDomain.getInstance().adjustSQL(sql); //log.debug(sql); Integer recordId = (Integer) session.getData(sql); if (recordId != null) { dataObjsIds.add(recordId); numbersList.add(numToken); } else { numMissingList.add(numToken); isOK = false; } } } } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(AskForNumbersDlg.class, ex); log.error(ex); ex.printStackTrace(); } finally { if (session != null) { session.close(); } } } buildNumberList(numbersList, textArea); pb.getPanel().removeAll(); CellConstraints cc = new CellConstraints(); pb.addSeparator(UIRegistry.getResourceString(labelKey), cc.xy(1, 1)); pb.add(UIHelper.createScrollPane(textArea), cc.xy(1, 3)); int y = 5; if (numErrorList.size() > 0) { errorPanel.setNumbers(numErrorList); pb.add(UIHelper.createScrollPane(errorPanel), cc.xy(1, y)); y += 2; } if (numMissingList.size() > 0) { missingPanel.setNumbers(numMissingList); pb.add(UIHelper.createScrollPane(missingPanel), cc.xy(1, y)); y += 2; } if (numErrorList.isEmpty() && numMissingList.isEmpty() && dataObjsIds.isEmpty()) { UIRegistry.showLocalizedError("BT_NO_NUMS_ERROR"); return false; } if (!isOK) { pack(); } return isOK; }
From source file:ddf.catalog.source.solr.SolrFilterDelegate.java
private void combineXpathFilterQueries(SolrQuery query, List<SolrQuery> subQueries, String operator) { List<String> queryParams = new ArrayList<>(); // Use Set to remove duplicates now that the namespaces have been stripped out Set<String> xpathFilters = new TreeSet<>(); Set<String> xpathIndexes = new TreeSet<>(); for (SolrQuery subQuery : subQueries) { String[] params = subQuery.getParams(FILTER_QUERY_PARAM_NAME); if (params != null) { for (String param : params) { if (StringUtils.startsWith(param, XPATH_QUERY_PARSER_PREFIX)) { if (StringUtils.contains(param, XPATH_FILTER_QUERY_INDEX)) { xpathIndexes//from ww w .ja va 2s . co m .add(StringUtils.substringAfter(StringUtils.substringBeforeLast(param, "\""), XPATH_FILTER_QUERY_INDEX + ":\"")); } else if (StringUtils.startsWith(param, XPATH_QUERY_PARSER_PREFIX + XPATH_FILTER_QUERY)) { xpathFilters.add(StringUtils.substringAfter( StringUtils.substringBeforeLast(param, "\""), XPATH_FILTER_QUERY + ":\"")); } } Collections.addAll(queryParams, param); } } } if (xpathFilters.size() > 1) { // More than one XPath found, need to combine String filter = XPATH_QUERY_PARSER_PREFIX + XPATH_FILTER_QUERY + ":\"(" + StringUtils.join(xpathFilters, operator.toLowerCase()) + ")\""; List<String> indexes = new ArrayList<>(); for (String xpath : xpathIndexes) { indexes.add("(" + XPATH_FILTER_QUERY_INDEX + ":\"" + xpath + "\")"); } // TODO DDF-1882 add pre-filter xpath index //String index = XPATH_QUERY_PARSER_PREFIX + StringUtils.join(indexes, operator); //query.setParam(FILTER_QUERY_PARAM_NAME, filter, index); query.setParam(FILTER_QUERY_PARAM_NAME, filter); } else if (queryParams.size() > 0) { // Pass through original filter queries if only a single XPath is present query.setParam(FILTER_QUERY_PARAM_NAME, queryParams.toArray(new String[queryParams.size()])); } }
From source file:com.pedra.storefront.filters.cms.CMSSiteFilter.java
/** * Processing normal request (i.e. when user goes directly to that application - not from cmscockpit) * <p/>//from w w w . j a va 2s.com * <b>Note:</b> <br/> * We preparing application by setting correct: * <ul> * <li>Current Site</li> * <li>Current Catalog Versions</li> * <li>Enabled language fallback</li> * </ul> * * @see ContextInformationLoader#initializeSiteFromRequest(String) * @see ContextInformationLoader#setCatalogVersions() * @param httpRequest * current request * @param httpResponse * the http response * @throws java.io.IOException */ protected boolean processNormalRequest(final HttpServletRequest httpRequest, final HttpServletResponse httpResponse) throws IOException { final String queryString = httpRequest.getQueryString(); final String currentRequestURL = httpRequest.getRequestURL().toString(); //set current site CMSSiteModel cmsSiteModel = getCurrentCmsSite(); if (cmsSiteModel == null || StringUtils.contains(queryString, CLEAR_CMSSITE_PARAM)) { final String absoluteURL = StringUtils.removeEnd(currentRequestURL, "/") + (StringUtils.isBlank(queryString) ? "" : "?" + queryString); cmsSiteModel = getContextInformationLoader().initializeSiteFromRequest(absoluteURL); } if (cmsSiteModel == null) { // Failed to lookup CMS site httpResponse.sendError(MISSING_CMS_SITE_ERROR_STATUS, MISSING_CMS_SITE_ERROR_MESSAGE); return false; } else if (!SiteChannel.B2C.equals(cmsSiteModel.getChannel())) // Restrict to B2C channel { // CMS site that we looked up was for an unsupported channel httpResponse.sendError(MISSING_CMS_SITE_ERROR_STATUS, INCORRECT_CMS_SITE_CHANNEL_ERROR_MESSAGE); return false; } if (isNotActiveSite(cmsSiteModel)) { throw new IllegalStateException( "Site is not active. Active flag behaviour must be implement for this project."); } getContextInformationLoader().setCatalogVersions(); //set fall back language enabled setFallbackLanguage(httpRequest, Boolean.TRUE); return true; }
From source file:com.greenline.guahao.web.module.home.controllers.json.area.JsonAreaController.java
private Map<String, String> areaPosition(String position) { Map<String, String> dataMap = new HashMap<String, String>(); String provinceName = StringUtils.EMPTY; String cityName = StringUtils.EMPTY; if (StringUtils.isNotBlank(position)) { if (StringUtils.contains(position, LOCATION_PROVINCE_SUFFIX)) { String[] positionArr = StringUtils.split(position, LOCATION_PROVINCE_SUFFIX); provinceName = positionArr[0]; if (positionArr.length > 1) { cityName = positionArr[1]; if (StringUtils.contains(cityName, LOCATION_CITY_SUFFIX)) { cityName = StringUtils.substring(cityName, 0, cityName.length() - 1); }/*from ww w. j a v a 2s . co m*/ } } else { if (StringUtils.contains(position, LOCATION_CITY_SUFFIX)) { String[] positionArr = StringUtils.split(position, LOCATION_CITY_SUFFIX); provinceName = positionArr[0]; if (positionArr.length > 1) { cityName = positionArr[1]; } } } } if (StringUtils.isNotBlank(provinceName)) { dataMap.put("provice", provinceName); } if (StringUtils.isNotBlank(cityName)) { dataMap.put("city", cityName); } return dataMap; }
From source file:com.epam.cme.storefront.filters.cms.CMSSiteFilter.java
/** * Processing normal request (i.e. when user goes directly to that application - not from * cmscockpit)//from w ww. j a v a 2 s. c o m * <p/> * <b>Note:</b> <br/> * We preparing application by setting correct: * <ul> * <li>Current Site</li> * <li>Current Catalog Versions</li> * <li>Enabled language fallback</li> * </ul> * * @see ContextInformationLoader#initializeSiteFromRequest(String) * @see ContextInformationLoader#setCatalogVersions() * @param httpRequest * current request * @param httpResponse * the http response * @throws java.io.IOException */ protected boolean processNormalRequest(final HttpServletRequest httpRequest, final HttpServletResponse httpResponse) throws IOException { final String queryString = httpRequest.getQueryString(); final String currentRequestURL = httpRequest.getRequestURL().toString(); // set current site CMSSiteModel cmsSiteModel = getCurrentCmsSite(); if (cmsSiteModel == null || StringUtils.contains(queryString, CLEAR_CMSSITE_PARAM)) { final String absoluteURL = StringUtils.removeEnd(currentRequestURL, "/") + (StringUtils.isBlank(queryString) ? "" : "?" + queryString); cmsSiteModel = getContextInformationLoader().initializeSiteFromRequest(absoluteURL); } if (cmsSiteModel == null) { // Failed to lookup CMS site httpResponse.sendError(MISSING_CMS_SITE_ERROR_STATUS, MISSING_CMS_SITE_ERROR_MESSAGE); return false; } else if (!SiteChannel.B2C.equals(cmsSiteModel.getChannel()) && !SiteChannel.TELCO.equals(cmsSiteModel.getChannel())) // Restrict to B2C and // Telco channel { // CMS site that we looked up was for an unsupported channel httpResponse.sendError(MISSING_CMS_SITE_ERROR_STATUS, INCORRECT_CMS_SITE_CHANNEL_ERROR_MESSAGE); return false; } if (!isActiveSite(cmsSiteModel)) { throw new IllegalStateException( "Site is not active. Active flag behaviour must be implement for this project."); } getContextInformationLoader().setCatalogVersions(); // set fall back language enabled setFallbackLanguage(httpRequest, Boolean.TRUE); return true; }
From source file:de.hybris.platform.ytelcoacceleratorstorefront.filters.cms.CMSSiteFilter.java
/** * Processing normal request (i.e. when user goes directly to that application - not from cmscockpit) * <p/>//from www. j a v a 2 s.c o m * <b>Note:</b> <br/> * We preparing application by setting correct: * <ul> * <li>Current Site</li> * <li>Current Catalog Versions</li> * <li>Enabled language fallback</li> * </ul> * * @see ContextInformationLoader#initializeSiteFromRequest(String) * @see ContextInformationLoader#setCatalogVersions() * @param httpRequest * current request * @param httpResponse * the http response * @throws java.io.IOException */ protected boolean processNormalRequest(final HttpServletRequest httpRequest, final HttpServletResponse httpResponse) throws IOException { final String queryString = httpRequest.getQueryString(); final String currentRequestURL = httpRequest.getRequestURL().toString(); //set current site CMSSiteModel cmsSiteModel = getCurrentCmsSite(); if (cmsSiteModel == null || StringUtils.contains(queryString, CLEAR_CMSSITE_PARAM)) { final String absoluteURL = StringUtils.removeEnd(currentRequestURL, "/") + (StringUtils.isBlank(queryString) ? "" : "?" + queryString); cmsSiteModel = getContextInformationLoader().initializeSiteFromRequest(absoluteURL); } if (cmsSiteModel == null) { // Failed to lookup CMS site httpResponse.sendError(MISSING_CMS_SITE_ERROR_STATUS, MISSING_CMS_SITE_ERROR_MESSAGE); return false; } else if (!SiteChannel.B2C.equals(cmsSiteModel.getChannel()) && !SiteChannel.TELCO.equals(cmsSiteModel.getChannel())) // Restrict to B2C and Telco channel { // CMS site that we looked up was for an unsupported channel httpResponse.sendError(MISSING_CMS_SITE_ERROR_STATUS, INCORRECT_CMS_SITE_CHANNEL_ERROR_MESSAGE); return false; } if (!isActiveSite(cmsSiteModel)) { throw new IllegalStateException( "Site is not active. Active flag behaviour must be implement for this project."); } getContextInformationLoader().setCatalogVersions(); //set fall back language enabled setFallbackLanguage(httpRequest, Boolean.TRUE); return true; }
From source file:cec.easyshop.storefront.filters.cms.CMSSiteFilter.java
/** * Processing normal request (i.e. when user goes directly to that application - not from cmscockpit) * <p/>//w w w .j a v a2s. c om * <b>Note:</b> <br/> * We preparing application by setting correct: * <ul> * <li>Current Site</li> * <li>Current Catalog Versions</li> * <li>Enabled language fallback</li> * </ul> * * @see ContextInformationLoader#initializeSiteFromRequest(String) * @see ContextInformationLoader#setCatalogVersions() * @param httpRequest * current request * @param httpResponse * the http response * @throws java.io.IOException */ protected boolean processNormalRequest(final HttpServletRequest httpRequest, final HttpServletResponse httpResponse) throws IOException { final String queryString = httpRequest.getQueryString(); final String currentRequestURL = httpRequest.getRequestURL().toString(); //set current site CMSSiteModel cmsSiteModel = getCurrentCmsSite(); if (cmsSiteModel == null || StringUtils.contains(queryString, CLEAR_CMSSITE_PARAM)) { final String absoluteURL = StringUtils.removeEnd(currentRequestURL, "/") + (StringUtils.isBlank(queryString) ? "" : "?" + queryString); cmsSiteModel = getContextInformationLoader().initializeSiteFromRequest(absoluteURL); } if (cmsSiteModel == null) { // Failed to lookup CMS site httpResponse.sendError(MISSING_CMS_SITE_ERROR_STATUS, MISSING_CMS_SITE_ERROR_MESSAGE); return false; } else if (!SiteChannel.B2C.equals(cmsSiteModel.getChannel())) // Restrict to B2C channel { // CMS site that we looked up was for an unsupported channel httpResponse.sendError(MISSING_CMS_SITE_ERROR_STATUS, INCORRECT_CMS_SITE_CHANNEL_ERROR_MESSAGE); return false; } if (!isActiveSite(cmsSiteModel)) { throw new IllegalStateException( "Site is not active. Active flag behaviour must be implement for this project."); } getContextInformationLoader().setCatalogVersions(); //set fall back language enabled setFallbackLanguage(httpRequest, Boolean.TRUE); return true; }
From source file:com.exxonmobile.ace.hybris.storefront.filters.cms.CMSSiteFilter.java
/** * Processing normal request (i.e. when user goes directly to that application - not from cmscockpit) * <p/>/*from w w w. j ava 2s. c o m*/ * <b>Note:</b> <br/> * We preparing application by setting correct: * <ul> * <li>Current Site</li> * <li>Current Catalog Versions</li> * <li>Enabled language fallback</li> * </ul> * * @see ContextInformationLoader#initializeSiteFromRequest(String) * @see ContextInformationLoader#setCatalogVersions() * @param httpRequest * current request * @param httpResponse * the http response * @throws java.io.IOException */ protected boolean processNormalRequest(final HttpServletRequest httpRequest, final HttpServletResponse httpResponse) throws IOException { final String queryString = httpRequest.getQueryString(); final String currentRequestURL = httpRequest.getRequestURL().toString(); // set current site CMSSiteModel cmsSiteModel = getCurrentCmsSite(); if (cmsSiteModel == null || StringUtils.contains(queryString, CLEAR_CMSSITE_PARAM)) { final String absoluteURL = StringUtils.removeEnd(currentRequestURL, "/") + (StringUtils.isBlank(queryString) ? "" : "?" + queryString); cmsSiteModel = getContextInformationLoader().initializeSiteFromRequest(absoluteURL); } if (cmsSiteModel == null) { // Failed to lookup CMS site httpResponse.sendError(MISSING_CMS_SITE_ERROR_STATUS, MISSING_CMS_SITE_ERROR_MESSAGE); return false; } else if (!SiteChannel.B2B.equals(cmsSiteModel.getChannel())) // Restrict to B2B channel { // CMS site that we looked up was for an unsupported channel httpResponse.sendError(MISSING_CMS_SITE_ERROR_STATUS, INCORRECT_CMS_SITE_CHANNEL_ERROR_MESSAGE); return false; } if (!isActiveSite(cmsSiteModel)) { throw new IllegalStateException( "Site is not active. Active flag behaviour must be implement for this project."); } getContextInformationLoader().setCatalogVersions(); // set fall back language enabled setFallbackLanguage(httpRequest, Boolean.TRUE); return true; }
From source file:co.marcin.novaguilds.impl.util.guiinventory.guild.rank.GUIInventoryGuildRankSettings.java
/** * Clones a rank//from w w w . ja v a2 s. c o m * * @return the rank */ private NovaRank cloneRank() { String clonePrefix = Message.INVENTORY_GUI_RANK_SETTINGS_CLONEPREFIX.get(); String cloneName = rank.getName().startsWith(clonePrefix) || rank.isGeneric() ? rank.getName() : clonePrefix + rank.getName(); if (StringUtils.contains(cloneName, ' ')) { String[] split = StringUtils.split(cloneName, ' '); if (NumberUtils.isNumeric(split[split.length - 1])) { cloneName = cloneName.substring(0, cloneName.length() - split[split.length - 1].length() - 1); } } NovaRank clone = new NovaRankImpl(rank); NovaGuild guild = getGuild(); boolean doubleName; int i = 1; do { if (i > 999) { break; } doubleName = false; for (NovaRank loopRank : guild.getRanks()) { if (!loopRank.isGeneric() && loopRank.getName().equalsIgnoreCase(clone.getName())) { doubleName = true; } } if (doubleName) { clone.setName(cloneName + " " + i); } i++; } while (doubleName); guild.addRank(clone); //Move players for (NovaPlayer nPlayer : rank.getMembers()) { rank.removeMember(nPlayer); clone.addMember(nPlayer); } return clone; }
From source file:hudson.plugins.trackplus.Updater.java
private static List<String> getScmComments(AbstractBuild<?, ?> build, TrackplusIssue trackplusIssue) { RepositoryBrowser repoBrowser = null; if (build.getProject().getScm() != null) { repoBrowser = build.getProject().getScm().getEffectiveBrowser(); }//from w ww . j a v a 2s .c o m List<String> scmChanges = new ArrayList<String>(); for (Entry change : build.getChangeSet()) { if (trackplusIssue != null && !StringUtils.contains(change.getMsg(), Integer.toString(trackplusIssue.getId()))) { continue; } try { String uid = change.getAuthor().getId(); URL url = repoBrowser == null ? null : repoBrowser.getChangeSetLink(change); StringBuilder scmChange = new StringBuilder(); if (StringUtils.isNotBlank(uid)) { scmChange.append("<br><b>").append(Messages.Updater_CommittedBy()).append("</b>:<br>") .append(uid).append(" <br> "); } if (url != null && StringUtils.isNotBlank(url.toExternalForm())) { scmChange.append("<a target='vc' href='" + url.toExternalForm() + "'>" + url.toExternalForm() + "</a><br>"); } scmChange.append("<b>").append(Messages.Updater_AffectedFiles()).append("</b>: ").append("<br>"); for (AffectedFile affectedFile : change.getAffectedFiles()) { scmChange.append("* ").append(affectedFile.getPath()).append("<br>"); } if (scmChange.length() > 0) { scmChanges.add(scmChange.toString()); } } catch (IOException e) { LOGGER.warning("skip failed to calculate scm repo browser link " + e.getMessage()); } } return scmChanges; }