List of usage examples for org.apache.commons.lang StringUtils stripAll
public static String[] stripAll(String[] strs)
Strips whitespace from the start and end of every String in an array.
From source file:ch.astina.hesperid.web.services.springsecurity.RequestInvocationDefinition.java
public RequestInvocationDefinition(String key, String roles) { this.requestKey = new RequestKey(key); String[] allAttrs = StringUtils.stripAll(StringUtils.splitPreserveAllTokens(roles, ',')); this.configAttributes = new ArrayList<ConfigAttribute>(); for (String attr : allAttrs) { this.configAttributes.add(new SecurityConfig(attr)); }/* ww w. j a v a 2s.co m*/ }
From source file:ch.ksfx.web.services.springsecurity.RequestInvocationDefinition.java
public RequestInvocationDefinition(String key, String roles) { this.requestKey = new RequestKey(key); String[] allAttrs = StringUtils.stripAll(StringUtils.splitPreserveAllTokens(roles, ',')); this.configAttributes = new ArrayList<ConfigAttribute>(); for (String attr : allAttrs) { this.configAttributes.add(new SecurityConfig(attr)); }// w w w .j av a 2 s . c o m }
From source file:it.openutils.mgnlaws.magnolia.init.ClasspathMgnlServletContextListener.java
private static String[] getNamesBetweenPlaceholders(String propertiesFilesString, String contextNamePlaceHolder) { final String[] names = StringUtils.substringsBetween(propertiesFilesString, PropertiesInitializer.PLACEHOLDER_PREFIX + contextNamePlaceHolder, PropertiesInitializer.PLACEHOLDER_SUFFIX); return StringUtils.stripAll(names); }
From source file:com.sun.socialsite.util.UtilitiesModel.java
public static String[] stripAll(String[] strs) { return StringUtils.stripAll(strs); }
From source file:de.softwareforge.pgpsigner.PGPSigner.java
private void run() throws Exception { Terminal.setupTerminal();/*from w w w .j a va2 s.c o m*/ Runtime.getRuntime().addShutdownHook(shutdownHook); List<Completor> completorList = new ArrayList<Completor>(); for (Command command : context.getCommands()) { if (command.hasCompletor()) { completorList.add(command.getCompletor()); } } Completor completor = new MultiCompletor(completorList.toArray(new Completor[completorList.size()])); ConsoleReader reader = new ConsoleReader(); reader.setHistory(new History()); reader.setUseHistory(true); reader.setBellEnabled(false); reader.setDefaultPrompt(PGPSigner.APPLICATION_NAME + "> "); reader.addCompletor(completor); System.out.println("\n\nWelcome to " + APPLICATION_VERSION); String line = null; commandLoop: while (!context.isShutdown() && (line = reader.readLine()) != null) { String[] cmd = StringUtils.stripAll(StringUtils.split(line)); if (cmd.length > 0) { for (Command command : context.getCommands()) { if (command.matchInteractiveCommand(cmd[0])) { if (command.prerequisiteInteractiveCommand(cmd)) { command.executeInteractiveCommand(cmd); } continue commandLoop; } } System.out.println("Unknown Command: " + cmd[0]); } } Runtime.getRuntime().removeShutdownHook(shutdownHook); System.out.println("Goodbye"); }
From source file:mitm.application.djigzo.james.matchers.SenderHeaderTrigger.java
@Override public Collection<MailAddress> matchMail(Mail mail) throws MessagingException { try {/* w ww . j a v a2 s . c o m*/ String trigger = getTrigger(mail); /* * Trigger must be a name value pair: * * Header : Reg. Epxr * * If there is only a header any value will be accepted */ if (StringUtils.isNotBlank(trigger)) { try { String[] pair = StringUtils.stripAll(StringUtils.split(trigger, ":", 2)); Pattern pattern = Pattern.compile(pair.length > 1 ? pair[1] : ".*"); Context context = new Context(pair[0], pattern); getActivationContext().set(ACTIVATION_CONTEXT_KEY, context); } catch (PatternSyntaxException e) { logger.warn("Invalid pattern. Trigger: " + trigger, e); } } return super.matchMail(mail); } catch (DatabaseException e) { throw new MessagingException("Error getting pattern", e); } }
From source file:io.apiman.plugins.cors_policy.CorsConnector.java
private String[] split(String input) { if (input == null) return null; return StringUtils.stripAll(input.split(",")); //$NON-NLS-1$ }
From source file:com.lmco.ddf.endpoints.OpenSearchEndpoint.java
/** * /* w ww .j ava2 s . c o m*/ * @param searchTerms * Space delimited list of search terms. * @param maxResults * Maximum # of results to return. If count is also specified, * the count value will take precedence over the maxResults value * @param sources * Comma delimited list of data sources to query (default: * default sources selected). * @param maxTimeout * Maximum timeout (msec) for query to respond (default: * mt=30000). * @param startIndex * Index of first result to return. Integer >= 0 (default: * start=1). * @param count * Number of results to retrieve per page (default: count=10). * @param geometry * WKT Geometries (Support POINT and POLYGON). * @param bbox * Comma delimited list of lat/lon (deg) bounding box coordinates * (geo format: geo:bbox ~ West,South,East,North). * @param polygon * Comma delimited list of lat/lon (deg) pairs, in clockwise * order around the polygon, with the last point being the same * as the first in order to close the polygon. * @param lat * Latitude in decimal degrees (typical GPS receiver WGS84 * coordinates). * @param lon * Longitude in decimal degrees (typical GPS receiver WGS84 * coordinates). * @param radius * The radius (m) parameter, used with the lat and lon * parameters, specifies the search distance from this point * (default: radius=5000). * @param dateStart * Specifies the beginning of the time slice of the search on the * modified time field (RFC-3339 - Date and Time format, i.e. * YYYY-MM-DDTHH:mm:ssZ). Default value of "1970-01-01T00:00:00Z" * is used when dtend is indicated but dtstart is not specified * @param dateEnd * Specifies the ending of the time slice of the search on the * modified time field (RFC-3339 - Date and Time format, i.e. * YYYY-MM-DDTHH:mm:ssZ). Current GMT date/time is used when * dtstart is specified but not dtend. * @param dateOffset * Specifies an offset, backwards from the current time, to * search on the modified time field for entries. Defined in * milliseconds. * @param sort * Specifies sort by field as sort=<sbfield>:<sborder>, where * <sbfield> may be 'date' or 'relevance' (default is * 'relevance'). The conditional param <sborder> is optional but * has a value of 'asc' or 'desc' (default is 'desc'). When * <sbfield> is 'relevance', <sborder> must be 'desc'. * @param format * Defines the format that the return type should be in. * (example:atom, html) * @param selector * Defines a comma delimited list of XPath selectors to narrow * the query. * @param type * Specifies the type of data to search for. (example: nitf) * @param versions * Specifies the versions in a comma delimited list. * @return */ @GET public Response processQuery(@QueryParam(PHRASE) String searchTerms, @QueryParam(MAX_RESULTS) String maxResults, @QueryParam(SOURCES) String sources, @QueryParam(MAX_TIMEOUT) String maxTimeout, @QueryParam(START_INDEX) String startIndex, @QueryParam(COUNT) String count, @QueryParam(GEOMETRY) String geometry, @QueryParam(BBOX) String bbox, @QueryParam(POLYGON) String polygon, @QueryParam(LAT) String lat, @QueryParam(LON) String lon, @QueryParam(RADIUS) String radius, @QueryParam(DATE_START) String dateStart, @QueryParam(DATE_END) String dateEnd, @QueryParam(DATE_OFFSET) String dateOffset, @QueryParam(SORT) String sort, @QueryParam(FORMAT) String format, @QueryParam(SELECTOR) String selector, @Context UriInfo ui, @QueryParam(TYPE) String type, @QueryParam(VERSION) String versions, @Context HttpServletRequest request) { final String methodName = "processQuery"; LOGGER.entry(methodName); Response response; String localCount = count; Subject subject; LOGGER.debug("request url: " + ui.getRequestUri()); subject = getSubject(request); if (subject == null) { LOGGER.info("Could not set security attributes for user, performing query with no permissions set."); } // DDF-1904: honor maxResults if count is not specified if ((StringUtils.isEmpty(localCount)) && (!(StringUtils.isEmpty(maxResults)))) { LOGGER.debug("setting count to: " + maxResults); localCount = maxResults; } try { String queryFormat = format; OpenSearchQuery query = createNewQuery(startIndex, localCount, sort, maxTimeout); if (!(StringUtils.isEmpty(sources))) { LOGGER.debug("Received site names from client."); Set<String> siteSet = new HashSet<String>(Arrays.asList(StringUtils.stripAll(sources.split(",")))); // This code block is for backward compatibility to support // src=local. // Since local is a magic work, not in any specification, we // need to // eventually remove support for it. if (siteSet.remove(LOCAL)) { LOGGER.debug("Found 'local' alias, replacing with " + localSiteName + "."); siteSet.add(localSiteName); } if (siteSet.contains(framework.getId()) && siteSet.size() == 1) { LOGGER.debug("Only local site specified, saving overhead and just performing a local query on " + framework.getId() + "."); } else { LOGGER.debug("Querying site set: " + siteSet); query.setSiteIds(siteSet); } query.setIsEnterprise(false); } else { LOGGER.debug("No sites found, defaulting to enterprise query."); query.setIsEnterprise(true); } // contextual if (searchTerms != null && !searchTerms.trim().isEmpty()) { try { query.addContextualFilter(searchTerms, selector); } catch (ParsingException e) { throw new IllegalArgumentException(e.getMessage()); } } // temporal // single temporal criterion per query if ((dateStart != null && !dateStart.trim().isEmpty()) || (dateEnd != null && !dateEnd.trim().isEmpty()) || (dateOffset != null && !dateOffset.trim().isEmpty())) { query.addTemporalFilter(dateStart, dateEnd, dateOffset); } // spatial // single spatial criterion per query addSpatialFilter(query, geometry, polygon, bbox, radius, lat, lon); if (type != null && !type.trim().isEmpty()) { query.addTypeFilter(type, versions); } response = executeQuery(queryFormat, query, ui, subject); } catch (IllegalArgumentException iae) { LOGGER.warn("Bad input found while executing a query", iae); response = Response.status(Response.Status.BAD_REQUEST) .entity(wrapStringInPreformattedTags(iae.getMessage())).build(); } catch (RuntimeException re) { LOGGER.warn("Exception while executing a query", re); response = Response.serverError().entity(wrapStringInPreformattedTags(re.getMessage())).build(); } LOGGER.exit(methodName); return response; }
From source file:com.bstek.dorado.core.pkgs.PackageManager.java
private static void doBuildPackageInfos() throws Exception { Map<String, PackageInfo> packageMap = new HashMap<String, PackageInfo>(); Enumeration<URL> defaultContextFileResources = org.springframework.util.ClassUtils.getDefaultClassLoader() .getResources(PACKAGE_PROPERTIES_LOCATION); while (defaultContextFileResources.hasMoreElements()) { URL url = defaultContextFileResources.nextElement(); InputStream in = null;//from w w w . ja va 2s .com try { URLConnection con = url.openConnection(); con.setUseCaches(false); in = con.getInputStream(); Properties properties = new Properties(); properties.load(in); String packageName = properties.getProperty("name"); if (StringUtils.isEmpty(packageName)) { throw new IllegalArgumentException("Package name undefined."); } PackageInfo packageInfo = new PackageInfo(packageName); packageInfo.setAddonVersion(properties.getProperty("addonVersion")); packageInfo.setVersion(properties.getProperty("version")); String dependsText = properties.getProperty("depends"); if (StringUtils.isNotBlank(dependsText)) { List<Dependence> dependences = new ArrayList<Dependence>(); for (String depends : StringUtils.split(dependsText, "; ")) { if (StringUtils.isNotEmpty(depends)) { Dependence dependence = parseDependence(depends); dependences.add(dependence); } } if (!dependences.isEmpty()) { packageInfo.setDepends(dependences.toArray(new Dependence[0])); } } String license = StringUtils.trim(properties.getProperty("license")); if (StringUtils.isNotEmpty(license)) { if (INHERITED.equals(license)) { packageInfo.setLicense(LICENSE_INHERITED); } else { String[] licenses = StringUtils.split(license); licenses = StringUtils.stripAll(licenses); packageInfo.setLicense(licenses); } } packageInfo.setLoadUnlicensed(BooleanUtils.toBoolean(properties.getProperty("loadUnlicensed"))); packageInfo.setClassifier(properties.getProperty("classifier")); packageInfo.setHomePage(properties.getProperty("homePage")); packageInfo.setDescription(properties.getProperty("description")); packageInfo.setPropertiesLocations(properties.getProperty("propertiesConfigLocations")); packageInfo.setContextLocations(properties.getProperty("contextConfigLocations")); packageInfo.setComponentLocations(properties.getProperty("componentConfigLocations")); packageInfo.setServletContextLocations(properties.getProperty("servletContextConfigLocations")); String configurerClass = properties.getProperty("configurer"); if (StringUtils.isNotBlank(configurerClass)) { Class<?> type = ClassUtils.forName(configurerClass); packageInfo.setConfigurer((PackageConfigurer) type.newInstance()); } String listenerClass = properties.getProperty("listener"); if (StringUtils.isNotBlank(listenerClass)) { Class<?> type = ClassUtils.forName(listenerClass); packageInfo.setListener((PackageListener) type.newInstance()); } String servletContextListenerClass = properties.getProperty("servletContextListener"); if (StringUtils.isNotBlank(servletContextListenerClass)) { Class<?> type = ClassUtils.forName(servletContextListenerClass); packageInfo.setServletContextListener((ServletContextListener) type.newInstance()); } if (packageMap.containsKey(packageName)) { PackageInfo conflictPackageInfo = packageMap.get(packageName); StringBuffer conflictInfo = new StringBuffer(20); conflictInfo.append('[').append(conflictPackageInfo.getName()).append(" - ") .append(conflictPackageInfo.getVersion()).append(']'); conflictInfo.append(" and "); conflictInfo.append('[').append(packageInfo.getName()).append(" - ") .append(packageInfo.getVersion()).append(']'); Exception e = new IllegalArgumentException("More than one package \"" + packageName + "\" found. They are " + conflictInfo.toString()); logger.warn(e, e); } packageMap.put(packageName, packageInfo); } catch (Exception e) { throw new IllegalArgumentException("Error occured during parsing \"" + url.getPath() + "\".", e); } finally { if (in != null) { in.close(); } } } List<PackageInfo> calculatedPackages = new ArrayList<PackageInfo>(); for (PackageInfo packageInfo : packageMap.values()) { calculateDepends(packageInfo, calculatedPackages, packageMap); } packageInfosMap.clear(); for (PackageInfo packageInfo : calculatedPackages) { packageInfosMap.put(packageInfo.getName(), packageInfo); } }
From source file:info.magnolia.cms.beans.config.PropertiesInitializer.java
private static String[] getNamesBetweenPlaceholders(String propertiesFilesString, String contextNamePlaceHolder) { final String[] names = StringUtils.substringsBetween(propertiesFilesString, PLACEHOLDER_PREFIX + contextNamePlaceHolder, PLACEHOLDER_SUFFIX); return StringUtils.stripAll(names); }