jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1382675 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: core/ kernel/ plugins/memory/ security/principal/ security/user/ spi/commit/ spi/security/principal/ spi/security/user/
Date Mon, 10 Sep 2012 07:44:27 GMT
Author: mreutegg
Date: Mon Sep 10 07:44:26 2012
New Revision: 1382675

URL: http://svn.apache.org/viewvc?rev=1382675&view=rev
Log:
OAK-292: Use Guava preconditions instead of asserts to enforce contract

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MergingNodeStateDiff.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ReadOnlyTree.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.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/kernel/KernelNodeState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyPropertyState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryChildNodeEntry.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiPropertyState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/PrincipalProviderImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProviderImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserValidatorProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/SubtreeValidator.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/CompositePrincipalProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserConfig.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java?rev=1382675&r1=1382674&r2=1382675&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java
Mon Sep 10 07:44:26 2012
@@ -35,6 +35,8 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * {@code MicroKernel}-based implementation of the {@link ContentSession} interface.
  */
@@ -52,11 +54,10 @@ class ContentSessionImpl implements Cont
     public ContentSessionImpl(LoginContext loginContext, String workspaceName,
                               NodeStore store, QueryEngineImpl queryEngine) {
 
-        assert queryEngine != null;
         this.loginContext = loginContext;
         this.workspaceName = workspaceName;
         this.store = store;
-        this.queryEngine = new SessionQueryEngineImpl(this, queryEngine);
+        this.queryEngine = new SessionQueryEngineImpl(this, checkNotNull(queryEngine));
     }
 
     @Nonnull

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MergingNodeStateDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MergingNodeStateDiff.java?rev=1382675&r1=1382674&r2=1382675&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MergingNodeStateDiff.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MergingNodeStateDiff.java
Mon Sep 10 07:44:26 2012
@@ -25,6 +25,8 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
 import static org.apache.jackrabbit.oak.api.ConflictHandler.Resolution.MERGED;
 import static org.apache.jackrabbit.oak.api.ConflictHandler.Resolution.OURS;
 
@@ -48,10 +50,8 @@ class MergingNodeStateDiff implements No
 
     static void merge(NodeState fromState, NodeState toState, final TreeImpl target,
             final ConflictHandler conflictHandler) {
-
-        assert target != null;
-
-        toState.compareAgainstBaseState(fromState, new MergingNodeStateDiff(target, conflictHandler));
+        toState.compareAgainstBaseState(fromState, new MergingNodeStateDiff(
+                checkNotNull(target), conflictHandler));
     }
 
     //------------------------------------------------------< NodeStateDiff >---
