[exo-jcr-commits] exo-jcr SVN: r4356 - in jcr/branches/1.12.x: exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/lock and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue May 10 08:18:03 EDT 2011


Author: paristote
Date: 2011-05-10 08:18:02 -0400 (Tue, 10 May 2011)
New Revision: 4356

Added:
   jcr/branches/1.12.x/patch/1.12.9-GA/JCR-1615/readme.txt
Modified:
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/lock/TestLock.java
Log:
JCR-1615

What is the problem to fix?
1- Go to the Drive "Collaboration"
2- Lock the "documents" folder
3- Create a new document in the "documents" folder, save it as draft than close it
4- Click on the "publish" button: we get an exception: "javax.jcr.lock.LockException: Node /Documents is locked..."
5- Changing publication state through Manage Publications action: it works fine even if the item is locked. 

How is the problem fixed?

    On JCR side locking bug is fixed. When calling Node.checkIn() JCR checks if parent is locked, that is actually a bug. Since Node.checkIn() doesn't modify the parent node, so it should only check if current node not locked.



Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java	2011-05-10 12:01:51 UTC (rev 4355)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java	2011-05-10 12:18:02 UTC (rev 4356)
@@ -433,8 +433,8 @@
       if (hasProperty(Constants.JCR_MERGEFAILED))
          throw new VersionException("Node has jcr:mergeFailed " + getPath());
 
-      if (!parent().checkLocking())
-         throw new LockException("Node " + parent().getPath() + " is locked ");
+      if (!checkLocking())
+         throw new LockException("Node " + getPath() + " is locked ");
 
       // the new version identifier
       String verIdentifier = IdGenerator.generate();
@@ -480,6 +480,9 @@
          throw new UnsupportedRepositoryOperationException(
             "Node.checkout() is not supported for not mix:versionable node ");
 
+      if (!checkLocking())
+         throw new LockException("Node " + getPath() + " is locked ");
+      
       if (checkedOut())
          return;
 

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/lock/TestLock.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/lock/TestLock.java	2011-05-10 12:01:51 UTC (rev 4355)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/lock/TestLock.java	2011-05-10 12:18:02 UTC (rev 4356)
@@ -50,17 +50,21 @@
       super.setUp();
 
       if (lockedNode == null)
