com.atlassian.jira.security.groups
Class DefaultGroupManager

java.lang.Object
  extended by com.atlassian.jira.security.groups.DefaultGroupManager
All Implemented Interfaces:
GroupManager

public class DefaultGroupManager
extends Object
implements GroupManager

Default implementation of GroupManager.

Since:
v3.13

Constructor Summary
DefaultGroupManager(com.atlassian.crowd.embedded.api.CrowdService crowdService)
           
 
Method Summary
 void addUserToGroup(com.atlassian.crowd.embedded.api.User user, com.atlassian.crowd.embedded.api.Group group)
          Adds a user as a member of a group.
 com.atlassian.crowd.embedded.api.Group createGroup(String groupName)
          Create a group with the given name.
 Collection<com.atlassian.crowd.embedded.api.Group> getAllGroups()
          Get all groups.
 Collection<com.atlassian.crowd.embedded.api.User> getDirectUsersInGroup(com.atlassian.crowd.embedded.api.Group group)
          Returns all the users that are direct members of the group.
 com.atlassian.crowd.embedded.api.Group getGroup(String groupName)
          Returns the Group for this groupName, else null if no such Group exists.
 Collection<String> getGroupNamesForUser(String userName)
          Returns the names of all the groups that the given user belongs to.
 Collection<String> getGroupNamesForUser(com.atlassian.crowd.embedded.api.User user)
          Returns the names of all the groups that the given user belongs to.
 com.atlassian.crowd.embedded.api.Group getGroupObject(String groupName)
          Returns the Group for this groupName, else null if no such Group exists.
 Collection<com.atlassian.crowd.embedded.api.Group> getGroupsForUser(String userName)
          Returns all the groups that the given user belongs to.
 Collection<com.atlassian.crowd.embedded.api.Group> getGroupsForUser(com.atlassian.crowd.embedded.api.User user)
          Returns all the groups that the given user belongs to.
 Collection<String> getUserNamesInGroup(com.atlassian.crowd.embedded.api.Group group)
          Returns the names of all the users in a group.
 Collection<String> getUserNamesInGroup(String groupName)
          Returns the names of all the users in a group.
 Collection<com.atlassian.crowd.embedded.api.User> getUsersInGroup(com.atlassian.crowd.embedded.api.Group group)
          Returns all the users in a group.
 Collection<com.atlassian.crowd.embedded.api.User> getUsersInGroup(String groupName)
          Returns all the users in a group.
 boolean groupExists(String groupName)
          Returns true if the given group name exists.
 boolean isUserInGroup(String username, String groupname)
          Returns true if the user is a member of the group.
 boolean isUserInGroup(com.atlassian.crowd.embedded.api.User user, com.atlassian.crowd.embedded.api.Group group)
          Returns true if the user is a member of the group.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultGroupManager

public DefaultGroupManager(com.atlassian.crowd.embedded.api.CrowdService crowdService)
Method Detail

getAllGroups

public Collection<com.atlassian.crowd.embedded.api.Group> getAllGroups()
Description copied from interface: GroupManager
Get all groups.

Specified by:
getAllGroups in interface GroupManager
Returns:
Collection of all Groups.

groupExists

public boolean groupExists(String groupName)
Description copied from interface: GroupManager
Returns true if the given group name exists.

Specified by:
groupExists in interface GroupManager
Parameters:
groupName - The group name.
Returns:
true if the given group name exists.

createGroup

public com.atlassian.crowd.embedded.api.Group createGroup(String groupName)
                                                   throws com.atlassian.crowd.exception.OperationNotPermittedException,
                                                          com.atlassian.crowd.exception.embedded.InvalidGroupException
Description copied from interface: GroupManager
Create a group with the given name.

Specified by:
createGroup in interface GroupManager
Parameters:
groupName - The group name.
Returns:
the newly created Group.
Throws:
com.atlassian.crowd.exception.OperationNotPermittedException - if the directory has been configured to not allow the operation to be performed
com.atlassian.crowd.exception.embedded.InvalidGroupException - if the group already exists in ANY associated directory or the group template does not have the required properties populated.

getGroup

public com.atlassian.crowd.embedded.api.Group getGroup(String groupName)
Description copied from interface: GroupManager
Returns the Group for this groupName, else null if no such Group exists.

Warning: previous incarnations of this method returned com.opensymphony.user.Group. This class has now been removed from the JIRA API, meaning that the 5.0 version is not binary or source compatible with earlier versions.

Specified by:
getGroup in interface GroupManager
Parameters:
groupName - The group name.
Returns:
The Group for this groupName, else null if no such Group exists.

getGroupObject

public com.atlassian.crowd.embedded.api.Group getGroupObject(String groupName)
Description copied from interface: GroupManager
Returns the Group for this groupName, else null if no such Group exists.

Legacy synonym for GroupManager.getGroup(String).

Specified by:
getGroupObject in interface GroupManager
Parameters:
groupName - The group name.
Returns:
The Group for this groupName, else null if no such Group exists.
See Also:
GroupManager.getGroup(String)

isUserInGroup

public boolean isUserInGroup(String username,
                             String groupname)
Description copied from interface: GroupManager
Returns true if the user is a member of the group.

Note that if the username or groupname is null, then it will return false.

Specified by:
isUserInGroup in interface GroupManager
Parameters:
username - user to inspect.
groupname - group to inspect.
Returns:
true if and only if the user is a direct or indirect (nested) member of the group.
See Also:
GroupManager.isUserInGroup(com.atlassian.crowd.embedded.api.User, com.atlassian.crowd.embedded.api.Group)

