com.atlassian.user.impl.memory
Class MemoryGroupManager

java.lang.Object
  extended bycom.atlassian.user.impl.memory.MemoryGroupManager
All Implemented Interfaces:
EntityManager, GroupManager

public class MemoryGroupManager
extends java.lang.Object
implements GroupManager


Constructor Summary
MemoryGroupManager(RepositoryIdentifier repository, MemoryProvider provider)
           
 
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.
 java.lang.String getApplicationKey()
           
 RepositoryIdentifier getConfiguration()
           
 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.
 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.
 Pager getMemberNames(Group group)
          Retrieves the names of all members of the specified group.
 RepositoryIdentifier getRepository(Entity entity)
           
 java.util.List getWritableGroups()
          Gets all editable groups.
 boolean hasMembership(Group group, User user)
          Returns true if the user is a member of the specified 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)
          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

MemoryGroupManager

public MemoryGroupManager(RepositoryIdentifier repository,
                          MemoryProvider provider)
Method Detail

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
Description copied from interface: GroupManager
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.

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

addMembership

public void addMembership(Group group,
                          User user)
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

hasMembership

public boolean hasMembership(Group group,
                             User user)
Description copied from interface: GroupManager
Returns true if the user is a member of the specified group.

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

If the group is not handled by this manager, returns false.

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

getGroups

public Pager getGroups()
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.

getGroup

public Group getGroup(java.lang.String groupName)
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.

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

getWritableGroups

public java.util.List getWritableGroups()
Description copied from interface: GroupManager
Gets all editable groups. That is, returns any groups that belong to read/write repositories. Groups in readonly repositories that are ReadOnly are not returned.

Specified by:
getWritableGroups in interface GroupManager
Returns:
list of Groups that can be edited.

getConfiguration

public RepositoryIdentifier getConfiguration()

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
Specified by:
getRepository in interface EntityManager
Returns:
the RepositoryIdentifier of the repository in which the entity is stored, or null if the entity cannot be found.
Throws:
EntityException - if the entity cannot be found, or trying to retrieve it results in an error

getApplicationKey

public java.lang.String getApplicationKey()

isCreative

public boolean isCreative()
Description copied from interface: EntityManager
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.

removeMembership

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

Specified by:
removeMembership in interface GroupManager

getMemberNames

public Pager getMemberNames(Group group)
Description copied from interface: GroupManager
Retrieves the names of all members of the specified group. The names are ordered by a Collator for the JVM's default locale (as returned by Collator.getInstance().

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.

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. The names are ordered by a Collator for the JVM's default locale (as returned by Collator.getInstance().

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.

The names are ordered by a Collator for the JVM's default locale (as returned by Collator.getInstance().

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

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

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 repositories can be granted membership to groups in this repository, otherwise false.
Throws:
EntityException


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