jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1508500 - in /jackrabbit/branches/2.4: ./ jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Date Tue, 30 Jul 2013 15:46:58 GMT
Author: reschke
Date: Tue Jul 30 15:46:58 2013
New Revision: 1508500

URL: http://svn.apache.org/r1508500
Log:
JCR-3633: If header field sent with PROPFIND (for lock discovery) (ported to 2.4)

Modified:
    jackrabbit/branches/2.4/   (props changed)
    jackrabbit/branches/2.4/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java
    jackrabbit/branches/2.4/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java

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

Modified: jackrabbit/branches/2.4/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java?rev=1508500&r1=1508499&r2=1508500&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java
(original)
+++ jackrabbit/branches/2.4/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java
Tue Jul 30 15:46:58 2013
@@ -18,8 +18,11 @@ package org.apache.jackrabbit.jcr2spi.lo
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
+import javax.jcr.Session;
 import javax.jcr.lock.Lock;
 import javax.jcr.lock.LockException;
+import javax.jcr.lock.LockManager;
+import javax.jcr.nodetype.NodeType;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -216,4 +219,64 @@ public class OpenScopedLockTest extends 
             throw e;
         }
     }
+
+    public void testIsLockedWhileAnotherLockIsPresent() throws Exception {
+
+        Session s = lockedNode.getSession();
+        LockManager lm = s.getWorkspace().getLockManager();
+
+        String l2token = null;
+        String l2path = null;
+
+        String path = lockedNode.getPath();
+        String lockToken = lock.getLockToken();
+        assertTrue(lm.isLocked(path));
+        assertTrue(lm.holdsLock(path));
+        lm.removeLockToken(lockToken);
+
+        Session anotherSession = null;
+        try {
+            // check lock is seen by new session
+            anotherSession = getHelper().getSuperuserSession();
+            LockManager anotherLockManager = anotherSession.getWorkspace().getLockManager();
+            assertTrue(anotherLockManager.isLocked(path));
+            assertTrue(anotherLockManager.holdsLock(path));
+
+            // create a second lock
+            Node l2node = anotherSession.getNode(path).getParent().addNode("second-lock");
+            l2node.addMixin(NodeType.MIX_LOCKABLE);
+            anotherSession.save();
+            l2path = l2node.getPath();
+
+            Lock l2 = anotherLockManager.lock(l2path, false, false, Long.MAX_VALUE, "foobar");
+            l2token = l2.getLockToken();
+            assertNotNull(l2token);
+            anotherSession.save();
+
+            anotherSession.refresh(false);
+            assertTrue(anotherLockManager.isLocked(path));
+            assertTrue(anotherLockManager.holdsLock(path));
+
+            // try to unlock the lock obtained from the other session
+            anotherLockManager.addLockToken(lockToken);
+            anotherLockManager.unlock(path);
+            anotherSession.save();
+
+            // unlock "my" lock
+            anotherLockManager.unlock(l2path);
+            anotherSession.save();
+            l2path = null;
+        }
+        finally {
+            if (anotherSession != null) {
+                anotherSession.logout();
+            }
+            if (l2path != null && l2token != null) {
+                superuser.refresh(false);
+                LockManager sulm = superuser.getWorkspace().getLockManager();
+                sulm.addLockToken(l2token);
+                sulm.unlock(l2path);
+            }
+        }
+    }
 }
\ No newline at end of file

Modified: jackrabbit/branches/2.4/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?rev=1508500&r1=1508499&r2=1508500&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
(original)
+++ jackrabbit/branches/2.4/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Tue Jul 30 15:46:58 2013
@@ -1516,8 +1516,7 @@ public class RepositoryServiceImpl imple
         try {
             String uri = getItemUri(nodeId, sessionInfo);
             method = new PropFindMethod(uri, nameSet, DEPTH_0);
-            // TODO: not correct. pass tokens in order avoid new session to be created TOBEFIXED
-            initMethod(method, sessionInfo, true);
+            initMethod(method, sessionInfo, false);
 
             getClient(sessionInfo).executeMethod(method);
             method.checkSuccess();



Mime
View raw message