jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1502473 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/api/ main/java/org/apache/jackrabbit/oak/core/ main/java/org/apache/jackrabbit/oak/plugins/commit/ main/java/org/apache/jackrabbit/oak/security/authorizat...
Date Fri, 12 Jul 2013 08:43:26 GMT
Author: mduerig
Date: Fri Jul 12 08:43:25 2013
New Revision: 1502473

URL: http://svn.apache.org/r1502473
Log:
OAK-798: Review / refactor TreeImpl and related classes
Factor common code of Tree implementations into abstract base class

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractTree.java   (with props)
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/IdentifierManager.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/ChildOrderConflictHandler.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidator.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/ChildOrderDiff.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHook.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidator.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/TreeImplTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/ChildOrderPropertyTest.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=1502473&r1=1502472&r2=1502473&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 Fri Jul 12 08:43:25 2013
@@ -154,7 +154,7 @@ public interface Tree {
      *         if no such property state exists or the property is not accessible.
      */
     @CheckForNull
-    PropertyState getProperty(String name);
+    PropertyState getProperty(@Nonnull String name);
 
     /**
      * Get the {@code Status} of a property state or {@code null}.
@@ -165,7 +165,7 @@ public interface Tree {
      *         to a property that is not accessible.
      */
     @CheckForNull
-    Status getPropertyStatus(String name);
+    Status getPropertyStatus(@Nonnull String name);
 
     /**
      * Determine if a property state exists and is accessible.
@@ -174,7 +174,7 @@ public interface Tree {
      * @return {@code true} if and only if a property with the given {@code name}
      *         exists and is accessible.
      */
-    boolean hasProperty(String name);
+    boolean hasProperty(@Nonnull String name);
 
     /**
      * Determine the number of properties accessible to the current content session.
@@ -246,7 +246,7 @@ public interface Tree {
      * @return the {@code Tree} instance of the child with the given {@code name}.
      */
     @Nonnull
-    Tree addChild(String name);
+    Tree addChild(@Nonnull String name);
 
     /**
      * Changes the nature of this tree such that the order of the children
@@ -304,7 +304,7 @@ public interface Tree {
      * @param <T>   The type of this property. Must be one of {@code String, Blob, byte[], Long, Integer, Double, Boolean, BigDecimal}
      * @throws IllegalArgumentException if {@code T} is not one of the above types.
      */
-    <T> void setProperty(String name, @Nonnull T value);
+    <T> void setProperty(@Nonnull String name, @Nonnull T value);
 
     /**
      * Set a property state
@@ -314,7 +314,7 @@ public interface Tree {
      * @param type  The type of this property.
      * @param <T>   The type of this property.
      */
-    <T> void setProperty(String name, @Nonnull T value, Type<T> type);
+    <T> void setProperty(@Nonnull String name, @Nonnull T value, Type<T> type);
 
     /**
      * Remove the property with the given name. This method has no effect if a
@@ -322,6 +322,6 @@ public interface Tree {
      *
      * @param name The name of the property
      */
-    void removeProperty(String name);
+    void removeProperty(@Nonnull String name);
 
 }

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractTree.java?rev=1502473&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractTree.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractTree.java Fri Jul 12 08:43:25 2013
@@ -0,0 +1,284 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.jackrabbit.oak.core;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.size;
+import static com.google.common.collect.Iterables.transform;
+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.spi.state.NodeStateUtils.isHidden;
+
+import java.util.Iterator;
+
+import javax.annotation.Nonnull;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import org.apache.jackrabbit.JcrConstants;
+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.commons.PathUtils;
+import org.apache.jackrabbit.oak.plugins.index.IndexConstants;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+
+/**
+ * {@code AbstractTree} provides default implementations for most
+ * read methods of {@code Tree}. Furthermore it handles the
+ * {@link #setOrderableChildren(boolean) ordering} of child nodes
+ * and controls visibility of internal items.
+ */
+public abstract class AbstractTree implements Tree {
+
+    /**
+     * Name of the internal property that contains the child order
+     */
+    public static final String OAK_CHILD_ORDER = ":childOrder";
+
+    // TODO: make this configurable
+    private static final String[] INTERNAL_NODE_NAMES = {IndexConstants.INDEX_CONTENT_NODE_NAME, MicroKernel.CONFLICT_NAME};
+
+    /**
+     * Flag to control visibility of internal properties
+     */
+    private final boolean showInternalProperties;
+
+    /**
+     * Name of this tree
+     */
+    protected String name;
+
+    /**
+     * The {@code NodeBuilder} for the underlying node state
+     */
+    protected NodeBuilder nodeBuilder;
+
+    /**
+     * Create a new {@code AbstractTree} instance
+     * @param name  name of the tree
+     * @param nodeBuilder  {@code NodeBuilder} for the underlying node state
+     * @param showInternalProperties  whether to show internal properties
+     */
+    protected AbstractTree(@Nonnull String name, @Nonnull NodeBuilder nodeBuilder, boolean showInternalProperties) {
+        this.name = checkNotNull(name);
+        this.nodeBuilder = checkNotNull(nodeBuilder);
+        this.showInternalProperties = showInternalProperties;
+    }
+
+    /**
+     * Factory method for creating child trees
+     * @param name  name of the child tree
+     * @return  child tree of this tree with the given {@code name}
+     */
+    @Nonnull
+    protected abstract AbstractTree createChild(@Nonnull String name);
+
+    /**
+     * @return {@code true} if this tree has orderable children;
+     *         {@code false} otherwise.
+     */
+    protected boolean hasOrderableChildren() {
+        return nodeBuilder.hasProperty(OAK_CHILD_ORDER);
+    }
+
+    /**
+     * Returns the list of child names considering its ordering
+     * when the {@link #OAK_CHILD_ORDER} property is set.
+     *
+     * @return the list of child names.
+     */
+    @Nonnull
+    protected Iterable<String> getChildNames() {
+        if (hasOrderableChildren()) {
+            return new Iterable<String>() {
+                @Override
+                public Iterator<String> iterator() {
+                    return new Iterator<String>() {
+                        final PropertyState childOrder = nodeBuilder.getProperty(OAK_CHILD_ORDER);
+                        int index;
+
+                        @Override
+                        public boolean hasNext() {
+                            return index < childOrder.count();
+                        }
+
+                        @Override
+                        public String next() {
+                            return childOrder.getValue(STRING, index++);
+                        }
+
+                        @Override
+                        public void remove() {
+                            throw new UnsupportedOperationException();
+                        }
+                    };
+                }
+            };
+        } else {
+            return nodeBuilder.getChildNodeNames();
+        }
+    }
+
+    //------------------------------------------------------------< Tree >---
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public boolean isRoot() {
+        return name.isEmpty();
+    }
+
+    @Override
+    public String getPath() {
+        if (isRoot()) {
+            return "/";
+        } else {
+            StringBuilder sb = new StringBuilder();
+            buildPath(sb);
+            return sb.toString();
+        }
+    }
+
+    private void buildPath(StringBuilder sb) {
+        if (!isRoot()) {
+            getParent().buildPath(sb);
+            sb.append('/').append(name);
+        }
+    }
+
+    @Override
+    public Status getStatus() {
+        if (nodeBuilder.isNew()) {
+            return NEW;
+        } else if (nodeBuilder.isModified()) {
+            return MODIFIED;
+        } else {
+            return EXISTING;
+        }
+    }
+
+    @Override
+    public boolean exists() {
+        return !isHidden(name) && nodeBuilder.exists();
+    }
+
+    @Override
+    public abstract AbstractTree getParent();
+
+    @Override
+    public PropertyState getProperty(String name) {
+        return showInternalProperties || !isHidden(checkNotNull(name))
+            ? nodeBuilder.getProperty(name)
+            : null;
+    }
+
+    @Override
+    public boolean hasProperty(String name) {
+        return (showInternalProperties || !isHidden(checkNotNull(name))) && nodeBuilder.hasProperty(name);
+    }
+
+    @Override
+    public long getPropertyCount() {
+        return size(getProperties());
+    }
+
+    @Override
+    public Iterable<? extends PropertyState> getProperties() {
+        return filter(nodeBuilder.getProperties(),
+            new Predicate<PropertyState>() {
+                @Override
+                public boolean apply(PropertyState propertyState) {
+                    return showInternalProperties || !isHidden(propertyState.getName());
+                }
+            });
+    }
+
+    @Override
+    public boolean hasChild(String name) {
+        return createChild(checkNotNull(name)).exists();
+    }
+
+    @Override
+    public long getChildrenCount() {
+        long count = nodeBuilder.getChildNodeCount();
+        for (String name : INTERNAL_NODE_NAMES) {
+            if (nodeBuilder.hasChildNode(name)) {
+                count--;
+            }
+        }
+        return count;
+    }
+
+    @Override
+    public Iterable<Tree> getChildren() {
+        return transform(
+                filter(getChildNames(), new Predicate<String>() {
+                    @Override
+                    public boolean apply(String name) {
+                        return !isHidden(name);
+                    }
+                }),
+                new Function<String, Tree>() {
+                    @Override
+                    public Tree apply(String name) {
+                        return createChild(name);
+                    }
+                });
+    }
+
+    //------------------------------------------------------------< internal >---
+
+    /**
+     * @return  the underlying {@code NodeState} of this tree
+     */
+    @Nonnull
+    NodeState getNodeState() {
+        return nodeBuilder.getNodeState();
+    }
+
+    /**
+     * The identifier of a tree is the value of its {@code jcr:uuid} property.
+     * If no such property exists the identifier is a slash ({@code/}) if the
+     * tree is the root. Otherwise the identifier is the tree's {@code name} appended
+     * to its parent's identifier separated by a slash ({@code/}).
+     * @return  the identifier of this tree
+     */
+    @Nonnull
+    String getIdentifier() {
+        PropertyState property = nodeBuilder.getProperty(JcrConstants.JCR_UUID);
+        if (property != null) {
+            return property.getValue(STRING);
+        } else if (isRoot()) {
+            return "/";
+        } else {
+            return PathUtils.concat(getParent().getIdentifier(), getName());
+        }
+    }
+
+
+}

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractTree.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractTree.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/IdentifierManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/IdentifierManager.java?rev=1502473&r1=1502472&r2=1502473&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/IdentifierManager.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/IdentifierManager.java Fri Jul 12 08:43:25 2013
@@ -94,10 +94,8 @@ public class IdentifierManager {
      */
     @Nonnull
     public String getIdentifier(Tree tree) {
-        if (tree instanceof TreeImpl) {
-            return ((TreeImpl) tree).getIdentifier();
-        } else if (tree instanceof ImmutableTree) {
-            return ((ImmutableTree) tree).getIdentifier();
+        if (tree instanceof AbstractTree) {
+            return ((AbstractTree) tree).getIdentifier();
         } else {
             return tree.getPath();
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java?rev=1502473&r1=1502472&r2=1502473&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java Fri Jul 12 08:43:25 2013
@@ -17,26 +17,17 @@
 package org.apache.jackrabbit.oak.core;
 
 import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.filter;
-import static com.google.common.collect.Iterables.transform;
-import static org.apache.jackrabbit.oak.api.Type.STRING;
-import static org.apache.jackrabbit.oak.spi.state.NodeStateUtils.isHidden;
-
-import java.util.Iterator;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 
-import com.google.common.base.Function;
 import com.google.common.base.Objects;
-import com.google.common.base.Predicate;
-import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Root;
 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.spi.state.NodeState;
+import org.apache.jackrabbit.oak.spi.state.ReadOnlyBuilder;
 
 /**
  * Immutable implementation of the {@code Tree} interface in order to provide
@@ -97,17 +88,7 @@ import org.apache.jackrabbit.oak.spi.sta
  * however, that according to the contract defined in {@code NodeState} these
  * objects are not expected to be used as hash keys.
  */
-public final class ImmutableTree implements Tree {
-
-    /**
-     * Internal and hidden property that contains the child order
-     */
-    public static final String OAK_CHILD_ORDER = ":childOrder";
-
-    /**
-     * Name of this tree
-     */
-    private final String name;
+public final class ImmutableTree extends AbstractTree {
 
     /**
      * Underlying node state
@@ -137,10 +118,10 @@ public final class ImmutableTree impleme
 
     public ImmutableTree(@Nonnull ParentProvider parentProvider, @Nonnull String name,
                          @Nonnull NodeState state, @Nonnull TreeTypeProvider typeProvider) {
-        this.name = checkNotNull(name);
-        this.state = checkNotNull(state);
+        super(name, new ReadOnlyBuilder(state), true);
+        this.state = state;
         this.parentProvider = checkNotNull(parentProvider);
-        this.typeProvider = typeProvider;
+        this.typeProvider = checkNotNull(typeProvider);
     }
 
     public static ImmutableTree createFromRoot(@Nonnull Root root, @Nonnull TreeTypeProvider typeProvider) {
@@ -153,60 +134,32 @@ public final class ImmutableTree impleme
         }
     }
 
-    //---------------------------------------------------------------< Tree >---
-
     @Override
-    public String getName() {
-        return name;
+    protected ImmutableTree createChild(String name) {
+        return new ImmutableTree(this, name, state.getChildNode(name));
     }
 
-    @Override
-    public boolean isRoot() {
-        return "".equals(getName());
-    }
+    //---------------------------------------------------------------< Tree >---
 
     @Override
     public String getPath() {
         if (path == null) {
-            if (isRoot()) {
-                path = "/";
-            } else {
-                StringBuilder sb = new StringBuilder();
-                buildPath(sb);
-                path = sb.toString();
-            }
+            path = super.getPath();
         }
         return path;
     }
 
-    private void buildPath(StringBuilder sb) {
-        if (!isRoot()) {
-            getParent().buildPath(sb);
-            sb.append('/').append(name);
-        }
-    }
-
     @Override
     public Status getStatus() {
         return Status.EXISTING;
     }
 
     @Override
-    public boolean exists() {
-        return state.exists();
-    }
-
-    @Override
     public ImmutableTree getParent() {
         return parentProvider.getParent();
     }
 
     @Override
-    public PropertyState getProperty(String name) {
-        return state.getProperty(name);
-    }
-
-    @Override
     public Status getPropertyStatus(String name) {
         if (hasProperty(name)) {
             return Status.EXISTING;
@@ -216,52 +169,8 @@ public final class ImmutableTree impleme
     }
 
     @Override
-    public boolean hasProperty(String name) {
-        return state.hasProperty(name);
-    }
-
-    @Override
-    public long getPropertyCount() {
-        return state.getPropertyCount();
-    }
-
-    @Override
-    public Iterable<? extends PropertyState> getProperties() {
-        return state.getProperties();
-    }
-
-    @Nonnull
-    @Override
-    public ImmutableTree getChild(@Nonnull String name) {
-        NodeState child = state.getChildNode(name);
-        return new ImmutableTree(this, name, child);
-    }
-
-    @Override
-    public boolean hasChild(@Nonnull String name) {
-        return state.hasChildNode(name);
-    }
-
-    @Override
-    public long getChildrenCount() {
-        return state.getChildNodeCount();
-    }
-
-    @Override
-    public Iterable<Tree> getChildren() {
-        return transform(
-                filter(getChildNames(), new Predicate<String>() {
-                    @Override
-                    public boolean apply(String name) {
-                        return !isHidden(name);
-                    }
-                }),
-                new Function<String, Tree>() {
-                    @Override
-                    public Tree apply(String name) {
-                        return new ImmutableTree(ImmutableTree.this, name, state.getChildNode(name));
-                    }
-                });
+    public ImmutableTree getChild(String name) {
+        return createChild(name);
     }
 
     @Override
@@ -328,13 +237,9 @@ public final class ImmutableTree impleme
         return "ImmutableTree '" + getName() + "':" + state.toString();
     }
 
-    //--------------------------------------------------------------------------
-
-    public NodeState getNodeState() {
-        return state;
-    }
+    //------------------------------------------------------------< internal >---
 
-    public int getType() {
+    int getType() {
         return typeProvider.getType(this);
     }
 
@@ -347,55 +252,6 @@ public final class ImmutableTree impleme
         }
     }
 
-    @Nonnull
-    String getIdentifier() {
-        PropertyState property = state.getProperty(JcrConstants.JCR_UUID);
-        if (property != null) {
-            return property.getValue(STRING);
-        } else if (isRoot()) {
-            return "/";
-        } else {
-            return PathUtils.concat(getParent().getIdentifier(), getName());
-        }
-    }
-
-    /**
-     * Returns the list of child names considering the its ordering
-     * when the {@link #OAK_CHILD_ORDER} property is set.
-     *
-     * @return the list of child names.
-     */
-    private Iterable<String> getChildNames() {
-        if (state.hasProperty(OAK_CHILD_ORDER)) {
-            return new Iterable<String>() {
-                @Override
-                public Iterator<String> iterator() {
-                    return new Iterator<String>() {
-                        final PropertyState childOrder = state.getProperty(OAK_CHILD_ORDER);
-                        int index = 0;
-
-                        @Override
-                        public boolean hasNext() {
-                            return index < childOrder.count();
-                        }
-
-                        @Override
-                        public String next() {
-                            return childOrder.getValue(STRING, index++);
-                        }
-
-                        @Override
-                        public void remove() {
-                            throw new UnsupportedOperationException();
-                        }
-                    };
-                }
-            };
-        } else {
-            return state.getChildNodeNames();
-        }
-    }
-
     //--------------------------------------------------------------------------
 
     public interface ParentProvider {

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=1502473&r1=1502472&r2=1502473&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 Fri Jul 12 08:43:25 2013
@@ -18,56 +18,39 @@
  */
 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.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;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
-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 {
-
-    /**
-     * Internal and hidden property that contains the child order
-     */
-    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);
+public class TreeImpl extends AbstractTree {
 
     /**
      * Underlying {@code Root} of this {@code Tree} instance
@@ -79,62 +62,45 @@ public class TreeImpl implements Tree {
      */
     private TreeImpl parent;
 
-    /**
-     * Name of this tree
-     */
-    private String name;
-
-    /**
-     * The {@code NodeBuilder} for the underlying node state
-     */
-    private NodeBuilder nodeBuilder;
-
     /** Pointer into the list of pending moves */
     private Move pendingMoves;
 
     TreeImpl(RootImpl root, NodeBuilder builder, Move pendingMoves) {
+        super("", builder, false);
         this.root = checkNotNull(root);
-        this.name = "";
-        this.nodeBuilder = checkNotNull(builder);
         this.pendingMoves = checkNotNull(pendingMoves);
     }
 
     private TreeImpl(RootImpl root, TreeImpl parent, String name, Move pendingMoves) {
+        super(name, parent.nodeBuilder.getChildNode(name), false);
         this.root = checkNotNull(root);
         this.parent = checkNotNull(parent);
-        this.name = checkNotNull(name);
-        this.nodeBuilder = parent.nodeBuilder.getChildNode(name);
         this.pendingMoves = checkNotNull(pendingMoves);
     }
 
     @Override
-    public String getName() {
-        enter();
-        return name;
+    protected TreeImpl createChild(String name) {
+        return new TreeImpl(root, this, name, pendingMoves);
     }
 
+    //------------------------------------------------------------< Tree >---
+
     @Override
-    public boolean isRoot() {
+    public String getName() {
         enter();
-        return parent == null;
+        return name;
     }
 
     @Override
     public String getPath() {
         enter();
-        return getPathInternal();
+        return super.getPath();
     }
 
     @Override
     public Status getStatus() {
         checkExists();
-        if (nodeBuilder.isNew()) {
-            return NEW;
-        } else if (nodeBuilder.isModified()) {
-            return MODIFIED;
-        } else {
-            return EXISTING;
-        }
+        return super.getStatus();
     }
 
     @Override
@@ -143,7 +109,7 @@ public class TreeImpl implements Tree {
     }
 
     @Override
-    public Tree getParent() {
+    public TreeImpl getParent() {
         checkState(parent != null, "root tree does not have a parent");
         root.checkLive();
         return parent;
@@ -152,7 +118,19 @@ public class TreeImpl implements Tree {
     @Override
     public PropertyState getProperty(String name) {
         enter();
-        return getVisibleProperty(name);
+        return super.getProperty(name);
+    }
+
+    @Override
+    public boolean hasProperty(String name) {
+        enter();
+        return super.hasProperty(name);
+    }
+
+    @Override
+    public long getPropertyCount() {
+        enter();
+        return super.getPropertyCount();
     }
 
     @Override
@@ -160,9 +138,9 @@ public class TreeImpl implements Tree {
         // TODO: see OAK-212
         Status nodeStatus = getStatus();
         if (nodeStatus == NEW) {
-            return (hasProperty(name)) ? NEW : null;
+            return (super.hasProperty(name)) ? NEW : null;
         }
-        PropertyState head = getVisibleProperty(name);
+        PropertyState head = super.getProperty(name);
         if (head == null) {
             return null;
         }
@@ -179,76 +157,33 @@ public class TreeImpl implements Tree {
     }
 
     @Override
-    public boolean hasProperty(String name) {
-        return getProperty(name) != null;
-    }
-
-    @Override
-    public long getPropertyCount() {
-        return size(getProperties());
-    }
-
-    @Override
     public Iterable<? extends PropertyState> getProperties() {
         enter();
-        return filter(nodeBuilder.getProperties(),
-                new Predicate<PropertyState>() {
-                    @Override
-                    public boolean apply(PropertyState propertyState) {
-                        return !isHidden(propertyState.getName());
-                    }
-                });
+        return super.getProperties();
     }
 
     @Override
-    public TreeImpl getChild(@Nonnull String name) {
-        checkNotNull(name);
+    public Tree getChild(String name) {
         enter();
-        return new TreeImpl(root, this, name, pendingMoves);
+        return createChild(name);
     }
 
     @Override
-    public boolean hasChild(@Nonnull String name) {
-        checkNotNull(name);
+    public boolean hasChild(String name) {
         enter();
-        TreeImpl child = new TreeImpl(root, this, name, pendingMoves);
-        return child.exists();
+        return super.hasChild(name);
     }
 
     @Override
     public long getChildrenCount() {
         enter();
-        long childCnt = nodeBuilder.getChildNodeCount();
-        for (String name : HIDDEN_NAMES) {
-            if (nodeBuilder.hasChildNode(name)) {
-                childCnt--;
-            }
-        }
-        return childCnt;
+        return super.getChildrenCount();
     }
 
     @Override
     public Iterable<Tree> getChildren() {
         enter();
-        Iterable<String> childNames;
-        if (hasOrderableChildren()) {
-            childNames = getOrderedChildNames();
-        } else {
-            childNames = nodeBuilder.getChildNodeNames();
-        }
-        return transform(
-                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) {
-                        return new TreeImpl(root, TreeImpl.this, input, pendingMoves);
-                    }
-                });
+        return super.getChildren();
     }
 
     @Override
@@ -274,7 +209,7 @@ public class TreeImpl implements Tree {
     @Override
     public Tree addChild(String name) {
         checkExists();
-        if (!hasChild(name)) {
+        if (!super.hasChild(name)) {
             nodeBuilder.setChildNode(name);
             if (hasOrderableChildren()) {
                 nodeBuilder.setProperty(
@@ -284,7 +219,7 @@ public class TreeImpl implements Tree {
             }
             root.updated();
         }
-        return new TreeImpl(root, this, name, pendingMoves);
+        return createChild(name);
     }
 
     @Override
@@ -312,10 +247,10 @@ public class TreeImpl implements Tree {
         parent.ensureChildOrderProperty();
         // all siblings but not this one
         Iterable<String> siblings = filter(
-                parent.getOrderedChildNames(),
+                parent.getChildNames(),
                 new Predicate<String>() {
                     @Override
-                    public boolean apply(@Nullable String name) {
+                    public boolean apply(String name) {
                         return !TreeImpl.this.name.equals(name);
                     }
                 });
@@ -328,7 +263,7 @@ public class TreeImpl implements Tree {
         } else {
             int idx = indexOf(siblings, new Predicate<String>() {
                 @Override
-                public boolean apply(@Nullable String sibling) {
+                public boolean apply(String sibling) {
                     return name.equals(sibling);
                 }
             });
@@ -379,11 +314,6 @@ public class TreeImpl implements Tree {
 
     //-----------------------------------------------------------< internal >---
 
-    @Nonnull
-    NodeState getNodeState() {
-        return nodeBuilder.getNodeState();
-    }
-
     /**
      * Move this tree to the parent at {@code destParent} with the new name
      * {@code destName}.
@@ -405,7 +335,7 @@ public class TreeImpl implements Tree {
         checkArgument(isAbsolute(checkNotNull(path)));
         TreeImpl child = this;
         for (String name : elements(path)) {
-            child = new TreeImpl(child.root, child, name, child.pendingMoves);
+            child = new TreeImpl(root, child, name, pendingMoves);
         }
         return child;
     }
@@ -420,7 +350,7 @@ public class TreeImpl implements Tree {
             return;
         }
         Set<String> names = Sets.newLinkedHashSet();
-        for (String name : getOrderedChildNames()) {
+        for (String name : getChildNames()) {
             if (nodeBuilder.hasChildNode(name)) {
                 names.add(name);
             }
@@ -434,26 +364,8 @@ public class TreeImpl implements Tree {
         nodeBuilder.setProperty(builder.getPropertyState());
     }
 
-    @Nonnull
-    String getIdentifier() {
-        PropertyState property = nodeBuilder.getProperty(JCR_UUID);
-        if (property != null) {
-            return property.getValue(STRING);
-        } else if (parent == null) {
-            return "/";
-        } else {
-            return PathUtils.concat(parent.getIdentifier(), name);
-        }
-    }
-
     String getPathInternal() {
-        if (parent == null) {
-            return "/";
-        }
-
-        StringBuilder sb = new StringBuilder();
-        buildPath(sb);
-        return sb.toString();
+        return super.getPath();
     }
 
     //------------------------------------------------------------< private >---
@@ -480,10 +392,6 @@ public class TreeImpl implements Tree {
         }
     }
 
-    private static boolean isHidden(String name) {
-        return NodeStateUtils.isHidden(name);
-    }
-
     /**
      * The (possibly non-existent) node state this tree is based on.
      * @return the base node state of this tree
@@ -510,63 +418,6 @@ public class TreeImpl implements Tree {
         return movesApplied;
     }
 
-    private PropertyState getVisibleProperty(String name) {
-        return !isHidden(name)
-            ? nodeBuilder.getProperty(name)
-            : null;
-
-    }
-
-    private void buildPath(StringBuilder sb) {
-        if (parent != null) {
-            parent.buildPath(sb);
-            sb.append('/').append(name);
-        }
-    }
-
-    /**
-     * @return {@code true} if this tree has orderable children;
-     *         {@code false} otherwise.
-     */
-    private boolean hasOrderableChildren() {
-        return nodeBuilder.hasProperty(OAK_CHILD_ORDER);
-    }
-
-    /**
-     * Returns the ordered child names. This method must only be called when
-     * this tree {@link #hasOrderableChildren()}.
-     *
-     * @return the ordered child names.
-     */
-    private Iterable<String> getOrderedChildNames() {
-        // FIXME (OAK-842) take access control restriction into consideration
-        assert hasOrderableChildren();
-        return new Iterable<String>() {
-            @Override
-            public Iterator<String> iterator() {
-                return new Iterator<String>() {
-                    final PropertyState childOrder = nodeBuilder.getProperty(OAK_CHILD_ORDER);
-                    int index = 0;
-
-                    @Override
-                    public boolean hasNext() {
-                        return index < childOrder.count();
-                    }
-
-                    @Override
-                    public String next() {
-                        return childOrder.getValue(STRING, index++);
-                    }
-
-                    @Override
-                    public void remove() {
-                        throw new UnsupportedOperationException();
-                    }
-                };
-            }
-        };
-    }
-
     /**
      * Ensures that the {@link #OAK_CHILD_ORDER} exists. This method will create
      * the property if it doesn't exist and initialize the value with the names

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/ChildOrderConflictHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/ChildOrderConflictHandler.java?rev=1502473&r1=1502472&r2=1502473&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/ChildOrderConflictHandler.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/ChildOrderConflictHandler.java Fri Jul 12 08:43:25 2013
@@ -21,7 +21,7 @@ import java.util.Set;
 import com.google.common.collect.Sets;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.core.TreeImpl;
+import org.apache.jackrabbit.oak.core.AbstractTree;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryPropertyBuilder;
 import org.apache.jackrabbit.oak.spi.commit.ConflictHandler;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
@@ -31,7 +31,7 @@ import org.apache.jackrabbit.oak.spi.sta
  * This conflict handler instance takes care of properly merging conflicts
  * occurring by concurrent reorder operations.
  *
- * @see TreeImpl#OAK_CHILD_ORDER
+ * @see AbstractTree#OAK_CHILD_ORDER
  */
 public class ChildOrderConflictHandler extends ConflictHandlerWrapper {
 
@@ -122,7 +122,7 @@ public class ChildOrderConflictHandler e
     //----------------------------< internal >----------------------------------
 
     private static boolean isChildOrderProperty(PropertyState p) {
-        return TreeImpl.OAK_CHILD_ORDER.equals(p.getName());
+        return AbstractTree.OAK_CHILD_ORDER.equals(p.getName());
     }
 }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java?rev=1502473&r1=1502472&r2=1502473&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java Fri Jul 12 08:43:25 2013
@@ -32,7 +32,7 @@ import java.util.Map;
 import com.google.common.collect.ImmutableMap;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.core.TreeImpl;
+import org.apache.jackrabbit.oak.core.AbstractTree;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryPropertyBuilder;
 import org.apache.jackrabbit.oak.spi.commit.ConflictHandler;
 import org.apache.jackrabbit.oak.spi.commit.ConflictHandler.Resolution;
@@ -234,7 +234,7 @@ public final class MergingNodeStateDiff 
 
     private static void addChild(NodeBuilder target, String name, NodeState state) {
         target.setChildNode(name, state);
-        PropertyState childOrder = target.getProperty(TreeImpl.OAK_CHILD_ORDER);
+        PropertyState childOrder = target.getProperty(AbstractTree.OAK_CHILD_ORDER);
         if (childOrder != null) {
             PropertyBuilder<String> builder = MemoryPropertyBuilder.copy(Type.STRING, childOrder);
             builder.addValue(name);
@@ -244,7 +244,7 @@ public final class MergingNodeStateDiff 
 
     private static void removeChild(NodeBuilder target, String name) {
         target.getChildNode(name).remove();
-        PropertyState childOrder = target.getProperty(TreeImpl.OAK_CHILD_ORDER);
+        PropertyState childOrder = target.getProperty(AbstractTree.OAK_CHILD_ORDER);
         if (childOrder != null) {
             PropertyBuilder<String> builder = MemoryPropertyBuilder.copy(Type.STRING, childOrder);
             builder.removeValue(name);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidator.java?rev=1502473&r1=1502472&r2=1502473&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidator.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidator.java Fri Jul 12 08:43:25 2013
@@ -16,10 +16,14 @@
  */
 package org.apache.jackrabbit.oak.security.authorization;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.jackrabbit.oak.api.CommitFailedException.ACCESS;
+
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
+
 import javax.jcr.security.AccessControlException;
 import javax.jcr.security.Privilege;
 
@@ -27,7 +31,7 @@ import org.apache.jackrabbit.JcrConstant
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
-import org.apache.jackrabbit.oak.core.TreeImpl;
+import org.apache.jackrabbit.oak.core.AbstractTree;
 import org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager;
 import org.apache.jackrabbit.oak.spi.commit.DefaultValidator;
 import org.apache.jackrabbit.oak.spi.commit.Validator;
@@ -37,9 +41,6 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.util.TreeUtil;
 import org.apache.jackrabbit.util.Text;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.apache.jackrabbit.oak.api.CommitFailedException.ACCESS;
-
 /**
  * Validation for access control information changed by regular JCR (and Jackrabbit)
  * access control management API.
@@ -153,7 +154,7 @@ class AccessControlValidator extends Def
             throw accessViolation(3, "Invalid policy name " + policyNode.getName());
         }
 
-        if (!policyNode.hasProperty(TreeImpl.OAK_CHILD_ORDER)) {
+        if (!policyNode.hasProperty(AbstractTree.OAK_CHILD_ORDER)) {
             throw accessViolation(4, "Invalid policy node: Order of children is not stable.");
         }
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/ChildOrderDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/ChildOrderDiff.java?rev=1502473&r1=1502472&r2=1502473&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/ChildOrderDiff.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/ChildOrderDiff.java Fri Jul 12 08:43:25 2013
@@ -27,7 +27,7 @@ import org.apache.jackrabbit.oak.api.Typ
 
 /**
  * Helper class to handle modifications to the hidden
- * {@link org.apache.jackrabbit.oak.core.TreeImpl#OAK_CHILD_ORDER} property.
+ * {@link org.apache.jackrabbit.oak.core.AbstractTree#OAK_CHILD_ORDER} property.
  */
 class ChildOrderDiff {
 
@@ -41,7 +41,7 @@ class ChildOrderDiff {
 
     /**
      * Tests if there was any user-supplied reordering involved with the
-     * modification of the {@link org.apache.jackrabbit.oak.core.TreeImpl#OAK_CHILD_ORDER}
+     * modification of the {@link org.apache.jackrabbit.oak.core.AbstractTree#OAK_CHILD_ORDER}
      * property.
      *
      * @return the name of the first reordered child if any user-supplied node

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHook.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHook.java?rev=1502473&r1=1502472&r2=1502473&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHook.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHook.java Fri Jul 12 08:43:25 2013
@@ -16,7 +16,13 @@
  */
 package org.apache.jackrabbit.oak.security.authorization.permission;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
+import static org.apache.jackrabbit.JcrConstants.JCR_SYSTEM;
+import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
+
 import java.util.Set;
+
 import javax.annotation.Nonnull;
 
 import com.google.common.base.Objects;
@@ -27,9 +33,9 @@ import org.apache.jackrabbit.oak.api.Pro
 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.AbstractTree;
 import org.apache.jackrabbit.oak.core.ImmutableRoot;
 import org.apache.jackrabbit.oak.core.ImmutableTree;
-import org.apache.jackrabbit.oak.core.TreeImpl;
 import org.apache.jackrabbit.oak.core.TreeTypeProvider;
 import org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager;
 import org.apache.jackrabbit.oak.security.privilege.PrivilegeBits;
@@ -48,11 +54,6 @@ import org.apache.jackrabbit.util.Text;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
-import static org.apache.jackrabbit.JcrConstants.JCR_SYSTEM;
-import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
-
 /**
  * {@code CommitHook} implementation that processes any modification made to
  * access control content and updates persisted permission caches associated
@@ -185,7 +186,7 @@ public class PermissionHook implements P
         @Nonnull
         private PermissionEntry createPermissionEntry(String name, NodeState ace, Node acl) {
             String accessControlledPath = (REP_REPO_POLICY.equals(acl.getName()) ? "" : Text.getRelativeParent(acl.getPath(), 1));
-            PropertyState ordering = checkNotNull(acl.getNodeState().getProperty(TreeImpl.OAK_CHILD_ORDER));
+            PropertyState ordering = checkNotNull(acl.getNodeState().getProperty(AbstractTree.OAK_CHILD_ORDER));
             int index = Lists.newArrayList(ordering.getValue(Type.STRINGS)).indexOf(name);
             return new PermissionEntry(getTree(name, ace), accessControlledPath, index);
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidator.java?rev=1502473&r1=1502472&r2=1502473&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidator.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidator.java Fri Jul 12 08:43:25 2013
@@ -16,6 +16,9 @@
  */
 package org.apache.jackrabbit.oak.security.authorization.permission;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.jackrabbit.oak.api.CommitFailedException.ACCESS;
+
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -24,7 +27,7 @@ import org.apache.jackrabbit.JcrConstant
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
-import org.apache.jackrabbit.oak.core.TreeImpl;
+import org.apache.jackrabbit.oak.core.AbstractTree;
 import org.apache.jackrabbit.oak.plugins.version.VersionConstants;
 import org.apache.jackrabbit.oak.spi.commit.DefaultValidator;
 import org.apache.jackrabbit.oak.spi.commit.Validator;
@@ -35,9 +38,6 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
 import org.apache.jackrabbit.oak.util.TreeUtil;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.apache.jackrabbit.oak.api.CommitFailedException.ACCESS;
-
 /**
  * Validator implementation that checks for sufficient permission for all
  * write operations executed by a given content session.
@@ -80,7 +80,7 @@ class PermissionValidator extends Defaul
 
     @Override
     public void propertyChanged(PropertyState before, PropertyState after) throws CommitFailedException {
-        if (TreeImpl.OAK_CHILD_ORDER.equals(after.getName())) {
+        if (AbstractTree.OAK_CHILD_ORDER.equals(after.getName())) {
             String childName = new ChildOrderDiff(before, after).firstReordered();
             if (childName != null) {
                 Tree child = parentAfter.getChild(childName);

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/TreeImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/TreeImplTest.java?rev=1502473&r1=1502472&r2=1502473&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/TreeImplTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/TreeImplTest.java Fri Jul 12 08:43:25 2013
@@ -363,20 +363,20 @@ public class TreeImplTest extends OakBas
     public void testSetOrderableChildrenSetsProperty() throws Exception {
         Tree tree = root.getTree("/").addChild("test");
         tree.setOrderableChildren(true);
-        assertTrue(((TreeImpl) tree).getNodeState().hasProperty(TreeImpl.OAK_CHILD_ORDER));
+        assertTrue(((TreeImpl) tree).getNodeState().hasProperty(AbstractTree.OAK_CHILD_ORDER));
 
         tree.setOrderableChildren(false);
-        assertFalse(((TreeImpl) tree).getNodeState().hasProperty(TreeImpl.OAK_CHILD_ORDER));
+        assertFalse(((TreeImpl) tree).getNodeState().hasProperty(AbstractTree.OAK_CHILD_ORDER));
 
         tree.setOrderableChildren(true);
         root.commit();
 
-        assertTrue(((TreeImpl) tree).getNodeState().hasProperty(TreeImpl.OAK_CHILD_ORDER));
+        assertTrue(((TreeImpl) tree).getNodeState().hasProperty(AbstractTree.OAK_CHILD_ORDER));
 
         tree.setOrderableChildren(false);
         root.commit();
 
-        assertFalse(((TreeImpl) tree).getNodeState().hasProperty(TreeImpl.OAK_CHILD_ORDER));
+        assertFalse(((TreeImpl) tree).getNodeState().hasProperty(AbstractTree.OAK_CHILD_ORDER));
     }
 
     @Test

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/ChildOrderPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/ChildOrderPropertyTest.java?rev=1502473&r1=1502472&r2=1502473&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/ChildOrderPropertyTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/ChildOrderPropertyTest.java Fri Jul 12 08:43:25 2013
@@ -16,23 +16,23 @@
  */
 package org.apache.jackrabbit.oak.security.authorization.evaluation;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
 import java.util.Set;
 
 import com.google.common.collect.Sets;
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
-import org.apache.jackrabbit.oak.core.TreeImpl;
+import org.apache.jackrabbit.oak.core.AbstractTree;
 import org.junit.Before;
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
 /**
- * Test for the hidden {@link TreeImpl#OAK_CHILD_ORDER} property
+ * Test for the hidden {@link AbstractTree#OAK_CHILD_ORDER} property
  */
 public class ChildOrderPropertyTest extends AbstractOakCoreTest {
 
@@ -49,13 +49,13 @@ public class ChildOrderPropertyTest exte
     @Test
     public void testHasProperty() {
         Tree a = root.getTree("/a");
-        assertFalse(a.hasProperty(TreeImpl.OAK_CHILD_ORDER));
+        assertFalse(a.hasProperty(AbstractTree.OAK_CHILD_ORDER));
     }
 
     @Test
     public void testGetProperty() {
         Tree a = root.getTree("/a");
-        assertNull(a.getProperty(TreeImpl.OAK_CHILD_ORDER));
+        assertNull(a.getProperty(AbstractTree.OAK_CHILD_ORDER));
     }
 
     @Test
@@ -78,7 +78,7 @@ public class ChildOrderPropertyTest exte
     @Test
     public void testGetPropertyStatus() {
         Tree a = root.getTree("/a");
-        assertNull(a.getPropertyStatus(TreeImpl.OAK_CHILD_ORDER));
+        assertNull(a.getPropertyStatus(AbstractTree.OAK_CHILD_ORDER));
     }
 
 }
\ No newline at end of file



Mime
View raw message