List of usage examples for org.apache.commons.lang StringUtils startsWith
public static boolean startsWith(String str, String prefix)
Check if a String starts with a specified prefix.
From source file:com.glaf.core.web.resource.WebResource.java
protected static void remove(String path) { Iterator<String> iterator = concurrentMap.keySet().iterator(); while (iterator.hasNext()) { String key = iterator.next(); if (StringUtils.startsWith(key, path)) { if (conf.getBoolean(DISTRIBUTED_ENABLED, false)) { ResourceFactory.remove(getWebResourceRegin(), key); } else { concurrentMap.remove(key); }//from www .ja va2s .c o m countConcurrentMap.remove(key); } } }
From source file:com.webtide.jetty.load.generator.jenkins.AlpnBootVersions.java
private AlpnBootVersions() { Map<String, String> map = new HashMap<>(); try {/*from w w w.j a va 2 s . c o m*/ try (InputStream inputStream = this.getClass().getResourceAsStream("/jetty/jetty-project.pom")) { SAXReader reader = new SAXReader(); Document document = reader.read(inputStream); Map<String, String> namespaceMap = new HashMap<>(); namespaceMap.put("mvn", "http://maven.apache.org/POM/4.0.0"); XPath xpath = document.createXPath("//mvn:profiles/mvn:profile"); xpath.setNamespaceURIs(namespaceMap); List<DefaultElement> nodes = xpath.selectNodes(document); for (DefaultElement o : nodes) { if (StringUtils.startsWith((String) o.element("id").getData(), "8u")) { // olamy well a bit fragile way to parse if more than one property... //"//mvn:properties/mvn:alpn.version" // o.selectSingleNode( "//properties/alpn.version" ); Node version = o.element("properties").element("alpn.version"); //"//mvn:activation/mvn:property/mvn:value" //o.selectSingleNode( "//activation/property/value" ); Node javaVersion = o.element("activation").element("property").element("value"); map.put(javaVersion.getStringValue(), version.getStringValue()); } } } } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } jdkVersionAlpnBootVersion = Collections.unmodifiableMap(map); }
From source file:gov.nih.nci.cacis.cdw.CDWLoaderSystemTest.java
@Test public void generateContext() throws TransformerException, RepositoryException, IOException, RDFParseException { assertTrue(StringUtils.startsWith(loader.generateContext(), "http://cacis.nci.nih.gov/")); }
From source file:net.shopxx.service.impl.ConfigServiceImpl.java
public void init() { try {/*from w ww . ja va 2 s .co m*/ Setting setting = SystemUtils.getSetting(); setting.setSmtpPassword(null); setting.setKuaidi100Key(null); setting.setCnzzPassword(null); setting.setSmsKey(null); ProxyFactory proxyFactory = new ProxyFactory(setting); proxyFactory.setProxyTargetClass(true); proxyFactory.addAdvice(new MethodBeforeAdvice() { public void before(Method method, Object[] args, Object target) throws Throwable { if (StringUtils.startsWith(method.getName(), "set")) { throw new UnsupportedOperationException("Operation not supported"); } } }); Configuration configuration = freeMarkerConfigurer.getConfiguration(); configuration.setSharedVariable("setting", proxyFactory.getProxy()); configuration.setSharedVariable("locale", setting.getLocale()); configuration.setSharedVariable("theme", setting.getTheme()); if (setting.getIsDevelopmentEnabled()) { configuration.setSetting("template_update_delay", "0"); reloadableResourceBundleMessageSource.setCacheSeconds(0); } else { configuration.setSetting("template_update_delay", templateUpdateDelay); reloadableResourceBundleMessageSource.setCacheSeconds(messageCacheSeconds); } fixedLocaleResolver.setDefaultLocale(LocaleUtils.toLocale(setting.getLocale().toString())); } catch (TemplateModelException e) { throw new RuntimeException(e.getMessage(), e); } catch (TemplateException e) { throw new RuntimeException(e.getMessage(), e); } }
From source file:com.ewcms.core.site.web.AclAction.java
private boolean isAuthority(String name) { return StringUtils.startsWith(name, "ROLE_"); }
From source file:io.kamax.mxisd.threepid.notification.GenericTemplateNotificationGenerator.java
private String getTemplateContent(String location) { try {/*from ww w . j a v a2s . co m*/ InputStream is = StringUtils.startsWith(location, "classpath:") ? app.getResource(location).getInputStream() : new FileInputStream(location); return IOUtils.toString(is, StandardCharsets.UTF_8); } catch (IOException e) { throw new InternalServerError("Unable to read template content at " + location + ": " + e.getMessage()); } }
From source file:com.enonic.cms.core.search.NodeSettingsBuilder.java
private Map<String, String> getNodePropertyMap() { return configProperties.getSubMap(new Predicate<String>() { @Override/*from w w w. j a va 2s. c om*/ public boolean apply(final String input) { return StringUtils.startsWith(input, ELASTICSEARCH_PROPERTIES_PREFIX) && !StringUtils.startsWith(input, INDEX_PROPERTIES_PREFIX); } }); }
From source file:com.cnd.greencube.web.base.interceptor.ExecuteTimeInterceptor.java
@Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { Long executeTime = (Long) request.getAttribute(EXECUTE_TIME_ATTRIBUTE_NAME); if (executeTime == null) { Long startTime = (Long) request.getAttribute(START_TIME_ATTRIBUTE_NAME); Long endTime = System.currentTimeMillis(); executeTime = endTime - startTime; request.setAttribute(START_TIME_ATTRIBUTE_NAME, startTime); }/* ww w. ja v a2 s .co m*/ if (modelAndView != null) { String viewName = modelAndView.getViewName(); if (!StringUtils.startsWith(viewName, REDIRECT_VIEW_NAME_PREFIX)) { modelAndView.addObject(EXECUTE_TIME_ATTRIBUTE_NAME, executeTime); } } if (logger.isDebugEnabled()) { logger.debug("[" + handler + "] executeTime: " + executeTime + "ms"); } }
From source file:biz.netcentric.vlt.upgrade.handler.SlingPipesHandler.java
/** * Builds the Map of Phases with a List of ScriptPaths for each Phase. * @return Map of ScriptPaths per Phase/* w ww . j a v a 2 s . c o m*/ */ private Map<Phase, LinkedList<String>> getScriptsFromConfig() { scripts = new HashMap<>(); for (Phase phase : Phase.values()) { scripts.put(phase, new LinkedList<String>()); } Resource resource = upgradeInfo.getConfigResource(); for (Resource child : resource.getChildren()) { // sling pipes if (StringUtils.startsWith(child.getResourceType(), "slingPipes/")) { scripts.get(getPhaseFromPrefix(child.getName())).add(child.getPath()); } } return scripts; }
From source file:com.ewcms.core.site.web.AclAction.java
private boolean isGroup(String name) { return StringUtils.startsWith(name, "GROUP_"); }