@@ -79,7 +79,8 @@ class MergingNodeStateDiff implements No
 
     @Override
     public void propertyChanged(PropertyState before, PropertyState after) {
-        assert before.getName().equals(after.getName());
+        checkArgument(before.getName().equals(after.getName()),
+                "before and after must have the same name");
 
         ConflictHandler.Resolution resolution;
         PropertyState p = target.getProperty(after.getName());

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ReadOnlyTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ReadOnlyTree.java?rev=1382675&r1=1382674&r2=1382675&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ReadOnlyTree.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ReadOnlyTree.java
Mon Sep 10 07:44:26 2012
@@ -28,6 +28,9 @@ import org.apache.jackrabbit.oak.api.Tre
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
 public class ReadOnlyTree implements Tree {
 
     /** Parent of this tree, {@code null} for the root */
@@ -44,13 +47,10 @@ public class ReadOnlyTree implements Tre
     }
 
     public ReadOnlyTree(ReadOnlyTree parent, String name, NodeState state) {
-        assert name != null;
-        assert !name.isEmpty() || parent == null;
-        assert state != null;
-
         this.parent = parent;
-        this.name = name;
-        this.state = state;
+        this.name = checkNotNull(name);
+        this.state = checkNotNull(state);
+        checkArgument(!name.isEmpty() || parent == null);
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java?rev=1382675&r1=1382674&r2=1382675&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
Mon Sep 10 07:44:26 2012
@@ -42,6 +42,7 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.apache.jackrabbit.oak.commons.PathUtils.getName;
 import static org.apache.jackrabbit.oak.commons.PathUtils.getParentPath;
 
@@ -138,7 +139,7 @@ public class RootImpl implements Root {
 
     @Override
     public TreeLocation getLocation(String path) {
-        assert path.startsWith("/");
+        checkArgument(path.startsWith("/"));
         return rootTree.getLocation().getChild(path.substring(1));
     }
 

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=1382675&r1=1382674&r2=1382675&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
Mon Sep 10 07:44:26 2012
@@ -38,6 +38,8 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
 import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
 import static org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState.EMPTY_NODE;
 
@@ -65,12 +67,9 @@ public class TreeImpl implements Tree, P
             CacheBuilder.newBuilder().weakValues().<String, TreeImpl>build().asMap();
 
     private TreeImpl(RootImpl root, TreeImpl parent, String name) {
-        assert root != null;
-        assert name != null;
-
-        this.root = root;
+        this.root = checkNotNull(root);
         this.parent = parent;
-        this.name = name;
+        this.name = checkNotNull(name);
     }
 
     @Nonnull
@@ -363,7 +362,7 @@ public class TreeImpl implements Tree, P
      */
     @CheckForNull
     TreeImpl getTree(String path) {
-        assert path.startsWith("/");
+        checkArgument(path.startsWith("/"));
         TreeImpl child = this;
         for (String name : elements(path)) {
             child = child.internalGetChild(name);
@@ -502,8 +501,7 @@ public class TreeImpl implements Tree, P
         private final TreeImpl tree;
 
         private NodeLocation(TreeImpl tree) {
-            assert tree != null;
-            this.tree = tree;
+            this.tree = checkNotNull(tree);
         }
 
         @Override
@@ -515,7 +513,7 @@ public class TreeImpl implements Tree, P
 
         @Override
         public TreeLocation getChild(String relPath) {
-            assert !relPath.startsWith("/");
+            checkArgument(!relPath.startsWith("/"));
             if (relPath.isEmpty()) {
                 return this;
             }
@@ -568,10 +566,8 @@ public class TreeImpl implements Tree, P
         private final PropertyState property;
 
         private PropertyLocation(NodeLocation parent, PropertyState property) {
-            assert parent != null;
-            assert property != null;
-            this.parent = parent;
-            this.property = property;
+            this.parent = checkNotNull(parent);
+            this.property = checkNotNull(property);
         }
 
         @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java?rev=1382675&r1=1382674&r2=1382675&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
Mon Sep 10 07:44:26 2012
@@ -18,6 +18,7 @@
  */
 package org.apache.jackrabbit.oak.kernel;
 
+import static com.google.common.base.Preconditions.checkNotNull;
 import static org.apache.jackrabbit.oak.kernel.CoreValueMapper.fromJsopReader;
 import static org.apache.jackrabbit.oak.kernel.CoreValueMapper.listFromJsopReader;
 
@@ -82,21 +83,18 @@ public final class KernelNodeState exten
      * given {@code path} and {@code revision}. It is an error if the
      * underlying Microkernel does not contain such a node.
      *
-     * @param kernel
-     * @param path
-     * @param revision
+     * @param kernel the underlying MicroKernel
+     * @param path the path of this KernelNodeState
+     * @param revision the revision of the node to read from the kernel.
+     * @param cache the KernelNodeState cache
      */
     public KernelNodeState(
             MicroKernel kernel, String path, String revision,
             LoadingCache<String, KernelNodeState> cache) {
-        assert kernel != null;
-        assert path != null;
-        assert revision != null;
-
-        this.kernel = kernel;
-        this.path = path;
-        this.revision = revision;
-        this.cache = cache;
+        this.kernel = checkNotNull(kernel);
+        this.path = checkNotNull(path);
+        this.revision = checkNotNull(revision);
+        this.cache = checkNotNull(cache);
     }
 
     private synchronized void init() {
@@ -348,11 +346,8 @@ public final class KernelNodeState exten
          * @param path child node path
          */
         public KernelChildNodeEntry(String name, String path) {
-            assert name != null;
-            assert path != null;
-
-            this.name = name;
-            this.path = path;
+            this.name = checkNotNull(name);
+            this.path = checkNotNull(path);
         }
 
         /**

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java?rev=1382675&r1=1382674&r2=1382675&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
Mon Sep 10 07:44:26 2012
@@ -37,6 +37,8 @@ import com.google.common.cache.CacheBuil
 import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * {@code NodeStore} implementations against {@link MicroKernel}.
  */
@@ -78,8 +80,7 @@ public class KernelNodeStore implements 
     private KernelNodeState root;
 
     public KernelNodeStore(MicroKernel kernel) {
-        assert kernel != null;
-        this.kernel = kernel;
+        this.kernel = checkNotNull(kernel);
         try {
             this.root = cache.get(kernel.getHeadRevision() + "/");
         } catch (Exception e) {
@@ -93,8 +94,7 @@ public class KernelNodeStore implements 
     }
 
     public void setHook(CommitHook hook) {
-        assert hook != null;
-        this.hook = hook;
+        this.hook = checkNotNull(hook);
     }
 
     @Nonnull
@@ -103,8 +103,7 @@ public class KernelNodeStore implements 
     }
 
     public void setObserver(Observer observer) {
-        assert observer != null;
-        this.observer = observer;
+        this.observer = checkNotNull(observer);
     }
 
     //----------------------------------------------------------< NodeStore >---

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java?rev=1382675&r1=1382674&r2=1382675&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
Mon Sep 10 07:44:26 2012
@@ -23,6 +23,7 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStoreBranch;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
 import static org.apache.jackrabbit.oak.commons.PathUtils.getName;
 import static org.apache.jackrabbit.oak.commons.PathUtils.getParentPath;
@@ -150,7 +151,7 @@ class KernelNodeStoreBranch implements N
     //------------------------------------------------------------< private >---
 
     private NodeState getNode(String path) {
-        assert path.startsWith("/");
+        checkArgument(path.startsWith("/"));
         NodeState node = getRoot();
         for (String name : elements(path)) {
             node = node.getChildNode(name);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyPropertyState.java?rev=1382675&r1=1382674&r2=1382675&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyPropertyState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyPropertyState.java
Mon Sep 10 07:44:26 2012
@@ -26,6 +26,8 @@ import javax.annotation.Nonnull;
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * Property state that contains an empty array of values. Used as a base
  * class for {@link SinglePropertyState} and {@link MultiPropertyState}.
@@ -35,8 +37,7 @@ class EmptyPropertyState implements Prop
     private final String name;
 
     public EmptyPropertyState(String name) {
-        assert name != null;
-        this.name = name;
+        this.name = checkNotNull(name);
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryChildNodeEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryChildNodeEntry.java?rev=1382675&r1=1382674&r2=1382675&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryChildNodeEntry.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryChildNodeEntry.java
Mon Sep 10 07:44:26 2012
@@ -28,6 +28,8 @@ import org.apache.jackrabbit.oak.spi.sta
 import com.google.common.base.Function;
 import com.google.common.collect.Iterables;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * Basic JavaBean implementation of a child node entry.
  */
@@ -57,11 +59,8 @@ public class MemoryChildNodeEntry extend
      * @param node child node state
      */
     public MemoryChildNodeEntry(String name, NodeState node) {
-        assert name != null;
-        assert node != null;
-
-        this.name = name;
-        this.node = node;
+        this.name = checkNotNull(name);
+        this.node = checkNotNull(node);
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiPropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiPropertyState.java?rev=1382675&r1=1382674&r2=1382675&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiPropertyState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MultiPropertyState.java
Mon Sep 10 07:44:26 2012
@@ -26,6 +26,8 @@ import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.oak.api.CoreValue;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * Multi-valued property state.
  */
@@ -35,9 +37,8 @@ public class MultiPropertyState extends 
 
     public MultiPropertyState(String name, List<CoreValue> values) {
         super(name);
-        assert values != null;
         this.values = Collections.unmodifiableList(
-                new ArrayList<CoreValue>(values));
+                new ArrayList<CoreValue>(checkNotNull(values)));
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/PrincipalProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/PrincipalProviderImpl.java?rev=1382675&r1=1382674&r2=1382675&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/PrincipalProviderImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/PrincipalProviderImpl.java
Mon Sep 10 07:44:26 2012
@@ -42,6 +42,9 @@ import org.apache.jackrabbit.oak.spi.sec
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+
 /**
  * The {@code PrincipalProviderImpl} is a principal provider implementation
  * that operates on principal information read from user information exposed by
@@ -138,8 +141,8 @@ public class PrincipalProviderImpl imple
     }
 
     private boolean isGroup(Tree authorizableTree) {
-        assert authorizableTree != null;
-        assert authorizableTree.hasProperty(JcrConstants.JCR_PRIMARYTYPE);
+        checkNotNull(authorizableTree);
+        checkState(authorizableTree.hasProperty(JcrConstants.JCR_PRIMARYTYPE));
 
         String ntName = authorizableTree.getProperty(JcrConstants.JCR_PRIMARYTYPE).getValue().getString();
         return UserConstants.NT_REP_GROUP.equals(ntName);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProviderImpl.java?rev=1382675&r1=1382674&r2=1382675&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProviderImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProviderImpl.java
Mon Sep 10 07:44:26 2012
@@ -43,6 +43,8 @@ import org.apache.jackrabbit.util.Text;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * User provider implementation and manager for group memberships with the
  * following characteristics:
@@ -219,7 +221,7 @@ class UserProviderImpl extends Authoriza
 
     @Override
     public String getAuthorizableId(Tree authorizableTree, Type authorizableType) {
-        assert authorizableTree != null;
+        checkNotNull(authorizableTree);
         if (isAuthorizableTree(authorizableTree, authorizableType)) {
             PropertyState idProp = authorizableTree.getProperty(UserConstants.REP_AUTHORIZABLE_ID);
             if (idProp != null) {
@@ -244,13 +246,13 @@ class UserProviderImpl extends Authoriza
 
     @Override
     public boolean isAdminUser(Tree userTree) {
-        assert userTree != null;
+        checkNotNull(userTree);
         return adminId.equals(getAuthorizableId(userTree, Type.USER));
     }
 
     @Override
     public void setProtectedProperty(Tree authorizableTree, String propertyName, String value,
int propertyType) {
-        assert authorizableTree != null;
+        checkNotNull(authorizableTree);
 
         if (value == null) {
             authorizableTree.removeProperty(propertyName);
@@ -262,7 +264,7 @@ class UserProviderImpl extends Authoriza
 
     @Override
     public void setProtectedProperty(Tree authorizableTree, String propertyName, String[]
values, int propertyType) {
-        assert authorizableTree != null;
+        checkNotNull(authorizableTree);
 
         if (values == null) {
             authorizableTree.removeProperty(propertyName);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserValidatorProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserValidatorProvider.java?rev=1382675&r1=1382674&r2=1382675&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserValidatorProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserValidatorProvider.java
Mon Sep 10 07:44:26 2012
@@ -25,6 +25,8 @@ import org.apache.jackrabbit.oak.spi.sec
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.util.NodeUtil;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * Provides a validator for user and group management.
  */
@@ -33,8 +35,7 @@ public class UserValidatorProvider imple
     private final UserConfig config;
 
     public UserValidatorProvider(UserConfig config) {
-        assert config != null;
-        this.config = config;
+        this.config = checkNotNull(config);
     }
     //--------------------------------------------------< ValidatorProvider >---
     @Nonnull

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/SubtreeValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/SubtreeValidator.java?rev=1382675&r1=1382674&r2=1382675&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/SubtreeValidator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/SubtreeValidator.java
Mon Sep 10 07:44:26 2012
@@ -17,11 +17,13 @@
 package org.apache.jackrabbit.oak.spi.commit;
 
 import java.util.Arrays;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * Validator that detects changes to a specified subtree and delegates the
  * validation of such changes to another given validator.
@@ -41,9 +43,9 @@ public class SubtreeValidator extends De
     }
 
     private SubtreeValidator(Validator validator, List<String> path) {
-        assert validator != null;
-        assert path != null && !path.isEmpty();
-        this.validator = validator;
+        this.validator = checkNotNull(validator);
+        checkNotNull(path);
+        checkArgument(!path.isEmpty());
         this.head = path.get(0);
         this.tail = path.subList(1, path.size());
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/CompositePrincipalProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/CompositePrincipalProvider.java?rev=1382675&r1=1382674&r2=1382675&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/CompositePrincipalProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/CompositePrincipalProvider.java
Mon Sep 10 07:44:26 2012
@@ -27,6 +27,8 @@ import com.google.common.collect.Iterato
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * {@code PrincipalProvider} implementation that aggregates a list of principal
  * providers into a single.
@@ -38,8 +40,7 @@ public class CompositePrincipalProvider 
     private final List<PrincipalProvider> providers;
 
     public CompositePrincipalProvider(List<PrincipalProvider> providers) {
-        assert providers != null;
-        this.providers = providers;
+        this.providers = checkNotNull(providers);
     }
 
     //--------------------------------------------------< PrincipalProvider >---

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserConfig.java?rev=1382675&r1=1382674&r2=1382675&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserConfig.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserConfig.java
Mon Sep 10 07:44:26 2012
@@ -25,6 +25,8 @@ import org.apache.jackrabbit.oak.spi.sec
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * UserManagerConfig provides utilities to retrieve configuration options
  * related to user management. In addition it defines some constants that
@@ -92,9 +94,7 @@ public class UserConfig {
     }
 
     public UserConfig(String adminId, Map<String, Object> options, Set<AuthorizableAction>
actions) {
-        assert adminId != null;
-
-        this.adminId = adminId;
+        this.adminId = checkNotNull(adminId);
         this.options = (options == null) ? Collections.<String, Object>emptyMap() :
Collections.unmodifiableMap(options);
         this.actions = (actions == null) ? Collections.<AuthorizableAction>emptySet()
: Collections.unmodifiableSet(actions);
     }



Mime
View raw message