1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.vfs2.provider.ftp;
18
19 import java.util.Arrays;
20 import java.util.Collection;
21 import java.util.Collections;
22
23 import org.apache.commons.vfs2.Capability;
24 import org.apache.commons.vfs2.FileName;
25 import org.apache.commons.vfs2.FileSystem;
26 import org.apache.commons.vfs2.FileSystemConfigBuilder;
27 import org.apache.commons.vfs2.FileSystemException;
28 import org.apache.commons.vfs2.FileSystemOptions;
29 import org.apache.commons.vfs2.UserAuthenticationData;
30 import org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider;
31 import org.apache.commons.vfs2.provider.GenericFileName;
32
33
34
35
36 public class FtpFileProvider extends AbstractOriginatingFileProvider {
37
38
39
40
41 public static final String ATTR_FILE_ENTRY_PARSER = "FEP";
42
43
44
45
46 public static final UserAuthenticationData.Type[] AUTHENTICATOR_TYPES = new UserAuthenticationData.Type[] {
47 UserAuthenticationData.USERNAME, UserAuthenticationData.PASSWORD };
48
49 static final Collection<Capability> CAPABILITIES = Collections
50 .unmodifiableCollection(Arrays.asList(Capability.CREATE, Capability.DELETE, Capability.RENAME,
51 Capability.GET_TYPE, Capability.LIST_CHILDREN, Capability.READ_CONTENT, Capability.GET_LAST_MODIFIED,
52 Capability.URI, Capability.WRITE_CONTENT, Capability.APPEND_CONTENT, Capability.RANDOM_ACCESS_READ));
53
54
55
56
57 public FtpFileProvider() {
58 setFileNameParser(FtpFileNameParser.getInstance());
59 }
60
61
62
63
64 @Override
65 protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions)
66 throws FileSystemException {
67
68 final GenericFileName/../../org/apache/commons/vfs2/provider/GenericFileName.html#GenericFileName">GenericFileName rootName = (GenericFileName) name;
69
70 final FTPClientWrapperp/FTPClientWrapper.html#FTPClientWrapper">FTPClientWrapper ftpClient = new FTPClientWrapper(rootName, fileSystemOptions);
71
72
73
74
75
76 return new FtpFileSystem(rootName, ftpClient, fileSystemOptions);
77 }
78
79 @Override
80 public Collection<Capability> getCapabilities() {
81 return CAPABILITIES;
82 }
83
84 @Override
85 public FileSystemConfigBuilder getConfigBuilder() {
86 return FtpFileSystemConfigBuilder.getInstance();
87 }
88 }