jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r776761 - in /jackrabbit/branches/1.x: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
Date Wed, 20 May 2009 16:48:47 GMT
Author: jukka
Date: Wed May 20 16:48:47 2009
New Revision: 776761

URL: http://svn.apache.org/viewvc?rev=776761&view=rev
Log:
1.x: Merged revision 773483 (JCR-1633)

Modified:
    jackrabbit/branches/1.x/   (props changed)
    jackrabbit/branches/1.x/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
    jackrabbit/branches/1.x/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java

Propchange: jackrabbit/branches/1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed May 20 16:48:47 2009
@@ -1 +1 @@
-/jackrabbit/trunk:770143-773197,773525-773554,773584,773588,773828,773835-775756,775833,775836,775840,775981,775986,776036,776256,776310,776313,776321-776322,776332,776356-776357,776362,776373,776650-776693,776737
+/jackrabbit/trunk:770143-773197,773483,773525-773554,773584,773588,773828,773835-775756,775833,775836,775840,775981,775986,776036,776256,776310,776313,776321-776322,776332,776356-776357,776362,776373,776650-776693,776737

Modified: jackrabbit/branches/1.x/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.x/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java?rev=776761&r1=776760&r2=776761&view=diff
==============================================================================
--- jackrabbit/branches/1.x/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
(original)
+++ jackrabbit/branches/1.x/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
Wed May 20 16:48:47 2009
@@ -135,7 +135,7 @@
     /**
      * System session
      */
-    private final SessionImpl session;
+    private final SessionImpl sysSession;
 
     /**
      * Locks file
@@ -162,7 +162,7 @@
     public LockManagerImpl(SessionImpl session, FileSystem fs)
             throws RepositoryException {
 
-        this.session = session;
+        this.sysSession = session;
         this.locksFile = new FileSystemResource(fs, FileSystem.SEPARATOR + LOCKS_FILE);
 
         session.getWorkspace().getObservationManager().
@@ -217,8 +217,8 @@
     private void reapplyLock(LockToken lockToken) {
         try {
             NodeImpl node = (NodeImpl)
-                session.getItemManager().getItem(lockToken.getId());
-            Path path = getPath(lockToken.getId());
+                sysSession.getItemManager().getItem(lockToken.getId());
+            Path path = getPath(sysSession, lockToken.getId());
 
             LockInfo info = new LockInfo(lockToken, false,
                     node.getProperty(NameConstants.JCR_LOCKISDEEP).getBoolean(),
@@ -315,7 +315,7 @@
 
         try {
             // check whether node is already locked
-            Path path = getPath(node.getId());
+            Path path = getPath(session, node.getId());
             PathMap.Element element = lockMap.map(path, false);
 
             LockInfo other = (LockInfo) element.get();
@@ -376,7 +376,7 @@
         try {
             SessionImpl session = (SessionImpl) node.getSession();
             // check whether node is locked by this session
-            PathMap.Element element = lockMap.map(getPath(node.getId()), true);
+            PathMap.Element element = lockMap.map(getPath(session, node.getId()), true);
             if (element == null) {
                 throw new LockException("Node not locked: " + node);
             }
@@ -437,7 +437,7 @@
     public AbstractLockInfo getLockInfo(NodeId id) throws RepositoryException {
         Path path;
         try {
-            path = getPath(id);
+            path = getPath(sysSession, id);
         } catch (ItemNotFoundException e) {
             return null;
         }
@@ -485,7 +485,7 @@
 
         try {
             SessionImpl session = (SessionImpl) node.getSession();
-            Path path = getPath(node.getId());
+            Path path = getPath(session, node.getId());
 
             PathMap.Element element = lockMap.map(path, false);
             AbstractLockInfo info = (AbstractLockInfo) element.get();
@@ -543,7 +543,8 @@
         acquire();
 
         try {
-            PathMap.Element element = lockMap.map(getPath(node.getId()), true);
+            SessionImpl session = (SessionImpl) node.getSession();
+            PathMap.Element element = lockMap.map(getPath(session, node.getId()), true);
             if (element == null) {
                 return false;
             }
@@ -563,7 +564,8 @@
         acquire();
 
         try {
-            PathMap.Element element = lockMap.map(getPath(node.getId()), true);
+            SessionImpl nodeSession = (SessionImpl) node.getSession();
+            PathMap.Element element = lockMap.map(getPath(nodeSession, node.getId()), true);
             if (element == null) {
                 return false;
             }
@@ -583,7 +585,8 @@
         acquire();
 
         try {
-            Path path = getPath(node.getId());
+            SessionImpl session = (SessionImpl) node.getSession();
+            Path path = getPath(session, node.getId());
 
             PathMap.Element element = lockMap.map(path, false);
             AbstractLockInfo info = (AbstractLockInfo) element.get();
@@ -609,7 +612,7 @@
             throws LockException, RepositoryException {
 
         SessionImpl session = (SessionImpl) node.getSession();
-        checkLock(getPath(node.getId()), session);
+        checkLock(getPath(session, node.getId()), session);
     }
 
     /**
@@ -637,7 +640,7 @@
             LockToken lockToken = LockToken.parse(lt);
 
             NodeImpl node = (NodeImpl)
-                this.session.getItemManager().getItem(lockToken.getId());
+                this.sysSession.getItemManager().getItem(lockToken.getId());
             PathMap.Element element = lockMap.map(node.getPrimaryPath(), true);
             if (element != null) {
                 AbstractLockInfo info = (AbstractLockInfo) element.get();
@@ -671,7 +674,7 @@
             LockToken lockToken = LockToken.parse(lt);
 
             NodeImpl node = (NodeImpl)
-                this.session.getItemManager().getItem(lockToken.getId());
+                this.sysSession.getItemManager().getItem(lockToken.getId());
             PathMap.Element element = lockMap.map(node.getPrimaryPath(), true);
             if (element != null) {
                 AbstractLockInfo info = (AbstractLockInfo) element.get();
@@ -698,7 +701,7 @@
      * Return the path of an item given its id. This method will lookup the
      * item inside the systme session.
      */
