jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1499246 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/ oak-mk-api/src/main/java/org/apache/jackrabbit/mk/api/
Date Wed, 03 Jul 2013 08:10:36 GMT
Author: angela
Date: Wed Jul  3 08:10:35 2013
New Revision: 1499246

URL: http://svn.apache.org/r1499246
Log:
OAK-753 : TreeImpl exposes hidden child trees

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/HiddenTreeTest.java
    jackrabbit/oak/trunk/oak-mk-api/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java?rev=1499246&r1=1499245&r2=1499246&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
Wed Jul  3 08:10:35 2013
@@ -18,38 +18,25 @@
  */
 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 com.google.common.collect.Iterables.size;
-import static com.google.common.collect.Iterables.transform;
-import static org.apache.jackrabbit.JcrConstants.JCR_UUID;
-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 java.util.Collections;
 import java.util.Iterator;
 import java.util.Set;
-
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import com.google.common.base.Function;
 import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Sets;
+import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.core.RootImpl.Move;
+import org.apache.jackrabbit.oak.plugins.index.IndexConstants;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryPropertyBuilder;
 import org.apache.jackrabbit.oak.plugins.memory.MultiStringPropertyState;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
@@ -57,6 +44,21 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
 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 com.google.common.collect.Iterables.size;
+import static com.google.common.collect.Iterables.transform;
+import static org.apache.jackrabbit.JcrConstants.JCR_UUID;
+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;
+
 public class TreeImpl implements Tree {
 
     /**
@@ -64,6 +66,9 @@ public class TreeImpl implements Tree {
      */
     public static final String OAK_CHILD_ORDER = ":childOrder";
 
+    // TODO: make this configurable
+    public static final Set<String> HIDDEN_NAMES = ImmutableSet.of(IndexConstants.INDEX_CONTENT_NODE_NAME,
MicroKernel.CONFLICT_NAME);
+
     /**
      * Underlying {@code Root} of this {@code Tree} instance
      */
@@ -122,7 +127,7 @@ public class TreeImpl implements Tree {
 
     @Override
     public Status getStatus() {
-        enter();
+        checkExists();
         if (nodeBuilder.isNew()) {
             return NEW;
         } else if (nodeBuilder.isModified()) {
@@ -207,13 +212,19 @@ public class TreeImpl implements Tree {
         checkNotNull(name);
         enter();
         TreeImpl child = new TreeImpl(root, this, name, pendingMoves);
-        return child.nodeBuilder.exists();
+        return child.exists();
     }
 
     @Override
     public long getChildrenCount() {
         enter();
-        return nodeBuilder.getChildNodeCount();
+        long childCnt = nodeBuilder.getChildNodeCount();
+        for (String name : HIDDEN_NAMES) {
+            if (nodeBuilder.hasChildNode(name)) {
+                childCnt--;
+            }
+        }
+        return childCnt;
     }
 
     @Override
@@ -226,7 +237,12 @@ public class TreeImpl implements Tree {
             childNames = nodeBuilder.getChildNodeNames();
         }
         return transform(
-                childNames,
+                filter(childNames, new Predicate<String>() {
+                    @Override
+                    public boolean apply(@Nullable String name) {
+                        return !isHidden(name);
+                    }
+                }),
                 new Function<String, Tree>() {
                     @Override
                     public Tree apply(String input) {
@@ -455,7 +471,9 @@ public class TreeImpl implements Tree {
 
     private boolean enter() {
         root.checkLive();
-        if (applyPendingMoves()) {
+        if (isHidden(name)) {
+            return false;
+        } else if (applyPendingMoves()) {
             return reconnect();
         } else {
             return nodeBuilder.exists();
@@ -463,7 +481,6 @@ public class TreeImpl implements Tree {
     }
 
     private static boolean isHidden(String name) {
-        // FIXME clarify handling of hidden items (OAK-753).
         return NodeStateUtils.isHidden(name);
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/HiddenTreeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/HiddenTreeTest.java?rev=1499246&r1=1499245&r2=1499246&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/HiddenTreeTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/HiddenTreeTest.java
Wed Jul  3 08:10:35 2013
@@ -18,12 +18,13 @@ package org.apache.jackrabbit.oak.securi
 
 import org.apache.jackrabbit.oak.api.Tree;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 /**
  * Test to make sure hidden trees are never exposed.
@@ -44,26 +45,54 @@ public class HiddenTreeTest extends Abst
         assertTrue(parent.exists());
     }
 
-    @Ignore("OAK-753") // FIXME
     @Test
     public void testHasHiddenTree() {
         assertFalse(parent.hasChild(hiddenName));
     }
 
-    @Ignore("OAK-753") // FIXME
     @Test
     public void testGetHiddenTree() {
-        assertFalse(parent.getChild(hiddenName).exists());
+        Tree hidden = parent.getChild(hiddenName);
+        assertNotNull(hidden);
+        assertFalse(hidden.exists());
+    }
+
+    @Test
+    public void testOrderBeforeOnHiddenTree() {
+        try {
+            Tree hidden = parent.getChild(hiddenName);
+            hidden.orderBefore("someother");
+            fail("IllegalStateException expected");
+        } catch (IllegalStateException e) {
+            // success
+        }
+    }
+
+    @Test
+    public void testSetOrderableChildNodesOnHiddenTree() {
+        try {
+            Tree hidden = parent.getChild(hiddenName);
+            hidden.setOrderableChildren(true);
+            fail("IllegalStateException expected");
+        } catch (IllegalStateException e) {
+            // success
+        }
+
+        try {
+            Tree hidden = parent.getChild(hiddenName);
+            hidden.setOrderableChildren(false);
+            fail("IllegalStateException expected");
+        } catch (IllegalStateException e) {
+            // success
+        }
     }
 
-    @Ignore("OAK-753") // FIXME
     @Test
     public void testGetHiddenChildren() {
         Iterable<Tree> children = parent.getChildren();
         assertFalse(children.iterator().hasNext());
     }
 
-    @Ignore("OAK-753") // FIXME
     @Test
     public void testGetHiddenChildrenCount() {
         assertEquals(0, parent.getChildrenCount());

Modified: jackrabbit/oak/trunk/oak-mk-api/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk-api/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java?rev=1499246&r1=1499245&r2=1499246&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk-api/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java
(original)
+++ jackrabbit/oak/trunk/oak-mk-api/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java
Wed Jul  3 08:10:35 2013
@@ -71,6 +71,8 @@ import javax.annotation.Nonnull;
  */
 public interface MicroKernel {
 
+    public static final String CONFLICT_NAME = ":conflict";
+
     //---------------------------------------------------------< REVISION ops >
 
     /**
@@ -506,7 +508,7 @@ public interface MicroKernel {
      * <p/>
      * If rebasing results in a conflict, conflicting nodes are annotated with a conflict
      * marker denoting the type of the conflict and the value(s) before the rebase operation.
-     * The conflict marker is an internal node with the name {@code :conflict} and is added
+     * The conflict marker is an internal node with the name {@link #CONFLICT_NAME} and is
added
      * to the node whose properties or child nodes are in conflict.
      * <p/>
      * type of conflicts:



Mime
View raw message