jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1370326 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/ main/java/org/apache/jackrabbit/core/security/user/ test/java/org/apache/jackrabbit/core/security/user/
Date Tue, 07 Aug 2012 15:54:41 GMT
Author: angela
Date: Tue Aug  7 15:54:40 2012
New Revision: 1370326

URL: http://svn.apache.org/viewvc?rev=1370326&view=rev
Log:
Improvements for UserManagement implementation:

- move configuration code to UserManagerConfig
- rename public method getGroupMembershipSplitSize to getMemberSplitSize
- add method hasMemberSplitSize and replace usage of getGroupMembershipSplitSize() > 0
- remove old class name from javadoc in NodeCreationTest

Added:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerConfig.java
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/DefaultSecurityManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/UserPerWorkspaceSecurityManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserAccessControlProvider.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserImporter.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserPerWorkspaceUserManager.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NodeCreationTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserImporterTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/DefaultSecurityManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/DefaultSecurityManager.java?rev=1370326&r1=1370325&r2=1370326&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/DefaultSecurityManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/DefaultSecurityManager.java
Tue Aug  7 15:54:40 2012
@@ -462,12 +462,6 @@ public class DefaultSecurityManager impl
      */
     protected UserManagerImpl createUserManager(SessionImpl session) throws RepositoryException
{
         UserManagerConfig umc = getConfig().getUserManagerConfig();
-        Properties params = (umc == null) ? null : umc.getParameters();
-
-        // since users are stored in and retrieved from a dedicated workspace
-        // only the system session assigned with that workspace will get the
-        // system user manager (special implementation that asserts the existence
-        // of the admin user).
         UserManagerImpl um;
         if (umc != null) {
             Class<?>[] paramTypes = new Class[] {
@@ -476,12 +470,9 @@ public class DefaultSecurityManager impl
                     Properties.class,
                     MembershipCache.class};
             um = (UserManagerImpl) umc.getUserManager(UserManagerImpl.class,
-                    paramTypes, session, adminId, params, getMembershipCache(session));
-            // TODO: should we make sure the implementation doesn't allow
-            // TODO: to change the autosave behavior? since the user manager
-            // TODO: writes to a separate workspace this would cause troubles.
+                    paramTypes, session, adminId, umc.getParameters(), getMembershipCache(session));
         } else {
-            um = new UserManagerImpl(session, adminId, params, getMembershipCache(session));
+            um = new UserManagerImpl(session, adminId, null, getMembershipCache(session));
         }
 
         if (umc != null && !(session instanceof SystemSession)) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/UserPerWorkspaceSecurityManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/UserPerWorkspaceSecurityManager.java?rev=1370326&r1=1370325&r2=1370326&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/UserPerWorkspaceSecurityManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/UserPerWorkspaceSecurityManager.java
Tue Aug  7 15:54:40 2012
@@ -219,8 +219,6 @@ public class UserPerWorkspaceSecurityMan
     @Override
     protected UserManagerImpl createUserManager(SessionImpl session) throws RepositoryException
{
         UserManagerConfig umc = getConfig().getUserManagerConfig();
-        Properties params = (umc == null) ? null : umc.getParameters();
-
         UserManagerImpl umgr;
         // in contrast to the DefaultSecurityManager users are not retrieved
         // from a dedicated workspace: the system session of each workspace must
@@ -232,9 +230,9 @@ public class UserPerWorkspaceSecurityMan
                     Properties.class,
                     MembershipCache.class};
             umgr = (UserPerWorkspaceUserManager) umc.getUserManager(UserPerWorkspaceUserManager.class,
-                    paramTypes, session, adminId, params, getMembershipCache(session));
+                    paramTypes, session, adminId, umc.getParameters(), getMembershipCache(session));
         } else {
-            umgr = new UserPerWorkspaceUserManager(session, adminId, params, getMembershipCache(session));
+            umgr = new UserPerWorkspaceUserManager(session, adminId, null, getMembershipCache(session));
         }
 
         if (umc != null && !(session instanceof SystemSession)) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java?rev=1370326&r1=1370325&r2=1370326&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