-    private Path getPath(ItemId id) throws RepositoryException {
+    private Path getPath(SessionImpl session, ItemId id) throws RepositoryException {
         return session.getHierarchyManager().getPath(id);
     }
 
@@ -993,7 +996,7 @@
 
             try {
                 he = new HierarchyEvent(event.getChildId(),
-                        session.getQPath(event.getPath()).getNormalizedPath(),
+                        sysSession.getQPath(event.getPath()).getNormalizedPath(),
                         event.getType());
             } catch (MalformedPathException e) {
                 log.info("Unable to get event's path: " + e.getMessage());
@@ -1037,7 +1040,7 @@
         for (int i = 0; i < infos.size(); i++) {
             LockInfo info = (LockInfo) infos.get(i);
             try {
-                NodeImpl node = (NodeImpl) session.getItemManager().
+                NodeImpl node = (NodeImpl) sysSession.getItemManager().
                         getItem(info.getId());
                 lockMap.put(node.getPrimaryPath(), info);
             } catch (RepositoryException e) {
@@ -1177,7 +1180,7 @@
                         // Use system session present with lock-mgr as fallback
                         // in order to make sure, that session-scoped locks are
                         // properly cleaned.
-                        SessionImpl systemSession = LockManagerImpl.this.session;
+                        SessionImpl systemSession = LockManagerImpl.this.sysSession;
                         setLockHolder(systemSession);
                         try {
                             NodeImpl node = (NodeImpl) systemSession.getItemManager().getItem(getId());
@@ -1222,7 +1225,7 @@
         acquire();
 
         try {
-            Path path = getPath(nodeId);
+            Path path = getPath(sysSession, nodeId);
 
             // create lock token
             LockInfo info = new LockInfo(new LockToken(nodeId), false, isDeep, lockOwner);
@@ -1242,7 +1245,7 @@
         acquire();
 
         try {
-            Path path = getPath(nodeId);
+            Path path = getPath(sysSession, nodeId);
             PathMap.Element element = lockMap.map(path, true);
             if (element == null) {
                 throw new LockException("Node not locked: " + path.toString());

Modified: jackrabbit/branches/1.x/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.x/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java?rev=776761&r1=776760&r2=776761&view=diff
==============================================================================
--- jackrabbit/branches/1.x/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
(original)
+++ jackrabbit/branches/1.x/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
Wed May 20 16:48:47 2009
@@ -887,7 +887,7 @@
      * Test locking a new node inside a transaction.
      * @throws Exception
      */
-    public void xxxtestLockNewNode() throws Exception {
+    public void testLockNewNode() throws Exception {
         // get user transaction object, start
         UserTransaction utx = new UserTransactionImpl(superuser);
         utx.begin();
@@ -900,9 +900,27 @@
 
         // lock this new node
         n.lock(false, true);
+        assertTrue("Node locked in transaction", n.isLocked());
 
         // commit
         utx.commit();
+        
+        // Check if it is locked in other session
+        Session other = helper.getSuperuserSession();
+        Node nOther = other.getNodeByUUID(n.getUUID());        
+        assertTrue(nOther.isLocked());
+
+        // Check if it is also locked in other transaction
+        Session other2 = helper.getSuperuserSession();
+        // start new Transaction and try to add locktoken
+        utx = new UserTransactionImpl(other2);
+        utx.begin();
+        
+        Node nOther2 = other2.getNodeByUUID(n.getUUID());        
+        assertTrue(nOther2.isLocked());
+        
+        utx.commit();
+
     }
 
     /**



Mime
View raw message