jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1565364 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/security/user/ main/java/org/apache/jackrabbit/oak/util/ test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/
Date Thu, 06 Feb 2014 17:29:05 GMT
Author: angela
Date: Thu Feb  6 17:29:05 2014
New Revision: 1565364

URL: http://svn.apache.org/r1565364
Log:
minor improvement

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerImplTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProvider.java?rev=1565364&r1=1565363&r2=1565364&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProvider.java
Thu Feb  6 17:29:05 2014
@@ -40,6 +40,7 @@ import org.apache.jackrabbit.oak.spi.sec
 import org.apache.jackrabbit.oak.spi.security.user.AuthorizableType;
 import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
 import org.apache.jackrabbit.oak.util.NodeUtil;
+import org.apache.jackrabbit.oak.util.TreeUtil;
 import org.apache.jackrabbit.util.Text;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -279,12 +280,13 @@ class UserProvider extends AuthorizableB
         // test for colliding folder child node.
         while (folder.hasChild(nodeName)) {
             NodeUtil colliding = folder.getChild(nodeName);
-            if (colliding.hasPrimaryNodeTypeName(NT_REP_AUTHORIZABLE_FOLDER)) {
+            String primaryType = TreeUtil.getPrimaryTypeName(colliding.getTree());
+            if (NT_REP_AUTHORIZABLE_FOLDER.equals(primaryType)) {
                 log.debug("Existing folder node collides with user/group to be created. Expanding
path by: " + colliding.getName());
                 folder = colliding;
             } else {
                 String msg = "Failed to create authorizable with id '" + authorizableId +
"' : " +
-                        "Detected conflicting node of unexpected node type '" + colliding.getPrimaryNodeTypeName()
+ "'.";
+                        "Detected conflicting node of unexpected node type '" + primaryType
+ "'.";
                 log.error(msg);
                 throw new ConstraintViolationException(msg);
             }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java?rev=1565364&r1=1565363&r2=1565364&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java
Thu Feb  6 17:29:05 2014
@@ -16,18 +16,9 @@
  */
 package org.apache.jackrabbit.oak.util;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.apache.jackrabbit.oak.api.Type.DATE;
-import static org.apache.jackrabbit.oak.api.Type.LONG;
-import static org.apache.jackrabbit.oak.api.Type.NAME;
-import static org.apache.jackrabbit.oak.api.Type.NAMES;
-import static org.apache.jackrabbit.oak.api.Type.STRING;
-import static org.apache.jackrabbit.oak.api.Type.STRINGS;
-
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.List;
-
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -39,7 +30,6 @@ import javax.jcr.ValueFactory;
 import com.google.common.base.Function;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
-
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
@@ -52,6 +42,14 @@ 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.oak.api.Type.DATE;
+import static org.apache.jackrabbit.oak.api.Type.LONG;
+import static org.apache.jackrabbit.oak.api.Type.NAME;
+import static org.apache.jackrabbit.oak.api.Type.NAMES;
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+import static org.apache.jackrabbit.oak.api.Type.STRINGS;
+
 /**
  * Utility class for accessing and writing typed content of a tree.
  */
@@ -183,15 +181,6 @@ public class NodeUtil {
         }
     }
 
-    public boolean hasPrimaryNodeTypeName(String ntName) {
-        return ntName.equals(getPrimaryNodeTypeName());
-    }
-
-    @CheckForNull
-    public String getPrimaryNodeTypeName() {
-        return TreeUtil.getPrimaryTypeName(tree);
-    }
-
     public void removeProperty(String name) {
         tree.removeProperty(name);
     }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerImplTest.java?rev=1565364&r1=1565363&r2=1565364&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerImplTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerImplTest.java
Thu Feb  6 17:29:05 2014
@@ -57,6 +57,7 @@ import org.apache.jackrabbit.api.securit
 import org.apache.jackrabbit.oak.api.ContentSession;
 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.namepath.GlobalNameMapper;
 import org.apache.jackrabbit.oak.namepath.LocalNameMapper;
 import org.apache.jackrabbit.oak.namepath.NameMapper;
@@ -1244,13 +1245,14 @@ public class AccessControlManagerImplTes
         assertArrayEquals(testPrivileges, privilegesFromNames(TreeUtil.getStrings(ace, REP_PRIVILEGES)));
         assertFalse(ace.hasChild(REP_RESTRICTIONS));
 
-        NodeUtil ace2 = new NodeUtil(children.next());
-        assertEquals(NT_REP_DENY_ACE, ace2.getPrimaryNodeTypeName());
-        assertEquals(EveryonePrincipal.NAME, ace2.getString(REP_PRINCIPAL_NAME, null));
-        assertArrayEquals(testPrivileges, privilegesFromNames(ace2.getNames(REP_PRIVILEGES)));
+        Tree ace2 = children.next();
+        assertEquals(NT_REP_DENY_ACE, TreeUtil.getPrimaryTypeName(ace2));
+        assertEquals(EveryonePrincipal.NAME, ace2.getProperty(REP_PRINCIPAL_NAME).getValue(Type.STRING));
+        Privilege[] privs = privilegesFromNames(TreeUtil.getNames(ace2, REP_PRIVILEGES));
+        assertArrayEquals(testPrivileges, privs);
         assertTrue(ace2.hasChild(REP_RESTRICTIONS));
-        NodeUtil restr = ace2.getChild(REP_RESTRICTIONS);
-        assertEquals("*/something", restr.getString(REP_GLOB, null));
+        Tree restr = ace2.getChild(REP_RESTRICTIONS);
+        assertEquals("*/something", restr.getProperty(REP_GLOB).getValue(Type.STRING));
     }
 
     @Test



Mime
View raw message