jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1508486 - in /jackrabbit/branches/2.4: ./ jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/ jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/lock/ jackrabbit-jcr-server/src/test/java/org/apache/jackr...
Date Tue, 30 Jul 2013 15:20:58 GMT
Author: reschke
Date: Tue Jul 30 15:20:57 2013
New Revision: 1508486

URL: http://svn.apache.org/r1508486
Log:
JCR-3209: introduce a JCR<->DAV lock token mapper (ported to 2.4)

Added:
    jackrabbit/branches/2.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/lock/LockTokenMapper.java
      - copied unchanged from r1233544, jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/lock/LockTokenMapper.java
    jackrabbit/branches/2.4/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/jcr/LockTokenMappingTest.java
      - copied unchanged from r1233544, jackrabbit/trunk/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/jcr/LockTokenMappingTest.java
Modified:
    jackrabbit/branches/2.4/   (props changed)
    jackrabbit/branches/2.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrDavSession.java
    jackrabbit/branches/2.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/lock/JcrActiveLock.java

Propchange: jackrabbit/branches/2.4/
------------------------------------------------------------------------------
  Merged /jackrabbit/trunk:r1233544

Modified: jackrabbit/branches/2.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrDavSession.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrDavSession.java?rev=1508486&r1=1508485&r2=1508486&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrDavSession.java
(original)
+++ jackrabbit/branches/2.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrDavSession.java
Tue Jul 30 15:20:57 2013
@@ -20,9 +20,11 @@ import org.apache.jackrabbit.webdav.DavE
 import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.jackrabbit.webdav.DavSession;
 import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.jcr.lock.LockTokenMapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import java.util.HashSet;
 
@@ -97,7 +99,14 @@ public abstract class JcrDavSession impl
      * @see DavSession#addLockToken(String)
      */
     public void addLockToken(String token) {
-        session.addLockToken(getJCRLockToken(token));
+        if (!LockTokenMapper.isForSessionScopedLock(token)) {
+            try {
+                session.getWorkspace().getLockManager().addLockToken(LockTokenMapper.getJcrLockToken(token));
+            }
+            catch (RepositoryException ex) {
+                log.debug("trying to add lock token " + token + " to session", ex);
+            }
+        }
         lockTokens.add(token);
     }
 
@@ -116,16 +125,14 @@ public abstract class JcrDavSession impl
      * @see DavSession#removeLockToken(String)
      */
     public void removeLockToken(String 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;
+        if (!LockTokenMapper.isForSessionScopedLock(token)) {
+            try {
+                session.getWorkspace().getLockManager().removeLockToken(LockTokenMapper.getJcrLockToken(token));
+            }
+            catch (RepositoryException ex) {
+                log.debug("trying to remove lock token " + token + " to session", ex);
+            }
         }
+        lockTokens.remove(token);
     }
 }

Modified: jackrabbit/branches/2.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/lock/JcrActiveLock.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/lock/JcrActiveLock.java?rev=1508486&r1=1508485&r2=1508486&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/lock/JcrActiveLock.java
(original)
+++ jackrabbit/branches/2.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/lock/JcrActiveLock.java
Tue Jul 30 15:20:57 2013
@@ -93,20 +93,14 @@ public class JcrActiveLock extends Abstr
      * @see ActiveLock#getToken()
      */
     public String getToken() {
-        String token = lock.getLockToken();
-        if (token == null && lock.isSessionScoped()
-                && lock.isLockOwningSession()) {
-            // special handling for session scoped locks that are owned by the
-            // current session but never expose their token with jsr 283.
-            try {
-                token = lock.getNode().getIdentifier();
-            } catch (RepositoryException e) {
-                // should never get here
-                log.warn("Unexpected error while retrieving node identifier for building
a DAV specific lock token.",e.getMessage());
-            }
+        try {
+            return LockTokenMapper.getDavLocktoken(lock);
+        } catch (RepositoryException e) {
+            // should never get here
+            log.warn("Unexpected error while retrieving node identifier for building a DAV
specific lock token.",
+                    e.getMessage());
+            return null;
         }
-        // default behaviour: just return the token exposed by the lock.
-        return token;
     }
 
     /**



Mime
View raw message