List of usage examples for org.springframework.util StringUtils stripFilenameExtension
public static String stripFilenameExtension(String path)
From source file:org.springframework.cloud.config.monitor.PropertyPathEndpoint.java
private Set<String> guessServiceName(String path) { Set<String> services = new LinkedHashSet<>(); if (path != null) { String stem = StringUtils.stripFilenameExtension(StringUtils.getFilename(StringUtils.cleanPath(path))); // TODO: correlate with service registry int index = stem.indexOf("-"); while (index >= 0) { String name = stem.substring(0, index); String profile = stem.substring(index + 1); if ("application".equals(name)) { services.add("*:" + profile); } else if (!name.startsWith("application")) { services.add(name + ":" + profile); }/*from ww w . ja va 2s.c o m*/ index = stem.indexOf("-", index + 1); } String name = stem; if ("application".equals(name)) { services.add("*"); } else if (!name.startsWith("application")) { services.add(name); } } return services; }
From source file:org.springframework.cloud.config.server.resource.GenericResourceRepository.java
private Collection<String> getProfilePaths(String profiles, String path) { Set<String> paths = new LinkedHashSet<>(); for (String profile : StringUtils.commaDelimitedListToSet(profiles)) { if (!StringUtils.hasText(profile) || "default".equals(profile)) { paths.add(path);/*from w w w . j a v a2s. c o m*/ } else { String ext = StringUtils.getFilenameExtension(path); String file = path; if (ext != null) { ext = "." + ext; file = StringUtils.stripFilenameExtension(path); } else { ext = ""; } paths.add(file + "-" + profile + ext); } } paths.add(path); return paths; }
From source file:org.springframework.osgi.web.deployer.support.DefaultContextPathStrategy.java
private String getBundleLocation(String location) { // remove prefix (if there's any) int index = location.lastIndexOf(PREFIX_DELIMITER); String path = ((index > 0) ? location.substring(index + 1) : location); // clean up the path path = StringUtils.cleanPath(path);//from ww w .j a va 2 s .c om // check if it's a folder if (path.endsWith(SLASH)) { // remove trailing slash path = path.substring(0, path.length() - 1); int separatorIndex = path.lastIndexOf(SLASH); // if there is no other slash, consider the whole location, otherwise detect the folder path = (separatorIndex > -1 ? path.substring(separatorIndex + 1) : path); } path = StringUtils.getFilename(path); // remove file extension path = StringUtils.stripFilenameExtension(path); if (log.isTraceEnabled()) log.trace("Bundle location [" + location + "] resulted in context path [" + path + "]"); return path; }
From source file:org.springframework.scripting.support.ResourceScriptSource.java
@Override @Nullable/*from w w w . ja v a2 s . c o m*/ public String suggestedClassName() { String filename = getResource().getFilename(); return (filename != null ? StringUtils.stripFilenameExtension(filename) : null); }
From source file:org.springframework.web.reactive.resource.AbstractFileNameVersionStrategy.java
@Override public String addVersion(String requestPath, String version) { String baseFilename = StringUtils.stripFilenameExtension(requestPath); String extension = StringUtils.getFilenameExtension(requestPath); return (baseFilename + '-' + version + '.' + extension); }
From source file:org.springframework.web.servlet.resource.FingerprintResourceResolver.java
@Override public String getPublicUrlPath(String resourceUrlPath, List<Resource> locations, ResourceResolverChain chain) { String baseUrl = chain.resolveUrlPath(resourceUrlPath, locations); if (StringUtils.hasText(baseUrl)) { Resource original = chain.resolveResource(null, resourceUrlPath, locations); String hash = calculateHash(original); return StringUtils.stripFilenameExtension(baseUrl) + "-" + hash + "." + StringUtils.getFilenameExtension(baseUrl); }//from w ww. j ava2s . c om return baseUrl; }