Return-Path: X-Original-To: apmail-jackrabbit-commits-archive@www.apache.org Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9AA71B26D for ; Fri, 6 Jan 2012 10:22:08 +0000 (UTC) Received: (qmail 65581 invoked by uid 500); 6 Jan 2012 10:22:05 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 64551 invoked by uid 500); 6 Jan 2012 10:21:42 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 64528 invoked by uid 99); 6 Jan 2012 10:21:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Jan 2012 10:21:36 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Jan 2012 10:21:33 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 599C023888D2; Fri, 6 Jan 2012 10:21:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@jackrabbit.apache.org From: reschke@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120106102112.599C023888D2@eris.apache.org> 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; /** AbstractVersionAccessTest... */ 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);