isUserInGroup

public boolean isUserInGroup(com.atlassian.crowd.embedded.api.User user,
                             com.atlassian.crowd.embedded.api.Group group)
Description copied from interface: GroupManager
Returns true if the user is a member of the group.

Note that if the User or Group object is null, then it will return false. This was done to retain consistency with the old OSUser behaviour of User.inGroup() and Group.containsUser()

Specified by:
isUserInGroup in interface GroupManager
Parameters:
user - user to inspect.
group - group to inspect.
Returns:
true if and only if the user is a direct or indirect (nested) member of the group.
See Also:
GroupManager.isUserInGroup(String, String)

getUsersInGroup

public Collection<com.atlassian.crowd.embedded.api.User> getUsersInGroup(String groupName)
Description copied from interface: GroupManager
Returns all the users in a group.

Specified by:
getUsersInGroup in interface GroupManager
Parameters:
groupName - The group
Returns:
all the users that belongs to the group.
See Also:
#getUsersInGroup(Group)}

getUsersInGroup

public Collection<com.atlassian.crowd.embedded.api.User> getUsersInGroup(com.atlassian.crowd.embedded.api.Group group)
Description copied from interface: GroupManager
Returns all the users in a group. This will include nested group members.

Specified by:
getUsersInGroup in interface GroupManager
Parameters:
group - The group
Returns:
all the users that belongs to the group.
See Also:
#getUsersInGroup(String)}

getUserNamesInGroup

public Collection<String> getUserNamesInGroup(com.atlassian.crowd.embedded.api.Group group)
Description copied from interface: GroupManager
Returns the names of all the users in a group. This will include nested group members.

Specified by:
getUserNamesInGroup in interface GroupManager
Parameters:
group - The group
Returns:
all the users that belongs to the group.
See Also:
#getUsersInGroup(Group)}

getUserNamesInGroup

public Collection<String> getUserNamesInGroup(String groupName)
Description copied from interface: GroupManager
Returns the names of all the users in a group. This will include nested group members.

Specified by:
getUserNamesInGroup in interface GroupManager
Parameters:
groupName - The group
Returns:
all the users that belongs to the group.
See Also:
#getUsersInGroup(String)}

getDirectUsersInGroup

public Collection<com.atlassian.crowd.embedded.api.User> getDirectUsersInGroup(com.atlassian.crowd.embedded.api.Group group)
Description copied from interface: GroupManager
Returns all the users that are direct members of the group. This will NOT include nested group members.

Specified by:
getDirectUsersInGroup in interface GroupManager
Parameters:
group - The group
Returns:
all the users that belongs to the group.
See Also:
#getUsersInGroup(String)}

getGroupsForUser

public Collection<com.atlassian.crowd.embedded.api.Group> getGroupsForUser(String userName)
Description copied from interface: GroupManager
Returns all the groups that the given user belongs to.

Specified by:
getGroupsForUser in interface GroupManager
Parameters:
userName - The user
Returns:
all the groups that the given user belongs to.
See Also:
GroupManager.getGroupNamesForUser(String)

getGroupsForUser

public Collection<com.atlassian.crowd.embedded.api.Group> getGroupsForUser(com.atlassian.crowd.embedded.api.User user)
Description copied from interface: GroupManager
Returns all the groups that the given user belongs to.

Specified by:
getGroupsForUser in interface GroupManager
Parameters:
user - The user
Returns:
all the groups that the given user belongs to.
See Also:
GroupManager.getGroupNamesForUser(String)

getGroupNamesForUser

public Collection<String> getGroupNamesForUser(String userName)
Description copied from interface: GroupManager
Returns the names of all the groups that the given user belongs to.

Specified by:
getGroupNamesForUser in interface GroupManager
Parameters:
userName - The user
Returns:
all the groups that the given user belongs to.
See Also:
GroupManager.getGroupsForUser(String)

getGroupNamesForUser

public Collection<String> getGroupNamesForUser(com.atlassian.crowd.embedded.api.User user)
Description copied from interface: GroupManager
Returns the names of all the groups that the given user belongs to.

Specified by:
getGroupNamesForUser in interface GroupManager
Parameters:
user - The user
Returns:
all the groups that the given user belongs to.
See Also:
GroupManager.getGroupsForUser(String)

addUserToGroup

public void addUserToGroup(com.atlassian.crowd.embedded.api.User user,
                           com.atlassian.crowd.embedded.api.Group group)
                    throws com.atlassian.crowd.exception.GroupNotFoundException,
                           com.atlassian.crowd.exception.UserNotFoundException,
                           com.atlassian.crowd.exception.OperationNotPermittedException,
                           com.atlassian.crowd.exception.OperationFailedException
Description copied from interface: GroupManager
Adds a user as a member of a group.

Specified by:
addUserToGroup in interface GroupManager
Parameters:
user - The user that will become a member of the group.
group - The group that will gain a new member.
Throws:
com.atlassian.crowd.exception.GroupNotFoundException - if the group could not be found
com.atlassian.crowd.exception.UserNotFoundException - if the user could not be found
com.atlassian.crowd.exception.OperationNotPermittedException - if the directory has been configured to not allow the operation to be performed
com.atlassian.crowd.exception.OperationFailedException - If the underlying directory implementation failed to execute the operation.


Copyright © 2002-2013 Atlassian. All Rights Reserved.