jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1518067 - in /jackrabbit/oak/trunk/oak-jcr: pom.xml src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockManagerImpl.java
Date Wed, 28 Aug 2013 04:06:33 GMT
Author: jukka
Date: Wed Aug 28 04:06:33 2013
New Revision: 1518067

URL: http://svn.apache.org/r1518067
Log:
OAK-150: Basic JCR LockManager support

Update NodeImpl locking methods to match the equivalent code in LockManagerImpl
Fix one failing test case, trim others.

Modified:
    jackrabbit/oak/trunk/oak-jcr/pom.xml
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockManagerImpl.java

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1518067&r1=1518066&r2=1518067&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Wed Aug 28 04:06:33 2013
@@ -67,29 +67,18 @@
       org.apache.jackrabbit.test.api.DocumentViewImportTest#testSessionGetImportContentHandler
        <!-- OAK-970 -->
 
       <!-- Locking : not fully implemented -->
-      org.apache.jackrabbit.test.api.SerializationTest#testLockExceptionWorkspaceWithHandler
          <!-- OAK-127: no session scoped locking -->
-      org.apache.jackrabbit.test.api.SerializationTest#testLockExceptionSessionWithHandler
            <!-- OAK-127: no session scoped locking -->
-      org.apache.jackrabbit.test.api.SerializationTest#testLockExceptionWorkspace       
              <!-- OAK-127: no session scoped locking -->
-      org.apache.jackrabbit.test.api.SerializationTest#testLockExceptionSession         
              <!-- OAK-127: no session scoped locking -->
-
       org.apache.jackrabbit.test.api.lock.LockTest#testNodeLocked
       org.apache.jackrabbit.test.api.lock.LockTest#testParentChildDeepLock
-      org.apache.jackrabbit.test.api.lock.LockTest#testIsSessionScoped
-      org.apache.jackrabbit.test.api.lock.LockTest#testLockTransfer
       org.apache.jackrabbit.test.api.lock.LockTest#testAddRemoveLockToken
-      org.apache.jackrabbit.test.api.lock.LockTest#testOpenScopedLocks
-      org.apache.jackrabbit.test.api.lock.LockTest#testLogout
 
       org.apache.jackrabbit.test.api.lock.SetValueLockExceptionTest#testSetValueLockException
 
-      org.apache.jackrabbit.test.api.lock.DeepLockTest#testShallowLockAboveLockedChild
       org.apache.jackrabbit.test.api.lock.DeepLockTest#testParentChildDeepLock
       org.apache.jackrabbit.test.api.lock.DeepLockTest#testDeepLockAboveLockedChild
       org.apache.jackrabbit.test.api.lock.DeepLockTest#testRemoveLockedChild
 
       org.apache.jackrabbit.test.api.lock.LockManagerTest#testLockTransfer2
       org.apache.jackrabbit.test.api.lock.LockManagerTest#testRemoveLockToken3
-      org.apache.jackrabbit.test.api.lock.LockManagerTest#testLockWithPendingChanges
       org.apache.jackrabbit.test.api.lock.LockManagerTest#testAddLockTokenToAnotherSession
 
       org.apache.jackrabbit.test.api.lock.SessionScopedLockTest#testImplicitUnlock

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1518067&r1=1518066&r2=1518067&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
Wed Aug 28 04:06:33 2013
@@ -1151,11 +1151,8 @@ public class NodeImpl<T extends NodeDele
         }
     }
 
-    /**
-     * @see javax.jcr.Node#lock(boolean, boolean)
-     */
     @Override @Nonnull
-    public Lock lock(final boolean isDeep, boolean isSessionScoped)
+    public Lock lock(final boolean isDeep, final boolean isSessionScoped)
             throws RepositoryException {
         perform(new LockOperation<Void>(sessionDelegate, dlg) {
             @Override
@@ -1165,28 +1162,37 @@ public class NodeImpl<T extends NodeDele
                             "Unable to lock a node with pending changes");
                 }
                 node.lock(isDeep);
+                String path = node.getPath();
+                if (isSessionScoped) {
+                    sessionContext.getSessionScopedLocks().add(path);
+                } else {
+                    sessionContext.getOpenScopedLocks().add(path);
+                }
                 session.refresh(true);
                 return null;
             }
         });
-        getSession().refresh(true); // TODO: better refresh
         return new LockImpl(sessionContext, dlg);
     }
 
-    /**
-     * @see javax.jcr.Node#unlock()
-     */
     @Override
     public void unlock() throws RepositoryException {
         perform(new LockOperation<Void>(sessionDelegate, dlg) {
             @Override
             public Void perform(NodeDelegate node) throws RepositoryException {
-                node.unlock();
-                session.refresh(true);
-                return null;
+                String path = node.getPath();
+                if (sessionContext.getSessionScopedLocks().contains(path)
+                        || sessionContext.getOpenScopedLocks().contains(path)) {
+                    node.unlock();
+                    sessionContext.getSessionScopedLocks().remove(path);
+                    sessionContext.getOpenScopedLocks().remove(path);
+                    session.refresh(true);
+                    return null;
+                } else {
+                    throw new LockException("Not an owner of the lock " + path);
+                }
             }
         });
-        getSession().refresh(true); // TODO: better refresh
     }
 
     @Override @Nonnull

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockManagerImpl.java?rev=1518067&r1=1518066&r2=1518067&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockManagerImpl.java
Wed Aug 28 04:06:33 2013
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.jcr.lo
 import java.util.Set;
 
 import javax.annotation.Nonnull;
+import javax.jcr.InvalidItemStateException;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
@@ -143,7 +144,7 @@ public class LockManagerImpl implements 
                     protected NodeDelegate perform(NodeDelegate node)
                             throws RepositoryException {
                         if (node.getStatus() != Status.EXISTING) {
-                            throw new LockException(
+                            throw new InvalidItemStateException(
                                     "Unable to lock a node with pending changes");
                         }
                         node.lock(isDeep);



Mime
View raw message