package org.apache.commons.vfs2.provider.ftp;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import org.apache.commons.vfs2.Capability;
import org.apache.commons.vfs2.FileName;
import org.apache.commons.vfs2.FileSystem;
import org.apache.commons.vfs2.FileSystemConfigBuilder;
import org.apache.commons.vfs2.FileSystemException;
import org.apache.commons.vfs2.FileSystemOptions;
import org.apache.commons.vfs2.UserAuthenticationData;
import org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider;
import org.apache.commons.vfs2.provider.GenericFileName;
public class FtpFileProvider extends AbstractOriginatingFileProvider {
public static final String ATTR_FILE_ENTRY_PARSER = "FEP";
public static final UserAuthenticationData.Type[] AUTHENTICATOR_TYPES = new UserAuthenticationData.Type[] {
UserAuthenticationData.USERNAME, UserAuthenticationData.PASSWORD };
static final Collection<Capability> capabilities = Collections.unmodifiableCollection(Arrays
.asList(new Capability[] { Capability.CREATE, Capability.DELETE, Capability.RENAME, Capability.GET_TYPE,
Capability.LIST_CHILDREN, Capability.READ_CONTENT, Capability.GET_LAST_MODIFIED, Capability.URI,
Capability.WRITE_CONTENT, Capability.APPEND_CONTENT, Capability.RANDOM_ACCESS_READ, }));
public FtpFileProvider() {
super();
setFileNameParser(FtpFileNameParser.getInstance());
}
@Override
protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions)
throws FileSystemException {
final GenericFileName rootName = (GenericFileName) name;
final FTPClientWrapper ftpClient = new FTPClientWrapper(rootName, fileSystemOptions);
return new FtpFileSystem(rootName, ftpClient, fileSystemOptions);
}
@Override
public FileSystemConfigBuilder getConfigBuilder() {
return FtpFileSystemConfigBuilder.getInstance();
}
@Override
public Collection<Capability> getCapabilities() {
return capabilities;
}
}