jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1228058 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/ jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/ jackr...
Date Fri, 06 Jan 2012 10:21:12 GMT
Author: reschke
Date: Fri Jan  6 10:21:11 2012
New Revision: 1228058

URL: http://svn.apache.org/viewvc?rev=1228058&view=rev
Log:
JCR-2859: Make open scoped locks recoverable

Undo change 1227171 due to jcr2dav breakage

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockImpl.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractLockManagementTest.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockImpl.java?rev=1228058&r1=1228057&r2=1228058&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockImpl.java
Fri Jan  6 10:21:11 2012
@@ -22,7 +22,6 @@ import org.apache.jackrabbit.core.securi
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
-import javax.jcr.Session;
 import javax.jcr.lock.LockException;
 
 /**
@@ -79,7 +78,7 @@ class LockImpl implements javax.jcr.lock
      * {@inheritDoc}
      */
     public String getLockToken() {
-        if (!info.isSessionScoped() && (info.isLockHolder(node.getSession()) || isAdminUser(node.getSession())))
{
+        if (!info.isSessionScoped() && info.isLockHolder(node.getSession())) {
             return info.getLockToken();
         } else {
             return null;
@@ -152,15 +151,4 @@ class LockImpl implements javax.jcr.lock
         return info.isLockHolder(node.getSession());
     }
 
-    /**
-     * Check whether a session belongs to an administrative user.
-     */
-    private boolean isAdminUser(Session session) {
-        if (session instanceof SessionImpl) {
-            return ((SessionImpl) session).isAdmin();
-        } else {
-            // fallback. use hardcoded default admin ID
-            return "admin".equals(session.getUserID());
-        }
-    }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java?rev=1228058&r1=1228057&r2=1228058&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
Fri Jan  6 10:21:11 2012
@@ -941,21 +941,14 @@ public class XATest extends AbstractJCRT
         n.save();
 
         superuser.removeLockToken(lockToken);
-
-        String nlt = lock.getLockToken();
-        assertTrue("freshly obtained lock token must either be null or the same as the one
returned earlier",
-                nlt == null || nlt.equals(lockToken));
-
+        assertNull("session must get a null lock token", lock.getLockToken());
         assertFalse("session must not hold lock token", containsLockToken(superuser, lockToken));
         
         // commit
         utx.commit();
 
-        nlt = lock.getLockToken();
-        assertTrue("freshly obtained lock token must either be null or the same as the one
returned earlier",
-                nlt == null || nlt.equals(lockToken));
-
         assertFalse("session must not hold lock token", containsLockToken(superuser, lockToken));
+        assertNull("session must get a null lock token", lock.getLockToken());
 
         // start new Transaction and try to unlock
         utx = new UserTransactionImpl(superuser);
@@ -1148,10 +1141,7 @@ public class XATest extends AbstractJCRT
         assertTrue("session must hold lock token", containsLockToken(superuser, lockToken));
 
         superuser.removeLockToken(lockToken);
-
-        String nlt = lock.getLockToken();
-        assertTrue("freshly obtained lock token must either be null or the same as the one
returned earlier",
-                nlt == null || nlt.equals(lockToken));
+        assertNull("session must get a null lock token", lock.getLockToken());
 
         // commit
         utx.commit();
@@ -1159,9 +1149,7 @@ public class XATest extends AbstractJCRT
         // refresh Lock Info
         lock = n.getLock();
 
-        nlt = lock.getLockToken();
-        assertTrue("freshly obtained lock token must either be null or the same as the one
returned earlier",
-                nlt == null || nlt.equals(lockToken));
+        assertNull("session must get a null lock token", lock.getLockToken());
 
         Session other = getHelper().getSuperuserSession();
         try {
@@ -1922,20 +1910,15 @@ public class XATest extends AbstractJCRT
         assertTrue("session must hold lock token", containsLockToken(superuser, lockToken));
 
         superuser.removeLockToken(lockToken);
-
-        String nlt = lock.getLockToken();
-        assertTrue("freshly obtained lock token must either be null or the same as the one
returned earlier",
-                nlt == null || nlt.equals(lockToken));
-
+        assertNull("session must get a null lock token", lock.getLockToken());
+        
         // commit
         utx.commit();
         
         // refresh Lock Info
         lock = n.getLock();
 
-        nlt = lock.getLockToken();
-        assertTrue("freshly obtained lock token must either be null or the same as the one
returned earlier",
-                nlt == null || nlt.equals(lockToken));
+        assertNull("session must get a null lock token", lock.getLockToken());
 
         Session other = getHelper().getSuperuserSession();
         // start new Transaction and try to add lock token unlock the node and then remove
it

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractLockManagementTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractLockManagementTest.java?rev=1228058&r1=1228057&r2=1228058&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractLockManagementTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractLockManagementTest.java
Fri Jan  6 10:21:11 2012
@@ -22,9 +22,7 @@ import org.apache.jackrabbit.test.NotExe
 import javax.jcr.AccessDeniedException;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
-import javax.jcr.Session;
 import javax.jcr.lock.Lock;
-import javax.jcr.lock.LockManager;
 
 /** <code>AbstractVersionAccessTest</code>... */
 public abstract class AbstractLockManagementTest extends AbstractEvaluationTest {
@@ -131,49 +129,4 @@ public abstract class AbstractLockManage
         boolean isLocked = n.isLocked();
         assertFalse(isLocked);
     }
-
-    public void testLockBreaking() throws RepositoryException, NotExecutableException {
-        String locktoken = null;
-        LockManager sulm = superuser.getWorkspace().getLockManager();
-        String lockedpath = null;
-
-        try {
-            Node trn = getTestNode();
-            modifyPrivileges(trn.getPath(), Privilege.JCR_READ, true);
-            modifyPrivileges(trn.getPath(), PrivilegeRegistry.REP_WRITE, true);
-            modifyPrivileges(trn.getPath(), Privilege.JCR_LOCK_MANAGEMENT, true);
-
-            Session lockingSession = trn.getSession();
-
-            assertFalse("super user and test user should have different user ids: " + lockingSession.getUserID()
+ " vs " + superuser.getUserID(),
-                    lockingSession.getUserID().equals(superuser.getUserID()));
-
-            trn.addNode("locktest", "nt:unstructured");
-            trn.addMixin("mix:lockable");
-            lockingSession.save();
-
-            // let the "other" user lock the node
-            LockManager oulm = lockingSession.getWorkspace().getLockManager();
-            Lock l = oulm.lock(trn.getPath(), true, false, Long.MAX_VALUE, null);
-            lockedpath = trn.getPath();
-            locktoken = l.getLockToken();
-            lockingSession.logout();
-
-            // transfer the lock token to the super user and try the unlock
-
-            Node lockednode = superuser.getNode(lockedpath);
-            assertTrue(lockednode.isLocked());
-            Lock sl = sulm.getLock(lockedpath);
-            assertNotNull(sl.getLockToken());
-            sulm.addLockToken(sl.getLockToken());
-            sulm.unlock(lockedpath);
-            locktoken = null;
-        }
-        finally {
-            if (locktoken != null && lockedpath != null) {
-                sulm.addLockToken(locktoken);
-                sulm.unlock(lockedpath);
-            }
-        }
-    }
 }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java?rev=1228058&r1=1228057&r2=1228058&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java
Fri Jan  6 10:21:11 2012
@@ -89,10 +89,7 @@ public class OpenScopedLockTest extends 
         String lockToken = lock.getLockToken();
         try {
             superuser.removeLockToken(lockToken);
-
-            String nlt = lock.getLockToken();
-            assertTrue("freshly obtained lock token must either be null or the same as the
one returned earlier",
-                    nlt == null || nlt.equals(lockToken));
+            assertNull("After token transfer lock-token must not be visible", lock.getLockToken());
         } finally {
             // move lock token back in order to have lock removed properly
             superuser.addLockToken(lockToken);



Mime
View raw message