Java Code Examples for org.springframework.util.StringUtils#applyRelativePath()
The following examples show how to use
org.springframework.util.StringUtils#applyRelativePath() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: FastBootWeixin File: WxMediaStore.java License: Apache License 2.0 | 6 votes |
/** * 保存tempMedia到File * * @param mediaId * @return File */ public File storeTempMediaToFile(String mediaId, Resource resource) throws IOException { WxMediaResource wxMediaResource = (WxMediaResource) resource; if (wxMediaResource.isUrlMedia()) { return null; } String fileName = resource.getFilename(); if (fileName == null) { fileName = mediaId; } File file = new File(StringUtils.applyRelativePath(defaultTempFilePath, fileName)); if (file.exists()) { return file; } StoreEntity storeEntity = storeFile(file, mediaId, resource); tempMediaFileDb.put(file.getAbsolutePath(), storeEntity); tempMediaIdDb.put(mediaId, file.getAbsolutePath()); db.commit(); return file; }
Example 2
Source Project: spring-analysis-note File: FileSystemResource.java License: MIT License | 5 votes |
/** * This implementation creates a FileSystemResource, applying the given path * relative to the path of the underlying file of this resource descriptor. * @see org.springframework.util.StringUtils#applyRelativePath(String, String) */ @Override public Resource createRelative(String relativePath) { String pathToUse = StringUtils.applyRelativePath(this.path, relativePath); return (this.file != null ? new FileSystemResource(pathToUse) : new FileSystemResource(this.filePath.getFileSystem(), pathToUse)); }
Example 3
Source Project: FastBootWeixin File: WxMediaResource.java License: Apache License 2.0 | 5 votes |
public synchronized File getFile(String path) throws IOException { if (this.file == null) { // 拿到临时文件路径 String pathToUse = StringUtils.applyRelativePath(path, this.filename); this.file = new File(pathToUse); if (!this.file.exists()) { this.file.getParentFile().mkdirs(); this.file.createNewFile(); } FileCopyUtils.copy(this.getBody(), file); } return this.file; }
Example 4
Source Project: lams File: ForwardedHeaderFilter.java License: GNU General Public License v2.0 | 5 votes |
@Override public void sendRedirect(String location) throws IOException { UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(location); // Absolute location if (builder.build().getScheme() != null) { super.sendRedirect(location); return; } // Network-path reference if (location.startsWith("//")) { String scheme = this.request.getScheme(); super.sendRedirect(builder.scheme(scheme).toUriString()); return; } // Relative to Servlet container root or to current request String path = (location.startsWith(FOLDER_SEPARATOR) ? location : StringUtils.applyRelativePath(this.request.getRequestURI(), location)); String result = UriComponentsBuilder .fromHttpRequest(new ServletServerHttpRequest(this.request)) .replacePath(path) .build().normalize().toUriString(); super.sendRedirect(result); }
Example 5
Source Project: FastBootWeixin File: WxMediaResource.java License: Apache License 2.0 | 5 votes |
@Override public Resource createRelative(String mediaId) throws IOException { if (isFileResource) { String pathToUse = StringUtils.applyRelativePath(StringUtils.cleanPath(file.getPath()), mediaId); return new WxMediaResource(new File(pathToUse)); } return WxContextUtils.getBean(WxApiService.class).getTempMedia(mediaId); }
Example 6
Source Project: java-technology-stack File: FileSystemResource.java License: MIT License | 5 votes |
/** * This implementation creates a FileSystemResource, applying the given path * relative to the path of the underlying file of this resource descriptor. * @see org.springframework.util.StringUtils#applyRelativePath(String, String) */ @Override public Resource createRelative(String relativePath) { String pathToUse = StringUtils.applyRelativePath(this.path, relativePath); return (this.file != null ? new FileSystemResource(pathToUse) : new FileSystemResource(this.filePath.getFileSystem(), pathToUse)); }
Example 7
Source Project: java-technology-stack File: ForwardedHeaderFilter.java License: MIT License | 5 votes |
@Override public void sendRedirect(String location) throws IOException { UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(location); UriComponents uriComponents = builder.build(); // Absolute location if (uriComponents.getScheme() != null) { super.sendRedirect(location); return; } // Network-path reference if (location.startsWith("//")) { String scheme = this.request.getScheme(); super.sendRedirect(builder.scheme(scheme).toUriString()); return; } String path = uriComponents.getPath(); if (path != null) { // Relative to Servlet container root or to current request path = (path.startsWith(FOLDER_SEPARATOR) ? path : StringUtils.applyRelativePath(this.request.getRequestURI(), path)); } String result = UriComponentsBuilder .fromHttpRequest(new ServletServerHttpRequest(this.request)) .replacePath(path) .replaceQuery(uriComponents.getQuery()) .fragment(uriComponents.getFragment()) .build().normalize().toUriString(); super.sendRedirect(result); }
Example 8
Source Project: lams File: DefaultResourceLoader.java License: GNU General Public License v2.0 | 4 votes |
@Override public Resource createRelative(String relativePath) { String pathToUse = StringUtils.applyRelativePath(getPath(), relativePath); return new ClassPathContextResource(pathToUse, getClassLoader()); }
Example 9
Source Project: spring-analysis-note File: ClassRelativeResourceLoader.java License: MIT License | 4 votes |
@Override public Resource createRelative(String relativePath) { String pathToUse = StringUtils.applyRelativePath(getPath(), relativePath); return new ClassRelativeContextResource(pathToUse, this.clazz); }
Example 10
Source Project: spring-analysis-note File: DefaultResourceLoader.java License: MIT License | 4 votes |
@Override public Resource createRelative(String relativePath) { String pathToUse = StringUtils.applyRelativePath(getPath(), relativePath); return new ClassPathContextResource(pathToUse, getClassLoader()); }
Example 11
Source Project: lams File: FileSystemResource.java License: GNU General Public License v2.0 | 4 votes |
/** * This implementation creates a FileSystemResource, applying the given path * relative to the path of the underlying file of this resource descriptor. * @see org.springframework.util.StringUtils#applyRelativePath(String, String) */ @Override public Resource createRelative(String relativePath) { String pathToUse = StringUtils.applyRelativePath(this.path, relativePath); return new FileSystemResource(pathToUse); }
Example 12
Source Project: spring4-understanding File: PortletContextResource.java License: Apache License 2.0 | 4 votes |
@Override public Resource createRelative(String relativePath) { String pathToUse = StringUtils.applyRelativePath(this.path, relativePath); return new PortletContextResource(this.portletContext, pathToUse); }
Example 13
Source Project: spring-analysis-note File: ServletContextResource.java License: MIT License | 4 votes |
/** * This implementation creates a ServletContextResource, applying the given path * relative to the path of the underlying file of this resource descriptor. * @see org.springframework.util.StringUtils#applyRelativePath(String, String) */ @Override public Resource createRelative(String relativePath) { String pathToUse = StringUtils.applyRelativePath(this.path, relativePath); return new ServletContextResource(this.servletContext, pathToUse); }
Example 14
Source Project: lams File: ClassRelativeResourceLoader.java License: GNU General Public License v2.0 | 4 votes |
@Override public Resource createRelative(String relativePath) { String pathToUse = StringUtils.applyRelativePath(getPath(), relativePath); return new ClassRelativeContextResource(pathToUse, this.clazz); }
Example 15
Source Project: spring4-understanding File: ClassPathResource.java License: Apache License 2.0 | 4 votes |
/** * This implementation creates a ClassPathResource, applying the given path * relative to the path of the underlying resource of this descriptor. * @see org.springframework.util.StringUtils#applyRelativePath(String, String) */ @Override public Resource createRelative(String relativePath) { String pathToUse = StringUtils.applyRelativePath(this.path, relativePath); return new ClassPathResource(pathToUse, this.classLoader, this.clazz); }
Example 16
Source Project: java-technology-stack File: DefaultResourceLoader.java License: MIT License | 4 votes |
@Override public Resource createRelative(String relativePath) { String pathToUse = StringUtils.applyRelativePath(getPath(), relativePath); return new ClassPathContextResource(pathToUse, getClassLoader()); }
Example 17
Source Project: HotswapAgent File: ClassRelativeResourceLoader.java License: GNU General Public License v2.0 | 4 votes |
@Override public Resource createRelative(String relativePath) { String pathToUse = StringUtils.applyRelativePath(getPath(), relativePath); return new ClassRelativeContextResource(pathToUse, this.clazz); }
Example 18
Source Project: spring4-understanding File: ClassRelativeResourceLoader.java License: Apache License 2.0 | 4 votes |
@Override public Resource createRelative(String relativePath) { String pathToUse = StringUtils.applyRelativePath(getPath(), relativePath); return new ClassRelativeContextResource(pathToUse, this.clazz); }
Example 19
Source Project: java-technology-stack File: RequestContext.java License: MIT License | 3 votes |
/** * Return a context-aware URl for the given relative URL with placeholders -- * named keys with braces {@code {}}. For example, send in a relative URL * {@code foo/{bar}?spam={spam}} and a parameter map {@code {bar=baz,spam=nuts}} * and the result will be {@code [contextpath]/foo/baz?spam=nuts}. * @param relativeUrl the relative URL part * @param params a map of parameters to insert as placeholders in the url * @return a URL that points back to the current web application with an * absolute path also URL-encoded accordingly */ public String getContextUrl(String relativeUrl, Map<String, ?> params) { String url = StringUtils.applyRelativePath(getContextPath() + "/", relativeUrl); UriTemplate template = new UriTemplate(url); url = template.expand(params).toASCIIString(); return getExchange().transformUrl(url); }
Example 20
Source Project: spring-analysis-note File: RequestContext.java License: MIT License | 2 votes |
/** * Return a context-aware URl for the given relative URL. * @param relativeUrl the relative URL part * @return a URL that points back to the current web application with an * absolute path also URL-encoded accordingly */ public String getContextUrl(String relativeUrl) { String url = StringUtils.applyRelativePath(getContextPath() + "/", relativeUrl); return getExchange().transformUrl(url); }