jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r293331 [3/3] - in /incubator/jackrabbit/trunk/contrib/jcr-server: server/src/java/org/apache/jackrabbit/server/ server/src/java/org/apache/jackrabbit/server/io/ server/src/java/org/apache/jackrabbit/util/ server/src/java/org/apache/jackrab...
Date Mon, 03 Oct 2005 13:13:32 GMT
Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java?rev=293331&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java Mon Oct  3 06:12:18 2005
@@ -0,0 +1,207 @@
+/*
+ * Copyright 2005 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.jackrabbit.webdav.simple;
+
+import org.apache.log4j.Logger;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.input.SAXBuilder;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import java.net.URL;
+import java.util.List;
+import java.util.Iterator;
+
+/**
+ * <code>ResourceConfig</code>...
+ */
+public class ResourceConfig {
+
+    private static Logger log = Logger.getLogger(ResourceConfig.class);
+
+    private ResourceFilter resourceFilter;
+    private String[] nodetypeNames = new String[0];
+    private boolean collectionNames = false;
+
+    /**
+     * Tries to parse the given xml configuration file.
+     * The xml must match the following structure:<br>
+     * <pre>
+     * &lt;!ELEMENT config ((collection | noncollection)?, filter?) &gt;
+     * &lt;!ELEMENT collection (nodetypes) &gt;
+     * &lt;!ELEMENT noncollection (nodetypes) &gt;
+     * &lt;!ELEMENT filter (class, namespaces?, nodetypes?) &gt;
+     * &lt;!ELEMENT class &gt;
+     *    &lt;!ATTLIST class
+     *      name  CDATA #REQUIRED
+     *    &gt;
+     * &lt;!ELEMENT namespaces (prefix|uri)* &gt;
+     * &lt;!ELEMENT prefix (CDATA) &gt;
+     * &lt;!ELEMENT uri (CDATA) &gt;
+     * &lt;!ELEMENT nodetypes (nodetype)* &gt;
+     * &lt;!ELEMENT nodetype (CDATA) &gt;
+     * </pre>
+     *
+     * @param configURL
+     */
+    public void parse(URL configURL) {
+        try {
+            Document doc = new SAXBuilder().build(configURL);
+            Element root = doc.getRootElement();
+
+            Element collection = root.getChild("collection");
+            Element noncollection = root.getChild("noncollection");
+            if (collection != null && noncollection != null) {
+                log.warn("Resource configuration may only contain a collection OR a noncollection element -> entries are ignored");
+            } else {
+                if (collection != null) {
+                    Element nts = collection.getChild("nodetypes");
+                    nodetypeNames = parseNodeTypesEntry(nts);
+                    collectionNames = true;
+                } else if (noncollection != null) {
+                    Element nts = noncollection.getChild("nodetypes");
+                    nodetypeNames = parseNodeTypesEntry(nts);
+                    collectionNames = false;
+                }
+            }
+
+            Element filter = root.getChild("filter");
+            if (filter != null) {
+                resourceFilter = buildResourceFilter(filter.getChild("class"));
+                if (resourceFilter != null) {
+                    Element nts = filter.getChild("nodetypes");
+                    resourceFilter.setFilteredNodetypes(parseNodeTypesEntry(nts));
+                    parseNamespacesEntry(filter.getChild("namespaces"), resourceFilter);
+                }
+            } else {
+                log.debug("Resource configuration: no 'filter' element specified.");
+            }
+        } catch (Exception e) {
+            log.warn("Error while reading resource configuration: " + e.getMessage());
+        }
+    }
+
+    private ResourceFilter buildResourceFilter(Element classElement) {
+        if (classElement == null) {
+            return null;
+        }
+        try {
+            String className = classElement.getAttributeValue("name");
+            if (className != null) {
+                Class cl = Class.forName(className);
+                Class[] interfaces = cl.getInterfaces();
+                boolean isfilterClass = false;
+                for (int i = 0; i < interfaces.length && !isfilterClass; i++) {
+                    isfilterClass = (interfaces[i].equals(ResourceFilter.class));
+                }
+                if (isfilterClass) {
+                    return (ResourceFilter) cl.newInstance();
+                } else {
+                    log.warn("Class '" + className + "' specified does not represent a resource filter > using default.");
+                }
+            } else {
+                log.warn("Invalid filter configuration: missing 'class' element");
+            }
+        } catch (Exception e) {
+            log.warn("Error while reading filter configuration. Using empty filter instead.");
+        }
+        return null;
+    }
+
+    private void parseNamespacesEntry(Element child, ResourceFilter filter) {
+        if (child == null) {
+            return;
+        }
+        List l = child.getChildren("prefix");
+        Iterator it = l.iterator();
+        String[] prefixes = new String[l.size()];
+        int i = 0;
+        while(it.hasNext()) {
+            prefixes[i++] = ((Element) it.next()).getText();
+        }
+
+        l = child.getChildren("uri");
+        it = l.iterator();
+        String[] uris = new String[l.size()];
+        i = 0;
+        while(it.hasNext()) {
+            uris[i++] = ((Element) it.next()).getText();
+        }
+
+        filter.setFilteredPrefixes(prefixes);
+        filter.setFilteredURIs(uris);
+    }
+
+    private String[] parseNodeTypesEntry(Element child) {
+        if (child == null) {
+            return new String[0];
+        }
+        List l = child.getChildren("nodetype");
+        Iterator it = l.iterator();
+        String[] ntNames = new String[l.size()];
+        int i = 0;
+        while(it.hasNext()) {
+            ntNames[i++] = ((Element) it.next()).getText();
+        }
+        return ntNames;
+    }
+
+    /**
+     * Returns true, if the given item represents a {@link Node node} that is
+     * either any of the nodetypes specified to represent a collection or
+     * none of the nodetypes specified to represent a non-collection, respectively.
+     * If no valid configuration entry is present, this method returns true
+     * for node items. For items which are not a node, this method always
+     * returns false.
+     *
+     * @param item
+     * @return true if the given item is a node that represents a webdav
+     * collection, false otherwise.
+     */
+    public boolean isCollectionResource(Item item) {
+        if (item.isNode()) {
+            boolean isCollection = true;
+            Node n = (Node)item;
+            try {
+                for (int i = 0; i < nodetypeNames.length && isCollection; i++) {
+                    isCollection = collectionNames ? n.isNodeType(nodetypeNames[i]) : !n.isNodeType(nodetypeNames[i]);
+                }
+            } catch (RepositoryException e) {
+                log.warn(e.getMessage());
+            }
+            return isCollection;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Returns the resource filter specified with the configuration or {@link DefaultResourceFilter}
+     * if the configuration was missing the corresponding entry or the parser failed
+     * to build a <code>ResourceFilter</code> instance from the configuration.
+     *
+     * @return resource filter as defined by the config or {@link DefaultResourceFilter}
+     */
+    public ResourceFilter getResourceFilter() {
+        if (resourceFilter == null) {
+            log.debug("ResourceConfig: missing resource filter > building DefaultResourceFilter ");
+            resourceFilter = new DefaultResourceFilter();
+        }
+        return resourceFilter;
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java Mon Oct  3 06:12:18 2005
@@ -28,7 +28,7 @@
 public class ResourceFactoryImpl implements DavResourceFactory {
 
     private final LockManager lockMgr;
-    private final ResourceFilter resourceFilter;
+    private final ResourceConfig resourceConfig;
 
     /**
      * Create a new <code>ResourceFactory</code> that uses the given lock manager
@@ -37,7 +37,8 @@
      * @param lockMgr
      */
     public ResourceFactoryImpl(LockManager lockMgr) {
-        this(lockMgr, new DefaultResourceFilter());
+        this.lockMgr = lockMgr;
+        this.resourceConfig = new ResourceConfig();
     }
 
     /**
@@ -45,11 +46,11 @@
      * and resource filter.
      *
      * @param lockMgr
-     * @param resourceFilter
+     * @param resourceConfig
      */
-    public ResourceFactoryImpl(LockManager lockMgr, ResourceFilter resourceFilter) {
+    public ResourceFactoryImpl(LockManager lockMgr, ResourceConfig resourceConfig) {
         this.lockMgr = lockMgr;
-        this.resourceFilter = resourceFilter;
+        this.resourceConfig = (resourceConfig != null) ? resourceConfig : new ResourceConfig();
     }
 
     /**
@@ -87,7 +88,7 @@
      */
     public DavResource createResource(DavResourceLocator locator, DavSession session) throws DavException {
         try {
-            DavResource res = new DavResourceImpl(locator, this, session, resourceFilter);
+            DavResourceImpl res = new DavResourceImpl(locator, this, session, resourceConfig);
             res.addLockManager(lockMgr);
             return res;
         } catch (RepositoryException e) {

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/SimpleWebdavServlet.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/SimpleWebdavServlet.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/SimpleWebdavServlet.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/SimpleWebdavServlet.java Mon Oct  3 06:12:18 2005
@@ -36,9 +36,7 @@
 import org.apache.jackrabbit.webdav.simple.DavSessionProviderImpl;
 import org.apache.jackrabbit.webdav.simple.LocatorFactoryImpl;
 import org.apache.jackrabbit.webdav.simple.ResourceFactoryImpl;
-import org.apache.jackrabbit.webdav.simple.ResourceFilterConfig;
-import org.apache.jackrabbit.webdav.simple.ResourceFilter;
-import org.apache.jackrabbit.webdav.simple.DefaultResourceFilter;
+import org.apache.jackrabbit.webdav.simple.ResourceConfig;
 import org.apache.log4j.Logger;
 
 import javax.jcr.Credentials;
@@ -87,7 +85,7 @@
      * Name of the init parameter that specify a separate configuration used
      * for filtering the resources displayed.
      */
-    public static final String INIT_PARAM_RESOURCE_FILTER = "resource-filter";
+    public static final String INIT_PARAM_RESOURCE_CONFIG = "resource-config";
 
     /**
      * Servlet context attribute used to store the path prefix instead of
@@ -145,9 +143,9 @@
     private SessionProvider sessionProvider;
 
     /**
-     * The resource filter
+     * The config
      */
-    private ResourceFilter resourceFilter;
+    private ResourceConfig config;
 
     /**
      * Init this servlet
@@ -185,11 +183,11 @@
         }
         log.info("WWW-Authenticate header = '" + authenticate_header + "'");
 
-        String filterParam = getInitParameter(INIT_PARAM_RESOURCE_FILTER);
-        if (filterParam != null) {
+        String configParam = getInitParameter(INIT_PARAM_RESOURCE_CONFIG);
+        if (configParam != null) {
             try {
-                ResourceFilterConfig config = new ResourceFilterConfig();
-                setResourceFilter(config.parse(getServletContext().getResource(filterParam)));
+                config = new ResourceConfig();
+                config.parse(getServletContext().getResource(configParam));
             } catch (MalformedURLException e) {
                 log.debug("Unable to build resource filter provider.");
             }
@@ -213,11 +211,6 @@
     protected boolean execute(WebdavRequest request, WebdavResponse response,
                               int method, DavResource resource)
             throws ServletException, IOException, DavException {
-        /* set cache control headers in order to deal with non-dav complient
-        * http1.1 or http1.0 proxies. >> see RFC2518 9.4.5 */
-        response.addHeader("Pragma", "No-cache");  // http1.0
-        response.addHeader("Cache-Control", "no-cache"); // http1.1
-
         switch (method) {
             case DavMethods.DAV_HEAD:
                 doHead(request, response, resource);
@@ -351,7 +344,7 @@
      */
     public DavResourceFactory getResourceFactory() {
         if (resourceFactory == null) {
-            resourceFactory = new ResourceFactoryImpl(getLockManager(), getResourceFilter());
+            resourceFactory = new ResourceFactoryImpl(getLockManager(), getResourceConfig());
         }
         return resourceFactory;
     }
@@ -436,25 +429,25 @@
     }
 
     /**
-     * Returns the resource filter to be applied
+     * Returns the resource configuration to be applied
      *
      * @return
      */
-    public ResourceFilter getResourceFilter() {
-        // fallback if no config present or invalid: an empty resource filter
-        if (resourceFilter == null) {
-            resourceFilter = new DefaultResourceFilter();
+    public ResourceConfig getResourceConfig() {
+        // fallback if no config present
+        if (config == null) {
+            config = new ResourceConfig();
         }
-        return resourceFilter;
+        return config;
     }
 
     /**
-     * Set the resource filter
+     * Set the resource configuration
      *
-     * @param resourceFilter
+     * @param config
      */
-    public void setResourceFilter(ResourceFilter resourceFilter) {
-        this.resourceFilter = resourceFilter;
+    public void setResourceConfig(ResourceConfig config) {
+        this.config = config;
     }
 
     /**

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/config.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/config.xml?rev=293331&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/config.xml (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/config.xml Mon Oct  3 06:12:18 2005
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+<!DOCTYPE config [
+        <!ELEMENT config ((collection | noncollection)? , filter?) >
+
+        <!ELEMENT collection (nodetypes) >
+        <!ELEMENT noncollection (nodetypes) >
+
+        <!ELEMENT filter (class, namespaces?, nodetypes?) >
+
+        <!ELEMENT class >
+        <!ATTLIST class
+            name  CDATA #REQUIRED
+        >
+        <!ELEMENT namespaces (prefix | uri)* >
+        <!ELEMENT prefix (CDATA) >
+        <!ELEMENT uri (CDATA) >
+
+        <!ELEMENT nodetypes (nodetype)* >
+        <!ELEMENT nodetype (CDATA) >
+]>
+-->
+
+<config>
+    <!--
+    Defines nodetypes, that should always be displayed as 'collection'.
+    -->
+    <!--
+    <collection>
+        <nodetypes>
+            <nodetype>nt:folder</nodetype>
+        </nodetypes>
+    </collection>
+    -->
+    <!--
+    Define nodetypes, that should never by displayed as 'collection'
+    -->
+    <noncollection>
+        <nodetypes>
+            <nodetype>nt:file</nodetype>
+            <nodetype>nt:resource</nodetype>
+        </nodetypes>
+    </noncollection>
+    <!--
+     Filter that allows to prevent certain items from being displayed.
+     Please note, that this has an effect on PROPFIND calls only and does not
+     provide limited access to those items matching any of the filters.
+
+     However specifying a filter may cause problems with PUT or MKCOL if the
+     resource to be created is being filtered out, thus resulting in inconsistent
+     responses (e.g. PUT followed by PROPFIND on parent).
+     -->
+    <filter>
+        <!-- class element defines the resource filter to be used. The specified class
+             must implement the ResourceFilter interface -->
+        <class name="org.apache.jackrabbit.webdav.simple.DefaultResourceFilter" />
+        <!-- Nodetype names to be used to filter child nodes.
+             A child node can be filtered if the declaring nodetype of its definition
+             is one of the nodetype names specified in the nodetypes Element.
+             E.g. defining 'rep:root' as filtered nodetype whould result in jcr:system
+             being hidden but no other child node of the root node, since those
+             are defined by the nodetype nt:unstructered.
+        -->
+        <!--
+        <nodetypes>
+            <nodetype>rep:root</nodetype>
+        </nodetypes>
+        -->
+        <!-- Namespace prefixes or uris. Items having a name that matches any of the
+             entries will be filtered.
+        -->
+        <namespaces>
+            <prefix>rep</prefix>
+            <prefix>jcr</prefix>
+            <!--
+            <uri>internal</uri>
+            <uri>http://www.jcp.org/jcr/1.0</uri>
+            -->
+        </namespaces>
+    </filter>
+</config>
+

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/config.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/web.xml?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/web.xml (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/web.xml Mon Oct  3 06:12:18 2005
@@ -179,16 +179,15 @@
             </description>
         </init-param>
         <!--
-            Optional parameter defining namespaces (or uri or prefixes) and/or
-            nodetype names that mark hidden resources.
-            If omitted not resources will be filtered out.
+            Parameter used to configure behaviour of webdav resources such as:
+            - destinction between collections and non-collections
+            - resource filtering
         -->
         <init-param>
-            <param-name>resource-filter</param-name>
-            <param-value>/WEB-INF/filter.xml</param-value>
+            <param-name>resource-config</param-name>
+            <param-value>/WEB-INF/config.xml</param-value>
             <description>
-                Defines namespace (uri or prefix) or nodetype names for hidden 
-                resources.
+                Defines various dav-resource configuration parameters.
             </description>
         </init-param>
         <load-on-startup>3</load-on-startup>

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavLocatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavLocatorFactory.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavLocatorFactory.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavLocatorFactory.java Mon Oct  3 06:12:18 2005
@@ -23,19 +23,45 @@
     /**
      * Create a new <code>DavResourceLocator</code>.
      *
-     * @param prefix
-     * @param requestHandle
+     * @param prefix String consisting of  [scheme:][//authority][path] where
+     * path defines the (imaginary) path to the {@link DavResourceLocator#isRootLocation root location}.
+     * @param href of the resource to be created. The given string may start with
+     * the 'prefix'. Please note, that in contrast to
+     * {@link DavLocatorFactory#createResourceLocator(String, String, String)} the
+     * href is expected to be URL encoded.
      * @return
      */
-    public DavResourceLocator createResourceLocator(String prefix, String requestHandle);
+    public DavResourceLocator createResourceLocator(String prefix, String href);
 
     /**
-     * Create a new <code>DavResourceLocator</code>.
-     * 
+     * Create a new <code>DavResourceLocator</code>. This methods corresponds to
+     * {@link DavLocatorFactory#createResourceLocator(String, String, String, boolean)}
+     * with the flag set to true.
+     *
+     * @param prefix String consisting of  [scheme:][//authority][path] where
+     * path defines the path to the {@link DavResourceLocator#isRootLocation root location}.
+     * @param workspacePath the first segment of the URIs path indicating the
+     * workspace. The implementation may allow a empty String if workspaces
+     * are not supported.
+     * @param resourcePath the URL decoded resource path
+     * @return
+     */
+    public DavResourceLocator createResourceLocator(String prefix, String workspacePath, String resourcePath);
+
+    /**
+     *
      * @param prefix
      * @param workspacePath
-     * @param resourcePath
+     * @param path
+     * @param isResourcePath If true this method returns the same as
+     * {@link DavLocatorFactory#createResourceLocator(String, String, String)},
+     * otherwise the given path is treated as {@link javax.jcr.Item#getPath JCR path}.
+     * The implementation may choose to modify the given item path if it contains
+     * escaped characters due to incompatibility of the JCR path with the URI
+     * definition. I.e. it would undo the modification that was applied when
+     * calling {@link DavResourceLocator#getJcrPath()}.
      * @return
+     * @see DavResourceLocator#getJcrPath()
      */
-    public DavResourceLocator createResourceLocator(String prefix, String workspacePath, String resourcePath);
+    public DavResourceLocator createResourceLocator(String prefix, String workspacePath, String path, boolean isResourcePath);
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResource.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResource.java Mon Oct  3 06:12:18 2005
@@ -169,9 +169,14 @@
      *
      * @param setProperties Set of properties to be added or modified
      * @param removePropertyNames Set of property names to be removed
-     * @throws DavException if an error occurs
+     * @return multistatus response listing the status resulting from
+     * setting and/or removing the specified properties, in order to allow a
+     * detailled multistatus response.
+     * @throws DavException if an error occured. This may be the case if the
+     * general state of the resource prevents any properties to be set or removed
+     * (e.g. due to a lock).
      */
-    public void alterProperties(DavPropertySet setProperties, DavPropertyNameSet removePropertyNames) throws DavException;
+    public MultiStatusResponse alterProperties(DavPropertySet setProperties, DavPropertyNameSet removePropertyNames) throws DavException;
 
     /**
      * Retrieve the resource this resource is internal member of.

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResourceLocator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResourceLocator.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResourceLocator.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResourceLocator.java Mon Oct  3 06:12:18 2005
@@ -73,7 +73,8 @@
     public boolean isSameWorkspace(String workspaceName);
 
     /**
-     * Return the 'href' representation of this locator object.
+     * Return the 'href' representation of this locator object. The implementation
+     * should perform an URL encoding of the resource path.
      *
      * @param isCollection
      * @return 'href' representation of this path
@@ -97,4 +98,16 @@
      * @return the locator factory
      */
     public DavLocatorFactory getFactory();
+
+    /**
+     * An implementation may choose to circumvent the incompatibility of the
+     * JCR path with the URI path by applying an appropriate escaping. This
+     * utility method allows to retrieve the jcr path that corresponds to
+     * the resource path as returned by {#link getResourcePath()}.
+     *
+     * @return a jcr compatible form if the resource path.
+     * @see DavLocatorFactory#createResourceLocator(String, String, String, boolean)
+     * that allows to build a valid <code>DavResourceLocator</code> from a jcr path.
+     */
+    public String getJcrPath();
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavServletResponse.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavServletResponse.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavServletResponse.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavServletResponse.java Mon Oct  3 06:12:18 2005
@@ -75,7 +75,7 @@
      * @param error
      * @throws IOException
      */
-    public void sendErrorResponse(DavException error) throws IOException;
+    public void sendError(DavException error) throws IOException;
 
     /**
      * Send the multistatus response to the client. A multistatus response
@@ -87,7 +87,7 @@
      * @throws IOException
      * @see #SC_MULTI_STATUS
      */
-    public void sendMultiStatusResponse(MultiStatus multistatus) throws IOException;
+    public void sendMultiStatus(MultiStatus multistatus) throws IOException;
 
     /**
      * Send the lock response for a successful LOCK request. The given <code>ActiveLock</code>

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/MultiStatus.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/MultiStatus.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/MultiStatus.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/MultiStatus.java Mon Oct  3 06:12:18 2005
@@ -71,7 +71,8 @@
 
     /**
      * Add response(s) to this multistatus, in order to build a multistatus
-     * as returned for failed COPY, MOVE, LOCK or DELETE requests
+     * as returned for COPY, MOVE, LOCK or DELETE requests resulting in an error
+     * with a resource other than the resource identified in the Request-URI.
      *
      * @param resource
      * @param status

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/MultiStatusResponse.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/MultiStatusResponse.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/MultiStatusResponse.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/MultiStatusResponse.java Mon Oct  3 06:12:18 2005
@@ -28,7 +28,6 @@
  * hold a WebDAV multistatus response. Properties can be added to this response
  * with the respective error/status code.
  */
-// todo: the propstat element may also contain a responsedescription (currently ignored)
 public class MultiStatusResponse implements DavConstants {
 
     private static Logger log = Logger.getLogger(MultiStatusResponse.class);
@@ -88,52 +87,53 @@
      * Note, that the set of property names is ignored in case of a {@link #PROPFIND_ALL_PROP}
      * and {@link #PROPFIND_PROPERTY_NAMES} propFindType.
      *
-     * @param resource The resource to retrieve the property from
-     * @param propNameSet The property name set as obtained from the request body.
+     * @param resource     The resource to retrieve the property from
+     * @param propNameSet  The property name set as obtained from the request body.
      * @param propFindType any of the following values: {@link #PROPFIND_ALL_PROP},
-     * {@link #PROPFIND_BY_PROPERTY}, {@link #PROPFIND_PROPERTY_NAMES}
+     *                     {@link #PROPFIND_BY_PROPERTY}, {@link #PROPFIND_PROPERTY_NAMES}
      */
     public MultiStatusResponse(DavResource resource, DavPropertyNameSet propNameSet,
-			       int propFindType) {
+                               int propFindType) {
         this(resource.getHref());
 
-	// only property names requested
-	if (propFindType == PROPFIND_PROPERTY_NAMES) {
-	    DavPropertyName[] propNames = resource.getPropertyNames();
-	    for (int i = 0; i < propNames.length; i++) {
-		status200.addContent(propNames[i].toXml());
-	    }
-	// all or a specified set of property and their values requested.
-	} else {
-	    // clone set of property, since several resources could use this again
-	    propNameSet = new DavPropertyNameSet(propNameSet);
-	    // Add requested properties or all non-protected properties
-	    DavPropertyIterator iter = resource.getProperties().iterator();
-	    while (iter.hasNext()) {
-		DavProperty wdp = iter.nextProperty();
-		if ((propFindType == PROPFIND_ALL_PROP && !wdp.isProtected()) || propNameSet.remove(wdp.getName())) {
-		    status200.addContent(wdp.toXml());
-		}
-	    }
-
-	    if (propFindType != PROPFIND_ALL_PROP) {
-		Iterator iter1 = propNameSet.iterator();
-		while (iter1.hasNext()) {
-		    DavPropertyName propName = (DavPropertyName) iter1.next();
-		    status404.addContent(propName.toXml());
-		}
-	    }
-	}
-    }
-
-   /**
-    * Constructs an WebDAV multistatus response for a given resource. This
-    * would be used by COPY, MOVE, DELETE, LOCK, UNLOCK that require a multistatus
-    * in case of failure.
-    */
+        // only property names requested
+        if (propFindType == PROPFIND_PROPERTY_NAMES) {
+            DavPropertyName[] propNames = resource.getPropertyNames();
+            for (int i = 0; i < propNames.length; i++) {
+                status200.addContent(propNames[i].toXml());
+            }
+            // all or a specified set of property and their values requested.
+        } else {
+            // clone set of property, since several resources could use this again
+            propNameSet = new DavPropertyNameSet(propNameSet);
+            // Add requested properties or all non-protected properties
+            DavPropertyIterator iter = resource.getProperties().iterator();
+            while (iter.hasNext()) {
+                DavProperty wdp = iter.nextProperty();
+                if ((propFindType == PROPFIND_ALL_PROP && !wdp.isProtected()) || propNameSet.remove(wdp.getName())) {
+                    status200.addContent(wdp.toXml());
+                }
+            }
+
+            if (propFindType != PROPFIND_ALL_PROP) {
+                Iterator iter1 = propNameSet.iterator();
+                while (iter1.hasNext()) {
+                    DavPropertyName propName = (DavPropertyName) iter1.next();
+                    status404.addContent(propName.toXml());
+                }
+            }
+        }
+    }
+
+    /**
+     * Constructs an WebDAV multistatus response for a given resource. This
+     * would be used by COPY, MOVE, DELETE, LOCK that require a multistatus
+     * in case of error with a resource other than the resource identified in the
+     * Request-URI.
+     */
     public MultiStatusResponse(String href, int status) {
         this(href);
-        statusMap.put(new Integer(status), new Element(null));
+        statusMap.put(new Integer(status), null);
     }
 
     /**
@@ -148,17 +148,17 @@
     /**
      * Adds a JDOM element to this response
      *
-     * @param propertyElem the property to add
-     * @param status the status of the response set to select
+     * @param propElem the property to add
+     * @param status   the status of the response set to select
      */
-    private void add(Element propertyElem, int status) {
+    private void add(Element propElem, int status) {
         Integer statusKey = new Integer(status);
-        Element propsContainer = (Element) statusMap.get(statusKey);
+        Object propsContainer = statusMap.get(statusKey);
         if (propsContainer == null) {
             propsContainer = new Element(XML_PROP, NAMESPACE);
             statusMap.put(statusKey, propsContainer);
         }
-        propsContainer.addContent(propertyElem.detach());
+        ((Element) propsContainer).addContent(propElem.detach());
     }
 
     /**
@@ -183,7 +183,7 @@
      * Adds a property to this response
      *
      * @param property the property to add
-     * @param status the status of the response set to select
+     * @param status   the status of the response set to select
      */
     public void add(DavProperty property, int status) {
         add(property.toXml(), status);
@@ -193,7 +193,7 @@
      * Adds a property name to this response
      *
      * @param propertyName the property name to add
-     * @param status the status of the response set to select
+     * @param status       the status of the response set to select
      */
     public void add(DavPropertyName propertyName, int status) {
         add(propertyName.toXml(), status);
@@ -201,6 +201,7 @@
 
     /**
      * Get properties present in this response for the given status code.
+     *
      * @param status
      * @return property set
      */
@@ -208,8 +209,9 @@
         DavPropertySet set = new DavPropertySet();
         Integer key = new Integer(status);
         if (statusMap.containsKey(key)) {
-            Element propElem = (Element) statusMap.get(key);
-            if (propElem != null) {
+            Object mapEntry = statusMap.get(key);
+            if (mapEntry != null) {
+                Element propElem = (Element) mapEntry;
                 Iterator it = propElem.getChildren().iterator();
                 while (it.hasNext()) {
                     Element propEntry = (Element) it.next();
@@ -231,8 +233,9 @@
         DavPropertyNameSet set = new DavPropertyNameSet();
         Integer key = new Integer(status);
         if (statusMap.containsKey(key)) {
-            Element propElem = (Element) statusMap.get(key);
-            if (propElem != null) {
+            Object mapEntry = statusMap.get(key);
+            if (mapEntry != null) {
+                Element propElem = (Element) mapEntry;
                 Iterator it = propElem.getChildren().iterator();
                 while (it.hasNext()) {
                     Element propEntry = (Element) it.next();
@@ -247,7 +250,7 @@
      * @return responseDescription
      */
     public String getResponseDescription() {
-	return responseDescription;
+        return responseDescription;
     }
 
     /**
@@ -271,16 +274,17 @@
         if ("".equals(href)) {
             return null;
         }
-        Element response= new Element(XML_RESPONSE, NAMESPACE);
+        Element response = new Element(XML_RESPONSE, NAMESPACE);
         // add '<href>'
         response.addContent(XmlUtil.hrefToXml(href));
         // add '<propstat>' elements or a single '<status>' element
         Iterator iter = statusMap.keySet().iterator();
         while (iter.hasNext()) {
             Integer statusKey = (Integer) iter.next();
-	    Element prop = (Element) statusMap.get(statusKey);
-            if (prop != null) {
-                Status status = new Status(statusKey.intValue());
+            Object mapEntry = statusMap.get(statusKey);
+            Status status = new Status(statusKey.intValue());
+            if (mapEntry != null) {
+                Element prop = (Element) mapEntry;
                 if (XML_PROP.equals(prop.getName())) {
                     // do not add empty propstat elements
                     if (prop.getContentSize() > 0) {
@@ -292,7 +296,9 @@
                 } else {
                     response.addContent(status.toXml());
                 }
-	    }
+            } else {
+                response.addContent(status.toXml());
+            }
         }
         // add the optional '<responsedescription>' element
         if (responseDescription != null) {
@@ -308,20 +314,20 @@
      *
      * @param responseElement
      * @return new <code>MultiStatusResponse</code> instance
-     * @throws  IllegalArgumentException if the specified element is <code>null</code>
+     * @throws IllegalArgumentException if the specified element is <code>null</code>
      */
     public static MultiStatusResponse createFromXml(Element responseElement) {
         if (responseElement == null) {
-	    throw new IllegalArgumentException("The response element must not be null.");
-	}
-        String href = responseElement.getChildText(XML_HREF, NAMESPACE);
+            throw new IllegalArgumentException("The response element must not be null.");
+        }
+        String href = XmlUtil.hrefFromXml(responseElement.getChild(XML_HREF, NAMESPACE));
         String statusLine = responseElement.getChildText(XML_STATUS, NAMESPACE);
         MultiStatusResponse response = (statusLine != null) ? new MultiStatusResponse(href, Status.createFromStatusLine(statusLine).getStatusCode()) : new MultiStatusResponse(href);
 
         // read propstat elements
         Iterator it = responseElement.getChildren(XML_PROPSTAT, NAMESPACE).iterator();
-	while (it.hasNext()) {
-	    Element propstat = (Element)it.next();
+        while (it.hasNext()) {
+            Element propstat = (Element) it.next();
             Element prop = propstat.getChild(XML_PROP, NAMESPACE);
             String propstatus = propstat.getChildText(XML_STATUS, NAMESPACE);
             if (propstatus != null) {
@@ -331,8 +337,8 @@
                     response.add(propertyElems[i], st.getStatusCode());
                 }
             }
-            // todo: propstat may also contain a responsedescription
-	}
+        // TODO: propstat may also contain a responsedescription
+        }
 
         response.setResponseDescription(responseElement.getChildText(XML_RESPONSEDESCRIPTION, NAMESPACE));
         return response;
@@ -388,7 +394,7 @@
                 //handle the HTTP-Version
                 at = statusLine.indexOf(" ", at);
                 if (at <= 0) {
-                    log.warn("Unable to parse HTTP-Version from the status line: '"+ statusLine + "'");
+                    log.warn("Unable to parse HTTP-Version from the status line: '" + statusLine + "'");
                 }
                 String version = (statusLine.substring(start, at)).toUpperCase();
                 //advance through spaces
@@ -404,7 +410,7 @@
                     int code = Integer.parseInt(statusLine.substring(at, to));
                     status = new Status(code);
                 } catch (NumberFormatException e) {
-                    throw new IllegalArgumentException("Unable to parse status code from status line: '"+ statusLine + "'");
+                    throw new IllegalArgumentException("Unable to parse status code from status line: '" + statusLine + "'");
                 }
                 //handle the Reason-Phrase
                 String phrase = "";

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java Mon Oct  3 06:12:18 2005
@@ -137,7 +137,7 @@
      * @see DavServletRequest#getRequestLocator()
      */
     public DavResourceLocator getRequestLocator() {
-        String path = Text.unescape(getRequestURI());
+        String path = getRequestURI();
         String ctx = getContextPath();
         if (path.startsWith(ctx)) {
             path = path.substring(ctx.length());
@@ -159,13 +159,13 @@
             try {
                 URI uri = new URI(destination);
                 if (uri.getAuthority().equals(httpRequest.getHeader("Host"))) {
-                    destination = Text.unescape(uri.getRawPath());
+                    destination = uri.getRawPath();
                 }
             } catch (URISyntaxException e) {
                 log.debug("Destination is path is not a valid URI (" + e.getMessage() + ".");
                 int pos = destination.lastIndexOf(":");
                 if (pos > 0) {
-                    destination = Text.unescape(destination.substring(destination.indexOf("/", pos)));
+                    destination = destination.substring(destination.indexOf("/", pos));
                     log.debug("Tried to retrieve resource destination path from invalid URI: " + destination);
                 }
             }
@@ -454,10 +454,10 @@
     }
 
     /**
-     * MTest if the if header matches the given resource. The comparison is
+     * Test if the if header matches the given resource. The comparison is
      * made with the {@link DavResource#getHref()
      * resource href} and the token returned from an exclusive write lock present on
-     * the resource. An empty strong ETag is currently assumed.<br>
+     * the resource.<br>
      * NOTE: If either the If header or the resource is <code>null</code> or if
      * the resource has not applied an exclusive write lock the preconditions are met.
      * If in contrast the lock applied to the given resource returns a
@@ -475,7 +475,7 @@
     public boolean matchesIfHeader(DavResource resource) {
         // no ifheader, no resource or no write lock on resource
         // >> preconditions ok so far
-        if (ifHeader == null || resource == null || !resource.hasLock(Type.WRITE, Scope.EXCLUSIVE)) {
+        if (!ifHeader.hasValue() || resource == null || !resource.hasLock(Type.WRITE, Scope.EXCLUSIVE)) {
             return true;
         }
 
@@ -489,6 +489,14 @@
     }
 
     /**
+     * @see DavServletRequest#matchesIfHeader(String, String, String)
+     * @see IfHeader#matches(String, String, String)
+     */
+    public boolean matchesIfHeader(String href, String token, String eTag) {
+        return ifHeader.matches(href, token, isStrongETag(eTag) ?  eTag : "");
+    }
+
+    /**
      * Returns the strong etag present on the given resource or empty string
      * if either the resource does not provide any etag or if the etag is weak.
      *
@@ -497,9 +505,9 @@
      */
     private String getStrongETag(DavResource resource) {
         DavProperty prop = resource.getProperty(DavPropertyName.GETETAG);
-        if (prop != null) {
+        if (prop != null && prop.getValue() != null) {
             String etag = prop.getValue().toString();
-            if (etag != null && etag.length() > 0 && !etag.startsWith("W\\")) {
+            if (isStrongETag(etag)) {
                 return etag;
             }
         }
@@ -508,11 +516,13 @@
     }
 
     /**
-     * @see DavServletRequest#matchesIfHeader(String, String, String)
-     * @see IfHeader#matches(String, String, String)
+     * Returns true if the given string represents a strong etag.
+     *
+     * @param eTag
+     * @return true, if its a strong etag
      */
-    public boolean matchesIfHeader(String href, String token, String eTag) {
-        return ifHeader.matches(href, token, eTag);
+    private boolean isStrongETag(String eTag) {
+        return eTag != null && eTag.length() > 0 && !eTag.startsWith("W\\");
     }
 
     //-----------------------------< TransactionDavServletRequest Interface >---

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java Mon Oct  3 06:12:18 2005
@@ -58,9 +58,9 @@
      *
      * @param exception
      * @throws IOException
-     * @see DavServletResponse#sendErrorResponse(org.apache.jackrabbit.webdav.DavException)
+     * @see DavServletResponse#sendError(org.apache.jackrabbit.webdav.DavException)
      */
-    public void sendErrorResponse(DavException exception) throws IOException {
+    public void sendError(DavException exception) throws IOException {
         Element errorElem = exception.getError();
         if (errorElem == null || errorElem.getChildren().size() == 0) {
             httpResponse.sendError(exception.getErrorCode(), exception.getStatusPhrase());
@@ -74,9 +74,9 @@
      *
      * @param multistatus
      * @throws IOException
-     * @see DavServletResponse#sendMultiStatusResponse(org.apache.jackrabbit.webdav.MultiStatus)
+     * @see DavServletResponse#sendMultiStatus(org.apache.jackrabbit.webdav.MultiStatus)
      */
-    public void sendMultiStatusResponse(MultiStatus multistatus) throws IOException {
+    public void sendMultiStatus(MultiStatus multistatus) throws IOException {
         sendXmlResponse(multistatus.toXml(), SC_MULTI_STATUS);
     }
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/header/IfHeader.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/header/IfHeader.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/header/IfHeader.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/header/IfHeader.java Mon Oct  3 06:12:18 2005
@@ -150,6 +150,15 @@
     }
 
     /**
+     * Returns true if an If header was present in the given request. False otherwise.
+     *
+     * @return  true if an If header was present.
+     */
+    public boolean hasValue() {
+        return ifHeader != null;
+    }
+
+    /**
      * Tries to match the contents of the <em>If</em> header with the given
      * token and etag values with the restriction to only check for the tag.
      * <p>

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/util/XmlUtil.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/util/XmlUtil.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/util/XmlUtil.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/util/XmlUtil.java Mon Oct  3 06:12:18 2005
@@ -17,6 +17,7 @@
 
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.util.Text;
 import org.jdom.Element;
 
 /**
@@ -67,12 +68,29 @@
     }
 
     /**
-     * Builds a 'href' Xml element from the given String
+     * Builds a 'DAV:href' Xml element from the given href. Please note, that
+     * the path present in the given String should be properly
+     * {@link Text#escapePath(String) escaped} in order to prevent problems with
+     * WebDAV clients.
      *
      * @param href String representing the text of the 'href' Xml element
      * @return Xml representation of a 'href' according to RFC 2518.
      */
     public static Element hrefToXml(String href) {
         return new Element(XML_HREF, NAMESPACE).setText(href);
+    }
+
+    /**
+     * Verifies that the given element is a DAV:href element, retrieves the
+     * element text.
+     *
+     * @param hrefElement a DAV:href element
+     * @return the URL decoded element text or empty String if the given element is empty.
+     */
+    public static String hrefFromXml(Element hrefElement) {
+        if (hrefElement == null || !XML_HREF.equals(hrefElement.getName()) || !NAMESPACE.equals(hrefElement.getNamespace())) {
+            throw new IllegalArgumentException("DAV:href element expected.");
+        }
+        return hrefElement.getText();
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionControlledResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionControlledResource.java?rev=293331&r1=293330&r2=293331&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionControlledResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionControlledResource.java Mon Oct  3 06:12:18 2005
@@ -18,8 +18,6 @@
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.MultiStatus;
 import org.apache.jackrabbit.webdav.property.DavPropertyName;
-import org.apache.jackrabbit.webdav.property.DavPropertySet;
-import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
 
 /**
  * The <code>VersionControlledResource</code> represents in contrast to the
@@ -177,7 +175,6 @@
      * </pre>
      *
      * @see #merge(MergeInfo)
-     * @see #resolveMergeConflict(DavPropertySet, DavPropertyNameSet)
      */
     public static final DavPropertyName MERGE_SET = DavPropertyName.create("merge-set", DeltaVConstants.NAMESPACE);
 
@@ -192,7 +189,6 @@
      * </pre>
      *
      * @see #merge(MergeInfo)
-     * @see #resolveMergeConflict(DavPropertySet, DavPropertyNameSet)
      */
     public static final DavPropertyName AUTO_MERGE_SET = DavPropertyName.create("auto-merge-set", DeltaVConstants.NAMESPACE);
 
@@ -238,26 +234,6 @@
      * @throws DavException
      */
     public MultiStatus merge(MergeInfo mergeInfo) throws DavException;
-
-    /**
-     * Resolve one or multiple merge conflicts present on this resource. Please
-     * note that the 'setProperties' or 'removeProperties' set my contain additional
-     * resource properties, that need to be changed. Those properties are left
-     * untouched, whereas the {@link #AUTO_MERGE_SET}, {@link #MERGE_SET} and
-     * the {@link #PREDECESSOR_SET} are removed from the list upon successful
-     * resolution of a merge conflict.<br>
-     * If the removeProperties or setProperties set do not contain any of the
-     * mentioned resource properties or if the value of those properties do
-     * not allow for a resolution of an existing merge conflict, this METHODS
-     * returns silently.
-     *
-     * @param setProperties
-     * @param removePropertyNames
-     * @throws DavException the set or remove property sets attempt to resolve
-     * a non-existing merge conflict of if another error occurs while resolving
-     * an existing conflict.
-     */
-    public void resolveMergeConflict(DavPropertySet setProperties, DavPropertyNameSet removePropertyNames) throws DavException;
 
     /**
      * Modify the labels of the version referenced by the DAV:checked-in property



Mime
View raw message