jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r157746 [1/2] - in incubator/jackrabbit/trunk/contrib/jcr-server: client/ server/ server/src/java/org/apache/jackrabbit/server/ server/src/java/org/apache/jackrabbit/server/simple/ server/src/java/org/apache/jackrabbit/server/simple/dav/ server/src/java/org/apache/jackrabbit/webdav/spi/ server/src/java/org/apache/jackrabbit/webdav/spi/nodetype/ server/src/java/org/apache/jackrabbit/webdav/spi/property/ webapp/ webdav/ webdav/src/java/org/apache/jackrabbit/webdav/ webdav/src/java/org/apache/jackrabbit/webdav/header/
Date Wed, 16 Mar 2005 13:36:14 GMT
Author: tripod
Date: Wed Mar 16 05:36:05 2005
New Revision: 157746

URL: http://svn.apache.org/viewcvs?view=rev&rev=157746
Log:
- refactoring of DavSession acquisition in jcr-server (JCR-66)
- some cleanup

Added:
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavSessionImpl.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavSessionProviderImpl.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/VersionControlledItemCollection.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/property/
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/property/LengthsProperty.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/property/ValuesProperty.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavSessionProvider.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/header/
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/header/DepthHeader.java   (with props)
Modified:
    incubator/jackrabbit/trunk/contrib/jcr-server/client/   (props changed)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/   (props changed)
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/JCRWebdavServer.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/WebdavServlet.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/AbstractItemResource.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/AbstractResource.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DavResourceFactoryImpl.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemCollection.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemResource.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/RootItemCollection.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/nodetype/NodeTypeProperty.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webapp/   (props changed)
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/   (props changed)
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavConstants.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavException.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavMethods.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/MultiStatusResponse.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/client/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Mar 16 05:36:05 2005
@@ -0,0 +1 @@
+target

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Mar 16 05:36:05 2005
@@ -0,0 +1 @@
+target

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/JCRWebdavServer.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/JCRWebdavServer.java?view=diff&r1=157745&r2=157746
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/JCRWebdavServer.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/JCRWebdavServer.java Wed Mar 16 05:36:05 2005
@@ -27,7 +27,7 @@
 /**
  * <code>JCRWebdavServer</code>...
  */