Tue Aug  7 15:54:40 2012
@@ -202,7 +202,7 @@ class GroupImpl extends AuthorizableImpl
      */
     private MembershipProvider getMembershipProvider(NodeImpl node) throws RepositoryException
{
         MembershipProvider msp;
-        if (userManager.getGroupMembershipSplitSize() > 0) {
+        if (userManager.hasMemberSplitSize()) {
             if (node.hasNode(N_MEMBERS) || !node.hasProperty(P_MEMBERS)) {
                 msp = new NodeBasedMembershipProvider(node);
             } else {
@@ -214,7 +214,7 @@ class GroupImpl extends AuthorizableImpl
 
         if (node.hasProperty(P_MEMBERS) && node.hasNode(N_MEMBERS)) {
             log.warn("Found members node and members property on node {}. Ignoring {} members",
node,
-                    userManager.getGroupMembershipSplitSize() > 0 ? "property" : "node");
+                    userManager.hasMemberSplitSize() ? "property" : "node");
         }
 
         return msp;
@@ -267,7 +267,7 @@ class GroupImpl extends AuthorizableImpl
 
     static PropertySequence getPropertySequence(Node nMembers, UserManagerImpl userManager)
throws RepositoryException {
         Comparator<String> order = Rank.comparableComparator();
-        int maxChildren = userManager.getGroupMembershipSplitSize();
+        int maxChildren = userManager.getMemberSplitSize();
         int minChildren = maxChildren / 2;
 
         TreeManager treeManager = new BTreeManager(nMembers, minChildren, maxChildren, order,

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserAccessControlProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserAccessControlProvider.java?rev=1370326&r1=1370325&r2=1370326&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserAccessControlProvider.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserAccessControlProvider.java
Tue Aug  7 15:54:40 2012
@@ -182,7 +182,7 @@ public class UserAccessControlProvider e
             usersPath = (uMgr instanceof UserManagerImpl) ? ((UserManagerImpl) uMgr).getUsersPath()
: UserConstants.USERS_PATH;
             groupsPath = (uMgr instanceof UserManagerImpl) ? ((UserManagerImpl) uMgr).getGroupsPath()
: UserConstants.GROUPS_PATH;
 
-            membersInProperty = (!(uMgr instanceof UserManagerImpl)) || ((UserManagerImpl)
uMgr).getGroupMembershipSplitSize() <= 0;
+            membersInProperty = !(uMgr instanceof UserManagerImpl) || !((UserManagerImpl)
uMgr).hasMemberSplitSize();
 
             if (configuration.containsKey(PARAM_ANONYMOUS_ID)) {
                 anonymousId = (String) configuration.get(PARAM_ANONYMOUS_ID);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserImporter.java?rev=1370326&r1=1370325&r2=1370326&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserImporter.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserImporter.java
Tue Aug  7 15:54:40 2012
@@ -440,7 +440,7 @@ public class UserImporter implements Pro
                         log.info("ImportBehavior.BESTEFFORT: Found " + nonExisting.size()
+ " entries of rep:members pointing to non-existing authorizables. Adding to rep:members.");
                         final NodeImpl groupNode = ((AuthorizableImpl) gr).getNode();
 
-                        if (userManager.getGroupMembershipSplitSize() > 0) {
+                        if (userManager.hasMemberSplitSize()) {
                             userManager.performProtectedOperation((SessionImpl) session,
new SessionWriteOperation<Object>() {
                                 public Boolean perform(SessionContext context) throws RepositoryException
{
                                     NodeImpl nMembers = (groupNode.hasNode(UserConstants.N_MEMBERS)

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerConfig.java?rev=1370326&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerConfig.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerConfig.java
Tue Aug  7 15:54:40 2012
@@ -0,0 +1,102 @@
+/*
+ * 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.core.security.user;
+
+import org.apache.jackrabbit.core.security.user.action.AuthorizableAction;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Properties;
+
+/**
+ * Utility to retrieve configuration parameters for UserManagerImpl
+ */
+class UserManagerConfig {
+
+    private static final Logger log = LoggerFactory.getLogger(UserManagerImpl.class);
+
+    private final Properties config;
+    private final String adminId;
+    /**
+     * Authorizable actions that will all be executed upon creation and removal
+     * of authorizables in the order they are contained in the array.<p/>
+     * Note, that if {@link #isAutoSave() autosave} is turned on, the configured
+     * actions are executed before persisting the creation or removal.
+     */
+    private AuthorizableAction[] actions;
+
+    UserManagerConfig(Properties config, String adminId, AuthorizableAction[] actions) {
+        this.config = config;
+        this.adminId = adminId;
+        this.actions = (actions == null) ? new AuthorizableAction[0] : actions;
+    }
+
+    public <T> T getConfigValue(String key, T defaultValue) {
+        if (config != null && config.containsKey(key)) {
+            return convert(config.get(key), defaultValue);
+        } else {
+            return defaultValue;
+        }
+    }
+
+    public String getAdminId() {
+        return adminId;
+    }
+
+    public AuthorizableAction[] getAuthorizableActions() {
+        return actions;
+    }
+
+    public void setAuthorizableActions(AuthorizableAction[] actions) {
+        if (actions != null) {
+            this.actions = actions;
+        }
+    }
+
+    //--------------------------------------------------------< private >---
+    private <T> T convert(Object v, T defaultValue) {
+        if (v == null) {
+            return null;
+        }
+
+        T value;
+        String str = v.toString();
+        Class targetClass = (defaultValue == null) ? String.class : defaultValue.getClass();
+        try {
+            if (targetClass == String.class) {
+                value = (T) str;
+            } else if (targetClass == Integer.class) {
+                value = (T) Integer.valueOf(str);
+            } else if (targetClass == Long.class) {
+                value = (T) Long.valueOf(str);
+            } else if (targetClass == Double.class) {
+                value = (T) Double.valueOf(str);
+            } else if (targetClass == Boolean.class) {
+                value = (T) Boolean.valueOf(str);
+            } else {
+                // unsupported target type
+                log.warn("Unsupported target type {} for value {}", targetClass.getName(),
v);
+                throw new IllegalArgumentException("Cannot convert config entry " + v + "
to " + targetClass.getName());
+            }
+        } catch (NumberFormatException e) {
+            log.warn("Invalid value {}; cannot be parsed into {}", v, targetClass.getName());
+            value = defaultValue;
+        }
+
+        return value;
+    }
+}

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java?rev=1370326&r1=1370325&r2=1370326&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java
Tue Aug  7 15:54:40 2012
@@ -231,11 +231,13 @@ public class UserManagerImpl extends Pro
     public static final String PARAM_AUTO_EXPAND_SIZE = "autoExpandSize";
 
     /**
-     * If this parameter is present group memberships are collected in a node
+     * If this parameter is present group members are collected in a node
      * structure below {@link UserConstants#N_MEMBERS} instead of the default
      * multi valued property {@link UserConstants#P_MEMBERS}. Its value determines
      * the maximum number of member properties until additional intermediate nodes
-     * are inserted. Valid values are integers > 4.
+     * are inserted. Valid values are integers &gt; 4. The default value is 0 and
+     * indicates that the {@link UserConstants#P_MEMBERS} property is used to
+     * record group members.
      */
     public static final String PARAM_GROUP_MEMBERSHIP_SPLIT_SIZE = "groupMembershipSplitSize";
 
@@ -245,51 +247,13 @@ public class UserManagerImpl extends Pro
     private final String adminId;
     private final NodeResolver authResolver;
     private final NodeCreator nodeCreator;
+    private final UserManagerConfig config;
 
-    /**
-     * Configuration value defining the node where User nodes will be created.
-     * Default value is {@link UserConstants#USERS_PATH}.
-     */
     private final String usersPath;
-
-    /**
-     * Configuration value defining the node where Group nodes will be created.
-     * Default value is {@link UserConstants#GROUPS_PATH}.
-     */
     private final String groupsPath;
-
-    /**
-     * Flag indicating if {@link #getAuthorizable(String)} should be able to deal
-     * with users or groups created with Jackrabbit < 2.0.<br>
-     * As of 2.0 authorizables are created using a defined logic that allows
-     * to retrieve them without searching/traversing. If this flag is
-     * <code>true</code> this method will try to find authorizables using the
-     * <code>authResolver</code> if not found otherwise.
-     */
-    private final boolean compatibleJR16;
-
-    /**
-     * Maximum number of properties on the group membership node structure under
-     * {@link UserConstants#N_MEMBERS} until additional intermediate nodes are inserted.
-     * If 0 (default), {@link UserConstants#P_MEMBERS} is used to record group
-     * memberships.
-     */
-    private final int groupMembershipSplitSize;
-
-    /**
-     * The membership cache.
-     */
     private final MembershipCache membershipCache;
 
     /**
-     * Authorizable actions that will all be executed upon creation and removal
-     * of authorizables in the order they are contained in the array.<p/>
-     * Note, that if {@link #isAutoSave() autosave} is turned on, the configured
-     * actions are executed before persisting the creation or removal.
-     */
-    private AuthorizableAction[] authorizableActions = new AuthorizableAction[0];
-
-    /**
      * Create a new <code>UserManager</code> with the default configuration.
      *
      * @param session The editing/reading session.
@@ -336,27 +300,31 @@ public class UserManagerImpl extends Pro
      */
     public UserManagerImpl(SessionImpl session, String adminId, Properties config,
                            MembershipCache mCache) throws RepositoryException {
+        this(session, new UserManagerConfig(config, adminId, null), mCache);
+    }
+
+    /**
+     * Create a new <code>UserManager</code> for the given <code>session</code>.
+     *
+     * @param session The editing/reading session.
+     * @param config The user manager configuration.
+     * @param mCache The shared membership cache.
+     * @throws RepositoryException If an error occurs.
+     */
+    private UserManagerImpl(SessionImpl session, UserManagerConfig config, MembershipCache
mCache) throws RepositoryException {
         this.session = session;
-        this.adminId = adminId;
+        this.adminId = config.getAdminId();
+        this.config = config;
 
         nodeCreator = new NodeCreator(config);
 
-        Object param = (config != null) ? config.get(PARAM_USERS_PATH) : null;
-        usersPath = (param != null) ? param.toString() : USERS_PATH;
-
-        param = (config != null) ? config.get(PARAM_GROUPS_PATH) : null;
-        groupsPath = (param != null) ? param.toString() : GROUPS_PATH;
-
-        param = (config != null) ? config.get(PARAM_COMPATIBLE_JR16) : null;
-        compatibleJR16 = (param != null) && Boolean.parseBoolean(param.toString());
-
-        param = (config != null) ? config.get(PARAM_GROUP_MEMBERSHIP_SPLIT_SIZE) : null;
-        groupMembershipSplitSize = parseMembershipSplitSize(param);
+        this.usersPath = config.getConfigValue(PARAM_USERS_PATH, USERS_PATH);
+        this.groupsPath = config.getConfigValue(PARAM_GROUPS_PATH, GROUPS_PATH);
 
         if (mCache != null) {
             membershipCache = mCache;
         } else {
-            membershipCache = new MembershipCache(session, groupsPath, groupMembershipSplitSize
> 0);
+            membershipCache = new MembershipCache(session, groupsPath, hasMemberSplitSize());
         }
 
         NodeResolver nr;
@@ -407,8 +375,25 @@ public class UserManagerImpl extends Pro
      *
      * @return The maximum number of group members before splitting up the structure.
      */
-    public int getGroupMembershipSplitSize() {
-        return groupMembershipSplitSize;
+    public int getMemberSplitSize() {
+        int splitSize = config.getConfigValue(PARAM_GROUP_MEMBERSHIP_SPLIT_SIZE, 0);
+        if (splitSize < 4) {
+            log.warn("Invalid value {} for {}. Expected integer >= 4", splitSize, PARAM_GROUP_MEMBERSHIP_SPLIT_SIZE);
+            splitSize = 0;
+        }
+        return splitSize;
+    }
+
+    /**
+     * Returns <code>true</code> if the split-member configuration parameter
+     * is greater or equal than 4 indicating that group members should be stored
+     * in a tree instead of a single multivalued property.
+     *
+     * @return true if group members are being stored in a tree instead of a
+     * single multivalued property.
+     */
+    public boolean hasMemberSplitSize() {
+        return getMemberSplitSize() >= 4;
     }
 
     /**
@@ -418,9 +403,7 @@ public class UserManagerImpl extends Pro
      * @param authorizableActions An array of authorizable actions.
      */
     public void setAuthorizableActions(AuthorizableAction[] authorizableActions) {
-        if (authorizableActions != null) {
-            this.authorizableActions = authorizableActions;
-        }
+        config.setAuthorizableActions(authorizableActions);
     }
 
     //--------------------------------------------------------< UserManager >---
@@ -596,8 +579,7 @@ public class UserManagerImpl extends Pro
     /**
      * @see UserManager#createGroup(String)
      */
-    public Group createGroup(String groupID)
-    		throws AuthorizableExistsException, RepositoryException {
+    public Group createGroup(String groupID) throws AuthorizableExistsException, RepositoryException
{
     	return createGroup(groupID, new PrincipalImpl(groupID), null);
     }
     
@@ -850,6 +832,7 @@ public class UserManagerImpl extends Pro
         try {
             n = session.getNodeById(nodeId);
         } catch (ItemNotFoundException e) {
+            boolean compatibleJR16 = config.getConfigValue(PARAM_COMPATIBLE_JR16, false);
             if (compatibleJR16) {
                 // backwards-compatibility with JR < 2.0 user/group structure that doesn't
                 // allow to determine existence of an authorizable from the id directly.
@@ -1037,27 +1020,6 @@ public class UserManagerImpl extends Pro
         }
     }
 
-    private static int parseMembershipSplitSize(Object param) {
-        int n = 0;
-        if (param != null) {
-            try {
-                n = Integer.parseInt(param.toString());
-                if (n < 4) {
-                    n = 0;
-                }
-            }
-            catch (NumberFormatException e) {
-                n = 0;
-            }
-            if (n == 0) {
-                log.warn("Invalid value {} for {}. Expected integer >= 4",
-                        param.toString(), PARAM_GROUP_MEMBERSHIP_SPLIT_SIZE);
-            }
-        }
-
-        return n;
-    }
-
     //--------------------------------------------------------------------------
     /**
      * Let the configured <code>AuthorizableAction</code>s perform additional
@@ -1069,7 +1031,7 @@ public class UserManagerImpl extends Pro
      * @throws RepositoryException If an exception occurs.
      */
     void onCreate(User user, String pw) throws RepositoryException {
-        for (AuthorizableAction action : authorizableActions) {
+        for (AuthorizableAction action : config.getAuthorizableActions()) {
             action.onCreate(user, pw, session);
         }
     }
@@ -1083,7 +1045,7 @@ public class UserManagerImpl extends Pro
      * @throws RepositoryException If an exception occurs.
      */
     void onCreate(Group group) throws RepositoryException {
-        for (AuthorizableAction action : authorizableActions) {
+        for (AuthorizableAction action : config.getAuthorizableActions()) {
             action.onCreate(group, session);
         }
     }
@@ -1097,7 +1059,7 @@ public class UserManagerImpl extends Pro
      * @throws RepositoryException If an exception occurs.
      */
     void onRemove(Authorizable authorizable) throws RepositoryException {
-        for (AuthorizableAction action : authorizableActions) {
+        for (AuthorizableAction action : config.getAuthorizableActions()) {
             action.onRemove(authorizable, session);
         }
     }
@@ -1112,7 +1074,7 @@ public class UserManagerImpl extends Pro
      * @throws RepositoryException If an exception occurs.
      */
     void onPasswordChange(User user, String password) throws RepositoryException {
-        for (AuthorizableAction action : authorizableActions) {
+        for (AuthorizableAction action : config.getAuthorizableActions()) {
             action.onPasswordChange(user, password, session);
         }
     }
@@ -1350,36 +1312,22 @@ public class UserManagerImpl extends Pro
         // all child nodes.
         private final long autoExpandSize;
 
-        private NodeCreator(Properties config) {
+        private NodeCreator(UserManagerConfig config) {
             int d = DEFAULT_DEPTH;
             boolean expand = false;
             long size = DEFAULT_SIZE;
 
             if (config != null) {
-                if (config.containsKey(PARAM_DEFAULT_DEPTH)) {
-                    try {
-                        d = Integer.parseInt(config.get(PARAM_DEFAULT_DEPTH).toString());
-                        if (d <= 0) {
-                           log.warn("Invalid defaultDepth '" + d + "' -> using default.");
-                           d = DEFAULT_DEPTH;
-                        }
-                    } catch (NumberFormatException e) {
-                        log.warn("Unable to parse defaultDepth config parameter -> using
default.", e);
-                    }
+                d = config.getConfigValue(PARAM_DEFAULT_DEPTH, DEFAULT_DEPTH);
+                if (d <= 0) {
+                    log.warn("Invalid defaultDepth '" + d + "' -> using default.");
+                    d = DEFAULT_DEPTH;
                 }
-                if (config.containsKey(PARAM_AUTO_EXPAND_TREE)) {
-                    expand = Boolean.parseBoolean(config.get(PARAM_AUTO_EXPAND_TREE).toString());
-                }
-                if (config.containsKey(PARAM_AUTO_EXPAND_SIZE)) {
-                    try {
-                        size = Integer.parseInt(config.get(PARAM_AUTO_EXPAND_SIZE).toString());
-                        if (expand && size <= 0) {
-                            log.warn("Invalid autoExpandSize '" + size + "' -> using default.");
-                            size = DEFAULT_SIZE;
-                        }
-                    } catch (NumberFormatException e) {
-                        log.warn("Unable to parse autoExpandSize config parameter -> using
default.", e);
-                    }
+                expand = config.getConfigValue(PARAM_AUTO_EXPAND_TREE, false);
+                size = config.getConfigValue(PARAM_AUTO_EXPAND_SIZE, DEFAULT_SIZE);
+                if (expand && size <= 0) {
+                    log.warn("Invalid autoExpandSize '" + size + "' -> using default.");
+                    size = DEFAULT_SIZE;
                 }
             }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserPerWorkspaceUserManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserPerWorkspaceUserManager.java?rev=1370326&r1=1370325&r2=1370326&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserPerWorkspaceUserManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserPerWorkspaceUserManager.java
Tue Aug  7 15:54:40 2012
@@ -117,6 +117,7 @@ public class UserPerWorkspaceUserManager
      * @return The path of the node.
      * @throws RepositoryException If an error occurs while retrieving the path.
      */
+    @Override
     String getPath(Node authorizableNode) throws RepositoryException {
         return authorizableNode.getPath();
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NodeCreationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NodeCreationTest.java?rev=1370326&r1=1370325&r2=1370326&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NodeCreationTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NodeCreationTest.java
Tue Aug  7 15:54:40 2012
@@ -38,7 +38,7 @@ import java.util.Map;
 import java.util.Properties;
 
 /**
- * <code>IdResolverTest</code>...
+ * <code>NodeCreationTest</code>...
  */
 public class NodeCreationTest extends AbstractUserTest {
 

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserImporterTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserImporterTest.java?rev=1370326&r1=1370325&r2=1370326&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserImporterTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserImporterTest.java
Tue Aug  7 15:54:40 2012
@@ -860,7 +860,7 @@ public class UserImporterTest extends Ab
     }
 
     public void testImportNonExistingMemberBestEffort() throws IOException, RepositoryException,
SAXException, NotExecutableException {
-        if (umgr.getGroupMembershipSplitSize() > 0) {
+        if (umgr.hasMemberSplitSize()) {
             throw new NotExecutableException();
         }
 
@@ -914,7 +914,7 @@ public class UserImporterTest extends Ab
 
         String g1Id = "0120a4f9-196a-3f9e-b9f5-23f31f914da7";
         String nonExistingId = "b2f5ff47-4366-31b6-a533-d8dc3614845d"; // groupId of 'g'
group.
-        if (umgr.getAuthorizable("g") != null || umgr.getGroupMembershipSplitSize() >
0) {
+        if (umgr.getAuthorizable("g") != null || umgr.hasMemberSplitSize()) {
             throw new NotExecutableException();
         }
 



Mime
View raw message