jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1450720 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: security/authorization/ security/authorization/permission/ security/privilege/ security/user/ util/
Date Wed, 27 Feb 2013 10:34:14 GMT
Author: angela
Date: Wed Feb 27 10:34:13 2013
New Revision: 1450720

URL: http://svn.apache.org/r1450720
Log:
OAK-372: create utility for common used static methods of MemoryPropertyBuilder in order to
avoid having the related TODO spread throughout the code base.

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/PropertyUtil.java
Modified:
    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/security/authorization/permission/PermissionHook.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHook.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProvider.java

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=1450720&r1=1450719&r2=1450720&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 27 10:34:13 2013
@@ -58,7 +58,6 @@ import org.apache.jackrabbit.oak.api.Tre
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
-import org.apache.jackrabbit.oak.plugins.memory.MemoryPropertyBuilder;
 import org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager;
 import org.apache.jackrabbit.oak.security.authorization.restriction.PrincipalRestrictionProvider;
 import org.apache.jackrabbit.oak.security.principal.PrincipalImpl;
@@ -72,6 +71,7 @@ import org.apache.jackrabbit.oak.spi.sec
 import org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider;
 import org.apache.jackrabbit.oak.spi.state.PropertyBuilder;
 import org.apache.jackrabbit.oak.util.NodeUtil;
+import org.apache.jackrabbit.oak.util.PropertyUtil;
 import org.apache.jackrabbit.oak.util.TreeUtil;
 import org.apache.jackrabbit.util.ISO9075;
 import org.apache.jackrabbit.util.Text;
@@ -402,7 +402,7 @@ public class AccessControlManagerImpl im
             if (mixins == null) {
                 tree.setProperty(JcrConstants.JCR_MIXINTYPES, Collections.singleton(mixinName),
Type.NAMES);
             } else {
-                PropertyBuilder pb = MemoryPropertyBuilder.copy(Type.NAME, mixins);
+                PropertyBuilder pb = PropertyUtil.getPropertyBuilder(Type.NAME, mixins);
                 pb.addValue(mixinName);
                 tree.setProperty(pb.getPropertyState());
             }

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=1450720&r1=1450719&r2=1450720&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
Wed Feb 27 10:34:13 2013
@@ -33,7 +33,6 @@ import org.apache.jackrabbit.oak.core.Re
 import org.apache.jackrabbit.oak.core.ReadOnlyTree;
 import org.apache.jackrabbit.oak.core.TreeImpl;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState;
-import org.apache.jackrabbit.oak.plugins.memory.MemoryPropertyBuilder;
 import org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants;
 import org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager;
 import org.apache.jackrabbit.oak.security.authorization.AccessControlConstants;
@@ -46,6 +45,7 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
 import org.apache.jackrabbit.oak.spi.state.PropertyBuilder;
+import org.apache.jackrabbit.oak.util.PropertyUtil;
 import org.apache.jackrabbit.oak.util.TreeUtil;
 import org.apache.jackrabbit.util.Text;
 import org.slf4j.Logger;
