Interface GroupService
- All Known Implementing Classes:
DefaultGroupService
Group
's in JIRA.- Since:
- v3.12
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
This class is used for a return type for edit group validation. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addGroupsToGroups
(JiraServiceContext jiraServiceContext, Collection<String> groupsToJoin, Collection<String> childNames) This method will add the provided groups to the specified groups.boolean
addUsersToGroups
(JiraServiceContext jiraServiceContext, Collection<String> groupsToJoin, Collection<String> userNames) This method will add the provided users to the specified groups.boolean
areOnlyGroupsGrantingUserAdminPermissions
(JiraServiceContext jiraServiceContext, Collection groupNames) This is a validation utility method that will determine if the specified groups are the only groups that are granting the current user theirPermissions.ADMINISTER
permissions.boolean
delete
(JiraServiceContext jiraServiceContext, String groupName, String swapGroup) This will delete a group from JIRA.getChildGroupNames
(com.atlassian.crowd.embedded.api.Group group) Return the name of groups that are members of this Group.long
getCommentsAndWorklogsGuardedByGroupCount
(String groupName) getParentGroupNames
(com.atlassian.crowd.embedded.api.Group group) Return the name of groups that are parents of this Group.boolean
isAdminDeletingSysAdminGroup
(JiraServiceContext jiraServiceContext, String groupName) This is a validation utility method that will determine if the current user is only a JIRA Administrator and they are trying to delete a group that is associated with JIRA System Administrators.boolean
removeGroupsFromGroups
(JiraServiceContext jiraServiceContext, GroupRemoveChildMapper mapper) This method will remove the provided child groups from the specified groups.boolean
removeUsersFromGroups
(JiraServiceContext jiraServiceContext, GroupRemoveChildMapper mapper) This method will remove the provided users from the specified groups.validateAddGroupsToGroup
(JiraServiceContext jiraServiceContext, Collection<String> groupsToJoin, Collection<String> groupNames) Performs validation to see if the provided groups (identified by the groupNames collection) can be added to the provided group by the current user (as specified in the jiraServiceContext).validateAddUsersToGroup
(JiraServiceContext jiraServiceContext, Collection<String> groupsToJoin, Collection<String> userNames) Performs validation to see if the provided users (identified by the userNames collection) can be added to the provided group by the current user (as specified in the jiraServiceContext).boolean
validateAddUserToGroup
(JiraServiceContext jiraServiceContext, Collection<String> groupsToJoin, String userName) Performs validation to see if the provided user (identified by username) can be added to the provided group by the current user (as specified in the jiraServiceContext).boolean
validateDelete
(JiraServiceContext jiraServiceContext, String groupName, String swapGroup) Validates if the group provided can be deleted in JIRA.boolean
validateRemoveGroupsFromGroups
(JiraServiceContext jiraServiceContext, GroupRemoveChildMapper mapper) Performs validation to see if the groups identified inmapper
can be removed from their respective groups by the current user (as specified in the jiraServiceContext).boolean
validateRemoveUserFromGroups
(JiraServiceContext jiraServiceContext, List groupsToLeave, String userName) Performs validation to see if the user can be removed from the groups by the current user (as specified in the jiraServiceContext).boolean
validateRemoveUsersFromGroups
(JiraServiceContext jiraServiceContext, GroupRemoveChildMapper mapper) Performs validation to see if the users identified inmapper
can be removed from their respective groups by the current user (as specified in the jiraServiceContext).
-
Method Details
-
validateDelete
Validates if the group provided can be deleted in JIRA. If there are any problems deleting the group they will be reported in the error collection and the method will return false. Comment and worklogs visibility can be restricted by groups. If there are any associated comments or worklogs and a swap group is not provided then errors will be added to the error collection.- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the methodgroupName
- identifies the group to delete.swapGroup
- identifies the group to change comment and worklog visibility to.- Returns:
- true if you can delete the group, false otherwise.
- Since:
- v3.12
-
delete
This will delete a group from JIRA. This method will remove the group from any notifications schemes, any associated permissions, and any associated project roles. This method will also update anyComment
's andWorklog
's that have visibility restrictions set to the current group such that their restrictions will be changed to the swapGroup.This method assumes that the
validateDelete(com.atlassian.jira.bc.JiraServiceContext, String, String)
method has been called and that it did not generate any errors.You must have
Permissions.ADMINISTER
permissions or higher to invoke this method.- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the methodgroupName
- identifies the group to delete.swapGroup
- identifies the group to change comment and worklog visibility to.- Returns:
- true if the operation succeeds, false otherwise.
- Since:
- v3.12
-
validateAddUserToGroup
boolean validateAddUserToGroup(JiraServiceContext jiraServiceContext, Collection<String> groupsToJoin, String userName) Performs validation to see if the provided user (identified by username) can be added to the provided group by the current user (as specified in the jiraServiceContext). If there are any problems with adding the user to the groups this method will return false and the error will be reported in the errorCollection.The operation will not be valid if external user management is enabled, the groups or user does not exist, the user is already a member of all the groups, or the current user does not have permission to add the user to the groups.
- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the methodgroupsToJoin
- a collection ofString
's that represent groupNames that the user should be added to. This must not be null.userName
- identifies the user to be added to the groups, must not be null.- Returns:
- true if you can successfully add the user to the groups, false otherwise.
- Since:
- v3.12
-
validateAddUsersToGroup
GroupService.BulkEditGroupValidationResult validateAddUsersToGroup(JiraServiceContext jiraServiceContext, Collection<String> groupsToJoin, Collection<String> userNames) Performs validation to see if the provided users (identified by the userNames collection) can be added to the provided group by the current user (as specified in the jiraServiceContext). If there are any problems with adding the users to the groups this method will returns an unsuccessful result and the errors will be reported in the errorCollection.The operation will not be valid if external user management is enabled, the groups or user does not exist, the user is already a member of the groups, or the current user does not have permission to add the user to the groups.
- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the methodgroupsToJoin
- a collection ofString
's that represent groupNames that the user should be added to. This must not be null.userNames
- collection ofString
userNames that identifies the users to be added to the groups, must not be null.- Returns:
- a
GroupService.BulkEditGroupValidationResult
which if the users can be added to the groups will have isSuccess be true. Otherwise isSuccess will be false and if there was any problem validating the users to add theGroupService.BulkEditGroupValidationResult.getInvalidChildren()
method will contain the usernames that were not valid to add to the groups. - Since:
- v3.12
-
validateAddGroupsToGroup
GroupService.BulkEditGroupValidationResult validateAddGroupsToGroup(JiraServiceContext jiraServiceContext, Collection<String> groupsToJoin, Collection<String> groupNames) Performs validation to see if the provided groups (identified by the groupNames collection) can be added to the provided group by the current user (as specified in the jiraServiceContext). If there are any problems with adding the users to the groups this method will returns an unsuccessful result and the errors will be reported in the errorCollection.The operation will not be valid if external user management is enabled, the parent or child groups do not exist, the child is already a member of the groups, or the current user does not have permission to add the group to the groups.
- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the methodgroupsToJoin
- a collection ofString
's that represent groupNames that the user should be added to. This must not be null.groupNames
- collection ofString
groupNames that identifies the groups to be added to the groups, must not be null.- Returns:
- a
GroupService.BulkEditGroupValidationResult
which if the groups can be added to the groups will have isSuccess be true. Otherwise isSuccess will be false and if there was any problem validating the users to add theGroupService.BulkEditGroupValidationResult.getInvalidChildren()
method will contain the groups that were not valid to add to the groups. - Since:
- v4.3
-
addUsersToGroups
boolean addUsersToGroups(JiraServiceContext jiraServiceContext, Collection<String> groupsToJoin, Collection<String> userNames) This method will add the provided users to the specified groups. It is assumed that eithervalidateAddUsersToGroup(com.atlassian.jira.bc.JiraServiceContext, java.util.Collection, java.util.Collection)
orvalidateAddUserToGroup(com.atlassian.jira.bc.JiraServiceContext, java.util.Collection, String)
has been called and not returned any errors. This method will not perform any validation other than simple permissions checks.- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the methodgroupsToJoin
- a collection ofString
's that represent groupNames that the user should be added to. This must not be null.userNames
- collection ofString
userNames that identifies the users to be added to the groups, must not be null.- Returns:
- true if the operation succeeds, false otherwise.
-
addGroupsToGroups
boolean addGroupsToGroups(JiraServiceContext jiraServiceContext, Collection<String> groupsToJoin, Collection<String> childNames) This method will add the provided groups to the specified groups. It is assumed thatvalidateAddGroupsToGroup(com.atlassian.jira.bc.JiraServiceContext, java.util.Collection, java.util.Collection)
has been called and not returned any errors. This method will not perform any validation other than simple permissions checks.- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the methodgroupsToJoin
- a collection ofString
's that represent groupNames that the child group should be added to. This must not be null.childNames
- collection ofString
childNames that identifies the child groups to be added to the groups, must not be null.- Returns:
- true if the operation succeeds, false otherwise.
-
validateRemoveUsersFromGroups
boolean validateRemoveUsersFromGroups(JiraServiceContext jiraServiceContext, GroupRemoveChildMapper mapper) Performs validation to see if the users identified inmapper
can be removed from their respective groups by the current user (as specified in the jiraServiceContext). If there are any problems with removing the users from the groups this method will return false and the errors will be reported in the errorCollection.The operation will not be valid if external user management is enabled, the groups or users do not exist, the user is not currently a member of the groups, or the current user does not have permission to remove the users from the groups.
- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the methodmapper
- represents which users to remove from which groups.- Returns:
- true only if the operation is valid.
- Since:
- v4.3
-
validateRemoveGroupsFromGroups
boolean validateRemoveGroupsFromGroups(JiraServiceContext jiraServiceContext, GroupRemoveChildMapper mapper) Performs validation to see if the groups identified inmapper
can be removed from their respective groups by the current user (as specified in the jiraServiceContext). If there are any problems with removing the groups from the groups this method will return false and the errors will be reported in the errorCollection.The operation will not be valid if external user management is enabled, the parent or child groups do not exist, the group is not currently a member of the groups, or the current user does not have permission to remove the groups from the groups.
- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the methodmapper
- represents which groups to remove from which groups.- Returns:
- true only if the operation is valid.
- Since:
- v3.12
-
validateRemoveUserFromGroups
boolean validateRemoveUserFromGroups(JiraServiceContext jiraServiceContext, List groupsToLeave, String userName) Performs validation to see if the user can be removed from the groups by the current user (as specified in the jiraServiceContext). If there are any problems with removing the user from the groups this method will return false and the errors will be reported in the errorCollection.The operation will not be valid if external user management is enabled, the groups or user does not exist, the user is not currently a member of the groups, or the current user does not have permission to remove the user from the groups.
- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the methodgroupsToLeave
- the group names to remove the user from.userName
- the name of the user to remove from the groupsToLeave.- Returns:
- true only if the operation is valid.
- Since:
- v3.12
-
removeUsersFromGroups
This method will remove the provided users from the specified groups. It is assumed that eithervalidateRemoveUsersFromGroups(com.atlassian.jira.bc.JiraServiceContext, GroupRemoveChildMapper)
orvalidateRemoveUserFromGroups(com.atlassian.jira.bc.JiraServiceContext, java.util.List, String)
been called and not returned any errors. This method will not perform any validation other than simple permissions checks.- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the methodmapper
- represents which users to remove from which groups.- Returns:
- true if the operation succeeds, false otherwise.
-
removeGroupsFromGroups
boolean removeGroupsFromGroups(JiraServiceContext jiraServiceContext, GroupRemoveChildMapper mapper) This method will remove the provided child groups from the specified groups. It is assumed thatvalidateRemoveGroupsFromGroups(com.atlassian.jira.bc.JiraServiceContext, GroupRemoveChildMapper)
has been called and not returned any errors. This method will not perform any validation other than simple permissions checks.- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the methodmapper
- represents which child groups to remove from which groups.- Returns:
- true if the operation succeeds, false otherwise.
-
getCommentsAndWorklogsGuardedByGroupCount
This method will return the count of allComment
's andWorklog
's that have the named group set as its visibility restriction.- Parameters:
groupName
- identifies the group that the worklog or comments visibility is restricted by.- Returns:
- the number of comments and worklogs that have their visibility restricted by the named group.
- Since:
- v3.12
-
areOnlyGroupsGrantingUserAdminPermissions
boolean areOnlyGroupsGrantingUserAdminPermissions(JiraServiceContext jiraServiceContext, Collection groupNames) This is a validation utility method that will determine if the specified groups are the only groups that are granting the current user theirPermissions.ADMINISTER
permissions.- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the methodgroupNames
- identifies the groups in question.- Returns:
- true if the specified groups are the only ones granting the administrator rights, false otherwise.
- Since:
- v3.12
-
isAdminDeletingSysAdminGroup
This is a validation utility method that will determine if the current user is only a JIRA Administrator and they are trying to delete a group that is associated with JIRA System Administrators.- Parameters:
jiraServiceContext
- containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the methodgroupName
- identifies the group in question.- Returns:
- true if the current user is a JIRA Administrator and they are trying to delete a group that is associated with JIRA System Administrators, false otherwise.
- Since:
- v3.12
-
getChildGroupNames
Return the name of groups that are members of this Group.- Parameters:
group
- to search for.- Returns:
- names of child Groups
-
getParentGroupNames
Return the name of groups that are parents of this Group.- Parameters:
group
- to search for.- Returns:
- names of parent Groups
-