Search in sources :

Example 46 with FileSystemOptions

use of org.apache.commons.vfs2.FileSystemOptions in project commons-vfs by apache.

the class AbstractLayeredFileProvider method createFileSystem.

/**
 * Creates a layered file system.
 *
 * @param scheme The protocol to use.
 * @param file a FileObject.
 * @param fileSystemOptions Options to access the FileSystem.
 * @return A FileObject associated with the new FileSystem.
 * @throws FileSystemException if an error occurs.
 */
@Override
public synchronized FileObject createFileSystem(final String scheme, final FileObject file, final FileSystemOptions fileSystemOptions) throws FileSystemException {
    // Check if cached
    final FileName rootName = file.getName();
    FileSystem fs = findFileSystem(rootName, fileSystemOptions);
    if (fs == null) {
        // Create the file system
        fs = doCreateFileSystem(scheme, file, fileSystemOptions);
        addFileSystem(rootName, fs);
    }
    return fs.getRoot();
}
Also used : FileName(org.apache.commons.vfs2.FileName) FileSystem(org.apache.commons.vfs2.FileSystem)

Example 47 with FileSystemOptions

use of org.apache.commons.vfs2.FileSystemOptions in project commons-vfs by apache.

the class AbstractOriginatingFileProvider method getFileSystem.

/**
 * Returns the FileSystem associated with the specified root.
 *
 * @param rootFileName The root path.
 * @param fileSystemOptions The FileSystem options.
 * @return The FileSystem.
 * @throws FileSystemException if an error occurs.
 * @since 2.0
 */
protected synchronized FileSystem getFileSystem(final FileName rootFileName, final FileSystemOptions fileSystemOptions) throws FileSystemException {
    FileSystem fs = findFileSystem(rootFileName, fileSystemOptions);
    if (fs == null) {
        // Need to create the file system, and cache it
        fs = doCreateFileSystem(rootFileName, fileSystemOptions);
        addFileSystem(rootFileName, fs);
    }
    return fs;
}
Also used : FileSystem(org.apache.commons.vfs2.FileSystem)

Example 48 with FileSystemOptions

use of org.apache.commons.vfs2.FileSystemOptions in project commons-vfs by apache.

the class FtpFileProvider method doCreateFileSystem.

/**
 * Creates the file system.
 */
@Override
protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions) throws FileSystemException {
    // Create the file system
    final GenericFileName rootName = (GenericFileName) name;
    final FTPClientWrapper ftpClient = new FTPClientWrapper(rootName, fileSystemOptions);
    return new FtpFileSystem(rootName, ftpClient, fileSystemOptions);
}
Also used : GenericFileName(org.apache.commons.vfs2.provider.GenericFileName)

Example 49 with FileSystemOptions

use of org.apache.commons.vfs2.FileSystemOptions in project commons-vfs by apache.

the class FtpsFileProvider method doCreateFileSystem.

/**
 * Creates the file system.
 */
@Override
protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions) throws FileSystemException {
    // Create the file system
    final GenericFileName rootName = (GenericFileName) name;
    final FtpsClientWrapper ftpClient = new FtpsClientWrapper(rootName, fileSystemOptions);
    return new FtpsFileSystem(rootName, ftpClient, fileSystemOptions);
}
Also used : GenericFileName(org.apache.commons.vfs2.provider.GenericFileName)

Example 50 with FileSystemOptions

use of org.apache.commons.vfs2.FileSystemOptions in project commons-vfs by apache.

the class FTPClientWrapper method createClient.

private FTPClient createClient() throws FileSystemException {
    final GenericFileName rootName = getRoot();
    UserAuthenticationData authData = null;
    try {
        authData = UserAuthenticatorUtils.authenticate(fileSystemOptions, FtpFileProvider.AUTHENTICATOR_TYPES);
        return createClient(rootName, authData);
    } finally {
        UserAuthenticatorUtils.cleanup(authData);
    }
}
Also used : UserAuthenticationData(org.apache.commons.vfs2.UserAuthenticationData) GenericFileName(org.apache.commons.vfs2.provider.GenericFileName)

Aggregations

FileSystemOptions (org.apache.commons.vfs2.FileSystemOptions)97 FileObject (org.apache.commons.vfs2.FileObject)46 FileSystemException (org.apache.commons.vfs2.FileSystemException)29 Test (org.junit.Test)25 IOException (java.io.IOException)16 FileName (org.apache.commons.vfs2.FileName)16 URL (java.net.URL)13 File (java.io.File)12 GenericFileName (org.apache.commons.vfs2.provider.GenericFileName)12 UserAuthenticationData (org.apache.commons.vfs2.UserAuthenticationData)11 StaticUserAuthenticator (org.apache.commons.vfs2.auth.StaticUserAuthenticator)9 FileSystem (org.apache.commons.vfs2.FileSystem)8 ArrayList (java.util.ArrayList)7 DefaultFileSystemManager (org.apache.commons.vfs2.impl.DefaultFileSystemManager)7 FileNotFolderException (org.apache.commons.vfs2.FileNotFolderException)6 Test (org.junit.jupiter.api.Test)6 OutputStream (java.io.OutputStream)5 UserAuthenticator (org.apache.commons.vfs2.UserAuthenticator)5 Before (org.junit.Before)5 AmazonS3 (com.amazonaws.services.s3.AmazonS3)4