@@ -360,7 +360,7 @@ public class PermissionHook implements C
             if (ordering == null) {
                 principalRoot.setProperty(TreeImpl.OAK_CHILD_ORDER, Collections.singleton(entryName),
Type.NAMES);
             } else {
-                PropertyBuilder pb = MemoryPropertyBuilder.copy(Type.NAME, ordering);
+                PropertyBuilder pb = PropertyUtil.getPropertyBuilder(Type.NAME, ordering);
                 // TODO: determine ordering index
                 int index = 0;
                 pb.setValue(entryName, index);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHook.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHook.java?rev=1450720&r1=1450719&r2=1450720&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHook.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHook.java
Wed Feb 27 10:34:13 2013
@@ -21,12 +21,12 @@ import javax.annotation.Nonnull;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.plugins.memory.MemoryPropertyBuilder;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.state.EmptyNodeStateDiff;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.PropertyBuilder;
+import org.apache.jackrabbit.oak.util.PropertyUtil;
 import org.apache.jackrabbit.util.Text;
 
 /**
@@ -62,12 +62,11 @@ public class JcrAllCommitHook implements
                 NodeBuilder jcrAll = nodeBuilder.child(JCR_ALL);
                 PropertyState aggregates = jcrAll.getProperty(REP_AGGREGATES);
 
-                // FIXME: remove usage of MemoryPropertyBuilder (OAK-372)
                 PropertyBuilder<String> propertyBuilder;
                 if (aggregates == null) {
-                    propertyBuilder = MemoryPropertyBuilder.array(Type.NAME, REP_AGGREGATES);
+                    propertyBuilder = PropertyUtil.getPropertyBuilder(Type.NAME, REP_AGGREGATES,
true);
                 } else {
-                    propertyBuilder = MemoryPropertyBuilder.copy(Type.NAME, aggregates);
+                    propertyBuilder = PropertyUtil.getPropertyBuilder(Type.NAME, aggregates);
                 }
                 if (!propertyBuilder.hasValue(name)) {
                     propertyBuilder.addValue(name);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProvider.java?rev=1450720&r1=1450719&r2=1450720&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProvider.java
Wed Feb 27 10:34:13 2013
@@ -31,13 +31,13 @@ import org.apache.jackrabbit.commons.ite
 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.plugins.memory.MemoryPropertyBuilder;
 import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
 import org.apache.jackrabbit.oak.spi.security.user.AuthorizableType;
 import org.apache.jackrabbit.oak.spi.security.user.util.UserUtility;
 import org.apache.jackrabbit.oak.spi.state.PropertyBuilder;
 import org.apache.jackrabbit.oak.util.NodeUtil;
+import org.apache.jackrabbit.oak.util.PropertyUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -231,12 +231,11 @@ class MembershipProvider extends Authori
     //-----------------------------------------< private MembershipProvider >---
 
     private PropertyBuilder<String> getMembersPropertyBuilder(Tree groupTree) {
-        // FIXME: remove usage of MemoryPropertyBuilder (OAK-372)
         PropertyState property = groupTree.getProperty(REP_MEMBERS);
         if (property == null) {
-            return MemoryPropertyBuilder.array(WEAKREFERENCE, REP_MEMBERS);
+            return PropertyUtil.getPropertyBuilder(WEAKREFERENCE, REP_MEMBERS, true);
         } else {
-            return MemoryPropertyBuilder.copy(WEAKREFERENCE, property);
+            return PropertyUtil.getPropertyBuilder(WEAKREFERENCE, property);
         }
     }
 

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/PropertyUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/PropertyUtil.java?rev=1450720&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/PropertyUtil.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/PropertyUtil.java
Wed Feb 27 10:34:13 2013
@@ -0,0 +1,48 @@
+/*
+ * 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.util;
+
+import javax.annotation.Nonnull;
+
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.plugins.memory.MemoryPropertyBuilder;
+import org.apache.jackrabbit.oak.spi.state.PropertyBuilder;
+
+/**
+ * {@code PropertyUtil} provides common property handling which lead to
+ * dependencies to {@link org.apache.jackrabbit.oak.plugins.memory.MemoryPropertyBuilder}
+ * throughout oak-core packages.
+ *
+ * TODO: review and clean-up once OAK-372 has been addressed
+ */
+public final class PropertyUtil {
+
+    private PropertyUtil() {}
+
+    public static <T> PropertyBuilder<T> getPropertyBuilder(@Nonnull Type<T>
type, @Nonnull PropertyState baseState) {
+        return MemoryPropertyBuilder.copy(type, baseState);
+    }
+
+    public static <T> PropertyBuilder<T> getPropertyBuilder(@Nonnull Type<T>
type, @Nonnull String name, boolean isArray) {
+        if (isArray) {
+            return MemoryPropertyBuilder.array(type, name);
+        } else {
+            return MemoryPropertyBuilder.scalar(type, name);
+        }
+    }
+}
\ No newline at end of file



Mime
View raw message