You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by an...@apache.org on 2015/08/04 14:48:11 UTC
svn commit: r1694048 - in /jackrabbit/trunk:
jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/user/Group.java
jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
Author: angela
Date: Tue Aug 4 12:48:11 2015
New Revision: 1694048
URL: http://svn.apache.org/r1694048
Log:
JCR-3880 : Allow to add/remove group members by ID
Modified:
jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/user/Group.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
Modified: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/user/Group.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/user/Group.java?rev=1694048&r1=1694047&r2=1694048&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/user/Group.java (original)
+++ jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/user/Group.java Tue Aug 4 12:48:11 2015
@@ -16,8 +16,10 @@
*/
package org.apache.jackrabbit.api.security.user;
+import javax.annotation.Nonnull;
import javax.jcr.RepositoryException;
import java.util.Iterator;
+import java.util.Set;
/**
* A Group is a collection of {@link #getMembers() Authorizable}s.
@@ -69,6 +71,24 @@ public interface Group extends Authoriza
boolean addMember(Authorizable authorizable) throws RepositoryException;
/**
+ * Add one or more member(s) to this Group. Note, that an implementation may
+ * define circumstances under which this method allows to add non-existing
+ * {@code Authorizable}s as new members. Also an implementation may choose to
+ * (partially) postpone validation/verification util {@link Session#save()}.
+ *
+ * @param memberIds The {@code Id}s of the authorizables to be added as
+ * members to this group.
+ * @return a set of those {@code memberIds} that could not be added or an
+ * empty set of all ids have been successfully processed. The former may include
+ * those cases where a given id cannot be resolved to an existing authorizable,
+ * one that is already member or if adding the member would create a
+ * cyclic group membership.
+ * @throws RepositoryException If one of the specified memberIds is invalid or
+ * if some other error occurs.
+ */
+ Set<String> addMembers(@Nonnull String... memberIds) throws RepositoryException;
+
+ /**
* Remove a member from this Group.
*
* @param authorizable The <code>Authorizable</code> to be removed from
@@ -77,4 +97,20 @@ public interface Group extends Authoriza
* @throws RepositoryException If an error occurs.
*/
boolean removeMember(Authorizable authorizable) throws RepositoryException;
+
+ /**
+ * Remove one or several members from this Group. Note, that an implementation
+ * may define circumstances under which this method allows to remove members
+ * that (no longer) exist. An implementation may choose to (partially)
+ * postpone validation/verification util {@link Session#save()}.
+ *
+ * @param memberIds The {@code Id}s of the authorizables to be removed
+ * from the members of this group.
+ * @return a set of those {@code memberIds} that could not be removed or an
+ * empty set if all ids have been successfully processed. The former may include
+ * those cases where a given id cannot be resolved to an existing authorizable.
+ * @throws RepositoryException If one of the specified memberIds is invalid
+ * or if some other error occurs.
+ */
+ Set<String> removeMembers(@Nonnull String... memberIds) throws RepositoryException;
}
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=1694048&r1=1694047&r2=1694048&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 4 12:48:11 2015
@@ -35,6 +35,7 @@ import javax.jcr.Node;
import javax.jcr.Property;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
import javax.jcr.Value;
import org.apache.jackrabbit.api.security.user.Authorizable;
@@ -172,6 +173,11 @@ class GroupImpl extends AuthorizableImpl
return getMembershipProvider(getNode()).addMember(authImpl);
}
+ @Override
+ public Set<String> addMembers(String... memberIds) throws RepositoryException {
+ throw new UnsupportedRepositoryOperationException("not implemented");
+ }
+
/**
* @see Group#removeMember(Authorizable)
@@ -188,6 +194,11 @@ class GroupImpl extends AuthorizableImpl
return getMembershipProvider(getNode()).removeMember((AuthorizableImpl) authorizable);
}
+ @Override
+ public Set<String> removeMembers(String... memberIds) throws RepositoryException {
+ throw new UnsupportedRepositoryOperationException("not implemented");
+ }
+
//--------------------------------------------------------------------------
/**
* Retrieve the membership provider for this group. This method deals with