1 16 package org.apache.commons.vfs.provider.webdav; 17 18 import org.apache.commons.httpclient.HttpClient; 19 import org.apache.commons.httpclient.HttpURL; 20 import org.apache.commons.vfs.FileSystemException; 21 import org.apache.commons.vfs.FileSystemOptions; 22 import org.apache.webdav.lib.WebdavResource; 23 24 import java.io.IOException ; 25 26 31 public class WebdavClientFactory 32 { 33 private WebdavClientFactory() 34 { 35 } 36 37 40 public static HttpClient createConnection(String hostname, int port, String username, String password, FileSystemOptions fileSystemOptions) throws FileSystemException 41 { 42 HttpClient client; 44 try 45 { 46 final HttpURL url = new HttpURL(username, 47 password, 48 hostname, 49 port, 50 "/"); 51 52 WebdavResource resource = new WebdavResource() 54 { 55 }; 56 57 if (fileSystemOptions != null) 58 { 59 String proxyHost = WebdavFileSystemConfigBuilder.getInstance().getProxyHost(fileSystemOptions); 60 int proxyPort = WebdavFileSystemConfigBuilder.getInstance().getProxyPort(fileSystemOptions); 61 62 if (proxyHost != null && proxyPort > 0) 63 { 64 resource.setProxy(proxyHost, proxyPort); 66 } 67 } 68 69 76 resource.setHttpURL(url, WebdavResource.NOACTION, 1); 77 78 client = resource.retrieveSessionInstance(); 79 client.setHttpConnectionManager(new WebdavConnectionManager()); 80 } 81 catch (final IOException e) 82 { 83 throw new FileSystemException("vfs.provider.webdav/connect.error", hostname, e); 84 } 85 86 return client; 87 } 88 } | Popular Tags |