com.atlassian.user.impl.delegation
Class DelegatingGroupManagerTemplate

java.lang.Object
  extended bycom.atlassian.user.impl.delegation.DelegatingGroupManagerTemplate
All Implemented Interfaces:
EntityManager, GroupManager
Direct Known Subclasses:
DelegatingListGroupManager

public abstract class DelegatingGroupManagerTemplate
extends java.lang.Object
implements GroupManager


Constructor Summary
DelegatingGroupManagerTemplate()
           
 
Method Summary
 void addMembership(Group group, User user)
          Adds the user to the specified group.
 Group createGroup(java.lang.String groupName)
          Create a new group with the specified name.
 Pager getExternalMemberNames(Group group)
          Retrieves the names of those members of the specified group which are stored in another repository.
 Group getGroup(java.lang.String groupName)
          Retrieves the group with the given name.
protected abstract  java.util.Iterator getGroupManagersIterator()
          Returns an iterator of GroupManager objects, in the order they are to be used for this delegating manager.
 Pager getGroups()
          Retrieves all groups in this repository.
 Pager getGroups(User user)
          Retrieves the groups to which the given user belongs.
 RepositoryIdentifier getIdentifier()
           
 Pager getLocalMemberNames(Group group)
          Retrieves the names of those members of the specified group which are also stored in this repository.
protected  GroupManager getMatchingGroupManager(Group group)
           
 Pager getMemberNames(Group group)
          Retrieves the names of all members of the specified group.
 RepositoryIdentifier getRepository(Entity entity)
          Don't use for now.
 boolean hasMembership(Group group, User user)
          Check whether this manager has a record of membership between the argued user and group.
 boolean isCreative()
          Used to detemine whether an entity can be created (eg, can call UserManager.createUser(String) or GroupManager.createGroup(String)
 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)
          Removes the specified group, if it is present.
 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

DelegatingGroupManagerTemplate

public DelegatingGroupManagerTemplate()
Method Detail

getMatchingGroupManager

protected GroupManager getMatchingGroupManager(Group group)
                                        throws EntityException
Throws:
EntityException

getGroups

public Pager getGroups()
                throws EntityException
Description copied from interface: GroupManager
Retrieves all groups in this repository.

Specified by:
getGroups in interface GroupManager
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
Description copied from interface: GroupManager
Retrieves the groups to which the given user belongs. Only groups which are managed by this repository are included.

Specified by:
getGroups in interface GroupManager
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

getMemberNames

public Pager getMemberNames(Group group)
                     throws EntityException
Description copied from interface: GroupManager
Retrieves the names of all members of the specified group.

Specified by:
getMemberNames in interface GroupManager
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
Description copied from interface: GroupManager
Retrieves the names of those members of the specified group which are also stored in this repository.

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

Specified by:
getLocalMemberNames in interface GroupManager
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
Description copied from interface: GroupManager
Retrieves the names of those members of the specified group which are stored in another repository. For example, an LDAP user which is a member of a Hibernate group is an external member of the Hibernate group.

If GroupManager.supportsExternalMembership() returns false, this method throws UnsupportedOperationException.

Specified by:
getExternalMemberNames in interface GroupManager
Returns:
a Pager containing a String with the name of each member of the group which is stored in a different repository. An empty pager will be returned if the group has no external members.
Throws:
EntityException

getGroup

public Group getGroup(java.lang.String groupName)
               throws EntityException
Description copied from interface: GroupManager
Retrieves the group with the given name. Returns null if the group does not exist in this repository.

Specified by:
getGroup in interface GroupManager
Returns:
a Group or null if the group does not exist.
Throws:
EntityException

createGroup

public Group createGroup(java.lang.String groupName)
                  throws EntityException
Description copied from interface: GroupManager
Create a new group with the specified name.

Specified by:
createGroup in interface GroupManager
Throws:
EntityException - if the Group could not be created.

removeGroup

public void removeGroup(Group group)
                 throws EntityException
Removes the specified group, if it is present.

Specified by:
removeGroup in interface GroupManager
Throws:
EntityException - - representing the exception which prohibited removal

addMembership

public void addMembership(Group group,
                          User user)
                   throws EntityException
Description copied from interface: GroupManager
Adds the user to the specified group.

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

Specified by:
addMembership in interface GroupManager
Throws:
EntityException

hasMembership

public boolean hasMembership(Group group,
                             User user)
                      throws EntityException
Check whether this manager has a record of membership between the argued user and group.

Specified by:
hasMembership in interface GroupManager
Returns:
true if the user is a member of the specified group, otherwise false.
Throws:
RepositoryException
EntityException

removeMembership

public void removeMembership(Group group,
                             User user)
                      throws EntityException
Description copied from interface: GroupManager
Removes the user from the specified group.

Specified by:
removeMembership in interface GroupManager
Throws:
EntityException - if the membership could not be removed.

supportsExternalMembership

public boolean supportsExternalMembership()
                                   throws EntityException
Description copied from interface: GroupManager
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.

Specified by:
supportsExternalMembership in interface GroupManager
Returns:
true if users from other systems can be granted membership in the underlying RepositoryIdentifier, otherwise false.
Throws:
EntityException

isReadOnly

public boolean isReadOnly(Group group)
                   throws EntityException
Description copied from interface: GroupManager
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.

Specified by:
isReadOnly in interface GroupManager
Returns:
true if the group and membership of the group cannot be modified, otherwise false.
Throws:
EntityException

getIdentifier

public RepositoryIdentifier getIdentifier()
Specified by:
getIdentifier in interface EntityManager
Returns:
the RepositoryIdentifier which is managed by this instance.

getRepository

public RepositoryIdentifier getRepository(Entity entity)
                                   throws EntityException
Don't use for now. This is very expensive for large LDAP instances. todo: get user/group entities to store which repository they came from

Specified by:
getRepository in interface EntityManager
Returns:
the RepositoryIdentifier in which the entity is stored, otherwise null.
Throws:
EntityException

isCreative

public boolean isCreative()
Used to detemine whether an entity can be created (eg, can call UserManager.createUser(String) or GroupManager.createGroup(String)

Specified by:
isCreative in interface EntityManager
Returns:
true to indicate that Entity objects can be created by this manager, or false to indicate not.

getGroupManagersIterator

protected abstract java.util.Iterator getGroupManagersIterator()
Returns an iterator of GroupManager objects, in the order they are to be used for this delegating manager.



Copyright © 2005-2007 Atlassian Software Systems Pty Ltd. All Rights Reserved.