/** Parses URI and constructs S3 file name. */ 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); // Normalize separators in the path UriParser.fixSeparators(name); // Normalise the path FileType fileType = UriParser.normalisePath(name); // Extract bucket name final String bucketName = UriParser.extractFirstElement(name); return new S3FileName(scheme, bucketName, name.toString(), fileType); }
public FileName parseUri(final VfsComponentContext context, FileName base, final String filename) throws FileSystemException { final StringBuffer name = new StringBuffer(); // Extract the scheme and authority parts final Authority auth = extractToPath(filename, name); // extract domain String username = auth.getUserName(); String domain = extractDomain(username); if (domain != null) { username = username.substring(domain.length() + 1); } // Decode and adjust separators UriParser.canonicalizePath(name, 0, name.length(), this); UriParser.fixSeparators(name); // Extract the share final String share = UriParser.extractFirstElement(name); if (share == null || share.length() == 0) { throw new FileSystemException("vfs.provider.smb/missing-share-name.error", filename); } // Normalise the path. Do this after extracting the share name, // to deal with things like smb://hostname/share/.. FileType fileType = UriParser.normalisePath(name); final String path = name.toString(); return new SmbFileName( auth.getScheme(), auth.getHostName(), auth.getPort(), username, auth.getPassword(), domain, share, path, fileType); }