+      {
          try
          {
             lockedNode = root.addNode("locked node");
             if (lockedNode.canAddMixin("mix:lockable"))
+            {
                lockedNode.addMixin("mix:lockable");
+            }
             root.save();
          }
          catch (RepositoryException e)
          {
             fail("Child node must be accessible and readable. But error occurs: " + e);
          }
+      }
    }
 
    /**
@@ -223,7 +227,9 @@
       Session session1 = repository.login(new CredentialsImpl("admin", "admin".toCharArray()), "ws");
       Node nodeToLockSession1 = session1.getRootNode().addNode("nodeToLockSession1");
       if (nodeToLockSession1.canAddMixin("mix:lockable"))
+      {
          nodeToLockSession1.addMixin("mix:lockable");
+      }
       session1.save();
       Lock lock = nodeToLockSession1.lock(true, false);// boolean isSessionScoped
       // in ECM we are using lock(true, true) without saving lockToken
@@ -317,7 +323,9 @@
       Session session1 = repository.login(new CredentialsImpl("admin", "admin".toCharArray()), "ws");
       Node nodeToCopyLock = session1.getRootNode().addNode("node2testCopyLockedNode");
       if (nodeToCopyLock.canAddMixin("mix:lockable"))
+      {
          nodeToCopyLock.addMixin("mix:lockable");
+      }
       session1.save();
       Lock lock = nodeToCopyLock.lock(true, false);// boolean isSessionScoped
       // in ECM we are using lock(true, true) without saving lockToken
@@ -503,4 +511,70 @@
       }
    }
 
+
+   public void testCheckInWhenParentLocked() throws RepositoryException
+   {
+      // creating node that is going to be locked, adding a child also.
+
+      Session session1 = repository.login(new CredentialsImpl("root", "exo".toCharArray()), "ws");
+      Node parentLockedNodeSession1 = session1.getRootNode().addNode("testCheckInWhenParentLocked");
+      parentLockedNodeSession1.addMixin("mix:lockable");
+      parentLockedNodeSession1.addMixin("mix:versionable");
+      Node childNodeSession1 = parentLockedNodeSession1.addNode("child");
+      childNodeSession1.addMixin("mix:versionable");
+      childNodeSession1.setProperty("property", "value");
+      session1.save();
+      // locking it    
+      parentLockedNodeSession1.lock(false, false);
+      session1.save();
+      assertTrue(parentLockedNodeSession1.isLocked());
+      Node parentLockedNode = session.getRootNode().getNode("testCheckInWhenParentLocked");
+      Node childNode = parentLockedNode.getNode("child");
+
+      try
+      {
+         childNode.checkin();
+      }
+      catch (LockException e)
+      {
+         fail("CheckIn shouldn't throw a lockException if parent node locked with isDeep=false");
+      }
+
+      session1.logout();
+
+   }
+   
+   public void testCheckOutWhenLocked() throws RepositoryException
+   {
+      // creating node that is going to be locked, adding a child also.
+
+      Session session1 = repository.login(new CredentialsImpl("root", "exo".toCharArray()), "ws");
+      Node lockedNodeSession1 = session1.getRootNode().addNode("testCheckOutWhenLocked");
+      lockedNodeSession1.addMixin("mix:lockable");
+      lockedNodeSession1.addMixin("mix:versionable");
+      session1.save();
+      lockedNodeSession1.checkin();
+      // locking it    
+      lockedNodeSession1.lock(false, false);
+      session1.save();
+      assertTrue(lockedNodeSession1.isLocked());
+
+      Node lockedNode = session.getRootNode().getNode("testCheckOutWhenLocked");
+
+      try
+      {
+         lockedNode.checkout();
+         fail("Lock exeption should be thrown");
+      }
+      catch (LockException e)
+      {
+         // it's okey
+      }
+
+      lockedNodeSession1.checkout();
+      session1.save();
+
+      session1.logout();
+   }
+   
 }

Added: jcr/branches/1.12.x/patch/1.12.9-GA/JCR-1615/readme.txt
===================================================================
--- jcr/branches/1.12.x/patch/1.12.9-GA/JCR-1615/readme.txt	                        (rev 0)
+++ jcr/branches/1.12.x/patch/1.12.9-GA/JCR-1615/readme.txt	2011-05-10 12:18:02 UTC (rev 4356)
@@ -0,0 +1,70 @@
+Summary
+
+    Status: Problem when publishing a locked item
+    CCP Issue: CCP-848, Product Jira Issue: JCR-1615.
+    Fixes also: ECMS-2079
+    Complexity: N/A
+
+The Proposal
+Problem description
+
+What is the problem to fix?
+1- Go to the Drive "Collaboration"
+2- Lock the "documents" folder
+3- Create a new document in the "documents" folder, save it as draft than close it
+4- Click on the "publish" button: we get an exception: "javax.jcr.lock.LockException: Node /Documents is locked..."
+5- Changing publication state through Manage Publications action: it works fine even if the item is locked.
+Fix description
+
+How is the problem fixed?
+
+    On JCR side locking bug is fixed. When calling Node.checkIn() JCR checks if parent is locked, that is actually a bug. Since Node.checkIn() doesn't modify the parent node, so it should only check if current node not locked.
+
+Patch information:
+Patch files: JCR-1615.patch
+
+Tests to perform
+
+Reproduction test
+
+    org.exoplatform.services.jcr.api.lock.TestLock.testCheckInWhenParentLocked()
+
+Tests performed at DevLevel
+
+    Full set of JCR-TCK and eXo-JCR tests
+
+Tests performed at QA/Support Level
+*
+
+Documentation changes
+
+Documentation changes:
+    No
+
+Configuration changes
+
+Configuration changes:
+    No
+
+Will previous configuration continue to work?
+    Yes
+
+Risks and impacts
+
+Can this bug fix have any side effects on current client projects?
+    None
+
+Is there a performance risk/cost?
+    No
+
+Validation (PM/Support/QA)
+
+PM Comment
+* Patch approved.
+
+Support Comment
+* Patch validated.
+
+QA Feedbacks
+*
+



More information about the exo-jcr-commits mailing list