com.atlassian.crowd.integration.atlassianuser
Class CrowdGroupManager

java.lang.Object
  extended by com.atlassian.crowd.integration.atlassianuser.CrowdGroupManager

public class CrowdGroupManager
extends Object

Crowd implementation of the atlassian-user group manager.

A group manager is responsible for all CRUD operations on groups and group memberships in a given repository.

Where an operation requires a Group as an argument, calling the method with a group from another repository will typically throw an IllegalArgumentException.

The group manager is responsible for ensuring the consistency of the underlying repository where relevant. For example, if membership information needs to be updated as part of the removeGroup(Group) operation, the group manager is responsible for ensuring it happens.

This interface is an extension of the EntityManager interface which is common to user and group management. The common functionality includes initialisation and access to the repository description.


Constructor Summary
CrowdGroupManager()
          Default contructor.
 
Method Summary
 void addMembership(Group group, User user)
          Adds the user to the specified group.
 Group createGroup(String name)
          Create a new group with the specified name.
protected  List findAllGroupNames()
           
protected  SOAPGroup findGroupByName(String name)
           
 Pager getExternalMemberNames(Group group)
          Sett #getLocalMemberNames(com.atlassian.user.Group)}
 Group getGroup(String name)
          Retrieves the group with the given name.
protected  List getGroupMembership(User user)
          Retrieves the groups to which the given user belongs.
 Pager getGroups()
          Retrieves all groups in this repository.
 Pager getGroups(User user)
          Retrieves the groups to which the given user belongs.
 Pager getLocalMemberNames(Group group)
          Retrieves the names of those members of the specified group which are also stored in this repository.
 Pager getMemberNames(Group group)
          Retrieves the names of all members of the specified group.
 Repository getRepository()
          Returns information about the respository implementation.
 Repository getRepository(Entity entity)
          Returns information about the respository for a specific entity.
 boolean hasMembership(Group group, User user)
          Returns true if the user is a member of the specified group.
 void init(HashMap args)
          Used for configuration by a config.
 boolean isCreative()
           
 boolean isReadOnly(Group group)
          Returns true if the specified group and membership of the specified group cannot be modified in the repository.
 void removeGroup(Group group)
          Remove the group specified, if it exists in this repository.
 void removeMembership(Group group, User user)
          Removes the user from the specified group.
 boolean supportsExternalMembership()
          Returns true if the repository supports users in other repositories being members of groups in this repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CrowdGroupManager

public CrowdGroupManager()
Default contructor. Configures to the Crowd client cache for better performance. See CacheManagerAtlassianUser.

Method Detail

getGroups

public Pager getGroups()
                throws EntityException
Retrieves all groups in this repository.

Returns:
a Pager containing a Group for each group managed by the repository. An empty pager will be returned if the repository does not contain any groups.
Throws:
EntityException

getGroups

public Pager getGroups(User user)
                throws EntityException
Retrieves the groups to which the given user belongs. Only groups which are managed by this repository are included.

Returns:
a Pager containing a Group for each group the user belongs to. An empty pager will be returned if the user does not belong to any groups that this manager knows about.
Throws:
EntityException

getGroupMembership

protected List getGroupMembership(User user)
                           throws EntityException
Retrieves the groups to which the given user belongs. Only groups which are managed by this repository are included.

Returns:
a List containing a Group for each group the user belongs to. An empty list will be returned if the user does not belong to any groups that this manager knows about.
Throws:
EntityException

getMemberNames

public Pager getMemberNames(Group group)
                     throws EntityException
Retrieves the names of all members of the specified group.

Returns:
a Pager containing a String with the name of each member of the group. An empty pager will be returned if the group has no members.
Throws:
EntityException

getLocalMemberNames

public Pager getLocalMemberNames(Group group)
                          throws EntityException
Retrieves the names of those members of the specified group which are also stored in this repository.

If supportsExternalMembership() returns false, this call is equivalent to getMemberNames(Group).