-public class JCRWebdavServer {
+public class JCRWebdavServer implements DavSessionProvider {
 
     /** the default logger */
     private static Logger log = Logger.getLogger(JCRWebdavServer.class);
@@ -47,6 +47,7 @@
 	this.repository = repository;
     }
 
+    //---------------------------------------< DavSessionProvider interface >---
     /**
      * Acquires a DavSession either from the session cache or creates a new
      * one by login to the repository.
@@ -54,6 +55,7 @@
      *
      * @param request
      * @throws DavException if no session could be obtained.
+     * @see DavSessionProvider#acquireSession(org.apache.jackrabbit.webdav.WebdavRequest)
      */
     public void acquireSession(WebdavRequest request)
             throws DavException {
@@ -67,12 +69,15 @@
      * cache.
      *
      * @param request
+     * @see DavSessionProvider#releaseSession(org.apache.jackrabbit.webdav.WebdavRequest)
      */
     public void releaseSession(WebdavRequest request) {
 	DavSession session = request.getDavSession();
 	if (session != null) {
 	    session.removeReference(request);
 	}
+	// remove the session from the request
+	request.setDavSession(null);
     }
 
     //--------------------------------------------------------------------------

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/WebdavServlet.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/WebdavServlet.java?view=diff&r1=157745&r2=157746
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/WebdavServlet.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/WebdavServlet.java Wed Mar 16 05:36:05 2005
@@ -18,18 +18,15 @@
 import org.apache.jackrabbit.server.simple.dav.lock.SimpleLockManager;
 import org.apache.jackrabbit.server.simple.dav.ResourceFactoryImpl;
 import org.apache.jackrabbit.server.simple.dav.LocatorFactoryImpl;
+import org.apache.jackrabbit.server.simple.dav.DavSessionProviderImpl;
 
 import javax.servlet.http.*;
 import javax.servlet.*;
-import javax.jcr.*;
 import java.io.*;
-import java.util.HashSet;
 
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.server.AbstractWebdavServlet;
 import org.apache.jackrabbit.webdav.*;
-import org.apache.jackrabbit.webdav.spi.JcrDavException;
-import org.apache.jackrabbit.client.RepositoryAccessServlet;
 
 /**
  * WebdavServlet provides webdav support (level 1 and 2 complient) for repository
@@ -57,6 +54,9 @@
     /** the locator factory */
     private DavLocatorFactory locatorFactory;
 
+    /** the session provider */
+    private DavSessionProvider sessionProvider;
+
     /** the repository prefix retrieved from config */
     private static String resourcePathPrefix;
 
@@ -77,16 +77,6 @@
     }
 
     /**
-     * Returns the configured path prefix
-     *
-     * @return resourcePathPrefix
-     * @see #INIT_PARAM_RESOURCE_PATH_PREFIX
-     */
-    public static String getPathPrefix() {
-	return resourcePathPrefix;
-    }
-
-    /**
      * Service the given request.
      *
      * @param request
@@ -102,10 +92,10 @@
             WebdavResponse webdavResponse = new WebdavResponseImpl(response);
 
             // make sure there is a authenticated user
-	    DavSession session = getSession(webdavRequest);
-	    if (session == null) {
-		return;
-	    }
+	    getDavSessionProvider().acquireSession(webdavRequest);
+	    if (webdavRequest.getDavSession() == null) {
+ 		return;
+ 	    }
 
 	    // check matching if=header for lock-token relevant operations
 	    DavResource resource = createResource(webdavRequest.getRequestLocator(), webdavRequest, webdavResponse);
@@ -159,6 +149,8 @@
 		    // GET, HEAD, TRACE......
 		    super.service(request, response);
 	    }
+	    getDavSessionProvider().releaseSession(webdavRequest);
+
 	} catch (DavException e) {
 	    response.sendError(e.getErrorCode());
 	}
@@ -193,92 +185,35 @@
     }
 
     /**
-     * Retrieve the repository session for the given request object and force a header
-     * authentication if necessary.
+     * Returns the configured path prefix
      *
-     * @param request
-     * @return a repository session for the given request or <code>null</code> if the
-     * authentication is missing. In the latter case the authentication is
-     * forces by the response code.
-     * @throws DavException
+     * @return resourcePathPrefix
+     * @see #INIT_PARAM_RESOURCE_PATH_PREFIX
      */
-    private DavSession getSession(WebdavRequest request) throws DavException {
-        try {
-	    Credentials creds = RepositoryAccessServlet.getCredentialsFromHeader(request.getHeader(DavConstants.HEADER_AUTHORIZATION));
-	    if (creds == null) {
-		// generate anonymous login to gain write access
-		creds = new SimpleCredentials("anonymous", "anonymous".toCharArray());
-	    }
-            Session repSession = RepositoryAccessServlet.getRepository().login(creds);
-	    DavSession ds = new DavSessionImpl(repSession);
-	    request.setDavSession(ds);
-	    return ds;
-        } catch (RepositoryException e) {
-	    throw new JcrDavException(e);
-	} catch (ServletException e) {
-	    throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
-	}
+    public static String getPathPrefix() {
+	return resourcePathPrefix;
     }
 
     /**
-     * Inner class implementing the DavSession interface
-     */
-    private class DavSessionImpl implements DavSession {
-
-	/** the underlaying jcr session */
-        private final Session session;
-
-	/** the lock tokens of this session */
-	private final HashSet lockTokens = new HashSet();
-
-	/**
-	 * Creates a new DavSession based on a jcr session
-	 * @param session
-	 */
-        private DavSessionImpl(Session session) {
-            this.session = session;
-        }
-
-	/**
-	 * @see DavSession#addReference(Object)
-	 */
-        public void addReference(Object reference) {
-            throw new UnsupportedOperationException("No yet implemented.");
-        }
-
-	/**
-	 * @see DavSession#removeReference(Object)
-	 */
-        public void removeReference(Object reference) {
-            throw new UnsupportedOperationException("No yet implemented.");
-        }
-
-	/**
-	 * @see DavSession#getRepositorySession()
-	 */
-        public Session getRepositorySession() {
-            return session;
-        }
-
-	/**
-	 * @see DavSession#addLockToken(String)
-	 */
-	public void addLockToken(String token) {
-	    lockTokens.add(token);
-	}
-
-	/**
-	 * @see DavSession#getLockTokens()
-	 */
-	public String[] getLockTokens() {
-	    return (String[]) lockTokens.toArray(new String[lockTokens.size()]);
+     * Returns the <code>DavSessionProvider</code>. If no session provider has
+     * been set or created a new instance of {@link DavSessionProviderImpl} is
+     * return.
+     *
+     * @return the session provider
+     */
+    public DavSessionProvider getDavSessionProvider() {
+	if (sessionProvider == null) {
+	    sessionProvider = new DavSessionProviderImpl();
 	}
+	return sessionProvider;
+    }
 
-	/**
-	 * @see DavSession#removeLockToken(String)
-	 */
-	public void removeLockToken(String token) {
-	    lockTokens.remove(token);
-	}
+    /**
+     * Set the session provider
+     *
+     * @param sessionProvider
+     */
+    public void setDavSessionProvider(DavSessionProvider sessionProvider) {
+	this.sessionProvider = sessionProvider;
     }
 }

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavSessionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavSessionImpl.java?view=auto&rev=157746
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavSessionImpl.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavSessionImpl.java Wed Mar 16 05:36:05 2005
@@ -0,0 +1,84 @@
+/*
+ * 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.server.simple.dav;
+
+import javax.jcr.Session;
+import java.util.HashSet;
+
+import org.apache.jackrabbit.webdav.DavSession;
+
+/**
+ * Simple implementation of the {@link DavSession} interface. Stores
+ * lock tokens but does not yet store references.
+ */
+public class DavSessionImpl implements DavSession {
+
+    /** the underlaying jcr session */
+    private final Session session;
+
+    /** the lock tokens of this session */
+    private final HashSet lockTokens = new HashSet();
+
+    /**
+     * Creates a new DavSession based on a jcr session
+     * @param session
+     */
+    public DavSessionImpl(Session session) {
+        this.session = session;
+    }
+
+    /**
+     * @see DavSession#addReference(Object)
+     */
+    public void addReference(Object reference) {
+        throw new UnsupportedOperationException("No yet implemented.");
+    }
+
+    /**
+     * @see DavSession#removeReference(Object)
+     */
+    public void removeReference(Object reference) {
+        throw new UnsupportedOperationException("No yet implemented.");
+    }
+
+    /**
+     * @see DavSession#getRepositorySession()
+     */
+    public Session getRepositorySession() {
+        return session;
+    }
+
+    /**
+     * @see DavSession#addLockToken(String)
+     */
+    public void addLockToken(String token) {
+        lockTokens.add(token);
+    }
+
+    /**
+     * @see DavSession#getLockTokens()
+     */
+    public String[] getLockTokens() {
+        return (String[]) lockTokens.toArray(new String[lockTokens.size()]);
+    }
+
+    /**
+     * @see DavSession#removeLockToken(String)
+     */
+    public void removeLockToken(String token) {
+        lockTokens.remove(token);
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavSessionImpl.java
------------------------------------------------------------------------------
    svn = 

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavSessionProviderImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavSessionProviderImpl.java?view=auto&rev=157746
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavSessionProviderImpl.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavSessionProviderImpl.java Wed Mar 16 05:36:05 2005
@@ -0,0 +1,74 @@
+/*
+ * 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.server.simple.dav;
+
+import javax.jcr.*;
+import javax.servlet.ServletException;
+
+import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.webdav.spi.JcrDavException;
+import org.apache.jackrabbit.client.RepositoryAccessServlet;
+
+/**
+ * Simple implementation of the {@link DavSessionProvider}
+ * interface that uses the {@link RepositoryAccessServlet} to locate
+ * credentials in the request, log into the respository, and provide
+ * a {@link DavSession} to the request.
+ */
+public class DavSessionProviderImpl implements DavSessionProvider {
+
+    /**
+     * Acquires a DavSession. Upon success, the WebdavRequest will
+     * reference that session.
+     *
+     * A session will not be available if credentials can not be found
+     * in the request (meaning that the  request has not been
+     * authenticated).
+     *
+     * @param request
+     * @throws DavException if a problem occurred while obtaining the
+     * session
+     * @see DavSessionProvider#acquireSession(org.apache.jackrabbit.webdav.WebdavRequest)
+     */
+    public void acquireSession(WebdavRequest request) throws DavException {
+        try {
+            Credentials creds = RepositoryAccessServlet.getCredentialsFromHeader(request.getHeader(DavConstants.HEADER_AUTHORIZATION));
+            if (creds == null) {
+                // generate anonymous login to gain write access
+                creds = new SimpleCredentials("anonymous", "anonymous".toCharArray());
+            }
+            Session repSession = RepositoryAccessServlet.getRepository().login(creds);
+            DavSession ds = new DavSessionImpl(repSession);
+            request.setDavSession(ds);
+        } catch (RepositoryException e) {
+	    throw new JcrDavException(e);
+	} catch (ServletException e) {
+	    throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
+	}
+    }
+
+    /**
+     * Only removes the <code>DavSession</code> object from the given request object.
+     * No further actions required, since <code>DavSessionImpl</code> does not
+     * allow to keep track of references to it.
+     *
+     * @param request
+     * @see DavSessionProvider#releaseSession(org.apache.jackrabbit.webdav.WebdavRequest)
+     */
+    public void releaseSession(WebdavRequest request) {
+        request.setDavSession(null);
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavSessionProviderImpl.java
------------------------------------------------------------------------------
    svn = 

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

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/AbstractItemResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/AbstractItemResource.java?view=diff&r1=157745&r2=157746
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/AbstractItemResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/AbstractItemResource.java Wed Mar 16 05:36:05 2005
@@ -39,8 +39,8 @@
  * <code>AbstractItemResource</code> covers common functionality for the various
  * resources, that represent a repository item.
  */
-abstract class AbstractItemResource extends AbstractResource implements DavResource,
-        SearchResource, DeltaVResource, ItemResourceConstants {
+abstract class AbstractItemResource extends AbstractResource implements
+    SearchResource, DeltaVResource, ItemResourceConstants {
 
     private static Logger log = Logger.getLogger(AbstractItemResource.class);
 
@@ -422,8 +422,30 @@
             properties.add(new DefaultDavProperty(DeltaVConstants.CREATOR_DISPLAYNAME, null, true));
             properties.add(new DefaultDavProperty(DeltaVConstants.COMMENT, null, true));
 
+
+	    // 'workspace' property as defined by RFC 3253
+	    String workspaceHref = getWorkspaceHref();
+	    if (workspaceHref != null) {
+		properties.add(new HrefProperty(DeltaVConstants.WORKSPACE, workspaceHref, true));
+	    }
             // TODO: required supported-live-property-set
         }
+    }
+
+    /**
+     * @return href of the workspace or <code>null</code> if this resource
+     * does not represent a repository item.
+     */
+    private String getWorkspaceHref() {
+        String workspaceHref = null;
+	DavResourceLocator locator = getLocator();
+        if (locator != null && locator.getWorkspaceName() != null) {
+            workspaceHref = locator.getHref(isCollection());
+            if (locator.getResourcePath() != null) {
+                workspaceHref = workspaceHref.substring(workspaceHref.indexOf(locator.getResourcePath()));
+            }
+        }
+        return workspaceHref;
     }
 
     /**

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/AbstractResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/AbstractResource.java?view=diff&r1=157745&r2=157746
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/AbstractResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/AbstractResource.java Wed Mar 16 05:36:05 2005
@@ -24,8 +24,6 @@
 import org.apache.jackrabbit.webdav.spi.transaction.TxLockManagerImpl;
 import org.apache.jackrabbit.webdav.observation.*;
 import org.apache.jackrabbit.webdav.util.Text;
-import org.apache.jackrabbit.webdav.property.HrefProperty;
-import org.apache.jackrabbit.webdav.version.DeltaVConstants;
 import org.apache.jackrabbit.webdav.version.SupportedMethodSetProperty;
 import org.apache.jackrabbit.webdav.lock.*;
 import org.apache.jackrabbit.webdav.property.*;
@@ -416,27 +414,7 @@
         SubscriptionDiscovery subsDiscovery = subsMgr.getSubscriptionDiscovery(this);
         properties.add(subsDiscovery);
 
-        // 'workspace' property as defined by RFC 3253
-        String workspaceHref = getWorkspaceHref();
-        if (workspaceHref != null) {
-           properties.add(new HrefProperty(DeltaVConstants.WORKSPACE, workspaceHref, true));
-        }
         properties.add(new SupportedMethodSetProperty(getSupportedMethods().split(",\\s")));
-    }
-
-    /**
-     * @return href of the workspace or <code>null</code> if this resource
-     * does not represent a repository item.
-     */
-    private String getWorkspaceHref() {
-        String workspaceHref = null;
-        if (locator != null && locator.getWorkspaceName() != null) {
-            workspaceHref = locator.getHref(isCollection());
-            if (locator.getResourcePath() != null) {
-                workspaceHref = workspaceHref.substring(workspaceHref.indexOf(locator.getResourcePath()));
-            }
-        }
-        return workspaceHref;
     }
 
     /**

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DavResourceFactoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DavResourceFactoryImpl.java?view=diff&r1=157745&r2=157746
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DavResourceFactoryImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DavResourceFactoryImpl.java Wed Mar 16 05:36:05 2005
@@ -25,7 +25,6 @@
 import org.apache.jackrabbit.webdav.version.VersionControlledResource;
 import org.apache.jackrabbit.webdav.spi.version.VersionItemCollection;
 import org.apache.jackrabbit.webdav.spi.version.VersionHistoryItemCollection;
-import org.apache.jackrabbit.webdav.spi.version.VersionControlledItemCollection;
 import org.apache.jackrabbit.webdav.spi.transaction.TxLockManagerImpl;
 
 import javax.jcr.*;
@@ -136,11 +135,12 @@
         try {
             resource = createResourceForItem(locator, session);
         } catch (RepositoryException e) {
-            log.info("Creating resource for non-existing repository item...");
+            log.info("Creating resource for non-existing repository item ...");
             if (locator.isRootLocation()) {
                 resource =  new RootCollection(locator, session, this);
             } else {
-                throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, "Failed to create resource for "+locator.getHref(false));
+		// todo: is this correct?
+		resource = new VersionControlledItemCollection(locator, session, this);
             }
         }
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemCollection.java?view=diff&r1=157745&r2=157746
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemCollection.java Wed Mar 16 05:36:05 2005
@@ -122,7 +122,7 @@
                 Node n = (Node)item;
                 NodeType[] existingMixin = n.getMixinNodeTypes();
                 NodeTypeProperty mix = new NodeTypeProperty(property);
-                List mixins = mix.getNodeTypeNames();
+                Set mixins = mix.getNodeTypeNames();
 
                 for (int i = 0; i < existingMixin.length; i++) {
                     String name = existingMixin[i].getName();

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemResource.java?view=diff&r1=157745&r2=157746
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemResource.java Wed Mar 16 05:36:05 2005
@@ -21,9 +21,10 @@
 import org.apache.jackrabbit.webdav.DavResource;
 import org.apache.jackrabbit.webdav.DavResourceIterator;
 import org.apache.jackrabbit.webdav.DavResourceIteratorImpl;
+import org.apache.jackrabbit.webdav.spi.property.ValuesProperty;
+import org.apache.jackrabbit.webdav.spi.property.LengthsProperty;
 import org.apache.jackrabbit.webdav.lock.*;
 import org.apache.jackrabbit.core.util.ValueHelper;
-import org.jdom.Element;
 
 import javax.jcr.*;
 import java.io.*;
@@ -110,7 +111,7 @@
                 Value val = ValueHelper.convert(String.valueOf(property.getValue()), type);
                 prop.setValue(val);
             } else if (property.getName().equals(JCR_VALUES)) {
-                prop.setValue(new ValuesProperty(property).getValues());
+                prop.setValue(new ValuesProperty(property).getValues(prop.getType()));
             } else {
                 throw new DavException(DavServletResponse.SC_CONFLICT);
             }
@@ -247,133 +248,5 @@
             log.error("Error while retrieving property definition: " + e.getMessage());
         }
         return false;
-    }
-
-    //------------------------------------------------------< inner classes >---
-    /**
-     * <code>ValuesProperty</code> extends {@link DavProperty} providing
-     * utilities to handle the multiple values of the property item represented
-     * by this resource.
-     */
-    private class ValuesProperty extends AbstractDavProperty {
-
-        private final Element[] value;
-
-        /**
-         * Wrap the specified <code>DavProperty</code> in a new <code>ValuesProperty</code>.
-         *
-         * @param property
-         */
-        private ValuesProperty(DavProperty property) {
-            super(JCR_VALUES, false);
-
-            if (!JCR_VALUES.equals(property.getName())) {
-               throw new IllegalArgumentException("ValuesProperty may only be created with a property that has name="+JCR_VALUES.getName());
-            }
-
-            Element[] elems = new Element[0];
-            if (property.getValue() instanceof List) {
-                Iterator elemIt = ((List)property.getValue()).iterator();
-                ArrayList valueElements = new ArrayList();
-                while (elemIt.hasNext()) {
-                    Object el = elemIt.next();
-                    /* make sure, only Elements with name 'value' are used for
-                     * the 'value' field. any other content (other elements, text,
-                     * comment etc.) is ignored. NO bad-request/conflict error is
-                     * thrown.
-                     */
-                    if (el instanceof Element && "value".equals(((Element)el).getName())) {
-                        valueElements.add(el);
-                    }
-                }
-                /* fill the 'value' with the valid 'value' elements found before */
-                elems = (Element[])valueElements.toArray(new Element[valueElements.size()]);
-            } else {
-                new IllegalArgumentException("ValuesProperty may only be created with a property that has a list of 'value' elements as content.");
-            }
-            // finally set the value to the DavProperty
-            value = elems;
-        }
-
-        /**
-         * Create a new <code>ValuesProperty</code> from the given {@link Value Value
-         * array}.
-         *
-         * @param values Array of Value objects as obtained from the JCR property.
-         */
-        private ValuesProperty(Value[] values) throws ValueFormatException, RepositoryException {
-            super(JCR_VALUES, false);
-
-            Element[] propValue = new Element[values.length];
-            for (int i = 0; i < values.length; i++) {
-                propValue[i] = new Element(XML_VALUE, ItemResourceConstants.NAMESPACE);
-                propValue[i].addContent(values[i].getString());
-            }
-            // finally set the value to the DavProperty
-            value = propValue;
-        }
-
-        /**
-         * Converts the value of this property to a {@link javax.jcr.Value value array}.
-         * Please note, that the convertion is done by using the {@link ValueHelper}
-         * class that is not part of the JSR170 API.
-         *
-         * @return Array of Value objects
-         * @throws RepositoryException
-         */
-        private Value[] getValues() throws ValueFormatException, RepositoryException {
-            Element[] propValue = (Element[])getValue();
-            Value[] values = new Value[propValue.length];
-            for (int i = 0; i < propValue.length; i++) {
-                values[i] = ValueHelper.convert(propValue[i].getText(), ((Property)item).getType());
-            }
-            return values;
-        }
-
-        /**
-         * Returns an array of {@link Element}s representing the value of this
-         * property.
-         *
-         * @return an array of {@link Element}s
-         */
-        public Object getValue() {
-            return value;
-        }
-    }
-
-    /**
-     * <code>LengthsProperty</code> extends {@link DavProperty} providing
-     * utilities to handle the multiple lengths of the property item represented
-     * by this resource.
-     */
-    private class LengthsProperty extends AbstractDavProperty {
-
-        private final Element[] value;
-
-        /**
-         * Create a new <code>LengthsProperty</code> from the given long array.
-         *
-         * @param lengths as retrieved from the JCR property
-         */
-        private LengthsProperty(long[] lengths) {
-            super(JCR_LENGTHS, false);
-
-            Element[] elems = new Element[lengths.length];
-            for (int i = 0; i < lengths.length; i++) {
-                elems[i] = new Element(XML_LENGTH, ItemResourceConstants.NAMESPACE);
-                elems[i].addContent(String.valueOf(lengths[i]));
-            }
-            this.value = elems;
-        }
-
-        /**
-         * Returns an array of {@link Element}s representing the value of this
-         * property.
-         *
-         * @return an array of {@link Element}s
-         */
-        public Object getValue() {
-            return value;
-        }
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/RootItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/RootItemCollection.java?view=diff&r1=157745&r2=157746
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/RootItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/RootItemCollection.java Wed Mar 16 05:36:05 2005
@@ -17,7 +17,6 @@
 
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.webdav.*;
-import org.apache.jackrabbit.webdav.spi.version.VersionControlledItemCollection;
 
 /**
  * <code>RootItemCollection</code> represents the root node of the underlaying

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/VersionControlledItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/VersionControlledItemCollection.java?view=auto&rev=157746
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/VersionControlledItemCollection.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/VersionControlledItemCollection.java Wed Mar 16 05:36:05 2005
@@ -0,0 +1,582 @@
+/*
+ * 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.spi;
+
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.webdav.property.*;
+import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.webdav.version.*;
+import org.apache.jackrabbit.webdav.version.report.*;
+
+import javax.jcr.*;
+import javax.jcr.observation.*;
+import javax.jcr.observation.EventListener;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionHistory;
+import java.util.List;
+
+/**
+ * <code>VersionControlledItemCollection</code> represents a JCR node item and
+ * covers all functionality related to versioning of {@link Node}s.
+ *
+ * @see Node
+ */
+public class VersionControlledItemCollection extends DefaultItemCollection
+        implements VersionControlledResource {
+
+    private static Logger log = Logger.getLogger(VersionControlledItemCollection.class);
+
+    /**
+     * Create a new <code>VersionControlledItemCollection</code>.
+     *
+     * @param locator
+     * @param session
+     */
+    public VersionControlledItemCollection(DavResourceLocator locator, DavSession session, DavResourceFactory factory) {
+        super(locator, session, factory);
+        if (exists() && !(item instanceof Node)) {
+            throw new IllegalArgumentException("A collection resource can not be constructed from a Property item.");
+        }
+    }
+
+    //----------------------------------------------< DavResource interface >---
+    /**
+     * Return a comma separated string listing the supported method names.
+     *
+     * @return the supported method names.
+     * @see org.apache.jackrabbit.webdav.DavResource#getSupportedMethods()
+     */
+    public String getSupportedMethods() {
+        StringBuffer sb = new StringBuffer(super.getSupportedMethods());
+        // Versioning support
+        sb.append(", ").append(VersionableResource.METHODS);
+        if (this.isVersionControlled()) {
+            try {
+                if (((Node)item).isCheckedOut()) {
+                    sb.append(", ").append(VersionControlledResource.methods_checkedOut);
+                } else {
+                    sb.append(", ").append(VersionControlledResource.methods_checkedIn);
+                }
+            } catch (RepositoryException e) {
+                // should not occur.
+                log.error(e.getMessage());
+            }
+        }
+        return sb.toString();
+    }
+
+    //--------------------------------< VersionControlledResource interface >---
+    /**
+     * Adds version control to this resource. If the resource is already under
+     * version control, this method has no effect.
+     *
+     * @throws org.apache.jackrabbit.webdav.DavException if this resource does not
+     * exist yet or if an error occurs while making the underlaying node versionable.
+     * @see org.apache.jackrabbit.webdav.version.VersionableResource#addVersionControl()
+     */
+    public void addVersionControl() throws DavException {
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+        if (!isVersionControlled()) {
+            try {
+                ((Node)item).addMixin(MIX_VERSIONABLE);
+                item.save();
+            } catch (RepositoryException e) {
+                throw new JcrDavException(e);
+            }
+        } // else: is already version controlled -> ignore
+    }
+
+    /**
+     * Calls {@link javax.jcr.Node#checkin()} on the underlaying repository node.
+     *
+     * @throws org.apache.jackrabbit.webdav.DavException
+     * @see org.apache.jackrabbit.webdav.version.VersionControlledResource#checkin()
+     */
+    public String checkin() throws DavException {
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+        if (!isVersionControlled()) {
+            throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED);
+        }
+        try {
+            Version v = ((Node) item).checkin();
+            DavResourceLocator loc = getLocator();
+            String versionHref = loc.getFactory().createResourceLocator(loc.getPrefix(), loc.getWorkspacePath(), v.getPath()).getHref(true);
+            return versionHref;
+        } catch (RepositoryException e) {
+            // UnsupportedRepositoryException should not occur
+            throw new JcrDavException(e);
+        }
+    }
+
+    /**
+     * Calls {@link javax.jcr.Node#checkout()} on the underlaying repository node.
+     *
+     * @throws org.apache.jackrabbit.webdav.DavException
+     * @see org.apache.jackrabbit.webdav.version.VersionControlledResource#checkout()
+     */
+    public void checkout() throws DavException {
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+        if (!isVersionControlled()) {
+            throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED);
+        }
+        try {
+            ((Node) item).checkout();
+        } catch (RepositoryException e) {
+            // UnsupportedRepositoryException should not occur
+            throw new JcrDavException(e);
+        }
+    }
+
+    /**
+     * Not implemented. Always throws a <code>DavException</code> with error code
+     * {@link org.apache.jackrabbit.webdav.DavServletResponse#SC_NOT_IMPLEMENTED}.
+     *
+     * @throws org.apache.jackrabbit.webdav.DavException
+     * @see org.apache.jackrabbit.webdav.version.VersionControlledResource#uncheckout()
+     */
+    public void uncheckout() throws DavException {
+        throw new DavException(DavServletResponse.SC_NOT_IMPLEMENTED);
+    }
+
+    /**
+     * Perform an update on this resource. Depending on the format of the <code>updateInfo</code>
+     * this is translated to one of the following methods defined by the JCR API:
+     * <ul>
+     * <li>{@link Node#restore(javax.jcr.version.Version, boolean)}</li>
+     * <li>{@link Node#restore(javax.jcr.version.Version, String, boolean)}</li>
+     * <li>{@link Node#restoreByLabel(String, boolean)}</li>
+     * <li>{@link Workspace#restore(javax.jcr.version.Version[], boolean)}</li>
+     * <li>{@link Node#update(String)}</li>
+     * </ul>
+     * </p>
+     * Limitation: note that the <code>MultiStatus</code> returned by this method
+     * will not list any nodes that have been removed due to an Uuid conflict.
+     *
+     * @param updateInfo
+     * @return
+     * @throws org.apache.jackrabbit.webdav.DavException
+     * @see org.apache.jackrabbit.webdav.version.VersionControlledResource#update(org.apache.jackrabbit.webdav.version.UpdateInfo)
+     * @todo with jcr the node must not be versionable in order to perform Node.update.
+     */
+    public MultiStatus update(UpdateInfo updateInfo) throws DavException {
+        if (updateInfo == null) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Valid update request body required.");
+        }
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+
+        MultiStatus ms = new MultiStatus();
+        try {
+            Node node = (Node)item;
+            boolean removeExisting = updateInfo.getUpdateElement().getChild(XML_REMOVEEXISTING, NAMESPACE) != null;
+
+            // register eventListener in order to be able to report the modified resources.
+            EventListener el = new EListener(updateInfo.getPropertyNameSet(), ms);
+            registerEventListener(el, node.getPath());
+
+            // perform the update/restore according to the update info
+            if (updateInfo.getVersionHref() != null) {
+                VersionHistory vh = node.getVersionHistory();
+                String[] hrefs = updateInfo.getVersionHref();
+                Version[] versions = new Version[hrefs.length];
+                for (int  i = 0; i < hrefs.length; i++) {
+                    versions[i] = vh.getVersion(getResourceName(hrefs[i], true));
+                }
+                if (versions.length == 1) {
+                    String relPath = updateInfo.getUpdateElement().getChildText(XML_RELPATH, NAMESPACE);
+                    if (relPath == null) {
+                        node.restore(versions[0], removeExisting);
+                    } else {
+                        node.restore(versions[0], relPath, removeExisting);
+                    }
+                } else {
+                    getRepositorySession().getWorkspace().restore(versions, removeExisting);
+                }
+            } else if (updateInfo.getLabelName() != null) {
+                String[] labels = updateInfo.getLabelName();
+                if (labels.length == 1) {
+                    node.restoreByLabel(labels[0], removeExisting);
+                } else {
+                    Version[] vs = new Version[labels.length];
+                    VersionHistory vh = node.getVersionHistory();
+                    for (int  i = 0; i < labels.length; i++) {
+                        vs[i] = vh.getVersionByLabel(labels[i]);
+                    }
+                    getRepositorySession().getWorkspace().restore(vs, removeExisting);
+                }
+            } else if (updateInfo.getWorkspaceHref() != null) {
+                String workspaceName = getResourceName(updateInfo.getWorkspaceHref(), true);
+                node.update(workspaceName);
+            } else {
+                throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Invalid update request body.");
+            }
+
+            // unregister the event listener again
+            unregisterEventListener(el);
+
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
+        }
+        return ms;
+    }
+
+    /**
+     * Merge the repository node represented by this resource according to the
+     * information present in the given {@link MergeInfo} object.
+     *
+     * @param mergeInfo
+     * @return <code>MultiStatus</code> reccording all repository items affected
+     * by this merge call.
+     * @throws org.apache.jackrabbit.webdav.DavException
+     * @see org.apache.jackrabbit.webdav.version.VersionControlledResource#merge(org.apache.jackrabbit.webdav.version.MergeInfo)
+     * @see Node#merge(String, boolean)
+     * @todo with jcr the node must not be versionable in order to perform Node.merge
+     */
+    public MultiStatus merge(MergeInfo mergeInfo) throws DavException {
+        if (mergeInfo == null) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
+        }
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+
+        MultiStatus ms = new MultiStatus();
+        try {
+            Node node = (Node)item;
+
+            // register eventListener in order to be able to report the modifications.
+            EventListener el = new EListener(mergeInfo.getPropertyNameSet(), ms);
+            registerEventListener(el, node.getPath());
+
+            String workspaceName = getResourceName(mergeInfo.getSourceHref(), true);
+            node.merge(workspaceName, !mergeInfo.isNoAutoMerge());
+
+            // unregister the event listener again
+            unregisterEventListener(el);
+
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
+        }
+
+        return ms;
+    }
+
+    /**
+     * Resolve the merge conflicts according to the value of the {@link #AUTO_MERGE_SET DAV:auto-merge-set}
+     * property present in the specified <code>DavPropertySet</code>s.
+     *
+     * @param setProperties
+     * @param removePropertyNames
+     * @throws org.apache.jackrabbit.webdav.DavException
+     * @see VersionControlledResource#resolveMergeConflict(DavPropertySet, DavPropertyNameSet)
+     * @see Node#doneMerge(Version)
+     * @see Node#cancelMerge(Version)
+     */
+    public void resolveMergeConflict(DavPropertySet setProperties,
+                                     DavPropertyNameSet removePropertyNames) throws DavException {
+
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+        if (!isVersionControlled()) {
+            throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED);
+        }
+
+        try {
+            Node n = (Node)item;
+            if (removePropertyNames.contains(AUTO_MERGE_SET)) {
+                // retrieve the current jcr:mergeFailed property values
+                if (!((Node)item).hasProperty(PROP_MERGEFAILED)) {
+                    throw new DavException(DavServletResponse.SC_CONFLICT, "Attempt to resolve non-existing merge conflicts.");
+                }
+                Value[] mergeFailed = ((Node)item).getProperty(PROP_MERGEFAILED).getValues();
+
+                // resolve all remaining merge conflicts with 'cancel'
+                for (int i = 0; i < mergeFailed.length; i++) {
+                    n.cancelMerge((Version)getRepositorySession().getNodeByUUID(mergeFailed[i].getString()));
+                }
+                // adjust removeProperty set
+                removePropertyNames.remove(AUTO_MERGE_SET);
+
+            } else if (setProperties.contains(AUTO_MERGE_SET) && setProperties.contains(PREDECESSOR_SET)){
+                // retrieve the current jcr:mergeFailed property values
+                if (!((Node)item).hasProperty(PROP_MERGEFAILED)) {
+                    throw new DavException(DavServletResponse.SC_CONFLICT, "Attempt to resolve non-existing merge conflicts.");
+                }
+                Value[] mergeFailed = ((Node)item).getProperty(PROP_MERGEFAILED).getValues();
+
+
+                // check which mergeFailed entries have been removed from the
+                // auto-merge-set (cancelMerge) and have been moved over to the
+                // predecessor set (doneMerge)
+                List mergeset = new HrefProperty(setProperties.get(AUTO_MERGE_SET)).getHrefs();
+                List predecSet = new HrefProperty(setProperties.get(PREDECESSOR_SET)).getHrefs();
+
+                Session session = getRepositorySession();
+                for (int i = 0; i < mergeFailed.length; i++) {
+                    // build version-href from each entry in the jcr:mergeFailed property
+                    Version version = (Version) session.getNodeByUUID(mergeFailed[i].getString());
+                    String href = this.getLocatorFromItem(version).getHref(true);
+
+                    // Test if that version has been removed from the merge-set.
+                    // thus indicating that the merge-conflict needs to be resolved.
+                    if (!mergeset.contains(href)) {
+                        // Test if the 'href' has been moved over to the
+                        // predecessor-set (thus 'doneMerge' is appropriate) or
+                        // if it is not present in the predecessor set and the
+                        // the conflict is resolved by 'cancelMerge'.
+                        if (predecSet.contains(href)) {
+                            n.doneMerge(version);
+                        } else {
+                            n.cancelMerge(version);
+                        }
+                    }
+                }
+                // adjust setProperty set
+                setProperties.remove(AUTO_MERGE_SET);
+                setProperties.remove(PREDECESSOR_SET);
+            } else {
+                // setPropertySet and removePropertySet do not ask for resolving merge conflicts */
+                log.debug("setProperties and removeProperties sets do not request for merge conflict resolution.");
+            }
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
+        }
+    }
+
+    /**
+     * Modify the labels present with the versions of this resource.
+     *
+     * @param labelInfo
+     * @throws DavException
+     * @see VersionHistory#addVersionLabel(String, String, boolean)
+     * @see VersionHistory#removeVersionLabel(String)
+     */
+    public void label(LabelInfo labelInfo) throws DavException {
+        if (labelInfo == null) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Valid label request body required.");
+        }
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+
+        try {
+            if (!isVersionControlled() || ((Node)item).isCheckedOut()) {
+                throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "A LABEL request may only be applied to a version-controlled, checked-in resource.");
+            }
+            DavResource[] resArr = this.getReferenceResources(CHECKED_IN);
+            if (resArr.length == 1 && resArr[0] instanceof VersionResource) {
+                ((VersionResource)resArr[0]).label(labelInfo);
+            } else {
+                throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, "DAV:checked-in property on '" + getHref() + "' did not point to a single VersionResource.");
+            }
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
+        }
+    }
+
+    /**
+     * Returns the {@link VersionHistory} associated with the repository node.
+     * If the node is not versionable an exception is thrown.
+     *
+     * @return the {@link VersionHistoryResource} associated with this resource.
+     * @throws org.apache.jackrabbit.webdav.DavException
+     * @see org.apache.jackrabbit.webdav.version.VersionControlledResource#getVersionHistory()
+     * @see javax.jcr.Node#getVersionHistory()
+     */
+    public VersionHistoryResource getVersionHistory() throws DavException {
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+
+        try {
+            VersionHistory vh = ((Node)item).getVersionHistory();
+            DavResourceLocator loc = getLocatorFromItem(vh);
+            return (VersionHistoryResource) createResourceFromLocator(loc);
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
+        }
+    }
+
+    //--------------------------------------------------------------------------
+    /**
+     * Define the set of reports supported by this resource.
+     *
+     * @see SupportedReportSetProperty
+     */
+    protected void initSupportedReports() {
+        super.initSupportedReports();
+        if (exists()) {
+	    supportedReports.addReportType(ReportType.LOCATE_BY_HISTORY);
+            if (this.isVersionControlled()) {
+            supportedReports.addReportType(ReportType.VERSION_TREE);
+	    }            
+        }
+    }
+
+    /**
+     * Fill the property set for this resource.
+     */
+    protected void initProperties() {
+        super.initProperties();
+        if (exists()) {
+            Node n = (Node)item;
+            // properties defined by RFC 3253 for version-controlled resources
+            if (isVersionControlled()) {
+                // workspace property already set in AbstractResource.initProperties()
+                try {
+                    // DAV:version-history (computed)
+                    String vhHref = getLocatorFromResourcePath(n.getVersionHistory().getPath()).getHref(true);
+                    properties.add(new HrefProperty(VERSION_HISTORY, vhHref, true));
+
+                    // DAV:auto-version property: there is no auto version, explicit CHECKOUT is required.
+                    properties.add(new DefaultDavProperty(AUTO_VERSION, null, false));
+
+                    String baseVHref = getLocatorFromResourcePath(n.getBaseVersion().getPath()).getHref(true);
+                    if (n.isCheckedOut()) {
+                        // DAV:checked-out property (protected)
+                        properties.add(new HrefProperty(CHECKED_OUT, baseVHref, true));
+
+                        // DAV:predecessors property
+                        if (n.hasProperty(PROP_PREDECESSORS)) {
+                            Value[] predec = n.getProperty(PROP_PREDECESSORS).getValues();
+                            addHrefProperty(PREDECESSOR_SET, predec, false);
+                        }
+                        // DAV:auto-merge-set property. NOTE: the DAV:merge-set
+                        // never occurs, because merging without bestEffort flag
+                        // being set results in an exception on failure.
+                        if (n.hasProperty(PROP_MERGEFAILED)) {
+                            ReferenceValue[] mergeFailed = (ReferenceValue[]) n.getProperty(PROP_MERGEFAILED).getValues();
+                            addHrefProperty(AUTO_MERGE_SET, mergeFailed, false);
+                        }
+                        // todo: checkout-fork, checkin-fork
+                    } else {
+                        // DAV:checked-in property (protected)
+                        properties.add(new HrefProperty(CHECKED_IN, baseVHref, true));
+                    }
+                } catch (RepositoryException e) {
+                    log.error(e.getMessage());
+                }
+            }
+        }
+    }
+
+    /**
+     * Add a {@link org.apache.jackrabbit.webdav.property.HrefProperty} with the specified property name and values.
+     *
+     * @param name
+     * @param values Array of {@link ReferenceValue}s.
+     * @param isProtected
+     * @throws javax.jcr.ValueFormatException
+     * @throws IllegalStateException
+     * @throws javax.jcr.RepositoryException
+     */
+    private void addHrefProperty(DavPropertyName name, Value[] values,
+                                 boolean isProtected)
+            throws ValueFormatException, IllegalStateException, RepositoryException {
+        Node[] nodes = new Node[values.length];
+        for (int i = 0; i < values.length; i++) {
+            nodes[i] = getRepositorySession().getNodeByUUID(values[i].getString());
+        }
+        addHrefProperty(name, nodes, isProtected);
+    }
+
+    /**
+     * @return true, if this resource represents an existing repository node
+     * that has the mixin nodetype 'mix:versionable' set.
+     */
+    private boolean isVersionControlled() {
+        boolean vc = false;
+        if (exists()) {
+            try {
+                vc = ((Node) item).isNodeType("mix:versionable");
+            } catch (RepositoryException e) {
+                log.warn(e.getMessage());
+            }
+        }
+        return vc;
+    }
+
+    /**
+     * Register the specified event listener with the observation manager present
+     * the repository session.
+     *
+     * @param listener
+     * @param nodePath
+     * @throws javax.jcr.RepositoryException
+     */
+    private void registerEventListener(EventListener listener, String nodePath) throws RepositoryException {
+        getRepositorySession().getWorkspace().getObservationManager().addEventListener(listener, EListener.ALL_EVENTS, nodePath, true, null, null, false);
+    }
+
+    /**
+     * Unregister the specified event listener with the observation manager present
+     * the repository session.
+     *
+     * @param listener
+     * @throws javax.jcr.RepositoryException
+     */
+    private void unregisterEventListener(EventListener listener) throws RepositoryException {
+        getRepositorySession().getWorkspace().getObservationManager().removeEventListener(listener);
+    }
+
+    //------------------------------------------------------< inner classes >---
+    /**
+     * Simple EventListener that creates a new {@link org.apache.jackrabbit.webdav.MultiStatusResponse} object
+     * for each event and adds it to the specified {@link org.apache.jackrabbit.webdav.MultiStatus}.
+     */
+    private class EListener implements EventListener {
+
+        private static final int ALL_EVENTS = Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED;
+
+        private final DavPropertyNameSet propNameSet;
+        private MultiStatus ms;
+
+        private EListener(DavPropertyNameSet propNameSet, MultiStatus ms) {
+            this.propNameSet = propNameSet;
+            this.ms = ms;
+        }
+
+        /**
+         * @see EventListener#onEvent(javax.jcr.observation.EventIterator)
+         */
+        public void onEvent(EventIterator events) {
+            while (events.hasNext()) {
+                try {
+                    Event e = events.nextEvent();
+                    String itemPath = e.getPath();
+                    DavResourceLocator loc = getLocatorFromResourcePath(itemPath);
+                    DavResource res = createResourceFromLocator(loc);
+                    ms.addResponse(new MultiStatusResponse(res, propNameSet));
+
+                } catch (DavException e) {
+                    // should not occur
+                    log.error("Error while building MultiStatusResponse from Event: " + e.getMessage());
+                } catch (RepositoryException e) {
+                    // should not occur
+                    log.error("Error while building MultiStatusResponse from Event: " + e.getMessage());
+                }
+            }
+        }
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/VersionControlledItemCollection.java
------------------------------------------------------------------------------
    svn = 

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

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/nodetype/NodeTypeProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/nodetype/NodeTypeProperty.java?view=diff&r1=157745&r2=157746
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/nodetype/NodeTypeProperty.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/nodetype/NodeTypeProperty.java Wed Mar 16 05:36:05 2005
@@ -22,9 +22,7 @@
 import org.jdom.Element;
 
 import javax.jcr.nodetype.NodeType;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.*;
 
 /**
  * <code>NodeTypeProperty</code>...
@@ -71,8 +69,13 @@
         }
     }
 
-    public List getNodeTypeNames() {
-        ArrayList names = new ArrayList();
+    /**
+     * Return a set of nodetype names present in this property.
+     *
+     * @return set of nodetype names
+     */
+    public Set getNodeTypeNames() {
+        HashSet names = new HashSet();
         Object val = getValue();
         if (val instanceof NodeTypeElement[]) {
             NodeTypeElement[] elems = (NodeTypeElement[])val;

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/property/LengthsProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/property/LengthsProperty.java?view=auto&rev=157746
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/property/LengthsProperty.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/property/LengthsProperty.java Wed Mar 16 05:36:05 2005
@@ -0,0 +1,56 @@
+/*
+* Copyright 2004 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.spi.property;
+
+import org.apache.jackrabbit.webdav.property.AbstractDavProperty;
+import org.apache.jackrabbit.webdav.spi.ItemResourceConstants;
+import org.jdom.Element;
+
+/**
+ * <code>LengthsProperty</code> extends {@link org.apache.jackrabbit.webdav.property.DavProperty} providing
+ * utilities to handle the multiple lengths of the property item represented
+ * by this resource.
+ */
+public class LengthsProperty extends AbstractDavProperty implements ItemResourceConstants {
+
+    private final Element[] value;
+
+    /**
+     * Create a new <code>LengthsProperty</code> from the given long array.
+     *
+     * @param lengths as retrieved from the JCR property
+     */
+    public LengthsProperty(long[] lengths) {
+	super(JCR_LENGTHS, false);
+
+	Element[] elems = new Element[lengths.length];
+	for (int i = 0; i < lengths.length; i++) {
+	    elems[i] = new Element(XML_LENGTH, ItemResourceConstants.NAMESPACE);
+	    elems[i].addContent(String.valueOf(lengths[i]));
+	}
+	this.value = elems;
+    }
+
+    /**
+     * Returns an array of {@link Element}s representing the value of this
+     * property.
+     *
+     * @return an array of {@link Element}s
+     */
+    public Object getValue() {
+	return value;
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/property/LengthsProperty.java
------------------------------------------------------------------------------
    svn = 

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/property/ValuesProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/property/ValuesProperty.java?view=auto&rev=157746
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/property/ValuesProperty.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/property/ValuesProperty.java Wed Mar 16 05:36:05 2005
@@ -0,0 +1,120 @@
+/*
+* Copyright 2004 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.spi.property;
+
+import org.apache.jackrabbit.webdav.property.AbstractDavProperty;
+import org.apache.jackrabbit.webdav.property.DavProperty;
+import org.apache.jackrabbit.webdav.spi.ItemResourceConstants;
+import org.apache.jackrabbit.core.util.ValueHelper;
+import org.jdom.Element;
+
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+import javax.jcr.RepositoryException;
+import java.util.List;
+import java.util.Iterator;
+import java.util.ArrayList;
+
+/**
+ * <code>ValuesProperty</code> extends {@link org.apache.jackrabbit.webdav.property.DavProperty} providing
+ * utilities to handle the multiple values of the property item represented
+ * by this resource.
+ */
+public class ValuesProperty extends AbstractDavProperty implements ItemResourceConstants {
+
+    private final Element[] value;
+
+    /**
+     * Wrap the specified <code>DavProperty</code> in a new <code>ValuesProperty</code>.
+     *
+     * @param property
+     */
+    public ValuesProperty(DavProperty property) {
+	super(JCR_VALUES, false);
+
+	if (!JCR_VALUES.equals(property.getName())) {
+	    throw new IllegalArgumentException("ValuesProperty may only be created with a property that has name="+JCR_VALUES.getName());
+	}
+
+	Element[] elems = new Element[0];
+	if (property.getValue() instanceof List) {
+	    Iterator elemIt = ((List)property.getValue()).iterator();
+	    ArrayList valueElements = new ArrayList();
+	    while (elemIt.hasNext()) {
+		Object el = elemIt.next();
+		/* make sure, only Elements with name 'value' are used for
+		* the 'value' field. any other content (other elements, text,
+		* comment etc.) is ignored. NO bad-request/conflict error is
+		* thrown.
+		*/
+		if (el instanceof Element && "value".equals(((Element)el).getName())) {
+		    valueElements.add(el);
+		}
+	    }
+	    /* fill the 'value' with the valid 'value' elements found before */
+	    elems = (Element[])valueElements.toArray(new Element[valueElements.size()]);
+	} else {
+	    new IllegalArgumentException("ValuesProperty may only be created with a property that has a list of 'value' elements as content.");
+	}
+	// finally set the value to the DavProperty
+	value = elems;
+    }
+
+    /**
+     * Create a new <code>ValuesProperty</code> from the given {@link javax.jcr.Value Value
+     * array}.
+     *
+     * @param values Array of Value objects as obtained from the JCR property.
+     */
+    public ValuesProperty(Value[] values) throws ValueFormatException, RepositoryException {
+	super(JCR_VALUES, false);
+
+	Element[] propValue = new Element[values.length];
+	for (int i = 0; i < values.length; i++) {
+	    propValue[i] = new Element(XML_VALUE, ItemResourceConstants.NAMESPACE);
+	    propValue[i].addContent(values[i].getString());
+	}
+	// finally set the value to the DavProperty
+	value = propValue;
+    }
+
+    /**
+     * Converts the value of this property to a {@link javax.jcr.Value value array}.
+     * Please note, that the convertion is done by using the {@link org.apache.jackrabbit.core.util.ValueHelper}
+     * class that is not part of the JSR170 API.
+     *
+     * @return Array of Value objects
+     * @throws RepositoryException
+     */
+    public Value[] getValues(int propertyType) throws ValueFormatException, RepositoryException {
+	Element[] propValue = (Element[])getValue();
+	Value[] values = new Value[propValue.length];
+	for (int i = 0; i < propValue.length; i++) {
+	    values[i] = ValueHelper.convert(propValue[i].getText(), propertyType);
+	}
+	return values;
+    }
+
+    /**
+     * Returns an array of {@link Element}s representing the value of this
+     * property.
+     *
+     * @return an array of {@link Element}s
+     */
+    public Object getValue() {
+	return value;
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/property/ValuesProperty.java
------------------------------------------------------------------------------
    svn = 

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

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Mar 16 05:36:05 2005
@@ -0,0 +1 @@
+target

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Mar 16 05:36:05 2005
@@ -0,0 +1 @@
+target

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavConstants.java?view=diff&r1=157745&r2=157746
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavConstants.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavConstants.java Wed Mar 16 05:36:05 2005
@@ -52,6 +52,7 @@
 
     //--------------------------------------------------------- Depth header ---
     public static final String HEADER_DEPTH = "Depth";
+    public static final String DEPTH_INFINITY_S = "infinity";
     public static final int DEPTH_INFINITY = Integer.MAX_VALUE;
     public static final int DEPTH_0 = 0;
     public static final int DEPTH_1 = 1;

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavException.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavException.java?view=diff&r1=157745&r2=157746
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavException.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavException.java Wed Mar 16 05:36:05 2005
@@ -49,13 +49,12 @@
      *
      * @param errorCode integer specifying any of the status codes defined by
      * {@link DavServletResponse}.
-     * @param conditionElement
+     * @param message Human readable error message.
      */
-    public DavException(int errorCode, Element conditionElement) {
-        super(conditionElement.getText());
+    public DavException(int errorCode, String message) {
+        super(message);
         this.errorCode = errorCode;
-        this.conditionElement = conditionElement;
-        log.debug("DavException: (" + errorCode + ") " + conditionElement.toString());
+        log.debug("DavException: (" + errorCode + ") " + message);
     }
 
     /**
@@ -63,12 +62,9 @@
      *
      * @param errorCode integer specifying any of the status codes defined by
      * {@link DavServletResponse}.
-     * @param message Human readable error message.
      */
-    public DavException(int errorCode, String message) {
-        super(message);
-        this.errorCode = errorCode;
-        log.debug("DavException: (" + errorCode + ") " + message);
+    public DavException(int errorCode) {
+        this(errorCode, statusPhrases.getProperty(String.valueOf(errorCode)));
     }
 
     /**
@@ -76,9 +72,13 @@
      *
      * @param errorCode integer specifying any of the status codes defined by
      * {@link DavServletResponse}.
+     * @param message
+     * @param conditionElement
      */
-    public DavException(int errorCode) {
-        this(errorCode, statusPhrases.getProperty(String.valueOf(errorCode)));
+    public DavException(int errorCode, String message, Element conditionElement) {
+        this(errorCode, message);
+        this.conditionElement = conditionElement;
+        log.debug("DavException: (" + errorCode + ") " + conditionElement.toString());
     }
 
     /**

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavMethods.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavMethods.java?view=diff&r1=157745&r2=157746
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavMethods.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavMethods.java Wed Mar 16 05:36:05 2005
@@ -41,19 +41,19 @@
      * The webdav OPTIONS method and public constant
      */
     public static final int DAV_OPTIONS = 1;
-    private static final String METHOD_OPTIONS = "OPTIONS";
+    public static final String METHOD_OPTIONS = "OPTIONS";
 
     /**
      * The webdav GET method and public constant
      */
     public static final int DAV_GET = DAV_OPTIONS + 1;
-    private static final String METHOD_GET = "GET";
+    public static final String METHOD_GET = "GET";
 
     /**
      * The webdav HEAD method and public constant
      */
     public static final int DAV_HEAD = DAV_GET + 1;
-    private static final String METHOD_HEAD = "HEAD";
+    public static final String METHOD_HEAD = "HEAD";
 
 
     /**
@@ -65,12 +65,12 @@
 
     /** The webdav DELETE method and public constant */
     public static final int DAV_DELETE = DAV_POST + 1;
-    private static final String METHOD_DELETE = "DELETE";
+    public static final String METHOD_DELETE = "DELETE";
 
 
     /** The webdav PUT method and public constant */
     public static final int DAV_PUT = DAV_DELETE + 1;
-    private static final String METHOD_PUT = "PUT";
+    public static final String METHOD_PUT = "PUT";
 
 
     /**
@@ -78,7 +78,7 @@
      * <a href="http://www.ietf.org/rfc/rfc2518.txt">RFC 2518</a>.
      */
     public static final int DAV_PROPFIND = DAV_PUT + 1;
-    private static final String METHOD_PROPFIND = "PROPFIND";
+    public static final String METHOD_PROPFIND = "PROPFIND";
 
 
     /**
@@ -86,7 +86,7 @@
      * <a href="http://www.ietf.org/rfc/rfc2518.txt">RFC 2518</a>
      */
     public static final int DAV_PROPPATCH = DAV_PROPFIND + 1;
-    private static final String METHOD_PROPPATCH = "PROPPATCH";
+    public static final String METHOD_PROPPATCH = "PROPPATCH";
 
 
     /**
@@ -94,7 +94,7 @@
      * <a href="http://www.ietf.org/rfc/rfc2518.txt">RFC 2518</a>
      */
     public static final int DAV_MKCOL = DAV_PROPPATCH + 1;
-    private static final String METHOD_MKCOL = "MKCOL";
+    public static final String METHOD_MKCOL = "MKCOL";
 
 
     /**
@@ -102,7 +102,7 @@
      * <a href="http://www.ietf.org/rfc/rfc2518.txt">RFC 2518</a>
      */
     public static final int DAV_COPY = DAV_MKCOL + 1;
-    private static final String METHOD_COPY = "COPY";
+    public static final String METHOD_COPY = "COPY";
 
 
     /**
@@ -110,7 +110,7 @@
      * <a href="http://www.ietf.org/rfc/rfc2518.txt">RFC 2518</a>
      */
     public static final int DAV_MOVE = DAV_COPY + 1;
-    private static final String METHOD_MOVE = "MOVE";
+    public static final String METHOD_MOVE = "MOVE";
 
 
     /**
@@ -118,7 +118,7 @@
      * <a href="http://www.ietf.org/rfc/rfc2518.txt">RFC 2518</a>
      */
     public static final int DAV_LOCK = DAV_MOVE + 1;
-    private static final String METHOD_LOCK = "LOCK";
+    public static final String METHOD_LOCK = "LOCK";
 
 
     /**
@@ -126,7 +126,7 @@
      * <a href="http://www.ietf.org/rfc/rfc2518.txt">RFC 2518</a>
      */
     public static final int DAV_UNLOCK = DAV_LOCK + 1;
-    private static final String METHOD_UNLOCK = "UNLOCK";
+    public static final String METHOD_UNLOCK = "UNLOCK";
 
 
     /**
@@ -134,7 +134,7 @@
      * defined by <a href="http://www.ietf.org/rfc/rfc3648.txt">RFC 3648</a>.
      */
     public static final int DAV_ORDERPATCH = DAV_UNLOCK + 1;
-    private static final String METHOD_ORDERPATCH = "ORDERPATCH";
+    public static final String METHOD_ORDERPATCH = "ORDERPATCH";
 
 
     /**
@@ -142,7 +142,7 @@
      * NOTE: This method is not defined by any of the Webdav RFCs
      */
     public static final int DAV_SUBSCRIBE = DAV_ORDERPATCH + 1;
-    private static final String METHOD_SUBSCRIBE = "SUBSCRIBE";
+    public static final String METHOD_SUBSCRIBE = "SUBSCRIBE";
 
 
     /**
@@ -150,7 +150,7 @@
      * NOTE: This method is not defined by any of the Webdav RFCs
      */
     public static final int DAV_UNSUBSCRIBE = DAV_SUBSCRIBE + 1;
-    private static final String METHOD_UNSUBSCRIBE = "UNSUBSCRIBE";
+    public static final String METHOD_UNSUBSCRIBE = "UNSUBSCRIBE";
 
 
     /**
@@ -158,7 +158,7 @@
      * NOTE: This method is not defined by any of the Webdav RFCs
      */
     public static final int DAV_POLL = DAV_UNSUBSCRIBE + 1;
-    private static final String METHOD_POLL = "POLL";
+    public static final String METHOD_POLL = "POLL";
 
 
     /**
@@ -166,7 +166,7 @@
      * Webdav Search internet draft.
      */
     public static final int DAV_SEARCH = DAV_POLL + 1;
-    private static final String METHOD_SEARCH = "SEARCH";
+    public static final String METHOD_SEARCH = "SEARCH";
 
 
     /**
@@ -174,7 +174,7 @@
      * <a href="http://www.ietf.org/rfc/rfc3253.txt">RFC 3253</a>
      */
     public static final int DAV_REPORT = DAV_SEARCH + 1;
-    private static final String METHOD_REPORT = "REPORT";
+    public static final String METHOD_REPORT = "REPORT";
 
 
     /**
@@ -182,56 +182,56 @@
      * <a href="http://www.ietf.org/rfc/rfc3253.txt">RFC 3253</a>
      */
     public static final int DAV_VERSION_CONTROL = DAV_REPORT + 1;
-    private static final String METHOD_VERSION_CONTROL = "VERSION-CONTROL";
+    public static final String METHOD_VERSION_CONTROL = "VERSION-CONTROL";
 
     /**
      * The webdav CHECKIN method and public constant defined by
      * <a href="http://www.ietf.org/rfc/rfc3253.txt">RFC 3253</a>
      */
     public static final int DAV_CHECKIN = DAV_VERSION_CONTROL + 1;
-    private static final String METHOD_CHECKIN = "CHECKIN";
+    public static final String METHOD_CHECKIN = "CHECKIN";
 
     /**
      * The webdav CHECKOUT method and public constant defined by
      * <a href="http://www.ietf.org/rfc/rfc3253.txt">RFC 3253</a>
      */
     public static final int DAV_CHECKOUT = DAV_CHECKIN + 1;
-    private static final String METHOD_CHECKOUT = "CHECKOUT";
+    public static final String METHOD_CHECKOUT = "CHECKOUT";
 
     /**
      * The webdav UNCHECKOUT method and public constant defined by
      * <a href="http://www.ietf.org/rfc/rfc3253.txt">RFC 3253</a>
      */
     public static final int DAV_UNCHECKOUT = DAV_CHECKOUT + 1;
-    private static final String METHOD_UNCHECKOUT = "UNCHECKOUT";
+    public static final String METHOD_UNCHECKOUT = "UNCHECKOUT";
 
     /**
      * The webdav LABEL method and public constant defined by
      * <a href="http://www.ietf.org/rfc/rfc3253.txt">RFC 3253</a>
      */
     public static final int DAV_LABEL = DAV_UNCHECKOUT + 1;
-    private static final String METHOD_LABEL = "LABEL";
+    public static final String METHOD_LABEL = "LABEL";
 
     /**
      * The webdav MERGE method and public constant defined by
      * <a href="http://www.ietf.org/rfc/rfc3253.txt">RFC 3253</a>
      */
     public static final int DAV_MERGE = DAV_LABEL + 1;
-    private static final String METHOD_MERGE = "MERGE";
+    public static final String METHOD_MERGE = "MERGE";
 
     /**
      * The webdav UPDATE method and public constant defined by
      * <a href="http://www.ietf.org/rfc/rfc3253.txt">RFC 3253</a>
      */
     public static final int DAV_UPDATE = DAV_MERGE + 1;
-    private static final String METHOD_UPDATE = "UPDATE";
+    public static final String METHOD_UPDATE = "UPDATE";
 
     /**
      * The webdav MKWORKSPACE method and public constant defined by
      * <a href="http://www.ietf.org/rfc/rfc3253.txt">RFC 3253</a>
      */
     public static final int DAV_MKWORKSPACE = DAV_UPDATE + 1;
-    private static final String METHOD_MKWORKSPACE = "MKWORKSPACE";
+    public static final String METHOD_MKWORKSPACE = "MKWORKSPACE";
 
     /**
      * Returns webdav method type code, error result <= 0

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavSessionProvider.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavSessionProvider.java?view=auto&rev=157746
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavSessionProvider.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavSessionProvider.java Wed Mar 16 05:36:05 2005
@@ -0,0 +1,48 @@
+/*
+ * 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;
+
+/**
+ * <code>DavSessionProvider</code> is an interface for components that
+ * can initiate and complete {@link DavSession}s. A provider is
+ * responsible for supplying references from a {@link WebdavRequest}
+ * to a {@link DavSession} when acquired and removing the references
+ * when released.
+
+ */
+public interface DavSessionProvider {
+
+    /**
+     * Acquires a DavSession. Upon success, the WebdavRequest will
+     * reference that session.
+     *
+     * A session will not be available if credentials can not be found
+     * in the request (meaning that the  request has not been
+     * authenticated).
+     *
+     * @param request
+     * @throws DavException if a problem occurred while obtaining the
+     * session
+     */
+    public void acquireSession(WebdavRequest request) throws DavException;
+
+    /**
+     * Releases the reference from the request to the session.
+     *
+     * @param request
+     */
+    public void releaseSession(WebdavRequest request);
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavSessionProvider.java
------------------------------------------------------------------------------
    svn = 

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



Mime
View raw message