You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by an...@apache.org on 2013/02/13 17:55:08 UTC
svn commit: r1445736 - in
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak:
core/TreeImpl.java security/authorization/AccessControlManagerImpl.java
util/TreeUtil.java
Author: angela
Date: Wed Feb 13 16:55:08 2013
New Revision: 1445736
URL: http://svn.apache.org/r1445736
Log:
OAK-51 : Access Control Management (WIP)
Modified:
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/security/authorization/AccessControlManagerImpl.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/TreeUtil.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=1445736&r1=1445735&r2=1445736&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 Feb 13 16:55:08 2013
@@ -573,7 +573,7 @@ public class TreeImpl implements Tree {
* the property if it doesn't exist and initialize the value with the names
* of the children as returned by {@link NodeBuilder#getChildNodeNames()}.
*/
- private void ensureChildOrderProperty() {
+ public void ensureChildOrderProperty() {
PropertyState childOrder = getNodeBuilder().getProperty(OAK_CHILD_ORDER);
if (childOrder == null) {
getNodeBuilder().setProperty(
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlManagerImpl.java?rev=1445736&r1=1445735&r2=1445736&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlManagerImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlManagerImpl.java Wed Feb 13 16:55:08 2013
@@ -57,7 +57,6 @@ import org.apache.jackrabbit.oak.api.Roo
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.TreeImpl;
import org.apache.jackrabbit.oak.namepath.NamePathMapper;
import org.apache.jackrabbit.oak.plugins.memory.MemoryPropertyBuilder;
import org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager;
@@ -220,6 +219,7 @@ public class AccessControlManagerImpl im
} else {
aclNode = createAclNode(oakPath, tree);
}
+ TreeUtil.ensureOrderableChildren(aclNode.getTree());
ACL acl = (ACL) policy;
for (JackrabbitAccessControlEntry ace : acl.getEntries()) {
@@ -397,9 +397,7 @@ public class AccessControlManagerImpl im
tree.setProperty(pb.getPropertyState());
}
}
- NodeUtil aclNode = new NodeUtil(tree).addChild(getAclName(oakPath), NT_REP_ACL);
- aclNode.setStrings(TreeImpl.OAK_CHILD_ORDER, new String[0]);
- return aclNode;
+ return new NodeUtil(tree).addChild(getAclName(oakPath), NT_REP_ACL);
}
@CheckForNull
@@ -633,4 +631,4 @@ public class AccessControlManagerImpl im
return rProvider;
}
}
-}
\ No newline at end of file
+}
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/TreeUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/TreeUtil.java?rev=1445736&r1=1445735&r2=1445736&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/TreeUtil.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/TreeUtil.java Wed Feb 13 16:55:08 2013
@@ -23,7 +23,9 @@ import org.apache.jackrabbit.JcrConstant
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.core.TreeImpl;
+import static com.google.common.base.Preconditions.checkArgument;
import static org.apache.jackrabbit.oak.api.Type.BOOLEAN;
import static org.apache.jackrabbit.oak.api.Type.STRINGS;
@@ -67,14 +69,26 @@ public final class TreeUtil {
* {@link org.apache.jackrabbit.oak.api.PropertyState#isArray() is an array}
* this method returns {@code false}.
*
- * @param tree The target tree.
+ * @param tree The target tree.
* @param propertyName The name of the property.
* @return the boolean representation of the property state with the given
- * name. This utility returns {@code false} if the property does not exist
- * or is an multivalued property.
+ * name. This utility returns {@code false} if the property does not exist
+ * or is an multivalued property.
*/
public static boolean getBoolean(Tree tree, String propertyName) {
PropertyState property = tree.getProperty(propertyName);
return property != null && !property.isArray() && property.getValue(BOOLEAN);
}
+
+ /**
+ * Utility method that assert that children of a tree keep the order such
+ * as defined by the insertion and any subsequent
+ * {@link Tree#orderBefore(String) reordering}.
+ *
+ * @param tree The parent tree whose children are mandated to be orderable.
+ */
+ public static void ensureOrderableChildren(Tree tree) {
+ checkArgument(tree instanceof TreeImpl);
+ ((TreeImpl) tree).ensureChildOrderProperty();
+ }
}
\ No newline at end of file