public interface

GroupManager

com.atlassian.jira.security.groups.GroupManager
Known Indirect Subclasses

Class Overview

This object can be used to manage groups in JIRA.

Summary

Public Methods
void addUserToGroup(ApplicationUser user, Group group)
Adds a user as a member of a group.
Group createGroup(String groupName)
Create a group with the given name.
Collection<String> filterUsersInAllGroupsDirect(Collection<String> userNames, Collection<String> groupNames)
Returns a collection of user names for the users that are direct members of every one of the supplied groups.
@Deprecated Collection<Group> getAllGroups()
This method is deprecated. Since v7.0. Only retrieve the users you really need. See GroupPickerSearchService
Set<ApplicationUser> getConnectUsers()
Returns all the connect add-on users.
Collection<ApplicationUser> getDirectUsersInGroup(Group group)
Returns all the users that are direct members of the group.
Group getGroup(String groupName)
Returns the Group for this groupName, else null if no such Group exists.
Group getGroupEvenWhenUnknown(String groupName)
Returns the Group for this groupName, if no such Group exists then a proxy unknown immutable Group object is returned.
Collection<String> getGroupNamesForUser(String userName)
Returns the names of all the groups that the given user belongs to.
Collection<String> getGroupNamesForUser(ApplicationUser user)
Returns the names of all the groups that the given user belongs to.
@Deprecated Group getGroupObject(String groupName)
This method is deprecated. use getGroup(String) instead. Since 6.5
Collection<Group> getGroupsForUser(String userName)
Returns all the groups that the given user belongs to.
Collection<Group> getGroupsForUser(ApplicationUser user)
Returns all the groups that the given user belongs to.
Collection<String> getNamesOfDirectMembersOfGroups(Collection<String> groupNames, int limit)
Returns a list of all active user names that are direct members in at least one of the supplied groups.
Collection<String> getUserNamesInGroup(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<String> getUserNamesInGroups(Collection<Group> groups)
Returns the names of all the users in a collection of groups.
Collection<ApplicationUser> getUsersInGroup(String groupName)
Returns all the users in a group.
Page<ApplicationUser> getUsersInGroup(String groupName, Boolean includeInactive, PageRequest pageRequest)
Returns a page with users in a group.
Collection<ApplicationUser> getUsersInGroup(Group group)
Returns all the users in a group.
Collection<ApplicationUser> getUsersInGroup(String groupName, Boolean includeInactive)
Returns all the users in a group.
int getUsersInGroupCount(Group group)
Returns a count of all active users in a group.
int getUsersInGroupCount(String groupName)
Returns a count of all active users in a group.
boolean groupExists(Group group)
Returns true if the given group exists.
boolean groupExists(String groupName)
Returns true if the given group name exists.
boolean isUserInGroup(ApplicationUser user, Group group)
Returns true if the user is a member of the group.
boolean isUserInGroup(String username, String groupname)
This method is deprecated. Use one of the other isUserInGroup methods that takes a concrete user object instead. Since v6.4.8.
boolean isUserInGroup(ApplicationUser user, String groupName)
Returns true if the user is a member of the named group.

Public Methods

public void addUserToGroup (ApplicationUser user, Group group)

Adds a user as a member of a group.

Parameters
user The user that will become a member of the group.
group The group that will gain a new member.
Throws
UserNotFoundException if the user could not be found
GroupNotFoundException if the group could not be found
OperationNotPermittedException if the directory has been configured to not allow the operation to be performed
OperationFailedException If the underlying directory implementation failed to execute the operation.

public Group createGroup (String groupName)

Create a group with the given name.

Parameters
groupName The group name.
Returns
  • the newly created Group.
Throws
InvalidGroupException if the group already exists in ANY associated directory or the group template does not have the required properties populated.
OperationNotPermittedException if the directory has been configured to not allow the operation to be performed

public Collection<String> filterUsersInAllGroupsDirect (Collection<String> userNames, Collection<String> groupNames)

Returns a collection of user names for the users that are direct members of every one of the supplied groups.

Parameters
userNames A collection of user names
groupNames A collection of groups
Returns
  • a collection of user names

@Deprecated public Collection<Group> getAllGroups ()

This method is deprecated.
Since v7.0. Only retrieve the users you really need. See GroupPickerSearchService

Get all groups.

Returns
  • Collection of all Groups.

public Set<ApplicationUser> getConnectUsers ()

Returns all the connect add-on users. This will return an empty Set in JIRA Server as connect plugins are only supported in JIRA Cloud. This result does not filter out inactive users.

Returns
  • all the connect add-on users.

public Collection<ApplicationUser> getDirectUsersInGroup (Group group)

Returns all the users that are direct members of the group. This will NOT include nested group members.

Parameters
group The group
Returns
  • all the users that belongs to the group.
Throws
NullPointerException if the group is null
See Also
  • {@link #getUsersInGroup(String)}

public Group getGroup (String groupName)

Returns the Group for this groupName, else null if no such Group exists.

Parameters
groupName The group name.
Returns
  • The Group for this groupName, else null if no such Group exists.

public Group getGroupEvenWhenUnknown (String groupName)

Returns the Group for this groupName, if no such Group exists then a proxy unknown immutable Group object is returned.

Parameters
groupName The group name.
Returns
  • The Group for this groupName.

public Collection<String> getGroupNamesForUser (String userName)

Returns the names of all the groups that the given user belongs to.

Parameters
userName The user
Returns
  • all the groups that the given user belongs to.

public Collection<String> getGroupNamesForUser (ApplicationUser user)

Returns the names of all the groups that the given user belongs to.

Parameters
user The user
Returns
  • all the groups that the given user belongs to.

@Deprecated public Group getGroupObject (String groupName)

This method is deprecated.
use getGroup(String) instead. Since 6.5

Returns the Group for this groupName, else null if no such Group exists.

Legacy synonym for getGroup(String).

Parameters
groupName The group name.
Returns
  • The Group for this groupName, else null if no such Group exists.
See Also

public Collection<Group> getGroupsForUser (String userName)

Returns all the groups that the given user belongs to.

Parameters
userName The user
Returns
  • all the groups that the given user belongs to.

public Collection<Group> getGroupsForUser (ApplicationUser user)

Returns all the groups that the given user belongs to.

Parameters
user The user
Returns
  • all the groups that the given user belongs to.

public Collection<String> getNamesOfDirectMembersOfGroups (Collection<String> groupNames, int limit)

Returns a list of all active user names that are direct members in at least one of the supplied groups.

Parameters
groupNames A collection of group names to find direct members of
limit A maximum number of names to return
Returns
  • a list of user names

public Collection<String> getUserNamesInGroup (Group group)

Returns the names of all the users in a group. This will include nested group members.

Parameters
group The group
Returns
  • all the users that belongs to the group.
Throws
NullPointerException if the group is null
See Also
  • {@link #getUsersInGroup(Group)}

public Collection<String> getUserNamesInGroup (String groupName)

Returns the names of all the users in a group. This will include nested group members.

Parameters
groupName The group
Returns
  • all the users that belongs to the group.
Throws
NullPointerException if the group is null
See Also
  • {@link #getUsersInGroup(String)}

public Collection<String> getUserNamesInGroups (Collection<Group> groups)

Returns the names of all the users in a collection of groups. This will include nested group members.

Parameters
groups The collection of groups
Returns
  • all the users that belongs to the group.
Throws
NullPointerException if a group is null

public Collection<ApplicationUser> getUsersInGroup (String groupName)

Returns all the users in a group.

Parameters
groupName The group
Returns
  • all the users that belongs to the group.
See Also
  • {@link #getUsersInGroup(Group)}

public Page<ApplicationUser> getUsersInGroup (String groupName, Boolean includeInactive, PageRequest pageRequest)

Returns a page with users in a group. Users are sorted by name in ascending order.

Parameters
groupName name of the group for which users are returned
includeInactive if set to true inactive users will be returned as well
pageRequest parameters of the page to return
Returns
  • page with the users

public Collection<ApplicationUser> getUsersInGroup (Group group)

Returns all the users in a group. This will include nested group members.

Parameters
group The group
Returns
  • all the users that belongs to the group.
Throws
NullPointerException if the group is null
See Also
  • {@link #getUsersInGroup(String)}

public Collection<ApplicationUser> getUsersInGroup (String groupName, Boolean includeInactive)

Returns all the users in a group. Allows for additional filtering by the active flag of a user.

Parameters
groupName The group
includeInactive if set to true inactive users will be returned as well
Returns
  • all the users that belongs to the group.

public int getUsersInGroupCount (Group group)

Returns a count of all active users in a group. This will include nested group members.

Parameters
group The group
Returns
  • a count of all the users that belongs to the group.
See Also
  • {@link #getUsersInGroupCount(String)}

public int getUsersInGroupCount (String groupName)

Returns a count of all active users in a group. This will include nested group members.

Parameters
groupName The group name
Returns
  • a count of all the users that belongs to the group.
See Also
  • {@link #getUsersInGroupCount(Group)}

public boolean groupExists (Group group)

Returns true if the given group exists.

Parameters
group The group.
Returns
  • true if the given group exists.

public boolean groupExists (String groupName)

Returns true if the given group name exists.

Parameters
groupName The group name.
Returns
  • true if the given group name exists.

public boolean isUserInGroup (ApplicationUser user, Group group)

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()

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.

public boolean isUserInGroup (String username, String groupname)

This method is deprecated.
Use one of the other isUserInGroup methods that takes a concrete user object instead. Since v6.4.8.

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.

Performance note: If you have a full user object, then calling one of the other isUserInGroup() methods directly is more efficient.

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.

public boolean isUserInGroup (ApplicationUser user, String groupName)

Returns true if the user is a member of the named group.

If you already have the user object, then this method is faster than the alternative of passing in the username because it saves on an unnecessary user lookup to find the correct User Directory.

Parameters
user 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.