1 16 package org.apache.commons.vfs.provider.webdav; 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.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 import org.apache.commons.vfs.provider.http.HttpFileNameParser; 27 28 import java.util.Arrays ; 29 import java.util.Collection ; 30 import java.util.Collections ; 31 32 37 public class WebdavFileProvider 38 extends AbstractOriginatingFileProvider 39 { 40 protected final static Collection capabilities = Collections.unmodifiableCollection(Arrays.asList(new Capability[] 41 { 42 Capability.CREATE, 43 Capability.DELETE, 44 Capability.RENAME, 45 Capability.GET_TYPE, 46 Capability.LIST_CHILDREN, 47 Capability.READ_CONTENT, 48 Capability.URI, 49 Capability.WRITE_CONTENT, 50 Capability.GET_LAST_MODIFIED, 51 Capability.ATTRIBUTES, 52 Capability.RANDOM_ACCESS_READ 53 })); 54 55 public WebdavFileProvider() 56 { 57 super(); 58 59 setFileNameParser(HttpFileNameParser.getInstance()); 60 } 61 62 65 protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions) 66 throws FileSystemException 67 { 68 final GenericFileName rootName = (GenericFileName) name; 70 71 HttpClient httpClient = WebdavClientFactory.createConnection(rootName.getHostName(), 72 rootName.getPort(), 73 rootName.getUserName(), 74 rootName.getPassword(), 75 fileSystemOptions); 76 77 return new WebDavFileSystem(rootName, httpClient, fileSystemOptions); 78 } 79 80 public Collection getCapabilities() 81 { 82 return capabilities; 83 } 84 } 85 | Popular Tags |