jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1520247 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/api/ oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/
Date Thu, 05 Sep 2013 08:19:22 GMT
Author: angela
Date: Thu Sep  5 08:19:22 2013
New Revision: 1520247

URL: http://svn.apache.org/r1520247
Log:
OAK-998 : Node#orderBefore() is not JCR conform

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OrderableNodesTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java?rev=1520247&r1=1520246&r2=1520247&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java Thu
Sep  5 08:19:22 2013
@@ -18,12 +18,12 @@
  */
 package org.apache.jackrabbit.oak.api;
 
-import com.google.common.base.Function;
-
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
+import com.google.common.base.Function;
+
 /**
  * A tree instance represents a snapshot of the {@link ContentRepository}
  * tree at the time the instance was acquired from a {@link ContentSession}.
@@ -292,7 +292,7 @@ public interface Tree {
      *             before. This tree will become the last sibling if
      *             {@code name} is {@code null}.
      * @return {@code false} if there is no sibling with the given
-     *         {@code name} and no reordering was performed;
+     *         {@code name} or no reordering was performed;
      *         {@code true} otherwise.
      */
     boolean orderBefore(@Nullable String name);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java?rev=1520247&r1=1520246&r2=1520247&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
Thu Sep  5 08:19:22 2013
@@ -18,22 +18,8 @@
  */
 package org.apache.jackrabbit.oak.core;
 
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.collect.Iterables.filter;
-import static com.google.common.collect.Iterables.indexOf;
-import static org.apache.jackrabbit.oak.api.Tree.Status.EXISTING;
-import static org.apache.jackrabbit.oak.api.Tree.Status.MODIFIED;
-import static org.apache.jackrabbit.oak.api.Tree.Status.NEW;
-import static org.apache.jackrabbit.oak.api.Type.STRING;
-import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
-import static org.apache.jackrabbit.oak.commons.PathUtils.isAbsolute;
-import static org.apache.jackrabbit.oak.spi.state.NodeStateUtils.isHidden;
-
 import java.util.Collections;
 import java.util.Set;
-
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 
@@ -50,6 +36,19 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.PropertyBuilder;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.indexOf;
+import static org.apache.jackrabbit.oak.api.Tree.Status.EXISTING;
+import static org.apache.jackrabbit.oak.api.Tree.Status.MODIFIED;
+import static org.apache.jackrabbit.oak.api.Tree.Status.NEW;
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
+import static org.apache.jackrabbit.oak.commons.PathUtils.isAbsolute;
+import static org.apache.jackrabbit.oak.spi.state.NodeStateUtils.isHidden;
+
 public class MutableTree extends AbstractTree {
 
     /**
@@ -295,9 +294,11 @@ public class MutableTree extends Abstrac
             // root does not have siblings
             return false;
         }
-        if (name != null && !parent.hasChild(name)) {
-            // so such sibling or not accessible
-            return false;
+        if (name != null) {
+            if (name.equals(this.name) || !parent.hasChild(name)) {
+                // same node or no such sibling (not existing or not accessible)
+                return false;
+            }
         }
         // perform the reorder
         parent.ensureChildOrderProperty();

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OrderableNodesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OrderableNodesTest.java?rev=1520247&r1=1520246&r2=1520247&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OrderableNodesTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OrderableNodesTest.java
Thu Sep  5 08:19:22 2013
@@ -18,15 +18,14 @@ package org.apache.jackrabbit.oak.jcr;
 
 import java.util.ArrayList;
 import java.util.List;
-
-import org.apache.jackrabbit.commons.iterator.NodeIterable;
-import org.junit.Test;
-
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
+import org.apache.jackrabbit.commons.iterator.NodeIterable;
+import org.junit.Test;
+
 import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -50,6 +49,15 @@ public class OrderableNodesTest extends 
     }
 
     @Test
+    public void orderSameNode() throws Exception {
+        Session session = getAdminSession();
+        Node n = session.getRootNode().addNode("test", "nt:unstructured");
+        Node a = n.addNode("a");
+
+        n.orderBefore("a", "a");
+    }
+
+    @Test
     public void setPrimaryType() throws Exception {
         new TestContentLoader().loadTestContent(getAdminSession());
         // start with a node without orderable nodes



Mime
View raw message