1 16 package org.apache.cocoon.components.source.impl; 17 18 import java.io.IOException ; 19 import java.net.MalformedURLException ; 20 import java.util.Map ; 21 22 import org.apache.avalon.framework.configuration.Configurable; 23 import org.apache.avalon.framework.configuration.Configuration; 24 import org.apache.avalon.framework.configuration.ConfigurationException; 25 import org.apache.avalon.framework.logger.AbstractLogEnabled; 26 import org.apache.avalon.framework.parameters.Parameters; 27 import org.apache.avalon.framework.thread.ThreadSafe; 28 import org.apache.commons.httpclient.HttpURL; 29 import org.apache.commons.httpclient.HttpsURL; 30 import org.apache.excalibur.source.Source; 31 import org.apache.excalibur.source.SourceException; 32 import org.apache.excalibur.source.SourceFactory; 33 34 39 public class WebDAVSourceFactory extends AbstractLogEnabled 40 implements SourceFactory, Configurable, ThreadSafe { 41 42 private String protocol; 43 private boolean secure; 44 45 48 public void configure(Configuration configuration) throws ConfigurationException { 49 this.protocol = configuration.getAttribute("name"); 50 51 Parameters parameters = Parameters.fromConfiguration(configuration); 53 this.secure = parameters.getParameterAsBoolean("secure", false); 54 } 55 56 60 public Source getSource(String location, Map parameters) 61 throws MalformedURLException , IOException , SourceException { 62 63 if (this.getLogger().isDebugEnabled()) { 64 this.getLogger().debug("Creating source object for " + location); 65 } 66 67 int index = location.indexOf(':'); 68 if (index != -1) { 69 location = location.substring(index+3); 70 } 71 72 HttpURL url; 73 if (this.secure) { 74 url = new HttpsURL("https://" + location); 75 } else { 76 url = new HttpURL("http://" + location); 77 } 78 79 return WebDAVSource.newWebDAVSource(url, this.protocol, getLogger()); 80 } 81 82 public void release(Source source) { 83 } 85 } 86 | Popular Tags |