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:co.marcin.novaguilds.command.admin.config.CommandAdminConfigGet.java
@Override public void execute(CommandSender sender, String[] args) throws Exception { if (args.length == 0) { command.getUsageMessage().send(sender); return;//from w ww . ja v a 2 s . com } String path = args[0]; String value = ""; Map<VarKey, String> vars = new HashMap<>(); FileConfiguration config = plugin.getConfigManager().getConfig(); if (!config.contains(path)) { Message.CHAT_INVALIDPARAM.send(sender); return; } if (config.isConfigurationSection(path)) { int depth = 1; String lastSection = null; vars.put(VarKey.DEPTH, ""); vars.put(VarKey.KEY, path); Message.CHAT_ADMIN_CONFIG_GET_LIST_SECTION.vars(vars).send(sender); for (String string : config.getConfigurationSection(path).getKeys(true)) { String[] prefixSplit = StringUtils.split(string, "."); String prefix = StringUtils.contains(string, ".") ? StringUtils.removeEnd(string, "." + prefixSplit[prefixSplit.length - 1]) : string; if (lastSection != null && !prefix.startsWith(lastSection)) { depth--; lastSection = null; } String space = ""; for (int i = 0; i < depth; i++) { space += " "; } vars.put(VarKey.DEPTH, space); if (config.isConfigurationSection(path + "." + string)) { depth++; lastSection = string; vars.put(VarKey.KEY, prefixSplit[prefixSplit.length - 1]); Message.CHAT_ADMIN_CONFIG_GET_LIST_SECTION.vars(vars).send(sender); } else { //key vars.put(VarKey.KEY, StringUtils.removeStart(string, prefix + ".")); Message.CHAT_ADMIN_CONFIG_GET_LIST_KEY.vars(vars).send(sender); } } } else { if (config.isList(path)) { value = StringUtils.join(config.getStringList(path), " "); } else { value = config.getString(path); } } vars.put(VarKey.KEY, path); vars.put(VarKey.VALUE, value); if (!value.isEmpty()) { Message.CHAT_ADMIN_CONFIG_GET_SINGLE.vars(vars).send(sender); } }
From source file:gov.nih.nci.cacisweb.action.SecureFTPAddAction.java
@Override public String execute() throws Exception { log.debug("execute() - START"); String secureFTPPropertyFileLocation = CaCISUtil .getProperty(CaCISWebConstants.COM_PROPERTY_NAME_SECFTP_PROPERTIES_FILE_LOCATION); String secureFTPKeystoreLocation = CaCISUtil.getPropertyFromPropertiesFile(secureFTPPropertyFileLocation, CaCISUtil.getProperty(CaCISWebConstants.COM_PROPERTY_NAME_SECFTP_TRUSTSTORE_LOCATION_PROP_NAME)); String secureFTPKeystorePassword = CaCISUtil.getPropertyFromPropertiesFile(secureFTPPropertyFileLocation, CaCISUtil.getProperty(CaCISWebConstants.COM_PROPERTY_NAME_SECFTP_TRUSTSTORE_PASSWORD_PROP_NAME)); try {//from ww w . java2 s . c o m CaCISUtil caCISUtil = new CaCISUtil(); KeyStore keystore = caCISUtil.getKeystore(secureFTPKeystoreLocation, CaCISWebConstants.COM_KEYSTORE_TYPE_JKS, secureFTPKeystorePassword); if (keystore.containsAlias(secureFTPBean.getCertificateAlias())) { log.error(getText("secureFTPBean.duplicateKey")); addFieldError("secureFTPBean.certificateAlias", getText("secureFTPBean.duplicateKey")); } if (StringUtils.contains(secureFTPBean.getCertificateAlias(), "ftps")) { if (StringUtils.isBlank(secureFTPBean.getCertificateFileName())) { log.error(getText("secureFTPBean.certificateRequired")); addFieldError("secureFTPBean.certificateFileName", getText("secureFTPBean.certificateRequired")); caCISUtil.releaseKeystore(); return INPUT; } else { caCISUtil.releaseKeystore(); FileInputStream certificateStream = new FileInputStream(secureFTPBean.getCertificate()); CertificateFactory cf = CertificateFactory.getInstance("X.509"); java.security.cert.Certificate cert = cf.generateCertificate(certificateStream); // Add the certificate keystore.setCertificateEntry(secureFTPBean.getCertificateAlias(), cert); // Save the new keystore contents FileOutputStream out = new FileOutputStream(new File(secureFTPKeystoreLocation)); keystore.store(out, secureFTPKeystorePassword.toCharArray()); out.close(); } } // add the new entry to FTP configuration properties file PropertiesConfiguration config = new PropertiesConfiguration( CaCISUtil.getProperty(CaCISWebConstants.COM_PROPERTY_NAME_SECFTP_CONFIG_FILE_LOCATION)); config.setProperty(secureFTPBean.getCertificateAlias(), ""); config.save(); } catch (KeystoreInstantiationException kie) { log.error(kie.getMessage()); addActionError(getText("exception.keystoreInstantiation")); return ERROR; } catch (CertificateException ce) { log.error(CaCISUtil.getStackTrace(ce)); addActionError(getText("exception.certification")); return INPUT; } addActionMessage(getText("secureFTPBean.addCertificateSuccessful")); log.debug("execute() - END"); return SUCCESS; }
From source file:com.mewmew.fairy.v1.book.Xargs.java
@Override public void each(String input, Output<String> output) throws IOException { String c[] = new String[cmd.length]; for (int i = 0; i < cmd.length; i++) { if (StringUtils.contains(cmd[i], token) || StringUtils.contains(cmd[i], "{}")) { c[i] = cmd[i].replaceAll(token, input); } else {/*from w ww. jav a 2 s .c om*/ c[i] = cmd[i]; } } if (c.length > 0) { try { exec(null, c, true, output); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }
From source file:gemlite.shell.converters.RegionConverter.java
public boolean getAllPossibleValues(List<Completion> completions, Class<?> targetType, String existingData, String optionContext, MethodTarget target) { if ((String.class.equals(targetType)) && (StringUtils.contains(optionContext, "param.context.region"))) { Set<String> regionPathSet = getAllRegionPaths(); for (String regionPath : regionPathSet) { if (existingData != null) { if (regionPath.startsWith(existingData)) { completions.add(new Completion(regionPath)); }/*from ww w .ja v a 2 s. c o m*/ } else { completions.add(new Completion(regionPath)); } } } return !completions.isEmpty(); }
From source file:com.safetys.framework.jmesa.core.filter.DateFilterMatcher.java
public boolean evaluate(Object itemValue, String filterValue) { if (itemValue == null) { return false; }//from ww w. ja v a 2s. c o m String pattern = getPattern(); if (pattern == null) { logger.debug("The filter (value " + filterValue + ") is trying to match against a date column using " + "the DateFilterMatcher, but there is no pattern defined. You need to register a DateFilterMatcher " + "to be able to filter against this column."); return false; } Locale locale = null; WebContext webContext = getWebContext(); if (webContext != null) { locale = webContext.getLocale(); } if (locale != null) { itemValue = DateFormatUtils.format((Date) itemValue, pattern, locale); } else { itemValue = DateFormatUtils.format((Date) itemValue, pattern); } String item = String.valueOf(itemValue); String filter = String.valueOf(filterValue); if (StringUtils.contains(item, filter)) { return true; } return false; }
From source file:com.thoughtworks.go.server.web.IgnoreResolver.java
private boolean isGoingToLogin(HttpServletRequest request) { return StringUtils.contains(request.getRequestURI(), request.getContextPath() + "/auth/"); }
From source file:com.microsoft.alm.common.utils.UrlHelper.java
public static boolean isGitRemoteUrl(final String gitRemoteUrl) { return StringUtils.contains(gitRemoteUrl, "/_git/"); }
From source file:cec.easyshop.storefront.web.wrappers.UrlEncodeHttpRequestWrapper.java
protected boolean urlPatternChecker(final String urlToBeChecked, final String pattern) { boolean containsPattern = StringUtils.contains(urlToBeChecked, "/" + pattern + "/"); if (!containsPattern) { final String[] splitUrl = urlToBeChecked.split("/"); final String last = splitUrl[splitUrl.length - 1]; if (last.equalsIgnoreCase(pattern)) { containsPattern = true;/* w w w . j a v a 2 s. c om*/ } } return containsPattern; }
From source file:info.magnolia.cms.gui.inline.BarNew.java
/** * Sets the default edit button./*from w w w .j av a 2 s .c o m*/ * @param path , path of the current page * @param nodeCollectionName , i.e. 'MainParagarphs' * @param nodeName , i.e. '01' * @param paragraph , paragraph type */ public void setButtonNew(String path, String nodeCollectionName, String nodeName, String paragraph) { Button b = new Button(); b.setLabel(MessagesManager.getMessages().get("buttons.new")); //$NON-NLS-1$ // todo: dynamic repository String repository = ContentRepository.WEBSITE; // if there are multiple paragraphs show the selectParagraph dialog if (StringUtils.contains(paragraph, ',')) { b.setOnclick("mgnlOpenDialog('" // //$NON-NLS-1$ + path + "','" //$NON-NLS-1$ + nodeCollectionName + "','" // //$NON-NLS-1$ + nodeName + "','" // //$NON-NLS-1$ + paragraph // this is a list + "','" // //$NON-NLS-1$ + repository + "','.magnolia/dialogs/selectParagraph.html');"); //$NON-NLS-1$ } // there is only one paragraph else { b.setOnclick("mgnlOpenDialog('" //$NON-NLS-1$ + path + "','" //$NON-NLS-1$ + nodeCollectionName + "','" //$NON-NLS-1$ + nodeName + "','" //$NON-NLS-1$ + paragraph + "','" //$NON-NLS-1$ + repository + "');"); //$NON-NLS-1$ } this.setButtonNew(b); }
From source file:com.iggroup.oss.restdoclet.doclet.util.DocTypeUtils.java
/** * Generates a comment string from the given method, consisting of the * method return comment and if the return type is an iggroup type, a list * of attributes (separated by <br> * )/*www. j av a 2 s . co m*/ * * @param element method doc * @return documentation string for the method */ public static String getReturnDoc(final MethodDoc element) { LOG.info("Get return type documentation for method: " + element.toString()); String doc = ""; Tag[] tags = element.tags(); String typeDoc = getTypeDoc(element.returnType()); //if (typeComment.isEmpty()) { // no class doc found, revert to @return comment for (final Tag tag : tags) { final String name = tag.name(); if (StringUtils.contains(name, RETURN_TAG)) { doc = tag.text(); if (!typeDoc.isEmpty()) { doc += "<table><tr><td>" + typeDoc + "</td></tr></table>"; } break; } } //} return doc; }