Interface GroupManager
- All Known Implementing Classes:
DefaultGroupManager,MockGroupManager,RequestCachingGroupManager
public interface GroupManager
This object can be used to manage groups in JIRA.
- Since:
- v3.13
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddUserToGroup(ApplicationUser user, com.atlassian.crowd.embedded.api.Group group) Adds a user as a member of a group.com.atlassian.crowd.embedded.api.GroupcreateGroup(String groupName) Create a group with the given name.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.Returns the names of all groups or an empty collection if there are no groups.Collection<com.atlassian.crowd.embedded.api.Group>Deprecated.Since v7.0.Deprecated.since 7.2.0.getDirectUsersInGroup(com.atlassian.crowd.embedded.api.Group group) Returns all the users that are direct members of the group.com.atlassian.crowd.embedded.api.GroupReturns the Group for this groupName, else null if no such Group exists.com.atlassian.crowd.embedded.api.GroupgetGroupEvenWhenUnknown(String groupName) Returns the Group for this groupName, if no such Group exists then a proxy unknown immutable Group object is returned.Returns the names of all the groups that the given user belongs to.getGroupNamesForUser(String userName) Returns the names of all the groups that the given user belongs to.com.atlassian.crowd.embedded.api.GroupgetGroupObject(String groupName) Deprecated.usegetGroup(String)instead.Collection<com.atlassian.crowd.embedded.api.Group>Returns all the groups that the given user belongs to.Collection<com.atlassian.crowd.embedded.api.Group>getGroupsForUser(String userName) Returns all the groups that the given user belongs to.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.getUserNamesInGroup(com.atlassian.crowd.embedded.api.Group group) Returns the names of all the users in a group.getUserNamesInGroup(String groupName) Returns the names of all the users in a group.getUserNamesInGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups) Returns the names of all the users in a collection of groups.getUsersInGroup(com.atlassian.crowd.embedded.api.Group group) Returns all the users in a group.getUsersInGroup(String groupName) Returns all the users in a group.getUsersInGroup(String groupName, Boolean includeInactive) Returns all the users in a group.getUsersInGroup(String groupName, Boolean includeInactive, PageRequest pageRequest) Returns a page with users in a group.intgetUsersInGroupCount(com.atlassian.crowd.embedded.api.Group group) Returns a count of all active users in a group.intgetUsersInGroupCount(String groupName) Returns a count of all active users in a group.booleangroupExists(com.atlassian.crowd.embedded.api.Group group) Returnstrueif the given group exists.booleangroupExists(String groupName) Returnstrueif the given group name exists.booleanisUserInGroup(ApplicationUser user, com.atlassian.crowd.embedded.api.Group group) Returnstrueif the user is a member of the group.booleanisUserInGroup(ApplicationUser user, String groupName) Returnstrueif the user is a member of the named group.booleanisUserInGroup(String username, String groupname) Deprecated.Use one of the otherisUserInGroupmethods that takes a concrete user object instead.booleanisUserInGroups(ApplicationUser user, Set<String> groupNames) Returnstrueif the user is a member of at least one of the named groups.
-
Method Details
-
groupExists
Returnstrueif the given group name exists.- Parameters:
groupName- The group name.- Returns:
trueif the given group name exists.- Since:
- v3.13
-
groupExists
boolean groupExists(@Nonnull com.atlassian.crowd.embedded.api.Group group) Returnstrueif the given group exists.- Parameters:
group- The group.- Returns:
trueif the given group exists.- Since:
- v7.0
-
getAllGroups
Deprecated.Since v7.0. Only retrieve the users you really need. SeeGroupPickerSearchServiceGet all groups.- Returns:
- Collection of all Groups.
- Since:
- v4.3
-
createGroup
com.atlassian.crowd.embedded.api.Group createGroup(String groupName) throws com.atlassian.crowd.exception.OperationNotPermittedException, com.atlassian.crowd.exception.embedded.InvalidGroupException Create a group with the given name.- Parameters:
groupName- The group name.- Returns:
- the newly created Group.
- Throws:
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.com.atlassian.crowd.exception.OperationNotPermittedException- if the directory has been configured to not allow the operation to be performed- Since:
- v4.3
-
getGroup
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.
-
getGroupEvenWhenUnknown
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.
-
getGroupObject
Deprecated.usegetGroup(String)instead. Since 6.5Returns 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:
-
isUserInGroup
Deprecated.Use one of the otherisUserInGroupmethods that takes a concrete user object instead. Since v6.4.8.Returnstrueif 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:
trueif and only if the user is a direct or indirect (nested) member of the group.- See Also:
-
isUserInGroup
boolean isUserInGroup(@Nullable ApplicationUser user, @Nullable com.atlassian.crowd.embedded.api.Group group) Returnstrueif 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:
trueif and only if the user is a direct or indirect (nested) member of the group.- Since:
- v6.4.8
-
isUserInGroup
Returnstrueif 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:
trueif and only if the user is a direct or indirect (nested) member of the group.- Since:
- v6.4.8
-
isUserInGroups
Returnstrueif the user is a member of at least one of the named groups.- Parameters:
user- user to inspect.groupNames- groups to inspect.- Returns:
trueif and only if the user is a direct or indirect (nested) member of the groups.- Since:
- v9.0
-
getUsersInGroup
Returns all the users in a group.- Parameters:
groupName- The group- Returns:
- all the users that belongs to the group.
- Since:
- v4.3
-
getUsersInGroup
Returns all the users in a group. Allows for additional filtering by the active flag of a user.- Parameters:
groupName- The groupincludeInactive- if set to true inactive users will be returned as well- Returns:
- all the users that belongs to the group.
- Since:
- v7.0.1
-
getUsersInGroup
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 returnedincludeInactive- if set to true inactive users will be returned as wellpageRequest- parameters of the page to return- Returns:
- page with the users
-
getUsersInGroup
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- Since:
- v4.3
-
getUsersInGroupCount
int getUsersInGroupCount(com.atlassian.crowd.embedded.api.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.
- Since:
- 7.0
-
getUsersInGroupCount
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.
- Since:
- 7.0
-
getNamesOfDirectMembersOfGroups
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 oflimit- A maximum number of names to return- Returns:
- a list of user names
- Since:
- 7.0
-
filterUsersInAllGroupsDirect
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 namesgroupNames- A collection of groups- Returns:
- a collection of user names
- Since:
- 7.0
-
getUserNamesInGroup
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- Since:
- v5.0
-
getUserNamesInGroups
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- Since:
- v7.0
-
getUserNamesInGroup
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- Since:
- v5.0
-
getDirectUsersInGroup
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- Since:
- v4.3
-
getGroupsForUser
Returns all the groups that the given user belongs to.- Parameters:
userName- The user- Returns:
- all the groups that the given user belongs to.
- Since:
- v4.3
- See Also:
-
getGroupsForUser
Returns all the groups that the given user belongs to.- Parameters:
user- The user- Returns:
- all the groups that the given user belongs to.
- Since:
- v4.3
- See Also:
-
getGroupNamesForUser
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.
- Since:
- v4.3
- See Also:
-
getGroupNamesForUser
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.
- Since:
- v6.2.5
- See Also:
-
getAllGroupNames
Collection<String> getAllGroupNames()Returns the names of all groups or an empty collection if there are no groups.- Returns:
- all the groups.
- Since:
- v8.11
-
addUserToGroup
void addUserToGroup(ApplicationUser 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 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:
com.atlassian.crowd.exception.UserNotFoundException- if theusercould not be foundcom.atlassian.crowd.exception.GroupNotFoundException- if thegroupcould not be foundcom.atlassian.crowd.exception.OperationNotPermittedException- if the directory has been configured to not allow the operation to be performedcom.atlassian.crowd.exception.OperationFailedException- If the underlying directory implementation failed to execute the operation.- Since:
- v4.3
-
getConnectUsers
Deprecated.since 7.2.0.Returns all the connect app users. This will return an emptySetin JIRA Server as connect plugins are only supported in JIRA Cloud. This result does not filter out inactive users.- Returns:
- all the connect app users.
- Since:
- v7.0.1
-