List of usage examples for org.apache.commons.vfs.provider UriParser canonicalizePath
public static void canonicalizePath(StringBuffer buffer, int offset, int length, FileNameParser fileNameParser) throws FileSystemException
From source file:com.thinkberg.moxo.vfs.s3.S3FileNameParser.java
public FileName parseUri(final VfsComponentContext context, final FileName base, final String filename) throws FileSystemException { StringBuffer name = new StringBuffer(); String scheme = UriParser.extractScheme(filename, name); UriParser.canonicalizePath(name, 0, name.length(), this); UriParser.fixSeparators(name);// w ww.j av a2 s.c o m // Normalise the path FileType fileType = UriParser.normalisePath(name); // Extract the root prefix final String bucketName = UriParser.extractFirstElement(name); return new S3FileName(scheme, bucketName, name.toString(), fileType); }
From source file:com.jaspersoft.jasperserver.api.metadata.common.util.RepositoryFileNameParser.java
public FileName parseUri(final VfsComponentContext context, final FileName base, final String filename) throws FileSystemException { final StringBuffer name = new StringBuffer(); // Extract the scheme final String foundScheme = UriParser.extractScheme(filename, name); if (!scheme.equals(foundScheme)) { throw new FileSystemException("invalid scheme: " + foundScheme); }// w w w.j av a 2s. c om // Decode and normalise the path UriParser.canonicalizePath(name, 0, name.length(), this); UriParser.fixSeparators(name); FileType fileType = UriParser.normalisePath(name); final String path = name.toString(); return new RepositoryFileName(scheme, path, fileType); }
From source file:com.newatlanta.appengine.vfs.provider.GaeFileNameParser.java
/** * Makes sure <code>filename</code> always specifies a path that is within a * sub-directory of the webapp root path. *//*from w w w .j a va 2 s .c o m*/ public FileName parseUri(VfsComponentContext context, FileName baseName, String uri) throws FileSystemException { StringBuffer name = new StringBuffer(); // Extract the scheme String scheme = UriParser.extractScheme(uri, name); if (scheme == null) { // this should never happen scheme = "gae"; } // Remove encoding, and adjust the separators UriParser.canonicalizePath(name, 0, name.length(), this); UriParser.fixSeparators(name); // Normalise the path FileType fileType = UriParser.normalisePath(name); // all GAE files *must* be relative to the root file, which must be the // webapp root (though we have no way of enforcing this) String rootPath = ""; if (baseName == null) { // this is the root object rootPath = name.toString(); name.setLength(0); } else { rootPath = getRootPath(baseName); if (name.indexOf(rootPath) == 0) { // if ( name.startsWith( basePath ) ) name.delete(0, rootPath.length()); } } return new GaeFileName(scheme, rootPath, name.toString(), fileType); }
From source file:org.jclouds.vfs.provider.blobstore.BlobStoreFileNameParser.java
public FileName parseUri(final VfsComponentContext context, FileName base, String filename) throws FileSystemException { // if there are unencoded characters in the password, things break. URI uri = HttpUtils.createUri(filename); filename = uri.toASCIIString();/*from w w w. j av a 2 s.co m*/ Credentials creds = Credentials.parse(uri); StringBuffer name = new StringBuffer(); // Extract the scheme and authority parts Authority auth = extractToPath(filename, name); // Decode and adjust separators UriParser.canonicalizePath(name, 0, name.length(), this); UriParser.fixSeparators(name); // Extract the container String container = UriParser.extractFirstElement(name); if (container == null || container.length() == 0) { throw new FileSystemException("vfs.provider.blobstore/missing-container-name.error", filename); } // Normalise the path. Do this after extracting the container name FileType fileType = UriParser.normalisePath(name); String path = name.toString(); return new BlobStoreFileName(auth.hostName, creds.identity, creds.credential, path, fileType, container); }
From source file:org.objectweb.proactive.extensions.vfsprovider.client.ProActiveFileNameParser.java
@Override public FileName parseUri(VfsComponentContext context, FileName base, String filename) throws FileSystemException { final StringBuffer name = new StringBuffer(); // Extract the scheme and authority parts final Authority auth = extractToPath(filename, name); // Extract the server service path before processing the file path. final String servicePath = extractServicePath(name); // Decode and adjust separators UriParser.canonicalizePath(name, 0, name.length(), this); UriParser.fixSeparators(name);//ww w .j ava 2s . com // Normalize the path. final FileType fileType = UriParser.normalisePath(name); final String path = name.toString(); try { return new ProActiveFileName(auth.scheme, auth.hostName, auth.port, auth.userName, auth.password, servicePath, path, fileType); } catch (UnknownProtocolException e) { throw new FileSystemException("Unknown protocol scheme of URL", e); } }