Parameters:
group - The group to lookup.
Returns:
a Pager containing a String with the name of each member of the group which is stored in the same repository. An empty pager will be returned if the group has no local members.
Throws:
EntityException

getExternalMemberNames

public Pager getExternalMemberNames(Group group)
                             throws EntityException
Sett #getLocalMemberNames(com.atlassian.user.Group)}

Parameters:
group - The group to lookup.
Returns:
Search results.
Throws:
EntityException - Search exception.

getGroup

public Group getGroup(String name)
               throws EntityException
Retrieves the group with the given name. Returns null if the group does not exist in this repository.

Returns:
a Group or null if the group does not exist.
Throws:
EntityException

createGroup

public Group createGroup(String name)
                  throws EntityException
Create a new group with the specified name.

Throws:
EntityException - if the Group could not be created.
UnsupportedOperationException - if isCreative() returns false

removeGroup

public void removeGroup(Group group)
                 throws EntityException
Remove the group specified, if it exists in this repository. If the group does not belong to this repository, an IllegalArgumentException will be thrown. If required to maintain the consistency of the repository, the group manager should remove users from the group before removing the group itself.

Throws:
EntityException - if the Group could not be removed.
UnsupportedOperationException - if isReadOnly(Group) returns true.

addMembership

public void addMembership(Group group,
                          User user)
                   throws EntityException
Adds the user to the specified group.

If the user is not in this repository, and supportsExternalMembership() returns true, the user will be added as an external user.

Throws:
UnsupportedOperationException - if isReadOnly(Group) returns true.
EntityException

hasMembership

public boolean hasMembership(Group group,
                             User user)
                      throws EntityException
Returns true if the user is a member of the specified group.

If the user is not in this repository, and supportsExternalMembership() returns true, external members will be checked as well.

Returns:
true if the user is a member of the specified group, otherwise false.
Throws:
EntityException

removeMembership

public void removeMembership(Group group,
                             User user)
                      throws EntityException
Removes the user from the specified group.

Throws:
EntityException - if the membership could not be removed.
UnsupportedOperationException - if GroupManager#isReadOnly(Group) returns true.

supportsExternalMembership

public boolean supportsExternalMembership()
                                   throws EntityException
Returns true if the repository supports users in other repositories being members of groups in this repository.

Typically this is true of an application-specific Hibernate repository, but not of a company's LDAP server. It is designed to allow the LDAP users to be members of the application's groups for flexible application-level security.

Returns:
true if users from other repositories can be granted membership to groups in this repository, otherwise false.
Throws:
EntityException

isReadOnly

public boolean isReadOnly(Group group)
                   throws EntityException
Returns true if the specified group and membership of the specified group cannot be modified in the repository.

If this returns true, invoking methods which attempt to modify the group or membership of the group will fail with UnsupportedOperationException.

Returns:
true if the group and membership of the group cannot be modified, otherwise false.
Throws:
EntityException

getRepository

public Repository getRepository()
Returns information about the respository implementation.

Returns:
The repository configuration.

getRepository

public Repository getRepository(Entity entity)
                         throws EntityException
Returns information about the respository for a specific entity.

Parameters:
entity - The entity.
Returns:
The repository configuration.
Throws:
EntityException

isCreative

public boolean isCreative()

init

public void init(HashMap args)
          throws ConfigurationException
Used for configuration by a config. file.

Parameters:
args -
Throws:
ConfigurationException

findAllGroupNames

protected List findAllGroupNames()
                          throws InvalidAuthorizationTokenException,
                                 RemoteException
Throws:
InvalidAuthorizationTokenException
RemoteException

findGroupByName

protected SOAPGroup findGroupByName(String name)
                             throws InvalidAuthorizationTokenException,
                                    RemoteException,
                                    ObjectNotFoundException
Throws:
InvalidAuthorizationTokenException
RemoteException
ObjectNotFoundException


Copyright © 2006 Atlassian Software Systems. All Rights Reserved.