jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r772892 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src: main/java/org/apache/jackrabbit/jcr2spi/operation/ main/java/org/apache/jackrabbit/jcr2spi/state/ test/java/org/apache/jackrabbit/jcr2spi/
Date Fri, 08 May 2009 08:51:00 GMT
Author: angela
Date: Fri May  8 08:51:00 2009
New Revision: 772892

URL: http://svn.apache.org/viewvc?rev=772892&view=rev
Log:
JCR-2005: JCR2SPI: Remove validation check for same-named Node and Property

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/MoveTest.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/WorkspaceMoveTest.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java?rev=772892&r1=772891&r2=772892&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java
Fri May  8 08:51:00 2009
@@ -182,10 +182,6 @@
 
         if (sessionMove) {
             NodeEntry destEntry = (NodeEntry) destParentState.getHierarchyEntry();
-            if (destEntry.hasPropertyEntry(destName)) {
-                // TODO: remove for 283
-                throw new ItemExistsException("Move destination already exists (Property).");
-            }
 
             // force childnodeentries list to be present before the move is executed
             // on the hierarchy entry.

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java?rev=772892&r1=772891&r2=772892&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java
Fri May  8 08:51:00 2009
@@ -546,13 +546,12 @@
      */
     private void checkCollision(NodeState parentState, Name propertyName) throws ItemExistsException,
RepositoryException {
         NodeEntry parentEntry = (NodeEntry) parentState.getHierarchyEntry();
-        // check for name collisions with existing child nodes
-        if (parentEntry.hasNodeEntry(propertyName)) {
-            String msg = "Child node with name '" + propertyName + "' already exists.";
-            log.debug(msg);
-            throw new RepositoryException(msg);
-        }
-        // check for name collisions with existing properties
+         // NOTE: check for name collisions with existing child node has been
+         // removed as with JSR 283 having same-named node and property can be
+         // allowed. thus delegate the correspoding validation to the underlying
+         // SPI implementation.
+
+        // check for name collisions with an existing property
         PropertyEntry pe = parentEntry.getPropertyEntry(propertyName);
         if (pe != null) {
             try {
@@ -575,13 +574,13 @@
      * @throws NoSuchNodeTypeException
      */
     private void checkCollision(NodeState parentState, Name nodeName, Name nodeTypeName)
throws RepositoryException, ConstraintViolationException, NoSuchNodeTypeException {
-        if (parentState.hasPropertyName(nodeName)) {
-            // there's already a property with that name
-            throw new ItemExistsException("cannot add child node '"
-                + nodeName.getLocalName() + "' to " + safeGetJCRPath(parentState)
-                + ": colliding with same-named existing property");
+         // NOTE: check for name collisions with existing child property has been
+         // removed as with JSR 283 having same-named node and property may be
+         // allowed. thus delegate the correspoding validation to the underlying
+         // SPI implementation.
 
-        } else if (parentState.hasChildNodeEntry(nodeName, Path.INDEX_DEFAULT)) {
+         // check for conflict with existing same-name sibling node.
+         if (parentState.hasChildNodeEntry(nodeName, Path.INDEX_DEFAULT)) {
             // retrieve the existing node state that ev. conflicts with the new one.
             try {
                 NodeState conflictingState = parentState.getChildNodeState(nodeName, Path.INDEX_DEFAULT);
@@ -591,9 +590,9 @@
                 // check same-name sibling setting of both target and existing node
                 if (!(conflictDef.allowsSameNameSiblings() && newDef.allowsSameNameSiblings()))
{
                     throw new ItemExistsException("Cannot add child node '"
-                        + nodeName.getLocalName() + "' to "
-                        + safeGetJCRPath(parentState)
-                        + ": colliding with same-named existing node.");
+                            + nodeName.getLocalName() + "' to "
+                            + safeGetJCRPath(parentState)
+                            + ": colliding with same-named existing node.");
                 }
             } catch (ItemNotFoundException e) {
                 // ignore: conflicting doesn't exist any more

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/MoveTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/MoveTest.java?rev=772892&r1=772891&r2=772892&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/MoveTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/MoveTest.java
Fri May  8 08:51:00 2009
@@ -27,6 +27,7 @@
 import javax.jcr.Item;
 import javax.jcr.Property;
 import javax.jcr.ItemExistsException;
+import javax.jcr.Repository;
 
 /**
  * <code>MoveTest</code>...
@@ -232,10 +233,11 @@
     /**
      * Tries to move a node using <code>{@link javax.jcr.Session#move(String src, String
dest)}
      * </code> to a location where a property already exists with same name.
-     * <br/> <br/>
-     * This should throw an <code>{@link javax.jcr.ItemExistsException}</code>.
+     * <br/>
+     * With JCR 1.0 this should throw an <code>{@link javax.jcr.ItemExistsException}</code>.
+     * With JCR 2.0 this must succeed.
      */
-    public void testMovePropertyExistsException() throws RepositoryException, NotExecutableException
{
+    public void testMovePropertyExists() throws RepositoryException, NotExecutableException
{
         // try to create a property with the name of the node to be moved
         // to the destination parent
         Property destProperty;
@@ -245,12 +247,18 @@
             throw new NotExecutableException("Cannot create property with name '" +nodeName2+
"' and value 'anyString' at move destination.");
         }
 
-        try {
-            // move the node
+        if ("1.0".equals(helper.getRepository().getDescriptor(Repository.SPEC_VERSION_DESC)))
{
+            try {
+                // move the node
+                doMove(moveNode.getPath(), destProperty.getPath());
+                fail("Moving a node to a location where a property exists must throw ItemExistsException");
+            } catch (ItemExistsException e) {
+                // ok, works as expected
+            }
+        } else {
+            // move the node: same name property and node must be supported
+            // see Issue 725 
             doMove(moveNode.getPath(), destProperty.getPath());
-            fail("Moving a node to a location where a property exists must throw ItemExistsException");
-        } catch (ItemExistsException e) {
-            // ok, works as expected
         }
     }
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java?rev=772892&r1=772891&r2=772892&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java
Fri May  8 08:51:00 2009
@@ -56,7 +56,7 @@
         suite.addTestSuite(MoveTreeTest.class);
         suite.addTestSuite(MoveNewTreeTest.class);
         suite.addTestSuite(MoveMultipleTest.class);
-        //suite.addTestSuite(WorkspaceMoveTest.class);  // see JCR-1276
+        suite.addTestSuite(WorkspaceMoveTest.class);
         suite.addTestSuite(RevertMoveTest.class);
         suite.addTestSuite(MoveToNewTest.class);
         suite.addTestSuite(MoveCombinedTest.class);

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/WorkspaceMoveTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/WorkspaceMoveTest.java?rev=772892&r1=772891&r2=772892&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/WorkspaceMoveTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/WorkspaceMoveTest.java
Fri May  8 08:51:00 2009
@@ -21,6 +21,7 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Property;
 import javax.jcr.ItemExistsException;
+import javax.jcr.Repository;
 
 /**
  * <code>WorkspaceMoveTest</code>...
@@ -40,9 +41,10 @@
      * Tries to move a node using to a location where a property already exists
      * with same name.
      * <br/> <br/>
-     * This should throw an <code>{@link javax.jcr.ItemExistsException}</code>.
+     * With JCR 1.0 this should throw an <code>{@link javax.jcr.ItemExistsException}</code>.
+     * With JCR 2.0 this must succeed.
      */
-    public void testMovePropertyExistsException() throws RepositoryException, NotExecutableException
{
+    public void testMovePropertyExists() throws RepositoryException, NotExecutableException
{
         // try to create a property with the name of the node to be moved
         // to the destination parent
         Property destProperty;
@@ -53,12 +55,17 @@
             throw new NotExecutableException("Cannot create property with name '" +nodeName2+
"' and value 'anyString' at move destination.");
         }
 
-        try {
-            // move the node
+        if ("1.0".equals(helper.getRepository().getDescriptor(Repository.SPEC_VERSION_DESC)))
{
+            try {
+                // move the node
+                doMove(moveNode.getPath(), destProperty.getPath());
+                fail("Moving a node to a location where a property exists must throw ItemExistsException");
+            } catch (ItemExistsException e) {
+                // ok, works as expected
+            }
+        } else {
+            // JCR 2.0 move the node: same name property and node must be supported
             doMove(moveNode.getPath(), destProperty.getPath());
-            fail("Moving a node to a location where a property exists must throw ItemExistsException");
-        } catch (ItemExistsException e) {
-            // ok, works as expected
         }
     }
 
@@ -74,12 +81,17 @@
 
         // workspace-move the node (must succeed)
         doMove(moveNode.getPath(), destProperty.getPath());
-        try {
-            // saving transient new property must fail
-            destParentNode.save();
-            fail("Saving new transient property must fail");
-        } catch (RepositoryException e) {
-            // ok.
-        }
+         if ("1.0".equals(helper.getRepository().getDescriptor(Repository.SPEC_VERSION_DESC)))
{
+             try {
+                 // saving transient new property must fail
+                 destParentNode.save();
+                 fail("Saving new transient property must fail");
+            } catch (RepositoryException e) {
+                // ok.
+             }
+         } else {
+             // JCR 2.0: saving must succeed.
+             destParentNode.save();
+         }
     }
 }
\ No newline at end of file



Mime
View raw message