Java Code Examples for org.apache.commons.vfs2.provider.UriParser#extractFirstElement()

The following examples show how to use org.apache.commons.vfs2.provider.UriParser#extractFirstElement() . 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 File: S3NFileNameParser.java    From hop with Apache License 2.0 6 votes vote down vote up
public FileName parseUri( VfsComponentContext context, FileName base, String uri ) throws FileSystemException {
  StringBuilder name = new StringBuilder();

  String scheme = UriParser.extractScheme( uri, 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 S3NFileName( scheme, bucketName, name.toString(), fileType );
}
 
Example 2
Source File: S3FileNameParser.java    From hop with Apache License 2.0 6 votes vote down vote up
public FileName parseUri( VfsComponentContext context, FileName base, String uri ) throws FileSystemException {
  StringBuilder name = new StringBuilder();

  String scheme = UriParser.extractScheme( uri, name );
  UriParser.canonicalizePath( name, 0, name.length(), this );

  // Normalize separators in the path
  UriParser.fixSeparators( name );

  // Normalise the path
  FileType fileType = UriParser.normalisePath( name );

  String fullPath = name.toString();
  // Extract bucket name
  final String bucketName = UriParser.extractFirstElement( name );

  return new S3FileName( scheme, bucketName, fullPath, fileType );
}
 
Example 3
Source File: S3AFileNameParser.java    From hop with Apache License 2.0 6 votes vote down vote up
public FileName parseUri( VfsComponentContext context, FileName base, String uri ) throws FileSystemException {
  StringBuilder name = new StringBuilder();

  String scheme = UriParser.extractScheme( uri, 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 S3AFileName( scheme, bucketName, name.toString(), fileType );
}
 
Example 4
Source File: SmbFileNameParser.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
@Override
public FileName parseUri(final VfsComponentContext context, final FileName base, final String filename)
        throws FileSystemException {
    final StringBuilder name = new StringBuilder();

    // Extract the scheme and authority parts
    final Authority auth = extractToPath(context, filename, name);

    // extract domain
    String username = auth.getUserName();
    final 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/..
    final 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);
}
 
Example 5
Source File: ConnectionFileNameParser.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public static AbstractFileName parseUri( String uri, FileNameParser fileNameParser ) throws FileSystemException {
  StringBuilder name = new StringBuilder();

  String scheme = UriParser.extractScheme( uri, name );
  UriParser.canonicalizePath( name, 0, name.length(), fileNameParser );

  UriParser.fixSeparators( name );

  FileType fileType = UriParser.normalisePath( name );

  // Extract the named connection name
  final String connection = UriParser.extractFirstElement( name );

  String path = name.toString();

  return new ConnectionFileName( scheme, connection, path, fileType );
}