com.atlassian.user.impl.osuser
Class OSUGroupManager

java.lang.Object
  extended bycom.atlassian.user.impl.osuser.OSUEntityManager
      extended bycom.atlassian.user.impl.osuser.OSUGroupManager
All Implemented Interfaces:
EntityManager, GroupManager

public class OSUGroupManager
extends OSUEntityManager
implements GroupManager

An adaptor class for AccessProvider and some of the higher level operations of UserManager

The rule is to use the credentialsProvider and/or profileProvider (for propertySets) for most things. Store() operations must be called on the entity itself.


Field Summary
protected  org.apache.log4j.Logger log
           
 
Fields inherited from class com.atlassian.user.impl.osuser.OSUEntityManager
repository
 
Constructor Summary
OSUGroupManager(RepositoryIdentifier repository, OSUAccessor accessor)
           
 
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.
 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.
 void saveGroup(Group group)
           
 boolean supportsExternalMembership()
          Returns true if the repository supports users in other repositories being members of groups in this repository.
 
Methods inherited from class com.atlassian.user.impl.osuser.OSUEntityManager
getConfiguration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.log4j.Logger log
Constructor Detail

OSUGroupManager

public OSUGroupManager(RepositoryIdentifier repository,
                       OSUAccessor accessor)
Method Detail

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.

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,
                        java.lang.IllegalArgumentException
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.
java.lang.IllegalArgumentException

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.

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

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

getMemberNames

public Pager getMemberNames(Group group)
                     throws EntityException
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.
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. 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

saveGroup

public void saveGroup(Group group)
               throws EntityException
Throws:
EntityException

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 RepositoryException
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:
RepositoryException

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.

getIdentifier

public RepositoryIdentifier getIdentifier()
Specified by:
getIdentifier in interface EntityManager
Overrides:
getIdentifier in class OSUEntityManager
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

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
Overrides:
isCreative in class OSUEntityManager
Returns:
mutability is hard-coded within each UserProvider then applied to the entity produced (here a Group).

All providers in the base OSUUser package are hardcoded to be mutable. This implementation returns the mutability value of the first group returned by UserProvider.list().

If there are no groups it returns true.

Thus, if you want immutable groups you should override this method or ensure that there is at least one entity which is handled by the provider. All groups should have the same mutability value.



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