KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > vfs > provider > ftp > FtpFileProvider


1 /*
2  * Copyright 2002-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.commons.vfs.provider.ftp;
17
18 import org.apache.commons.vfs.Capability;
19 import org.apache.commons.vfs.FileName;
20 import org.apache.commons.vfs.FileSystem;
21 import org.apache.commons.vfs.FileSystemConfigBuilder;
22 import org.apache.commons.vfs.FileSystemException;
23 import org.apache.commons.vfs.FileSystemOptions;
24 import org.apache.commons.vfs.provider.AbstractOriginatingFileProvider;
25 import org.apache.commons.vfs.provider.GenericFileName;
26
27 import java.util.Arrays JavaDoc;
28 import java.util.Collection JavaDoc;
29 import java.util.Collections JavaDoc;
30
31 /**
32  * A provider for FTP file systems.
33  *
34  * @author <a HREF="mailto:adammurdoch@apache.org">Adam Murdoch</a>
35  */

36 public class FtpFileProvider
37     extends AbstractOriginatingFileProvider
38 {
39     public final static String JavaDoc ATTR_FILE_ENTRY_PARSER = "FEP";
40
41     final static Collection JavaDoc capabilities = Collections.unmodifiableCollection(Arrays.asList(new Capability[]
42     {
43         Capability.CREATE,
44         Capability.DELETE,
45         Capability.RENAME,
46         Capability.GET_TYPE,
47         Capability.LIST_CHILDREN,
48         Capability.READ_CONTENT,
49         Capability.GET_LAST_MODIFIED,
50         Capability.URI,
51         Capability.WRITE_CONTENT,
52         Capability.APPEND_CONTENT,
53         Capability.RANDOM_ACCESS_READ,
54     }));
55
56     public FtpFileProvider()
57     {
58         super();
59         setFileNameParser(FtpFileNameParser.getInstance());
60     }
61
62     /**
63      * Creates the filesystem.
64      */

65     protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions)
66         throws FileSystemException
67     {
68         // Create the file system
69
final GenericFileName rootName = (GenericFileName) name;
70
71         FTPClientWrapper ftpClient = new FTPClientWrapper(rootName, fileSystemOptions);
72         /*
73         FTPClient ftpClient = FtpClientFactory.createConnection(rootName.getHostName(),
74             rootName.getPort(),
75             rootName.getUserName(),
76             rootName.getPassword(),
77             rootName.getPath(),
78             fileSystemOptions);
79         */

80
81         return new FtpFileSystem(rootName, ftpClient, fileSystemOptions);
82     }
83
84     public FileSystemConfigBuilder getConfigBuilder()
85     {
86         return FtpFileSystemConfigBuilder.getInstance();
87     }
88
89     public Collection JavaDoc getCapabilities()
90     {
91         return capabilities;
92     }
93 }
94
Popular Tags