jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r506936 - in /jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit: server/jcr/JCRWebdavServer.java webdav/jcr/JcrDavSession.java
Date Tue, 13 Feb 2007 10:06:05 GMT
Author: angela
Date: Tue Feb 13 02:06:00 2007
New Revision: 506936

URL: http://svn.apache.org/viewvc?view=rev&rev=506936
Log:
minor changes needed for spi2dav (see spi contrib)

Modified:
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrDavSession.java

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java?view=diff&rev=506936&r1=506935&r2=506936
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java
Tue Feb 13 02:06:00 2007
@@ -18,10 +18,10 @@
 
 import org.apache.jackrabbit.server.SessionProvider;
 import org.apache.jackrabbit.webdav.DavException;
-import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.jackrabbit.webdav.DavSession;
 import org.apache.jackrabbit.webdav.DavSessionProvider;
 import org.apache.jackrabbit.webdav.WebdavRequest;
+import org.apache.jackrabbit.webdav.header.IfHeader;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
 import org.apache.jackrabbit.webdav.jcr.JcrDavSession;
 import org.slf4j.Logger;
@@ -35,6 +35,8 @@
 import javax.servlet.http.HttpServletResponse;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
+
 /**
  * <code>JCRWebdavServer</code>...
  */
@@ -156,10 +158,6 @@
             String subscriptionId = request.getSubscriptionId();
             String lockToken = request.getLockToken();
 
-            if ((lockToken != null || txId != null) && subscriptionId != null) {
-                throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "Ambiguous
headers: either TransactionId/Lock-Token or SubscriptionId can be present, not both.");
-            }
-
             DavSession session = null;
             // try to retrieve a cached session
             if (lockToken != null && containsReference(lockToken)) {
@@ -169,6 +167,19 @@
             } else if (subscriptionId != null && containsReference(subscriptionId))
{
                 session = getSessionByReference(subscriptionId);
             }
+
+            if (session == null) {
+                // try tokens present in the if-header
+                IfHeader ifHeader = new IfHeader(request);
+                for (Iterator it = ifHeader.getAllTokens(); it.hasNext();) {
+                    String token = it.next().toString();
+                    if (containsReference(token)) {
+                        session = getSessionByReference(token);
+                        break;
+                    }
+                }
+            }
+
             // no cached session present -> create new one.
             if (session == null) {
                 Session repSession = getRepositorySession(request);

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrDavSession.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrDavSession.java?view=diff&rev=506936&r1=506935&r2=506936
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrDavSession.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrDavSession.java
Tue Feb 13 02:06:00 2007
@@ -19,10 +19,12 @@
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.DavConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.jcr.Session;
+import java.util.HashSet;
 
 /**
  * <code>JcrDavSession</code> specific base implementation of the
@@ -46,6 +48,13 @@
     /** the underlying jcr session */
     private final Session session;
 
+    /** the lock tokens of this session */
+    private final HashSet lockTokens = new HashSet();
+
+    /**
+     *
+     * @param session
+     */
     protected JcrDavSession(Session session) {
         this.session = session;
     }
@@ -88,7 +97,8 @@
      * @see DavSession#addLockToken(String)
      */
     public void addLockToken(String token) {
-        session.addLockToken(token);
+        session.addLockToken(getJCRLockToken(token));
+        lockTokens.add(token);
     }
 
     /**
@@ -97,7 +107,7 @@
      * @see DavSession#getLockTokens()
      */
     public String[] getLockTokens() {
-        return session.getLockTokens();
+        return (String[]) lockTokens.toArray(new String[lockTokens.size()]);
     }
 
     /**
@@ -106,6 +116,16 @@
      * @see DavSession#removeLockToken(String)
      */
     public void removeLockToken(String token) {
-        session.removeLockToken(token);
+        session.removeLockToken(getJCRLockToken(token));
+        lockTokens.remove(token);
+    }
+
+    //------------------------------------------------------------< private >---
+    private static String getJCRLockToken(String token) {
+        if (token.startsWith(DavConstants.OPAQUE_LOCK_TOKEN_PREFIX)) {
+            return token.substring(DavConstants.OPAQUE_LOCK_TOKEN_PREFIX.length());
+        } else {
+            return token;
+        }
     }
 }



Mime
View raw message