List of usage examples for org.apache.commons.vfs.provider UriParser extractFirstElement
public static String extractFirstElement(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);// w ww .j a v a 2 s . c om // 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: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 ww . ja v a 2 s .c om 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); }