You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by mp...@apache.org on 2006/01/05 12:29:21 UTC

svn commit: r366166 - in /cocoon/branches/BRANCH_2_1_X/src/blocks/webdav: conf/ java/org/apache/cocoon/components/repository/impl/ java/org/apache/cocoon/components/source/impl/ java/org/apache/cocoon/transformation/ samples/ samples/low-level/

Author: mpfingsthorn
Date: Thu Jan  5 03:28:32 2006
New Revision: 366166

URL: http://svn.apache.org/viewcvs?rev=366166&view=rev
Log:
Added the WebDAVTransformer, and samples about it. Also updated most copyright statements for 2006.

Added:
    cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/transformation/WebDAVTransformer.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/
    cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/sitemap.xmap
    cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-propfind.xml   (with props)
    cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-proppatch.xml   (with props)
    cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-put.xml   (with props)
    cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-search.xml   (with props)
Modified:
    cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/conf/webdav.xmap
    cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/repository/impl/WebDAVRepository.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/repository/impl/WebDAVRepositoryPropertyHelper.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/repository/impl/WebDAVRepositoryTransactionHelper.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/repository/impl/WebDAVRepositoryVersioningHelper.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSource.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSourceFactory.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/transformation/DASLTransformer.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/samples.xml
    cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/sitemap.xmap

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/conf/webdav.xmap
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/conf/webdav.xmap?rev=366166&r1=366165&r2=366166&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/conf/webdav.xmap (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/conf/webdav.xmap Thu Jan  5 03:28:32 2006
@@ -21,4 +21,7 @@
 
     <!-- =================== DASL Transformer ========================= -->
     <map:transformer name="dasl" src="org.apache.cocoon.transformation.DASLTransformer"/>
+    
+    <!-- =================== WebDAV Transformer ========================= -->
+    <map:transformer name="webdav" src="org.apache.cocoon.transformation.WebDAVTransformer"/>
 </xmap>

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/repository/impl/WebDAVRepository.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/repository/impl/WebDAVRepository.java?rev=366166&r1=366165&r2=366166&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/repository/impl/WebDAVRepository.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/repository/impl/WebDAVRepository.java Thu Jan  5 03:28:32 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/repository/impl/WebDAVRepositoryPropertyHelper.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/repository/impl/WebDAVRepositoryPropertyHelper.java?rev=366166&r1=366165&r2=366166&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/repository/impl/WebDAVRepositoryPropertyHelper.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/repository/impl/WebDAVRepositoryPropertyHelper.java Thu Jan  5 03:28:32 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/repository/impl/WebDAVRepositoryTransactionHelper.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/repository/impl/WebDAVRepositoryTransactionHelper.java?rev=366166&r1=366165&r2=366166&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/repository/impl/WebDAVRepositoryTransactionHelper.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/repository/impl/WebDAVRepositoryTransactionHelper.java Thu Jan  5 03:28:32 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/repository/impl/WebDAVRepositoryVersioningHelper.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/repository/impl/WebDAVRepositoryVersioningHelper.java?rev=366166&r1=366165&r2=366166&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/repository/impl/WebDAVRepositoryVersioningHelper.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/repository/impl/WebDAVRepositoryVersioningHelper.java Thu Jan  5 03:28:32 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSource.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSource.java?rev=366166&r1=366165&r2=366166&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSource.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSource.java Thu Jan  5 03:28:32 2006
@@ -237,6 +237,9 @@
             if (e.getReasonCode() == HttpStatus.SC_NOT_FOUND) {
                 throw new SourceNotFoundException("Not found: " + getSecureURI(), e);
             }
+            if (e.getReasonCode() == HttpStatus.SC_BAD_REQUEST) {
+            	throw new SourceException("Server doesn't appear to understand WebDAV: "+getSecureURI(), e);
+            }
             final String msg = "Could not initialize webdav resource at " + getSecureURI()
                 + ". Server responded " + e.getReasonCode() + " (" + e.getReason() + ") - " + e.getMessage();
             throw new SourceException(msg, e);

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSourceFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSourceFactory.java?rev=366166&r1=366165&r2=366166&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSourceFactory.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSourceFactory.java Thu Jan  5 03:28:32 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/transformation/DASLTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/transformation/DASLTransformer.java?rev=366166&r1=366165&r2=366166&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/transformation/DASLTransformer.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/transformation/DASLTransformer.java Thu Jan  5 03:28:32 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -241,7 +241,7 @@
             }
             optionsMethod.execute(state, conn);
             if(!optionsMethod.isAllowed("SEARCH")) {
-                throw new SAXException("The server don't support the SEARCH method");
+                throw new SAXException("The server doesn't support the SEARCH method");
             }
             int httpstatus = searchMethod.execute(state, conn);
             

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/transformation/WebDAVTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/transformation/WebDAVTransformer.java?rev=366166&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/transformation/WebDAVTransformer.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/transformation/WebDAVTransformer.java Thu Jan  5 03:28:32 2006
@@ -0,0 +1,395 @@
+/*
+ * Copyright 1999-2006 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.transformation;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.xml.transform.OutputKeys;
+
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.caching.CacheableProcessingComponent;
+import org.apache.cocoon.caching.validity.EventValidity;
+import org.apache.cocoon.components.webdav.WebDAVEventFactory;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.xml.AttributesImpl;
+import org.apache.cocoon.xml.IncludeXMLConsumer;
+import org.apache.cocoon.xml.XMLUtils;
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpState;
+import org.apache.commons.httpclient.HttpURL;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.excalibur.source.SourceValidity;
+import org.apache.excalibur.source.impl.validity.AggregatedValidity;
+import org.apache.excalibur.xmlizer.XMLizer;
+import org.apache.webdav.lib.methods.HttpRequestBodyMethodBase;
+import org.w3c.dom.DocumentFragment;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * A general purpose, low level webdav transformer. Sends http requests defined in xml
+ * directly to the server and returns the response to the processing stream.
+ * 
+ * For a more high level approach, use WebDAVSource (GET/PUT/PROPPATCH) and DASLTransformer (SEARCH).
+ * 
+ * 
+ * 
+ */
+public class WebDAVTransformer extends AbstractSAXTransformer 
+implements Disposable, CacheableProcessingComponent {
+	
+    // ---------------------------------------------------- Constants
+
+    private static final String WEBDAV_SCHEME = "webdav://";
+    private static final String HTTP_SCHEME= "http://";
+    
+    private static final String NS_URI = "http://cocoon.apache.org/webdav/1.0";
+    private static final String NS_PREFIX = "webdav:";
+    
+    private static final String REQUEST_TAG = "request";
+    private static final String METHOD_ATTR = "method";
+    private static final String TARGET_ATTR = "target";
+    
+    private static final String HEADER_TAG = "header";
+    private static final String NAME_ATTR = "name";
+    private static final String VALUE_ATTR = "value";
+    
+    private static final String BODY_TAG = "body";
+    
+    private static final String RESPONSE_TAG = "response";
+    private static final String STATUS_TAG = "status";
+    private static final String CODE_ATTR = "code";
+    private static final String MSG_ATTR = "msg";
+
+    private static HttpClient client = new HttpClient(new MultiThreadedHttpConnectionManager());
+
+    // ---------------------------------------------------- Member variables
+
+    private HttpState m_state = null;
+
+    private String m_method = null;
+	private String m_target = null;
+    private Map m_headers = null;
+
+    private WebDAVEventFactory m_eventfactory = null;
+
+    private DocumentFragment m_requestdocument = null;
+
+    private AggregatedValidity m_validity = null;
+
+    // ---------------------------------------------------- Lifecycle
+
+    public WebDAVTransformer() {
+        super.defaultNamespaceURI = "DAV:";
+    }
+
+    public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) 
+    throws ProcessingException, SAXException, IOException {
+        super.setup(resolver, objectModel, src, par);
+
+        m_state = new HttpState();
+        
+        if(null != par.getParameter("username", null)) {
+        	m_state.setCredentials(null, null, new UsernamePasswordCredentials(
+        			par.getParameter("username", ""),
+        			par.getParameter("password", ""))
+        			);
+        }
+
+        if(m_eventfactory == null) {
+        	try {
+        		m_eventfactory = (WebDAVEventFactory)manager.lookup(WebDAVEventFactory.ROLE);
+        	} catch (ServiceException e) {
+				throw new ProcessingException("Couldn't look up event factory!", e);
+			}
+        }
+    }
+    
+    /**
+     * Helper method to do event caching
+     * 
+     * @param methodurl The url to create the EventValidity for
+     * @return an EventValidity object or null
+     */
+    private SourceValidity makeWebdavEventValidity(HttpURL methodurl) {
+    	
+    	SourceValidity evalidity = null;
+    	try {
+    		
+    		evalidity = new EventValidity(m_eventfactory.createEvent(methodurl));
+    		
+    		if(getLogger().isDebugEnabled())
+    			getLogger().debug("Created eventValidity for webdav request: "+evalidity);
+    	
+    	} catch (Exception e) {
+    		if(getLogger().isErrorEnabled())
+    			getLogger().error("could not create EventValidity!",e);
+    	}
+    	return evalidity;
+    }
+    
+    public void recycle() {
+        super.recycle();
+
+        m_method = null;
+        m_target = null;
+        m_validity = null;
+        m_requestdocument = null;
+    }
+    
+    public void dispose() {
+        recycle();
+
+        manager = null;
+    }
+
+    // ---------------------------------------------------- Transformer
+
+    public void startElement(String uri, String name, String raw, Attributes atts) 
+    throws SAXException {
+        if (name.equals(REQUEST_TAG) && uri.equals(NS_URI)) {
+            m_headers = new HashMap();
+            if ((m_method = atts.getValue(METHOD_ATTR)) == null) {
+                final String msg = "The <request> element must contain a \"method\" attribute";
+                throw new IllegalStateException(msg);
+            }
+            if ((m_target = atts.getValue(TARGET_ATTR)) == null) {
+                throw new IllegalStateException("The <request> element must contain a \"target\" attribute");
+            }
+            if (m_target.startsWith(WEBDAV_SCHEME)) {
+                m_target = HTTP_SCHEME + m_target.substring(WEBDAV_SCHEME.length());
+            }
+            else {
+                throw new SAXException("Illegal value for target, must be an http:// or webdav:// URL");
+            }
+        }
+        else if (name.equals(HEADER_TAG) && uri.equals(NS_URI)) {
+            final String hname = atts.getValue(NAME_ATTR);
+            if (hname == null) {
+                throw new SAXException("The <header> element requires a \"name\" attribute");
+            }
+            final String value = atts.getValue(VALUE_ATTR);
+            if (value == null) {
+                throw new SAXException("The <header> element requires a \"value\" attribute");
+            }
+            m_headers.put(hname, value);
+        }
+        else if (name.equals(BODY_TAG) && uri.equals(NS_URI)) {
+            startRecording();
+        }
+        else {
+            super.startElement(uri, name, raw, atts);
+        }
+	}
+    
+    public void endElement(String uri, String name, String raw) 
+    throws SAXException {
+        if (name.equals(REQUEST_TAG) && uri.equals(NS_URI)) {
+            
+            try {
+	            HttpURL url = new HttpURL(m_target);
+	            if(url.getUser() != null && !"".equals(url.getUser())) {
+		            m_state.setCredentials(null, new UsernamePasswordCredentials(
+		                    url.getUser(),
+		                    url.getPassword()));
+	            }
+	            m_target = url.getURI();
+	            
+	            if (m_validity != null) {
+	                m_validity.add(makeWebdavEventValidity(url));
+	            }
+	            
+            } catch (Exception e) {
+				//ignore
+			}
+            
+            // create method
+            WebDAVRequestMethod method = new WebDAVRequestMethod(m_target, m_method);
+            
+            try {
+                // add request headers
+                Iterator headers = m_headers.entrySet().iterator();
+                while (headers.hasNext()) {
+                    Map.Entry header = (Map.Entry) headers.next();
+                    method.addRequestHeader((String) header.getKey(), (String) header.getValue());
+                }
+
+                Properties props = XMLUtils.createPropertiesForXML(false);
+                props.put(OutputKeys.ENCODING, "ISO-8859-1");
+                String body = XMLUtils.serializeNode(m_requestdocument, props);
+                // set request body
+                method.setRequestBody(body.getBytes("ISO-8859-1"));
+                
+                // execute the request
+                executeRequest(method);
+            } catch (ProcessingException e) {
+				if(getLogger().isErrorEnabled()) {
+					getLogger().debug("Couldn't read request from sax stream",e);
+				}
+				throw new SAXException("Couldn't read request from sax stream",e);
+			} catch (UnsupportedEncodingException e) {
+				if(getLogger().isErrorEnabled()) {
+					getLogger().debug("ISO-8859-1 encoding not present",e);
+				}
+				throw new SAXException("ISO-8859-1 encoding not present",e);
+			}
+            finally {
+                method.releaseConnection();
+                m_headers = null;
+            }
+        }
+        else if (name.equals(HEADER_TAG) && uri.equals(NS_URI)) {
+            // dont do anything
+        }
+        else if (name.equals(BODY_TAG) && uri.equals(NS_URI)) {
+        	m_requestdocument = super.endRecording();
+        }
+        else {
+            super.endElement(uri, name, raw);
+        }
+    }
+    
+    private void executeRequest(WebDAVRequestMethod method) throws SAXException {
+        try {
+            client.executeMethod(method.getHostConfiguration(), method, m_state);
+            
+            super.contentHandler.startPrefixMapping("webdav", NS_URI);
+            
+            // start <response>
+            AttributesImpl atts = new AttributesImpl();
+            atts.addCDATAAttribute(TARGET_ATTR, m_target);
+            atts.addCDATAAttribute(METHOD_ATTR, m_method);
+            super.contentHandler.startElement(NS_URI, RESPONSE_TAG, NS_PREFIX + RESPONSE_TAG, atts);
+            atts.clear();
+            
+            // <status>
+            atts.addCDATAAttribute(CODE_ATTR, String.valueOf(method.getStatusCode()));
+            atts.addCDATAAttribute(MSG_ATTR, method.getStatusText());
+            super.contentHandler.startElement(NS_URI, STATUS_TAG, NS_PREFIX + STATUS_TAG, atts);
+            atts.clear();
+            super.contentHandler.endElement(NS_URI, STATUS_TAG, NS_PREFIX + STATUS_TAG);
+            
+            // <header>s
+            Header[] headers = method.getResponseHeaders();
+            for (int i = 0; i < headers.length; i++) {
+                atts.addCDATAAttribute(NAME_ATTR, headers[i].getName());
+                atts.addCDATAAttribute(VALUE_ATTR, headers[i].getValue());
+                super.contentHandler.startElement(NS_URI, HEADER_TAG, NS_PREFIX + HEADER_TAG, atts);
+                atts.clear();
+                super.contentHandler.endElement(NS_URI, HEADER_TAG, NS_PREFIX + HEADER_TAG);
+            }
+            
+            // response <body>
+            final InputStream in = method.getResponseBodyAsStream();
+            if (in != null) {
+                String mimeType = null;
+                Header header = method.getResponseHeader("Content-Type");
+                if (header != null) {
+                    mimeType = header.getValue();
+                    int pos = mimeType.indexOf(';');
+                    if (pos != -1) {
+                        mimeType = mimeType.substring(0, pos);
+                    }
+                }
+                if (mimeType != null && mimeType.equals("text/xml")) {
+                    super.contentHandler.startElement(NS_URI, BODY_TAG, NS_PREFIX + BODY_TAG, atts);
+                    IncludeXMLConsumer consumer = new IncludeXMLConsumer(super.contentHandler);
+                    XMLizer xmlizer = null;
+                    try {
+                        xmlizer = (XMLizer) manager.lookup(XMLizer.ROLE);
+                        xmlizer.toSAX(in, mimeType, m_target, consumer);
+                    } catch (ServiceException ce) {
+                        throw new SAXException("Missing service dependency: " + XMLizer.ROLE, ce);
+                    } finally {
+                        manager.release(xmlizer);
+                    }
+                    super.contentHandler.endElement(NS_URI, BODY_TAG, NS_PREFIX + BODY_TAG);
+                }
+            }
+                
+            // end <response>
+            super.contentHandler.endElement(NS_URI, RESPONSE_TAG, NS_PREFIX + RESPONSE_TAG);
+            
+            super.contentHandler.endPrefixMapping(NS_URI);
+        }
+        catch (HttpException e) {
+            throw new SAXException("Error executing WebDAV request." + " Server responded " 
+                + e.getReasonCode() + " (" + e.getReason() + ") - " + e.getMessage(), e);
+        }
+        catch (IOException e) {
+            throw new SAXException("Error executing WebDAV request", e);
+        }
+    }
+
+    // ---------------------------------------------------- CacheableProcessingComponent
+
+    public Serializable getKey() {
+        if (m_state == null) {
+            return "WebDAVTransformer";
+        }
+        final StringBuffer key = new StringBuffer();
+        // get the credentials
+        final Credentials credentials = m_state.getCredentials(null, null);
+        if (credentials != null) {
+            if (credentials instanceof UsernamePasswordCredentials) {
+                key.append(((UsernamePasswordCredentials) credentials).getUserName());
+            }
+            else {
+                key.append(credentials.toString());
+            }
+        }
+        return key.toString();
+    }
+
+    public SourceValidity getValidity() {
+        if (m_validity == null) {
+            m_validity = new AggregatedValidity();
+        }
+        return m_validity;
+    }
+
+    // ---------------------------------------------------- Implementation
+
+    private static class WebDAVRequestMethod extends HttpRequestBodyMethodBase {
+
+        private String m_name;
+
+        private WebDAVRequestMethod(String uri, String name) {
+            super(uri);
+            m_name = name;
+        }
+
+		public String getName() {
+			return m_name;
+		}
+
+    }
+    
+}

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/sitemap.xmap?rev=366166&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/sitemap.xmap (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/sitemap.xmap Thu Jan  5 03:28:32 2006
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2006 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+
+
+
+  <map:pipelines>
+    <map:pipeline type="event-aware">
+
+      <!-- Here, you probably get an authorization error, try the pipeline below -->
+      <map:match pattern="">
+        <map:generate src="test-search.xml"/>
+        <map:transform type="webdav"/>
+        <map:serialize type="xml"/>
+      </map:match>
+
+      <map:match pattern="src/**">
+        <map:generate src="{1}"/>
+        <map:serialize type="xml"/>
+      </map:match>
+
+      <!-- Either enter the password here, or use input modules -->
+      <map:match pattern="**">
+        <map:generate src="{1}"/>
+        <map:transform type="webdav">
+          <map:parameter name="username" value="root"/>
+          <map:parameter name="password" value="password"/>
+        </map:transform>
+        <map:serialize type="xml"/>
+      </map:match>
+
+    </map:pipeline>
+  </map:pipelines>
+
+</map:sitemap>

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-propfind.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-propfind.xml?rev=366166&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-propfind.xml (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-propfind.xml Thu Jan  5 03:28:32 2006
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 1999-2006 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<request xmlns="http://cocoon.apache.org/webdav/1.0" 
+  xmlns:jx="http://apache.org/cocoon/templates/jx/1.0" 
+  xmlns:d="DAV:"
+  xmlns:some="http://cocoon.apache.org/samplenamespace/1.0"
+  target="webdav://localhost/repos" 
+  method="PROPFIND">
+  <header name="Depth" value="1"/>
+  <body>
+    <d:propfind>
+      <d:prop>
+        <some:caption/>
+      </d:prop>
+    </d:propfind>
+  </body>
+</request>
\ No newline at end of file

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-propfind.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-proppatch.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-proppatch.xml?rev=366166&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-proppatch.xml (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-proppatch.xml Thu Jan  5 03:28:32 2006
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 1999-2006 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<request xmlns="http://cocoon.apache.org/webdav/1.0" 
+  xmlns:jx="http://apache.org/cocoon/templates/jx/1.0" 
+  xmlns:d="DAV:"
+  xmlns:some="http://cocoon.apache.org/samplenamespace/1.0"
+  target="webdav://localhost/repos/test.xml" 
+  method="PROPPATCH">
+  <header name="Depth" value="0"/>
+  <body>
+    <d:propertyupdate>
+      <d:set>
+        <d:prop>
+          <some:caption>A sample caption for a sample namespace</some:caption>
+        </d:prop>
+      </d:set>
+    </d:propertyupdate>
+  </body>
+</request>
\ No newline at end of file

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-proppatch.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-put.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-put.xml?rev=366166&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-put.xml (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-put.xml Thu Jan  5 03:28:32 2006
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 1999-2006 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<request xmlns="http://cocoon.apache.org/webdav/1.0" 
+  xmlns:jx="http://apache.org/cocoon/templates/jx/1.0" 
+  xmlns:d="DAV:"
+  xmlns:some="http://cocoon.apache.org/samplenamespace/1.0"
+  target="webdav://localhost/repos/test.xml" 
+  method="PUT">
+  <header name="Content-type" value="text/xml; charset=UTF-8"/>
+  <body>
+    <document>
+      <title>Some Title</title>
+      <author>Author</author>
+    </document>
+  </body>
+</request>
\ No newline at end of file

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-put.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-search.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-search.xml?rev=366166&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-search.xml (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-search.xml Thu Jan  5 03:28:32 2006
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 1999-2006 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<request xmlns="http://cocoon.apache.org/webdav/1.0" 
+  xmlns:jx="http://apache.org/cocoon/templates/jx/1.0" 
+  
+  target="webdav://root:hippo@localhost:60000/maxdev/files" 
+  method="SEARCH">
+  <header name="Depth" value="infinity"/>
+  <body>
+    <D:searchrequest xmlns:D="DAV:">
+      <D:basicsearch>
+        <D:select>
+          <D:allprop/>
+        </D:select>
+        <D:from>
+          <D:scope>
+            <D:href></D:href>
+            <D:depth>infinity</D:depth>
+          </D:scope>
+        </D:from>
+        <D:where>
+          <D:eq>
+            <D:prop><D:getcontenttype/></D:prop>
+            <D:literal>text/xml</D:literal>
+          </D:eq>
+        </D:where>
+        <D:orderby>
+          <D:order>
+            <D:prop>
+              <D:getcontentlength/>
+            </D:prop>
+            <D:ascending/>
+          </D:order>
+          <D:order>
+            <D:prop>
+              <D:getcontenttype/>
+            </D:prop>
+            <D:ascending/>
+          </D:order>
+        </D:orderby>
+        <D:limit>
+          <D:nresults>4</D:nresults>
+        </D:limit>
+      </D:basicsearch>
+    </D:searchrequest>
+  </body>
+</request>
\ No newline at end of file

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/low-level/test-search.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/samples.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/samples.xml?rev=366166&r1=366165&r2=366166&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/samples.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/samples.xml Thu Jan  5 03:28:32 2006
@@ -97,6 +97,50 @@
       View the actual query source.
     </sample>
   </group>
+  
+  <group name="Protocol Level WebDAV Requests">
+    <note>
+      This sample shows how to run a query against a WebDAV server 
+      (such as Catacomb or Slide). It assumes that
+      on localhost a server is running with a resource 
+      path of /repos (the default place for Catacomb installs). If
+      that's not the case, please change low-level/test-search.xml and other test-*.xml accordingly.
+      Also, adjust your username/password there.
+    </note>
+    <sample name="SEARCH Request" href="low-level/test-search.xml">
+      Searches a WebDAV server for everthing that is of content type "text/xml" and return the first 4 hits ordered by content type.
+    </sample>
+    <sample name="SEARCH Request source" href="low-level/src/test-search.xml">
+      View the actual query source.
+    </sample>
+    <sample name="PUT Request" href="low-level/test-put.xml">
+      PUT will add a new resource to the WebDAV server.
+    </sample>
+    <sample name="PUT Request source" href="low-level/src/test-put.xml">
+      View the actual query source.
+    </sample>
+    <sample name="PROPPATCH Request" href="low-level/test-proppatch.xml">
+      PROPPATCH will set/remove WebDAV properties. Here, we set a sample property "http://cocoon.apache.org/samplenamespace/1.0:caption".
+    </sample>
+    <sample name="PROPPATCH Request source" href="low-level/src/test-proppatch.xml">
+      View the actual query source.
+    </sample>
+    <sample name="PROPFIND Request" href="low-level/test-propfind.xml">
+      PROPFIND will select all properties given from the target itself and all immediate decendants (because "Depth" is 1).
+    </sample>
+    <sample name="PROPFIND Request source" href="low-level/src/test-propfind.xml">
+      View the actual query source.
+    </sample>
+  </group>
+  
+  <group name="WebDAV Source">
+    <note>
+      Just as with the examples above, make sure a webdav server is running. You can use the sample below after using the PUT request above.
+    </note>
+    <sample name="GETting a WebDAV resource" href="source/test.xml">
+      with the webdav:// protocol.
+    </sample>
+  </group>
 
   <group name="Resources">
     <sample name="webdav.org" href="http://www.webdav.org/">

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/sitemap.xmap?rev=366166&r1=366165&r2=366166&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/sitemap.xmap (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/samples/sitemap.xmap Thu Jan  5 03:28:32 2006
@@ -40,9 +40,9 @@
         <map:serialize/>
       </map:match>
 
-      <!-- you have to make sure a slide instance is running and reachable on the host/port below -->
+      <!-- you have to make sure a webdav instance is running and reachable on the host/port below -->
       <map:match pattern="source/**">
-        <map:generate src="webdav://localhost:8080/slide/files/{1}"/>
+        <map:generate src="webdav://localhost/repos/{1}"/>
         <map:serialize type="xml"/>
       </map:match>