List of usage examples for org.apache.commons.vfs.provider UriParser fixSeparators
public static boolean fixSeparators(final StringBuffer name)
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); // 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); }/*from w w w .j a v a 2 s . c o m*/ // 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 ww . j a va2 s. co 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:com.bedatadriven.renjin.appengine.AppEngineLocalFilesSystemProvider.java
@Override public FileObject findFile(FileObject baseFile, String uri, FileSystemOptions properties) throws FileSystemException { System.out.println(uri);//from w w w . j ava2 s .c o m // Parse the name final StringBuffer buffer = new StringBuffer(uri); String scheme = UriParser.extractScheme(uri, buffer); if (scheme == null) { scheme = "file"; } UriParser.fixSeparators(buffer); FileType fileType = UriParser.normalisePath(buffer); final String path = buffer.toString(); // Create the temp file system if it does not exist // FileSystem filesystem = findFileSystem( this, (Properties) null); FileSystem filesystem = findFileSystem(this, properties); if (filesystem == null) { final FileName rootName = getContext().parseURI(scheme + ":" + FileName.ROOT_PATH); filesystem = new LocalFileSystem(rootName, rootFile.getAbsolutePath(), properties); addFileSystem(this, filesystem); } // Find the file return filesystem.resolveFile(path); }
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();// w w w . j a v a2s . c o 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); // Normalize the path. final FileType fileType = UriParser.normalisePath(name); final String path = name.toString(); try {/*from ww w .java2s.c o m*/ 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); } }