jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1510972 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: security/authorization/permission/ChildOrderDiff.java security/authorization/permission/PermissionValidator.java util/ChildOrderDiff.java
Date Tue, 06 Aug 2013 14:33:35 GMT
Author: angela
Date: Tue Aug  6 14:33:35 2013
New Revision: 1510972

URL: http://svn.apache.org/r1510972
Log:
OAK-527: permissions (move utility class to util package)

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/ChildOrderDiff.java
      - copied, changed from r1508829, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/ChildOrderDiff.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/ChildOrderDiff.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidator.java

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=1510972&r1=1510971&r2=1510972&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
Tue Aug  6 14:33:35 2013
@@ -16,9 +16,6 @@
  */
 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;
@@ -36,8 +33,12 @@ import org.apache.jackrabbit.oak.spi.sec
 import org.apache.jackrabbit.oak.spi.security.authorization.permission.Permissions;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
+import org.apache.jackrabbit.oak.util.ChildOrderDiff;
 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.
@@ -81,7 +82,7 @@ class PermissionValidator extends Defaul
     @Override
     public void propertyChanged(PropertyState before, PropertyState after) throws CommitFailedException
{
         if (AbstractTree.OAK_CHILD_ORDER.equals(after.getName())) {
-            String childName = new ChildOrderDiff(before, after).firstReordered();
+            String childName = ChildOrderDiff.firstReordered(before, after);
             if (childName != null) {
                 Tree child = parentAfter.getChild(childName);
                 checkPermissions(child, false, Permissions.MODIFY_CHILD_NODE_COLLECTION);

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/ChildOrderDiff.java
(from r1508829, 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/util/ChildOrderDiff.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/ChildOrderDiff.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/ChildOrderDiff.java&r1=1508829&r2=1510972&rev=1510972&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/util/ChildOrderDiff.java
Tue Aug  6 14:33:35 2013
@@ -14,45 +14,37 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.oak.security.authorization.permission;
-
-import static com.google.common.collect.Lists.newArrayList;
-import static com.google.common.collect.Sets.newLinkedHashSet;
+package org.apache.jackrabbit.oak.util;
 
 import java.util.Iterator;
-import java.util.List;
 import java.util.Set;
-
 import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Type;
 
+import static com.google.common.collect.Sets.newLinkedHashSet;
+
 /**
  * Helper class to handle modifications to the hidden
  * {@link org.apache.jackrabbit.oak.core.AbstractTree#OAK_CHILD_ORDER} property.
  */
-class ChildOrderDiff {
-
-    private final PropertyState before;
-    private final PropertyState after;
+public final class ChildOrderDiff {
 
-    ChildOrderDiff(PropertyState before, PropertyState after) {
-        this.before = before;
-        this.after = after;
-    }
+    private ChildOrderDiff() {}
 
     /**
      * Tests if there was any user-supplied reordering involved with the
      * modification of the {@link org.apache.jackrabbit.oak.core.AbstractTree#OAK_CHILD_ORDER}
      * property.
      *
+     * @param before
+     * @param after
      * @return the name of the first reordered child if any user-supplied node
      * reorder happened; {@code null} otherwise.
      */
     @CheckForNull
-    String firstReordered() {
+    public static String firstReordered(PropertyState before, PropertyState after) {
         Set<String> afterNames = newLinkedHashSet(after.getValue(Type.NAMES));
         Set<String> beforeNames = newLinkedHashSet(before.getValue(Type.NAMES));
 
@@ -82,33 +74,4 @@ class ChildOrderDiff {
 
         return null;
     }
-
-    /**
-     * Returns the names of all reordered nodes present in the 'after' property.
-     *
-     * @return
-     */
-    @Nonnull
-    List<String> getReordered() {
-        List<String> reordered = newArrayList();
-
-        Set<String> afterNames = newLinkedHashSet(after.getValue(Type.NAMES));
-        Set<String> beforeNames = newLinkedHashSet(before.getValue(Type.NAMES));
-
-        afterNames.retainAll(beforeNames);
-        beforeNames.retainAll(afterNames);
-
-        Iterator<String> a = afterNames.iterator();
-        Iterator<String> b = beforeNames.iterator();
-        while (a.hasNext() && b.hasNext()) {
-            String aName = a.next();
-            String bName = b.next();
-            if (!aName.equals(bName)) {
-                reordered.add(aName);
-            }
-        }
-
-        return reordered;
-    }
-
 }



Mime
View raw message