jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1232526 - in /jackrabbit/branches/2.4: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/ jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/
Date Tue, 17 Jan 2012 18:34:09 GMT
Author: jukka
Date: Tue Jan 17 18:34:09 2012
New Revision: 1232526

URL: http://svn.apache.org/viewvc?rev=1232526&view=rev
Log:
2.4: Merged revisions 1228149 and 1228155 (JCR-3202 and JCR-3203)

Modified:
    jackrabbit/branches/2.4/   (props changed)
    jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/AuthorizableImpl.java
    jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
    jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/AuthorizableImplTest.java

Propchange: jackrabbit/branches/2.4/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 17 18:34:09 2012
@@ -1,3 +1,3 @@
 /jackrabbit/branches/JCR-2272:1173165-1176545
 /jackrabbit/sandbox/JCR-2415-lucene-3.0:1060860-1064038
-/jackrabbit/trunk:1221447,1221579,1221593,1221789,1221818,1225179,1225191,1225196,1225207,1225525,1225528,1226452,1226472,1226515,1226750,1226863,1227171,1227240,1227590,1227593,1227615,1228058,1230681,1232100
+/jackrabbit/trunk:1221447,1221579,1221593,1221789,1221818,1225179,1225191,1225196,1225207,1225525,1225528,1226452,1226472,1226515,1226750,1226863,1227171,1227240,1227590,1227593,1227615,1228058,1228149,1228155,1230681,1232100

Modified: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/AuthorizableImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/AuthorizableImpl.java?rev=1232526&r1=1232525&r2=1232526&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/AuthorizableImpl.java
(original)
+++ jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/AuthorizableImpl.java
Tue Jan 17 18:34:09 2012
@@ -20,6 +20,7 @@ import org.apache.jackrabbit.api.securit
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.Group;
 import org.apache.jackrabbit.api.security.user.User;
+import org.apache.jackrabbit.commons.iterator.RangeIteratorAdapter;
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.id.NodeId;
@@ -370,7 +371,7 @@ abstract class AuthorizableImpl implemen
                 // group node doesn't exist or cannot be read -> ignore.
             }
         }
-        return groups.iterator();
+        return new RangeIteratorAdapter(groups.iterator(), groups.size());
     }
 
     /**

Modified: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java?rev=1232526&r1=1232525&r2=1232526&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
(original)
+++ jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
Tue Jan 17 18:34:09 2012
@@ -25,6 +25,7 @@ import org.apache.jackrabbit.commons.fla
 import org.apache.jackrabbit.commons.flat.Rank;
 import org.apache.jackrabbit.commons.flat.TreeManager;
 import org.apache.jackrabbit.commons.iterator.LazyIteratorChain;
+import org.apache.jackrabbit.commons.iterator.RangeIteratorAdapter;
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.PropertyImpl;
 import org.apache.jackrabbit.core.session.SessionContext;
@@ -189,7 +190,16 @@ class GroupImpl extends AuthorizableImpl
     }
 
     //--------------------------------------------------------------------------
-
+    /**
+     * Retrieve the membership provider for this group. This method deals with
+     * members stored in the <code>P_MEMBERS</code> property and with those
+     * repositories the store group members in a separate tree underneath the
+     * <code>N_MEMBERS</code> node.
+     *
+     * @param node The node associated with this group.
+     * @return an instance of <code>MembershipProvider</code>.
+     * @throws RepositoryException If an error occurs.
+     */
     private MembershipProvider getMembershipProvider(NodeImpl node) throws RepositoryException
{
         MembershipProvider msp;
         if (userManager.getGroupMembershipSplitSize() > 0) {
@@ -212,9 +222,9 @@ class GroupImpl extends AuthorizableImpl
 
     /**
      * @param includeIndirect If <code>true</code> all members of this group
-     *                        will be return; otherwise only the declared members.
-     * @param type            Any of {@link UserManager#SEARCH_TYPE_AUTHORIZABLE},
-     *                        {@link UserManager#SEARCH_TYPE_GROUP}, {@link UserManager#SEARCH_TYPE_USER}.
+     * will be return; otherwise only the declared members.
+     * @param type Any of {@link UserManager#SEARCH_TYPE_AUTHORIZABLE},
+     * {@link UserManager#SEARCH_TYPE_GROUP}, {@link UserManager#SEARCH_TYPE_USER}.
      * @return A collection of members of this group.
      * @throws RepositoryException If an error occurs while collecting the members.
      */
@@ -228,7 +238,7 @@ class GroupImpl extends AuthorizableImpl
      *
      * @param newMember The new member to be tested for cyclic membership.
      * @return true if the 'newMember' is a group and 'this' is an declared or
-     *         inherited member of it.
+     * inherited member of it.
      * @throws javax.jcr.RepositoryException If an error occurs.
      */
     private boolean isCyclicMembership(AuthorizableImpl newMember) throws RepositoryException
{
@@ -461,7 +471,7 @@ class GroupImpl extends AuthorizableImpl
                 if (includeIndirect) {
                     return includeIndirect(toAuthorizables(members, type), type);
                 } else {
-                    return toAuthorizables(members, type);
+                    return new RangeIteratorAdapter(toAuthorizables(members, type), members.length);
                 }
             } else {
                 return Iterators.empty();

Modified: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/AuthorizableImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/AuthorizableImplTest.java?rev=1232526&r1=1232525&r2=1232526&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/AuthorizableImplTest.java
(original)
+++ jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/AuthorizableImplTest.java
Tue Jan 17 18:34:09 2012
@@ -30,6 +30,7 @@ import org.apache.jackrabbit.value.Strin
 
 import javax.jcr.Property;
 import javax.jcr.PropertyIterator;
+import javax.jcr.RangeIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.Value;
@@ -170,6 +171,42 @@ public class AuthorizableImplTest extend
         }
     }
 
+    public void testMemberOfRangeIterator() throws NotExecutableException, RepositoryException
{
+        Authorizable auth = null;
+        Group group = null;
+
+        try {
+            auth = userMgr.createUser(getTestPrincipal().getName(), "pw");
+            group = userMgr.createGroup(getTestPrincipal());
+            save(superuser);
+
+            Iterator<Group>groups = auth.declaredMemberOf();
+            assertTrue(groups instanceof RangeIterator);
+            assertEquals(0, ((RangeIterator) groups).getSize());
+            groups = auth.memberOf();
+            assertTrue(groups instanceof RangeIterator);
+            assertEquals(0, ((RangeIterator) groups).getSize());
+
+            group.addMember(auth);
+            groups = auth.declaredMemberOf();
+            assertTrue(groups instanceof RangeIterator);
+            assertEquals(1, ((RangeIterator) groups).getSize());
+
+            groups = auth.memberOf();
+            assertTrue(groups instanceof RangeIterator);
+            assertEquals(1, ((RangeIterator) groups).getSize());
+
+        } finally {
+            if (auth != null) {
+                auth.remove();
+            }
+            if (group != null) {
+                group.remove();
+            }
+            save(superuser);
+        }
+    }
+
     public void testSetSpecialPropertiesDirectly() throws NotExecutableException, RepositoryException
{
         AuthorizableImpl user = (AuthorizableImpl) getTestUser(superuser);
         NodeImpl n = user.getNode();



Mime
View raw message