1 16 package org.apache.commons.vfs.provider.http; 17 18 import org.apache.commons.httpclient.HttpClient; 19 import org.apache.commons.vfs.Capability; 20 import org.apache.commons.vfs.FileName; 21 import org.apache.commons.vfs.FileSystem; 22 import org.apache.commons.vfs.FileSystemConfigBuilder; 23 import org.apache.commons.vfs.FileSystemException; 24 import org.apache.commons.vfs.FileSystemOptions; 25 import org.apache.commons.vfs.provider.AbstractOriginatingFileProvider; 26 import org.apache.commons.vfs.provider.GenericFileName; 27 28 import java.util.Arrays ; 29 import java.util.Collection ; 30 import java.util.Collections ; 31 32 33 38 public class HttpFileProvider 39 extends AbstractOriginatingFileProvider 40 { 41 final static Collection capabilities = Collections.unmodifiableCollection(Arrays.asList(new Capability[] 42 { 43 Capability.GET_TYPE, 44 Capability.READ_CONTENT, 45 Capability.URI, 46 Capability.GET_LAST_MODIFIED, 47 Capability.ATTRIBUTES, 48 Capability.RANDOM_ACCESS_READ 49 })); 50 51 public HttpFileProvider() 52 { 53 super(); 54 setFileNameParser(HttpFileNameParser.getInstance()); 55 } 56 57 60 protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions) 61 throws FileSystemException 62 { 63 final GenericFileName rootName = (GenericFileName) name; 65 66 HttpClient httpClient = HttpClientFactory.createConnection(rootName.getHostName(), 67 rootName.getPort(), 68 rootName.getUserName(), 69 rootName.getPassword(), 70 fileSystemOptions); 71 72 return new HttpFileSystem(rootName, httpClient, fileSystemOptions); 73 } 74 75 public FileSystemConfigBuilder getConfigBuilder() 76 { 77 return HttpFileSystemConfigBuilder.getInstance(); 78 } 79 80 public Collection getCapabilities() 81 { 82 return capabilities; 83 } 84 } 85 | Popular Tags |