com.atlassian.jira.bc.group
Class DefaultGroupService

java.lang.Object
  extended by com.atlassian.jira.bc.group.DefaultGroupService
All Implemented Interfaces:
GroupService

public class DefaultGroupService
extends Object
implements GroupService

Default implementation of a GroupService.

Since:
v3.12

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.atlassian.jira.bc.group.GroupService
GroupService.BulkEditGroupValidationResult
 
Constructor Summary
DefaultGroupService(ApplicationProperties applicationProperties, GlobalPermissionManager globalPermissionManager, GlobalPermissionGroupAssociationUtil globalPermissionGroupAssociationUtil, CommentManager commentManager, WorklogManager worklogManager, NotificationSchemeManager notificationSchemeManager, PermissionManager permissionManager, ProjectRoleService projectRoleService, IssueSecurityLevelManager issueSecurityLevelManager, CacheManager cacheManager, UserUtil userUtil, SharePermissionDeleteUtils sharePermissionDeleteUtils, SubscriptionManager subscriptionManager)
           
 
Method Summary
 boolean addUsersToGroups(JiraServiceContext jiraServiceContext, Collection groupsToJoin, Collection 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 their Permissions.ADMINISTER permissions.
 boolean delete(JiraServiceContext jiraServiceContext, String groupName, String swapGroup)
          This will delete a group from JIRA.
 long getCommentsAndWorklogsGuardedByGroupCount(String groupName)
          This method will return the count of all Comment's and Worklog's that have the named group set as its visibility restriction.
 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 removeUsersFromGroups(JiraServiceContext jiraServiceContext, GroupRemoveUserMapper mapper)
          This method will remove the provided users from the specified groups.
 GroupService.BulkEditGroupValidationResult validateAddUsersToGroup(JiraServiceContext jiraServiceContext, Collection groupsToJoin, Collection 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 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 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, GroupRemoveUserMapper mapper)
          Performs validation to see if the users identified in mapper can be removed from their respective groups by the current user (as specified in the jiraServiceContext).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultGroupService

public DefaultGroupService(ApplicationProperties applicationProperties,
                           GlobalPermissionManager globalPermissionManager,
                           GlobalPermissionGroupAssociationUtil globalPermissionGroupAssociationUtil,
                           CommentManager commentManager,
                           WorklogManager worklogManager,
                           NotificationSchemeManager notificationSchemeManager,
                           PermissionManager permissionManager,
                           ProjectRoleService projectRoleService,
                           IssueSecurityLevelManager issueSecurityLevelManager,
                           CacheManager cacheManager,
                           UserUtil userUtil,
                           SharePermissionDeleteUtils sharePermissionDeleteUtils,
                           SubscriptionManager subscriptionManager)
Method Detail

validateDelete

public boolean validateDelete(JiraServiceContext jiraServiceContext,
                              String groupName,
                              String swapGroup)
Description copied from interface: GroupService
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.

Specified by:
validateDelete in interface GroupService
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 method
groupName - 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.

delete

public boolean delete(JiraServiceContext jiraServiceContext,
                      String groupName,
                      String swapGroup)
Description copied from interface: GroupService
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 any Comment's and Worklog'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 GroupService.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.

Specified by:
delete in interface GroupService
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 method
groupName - identifies the group to delete.
swapGroup - identifies the group to change comment and worklog visibility to.
Returns:
true if the operation succeeds, false otherwise.

validateAddUserToGroup

public boolean validateAddUserToGroup(JiraServiceContext jiraServiceContext,
                                      Collection groupsToJoin,
                                      String userName)
Description copied from interface: GroupService
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.

Specified by:
validateAddUserToGroup in interface GroupService
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 method
groupsToJoin - a collection of String'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.

validateAddUsersToGroup

public GroupService.BulkEditGroupValidationResult validateAddUsersToGroup(JiraServiceContext jiraServiceContext,
                                                                          Collection groupsToJoin,
                                                                          Collection userNames)
Description copied from interface: GroupService
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.

Specified by:
validateAddUsersToGroup in interface GroupService
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 method
groupsToJoin - a collection of String's that represent groupNames that the user should be added to. This must not be null.
userNames - collection of String 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 the GroupService.BulkEditGroupValidationResult.getInvalidUsers() method will contain the usernames that were not valid to add to the groups.

addUsersToGroups

public boolean addUsersToGroups(JiraServiceContext jiraServiceContext,
                                Collection groupsToJoin,
                                Collection userNames)
Description copied from interface: GroupService
This method will add the provided users to the specified groups. It is assumed that either GroupService.validateAddUsersToGroup(com.atlassian.jira.bc.JiraServiceContext, java.util.Collection, java.util.Collection) or GroupService.validateAddUserToGroup(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.

Specified by:
addUsersToGroups in interface GroupService
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 method
groupsToJoin - a collection of String's that represent groupNames that the user should be added to. This must not be null.
userNames - collection of String userNames that identifies the users to be added to the groups, must not be null.
Returns:
true if the operation succeeds, false otherwise.

validateRemoveUserFromGroups

public boolean validateRemoveUserFromGroups(JiraServiceContext jiraServiceContext,
                                            List groupsToLeave,
                                            String userName)
Description copied from interface: GroupService
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.

Specified by:
validateRemoveUserFromGroups in interface GroupService
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 method
groupsToLeave - 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.

validateRemoveUsersFromGroups

public boolean validateRemoveUsersFromGroups(JiraServiceContext jiraServiceContext,
                                             GroupRemoveUserMapper mapper)
Description copied from interface: GroupService
Performs validation to see if the users identified in mapper 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.

Specified by:
validateRemoveUsersFromGroups in interface GroupService
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 method
mapper - represents which users to remove from which groups.
Returns:
true only if the operation is valid.

removeUsersFromGroups

public boolean removeUsersFromGroups(JiraServiceContext jiraServiceContext,
                                     GroupRemoveUserMapper mapper)
Description copied from interface: GroupService
This method will remove the provided users from the specified groups. It is assumed that either GroupService.validateRemoveUsersFromGroups(com.atlassian.jira.bc.JiraServiceContext, GroupRemoveUserMapper) or GroupService.validateRemoveUserFromGroups(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.

Specified by:
removeUsersFromGroups in interface GroupService
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 method
mapper - represents which users to remove from which groups.
Returns:
true if the operation succeeds, false otherwise.

getCommentsAndWorklogsGuardedByGroupCount

public long getCommentsAndWorklogsGuardedByGroupCount(String groupName)
Description copied from interface: GroupService
This method will return the count of all Comment's and Worklog's that have the named group set as its visibility restriction.

Specified by:
getCommentsAndWorklogsGuardedByGroupCount in interface GroupService
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.

areOnlyGroupsGrantingUserAdminPermissions

public boolean areOnlyGroupsGrantingUserAdminPermissions(JiraServiceContext jiraServiceContext,
                                                         Collection groupNames)
Description copied from interface: GroupService
This is a validation utility method that will determine if the specified groups are the only groups that are granting the current user their Permissions.ADMINISTER permissions.

Specified by:
areOnlyGroupsGrantingUserAdminPermissions in interface GroupService
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 method
groupNames - identifies the groups in question.
Returns:
true if the specified groups are the only ones granting the administrator rights, false otherwise.

isAdminDeletingSysAdminGroup

public boolean isAdminDeletingSysAdminGroup(JiraServiceContext jiraServiceContext,
                                            String groupName)
Description copied from interface: GroupService
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.

Specified by:
isAdminDeletingSysAdminGroup in interface GroupService
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 method
groupName - 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.


Copyright © 2002-2009 Atlassian. All Rights Reserved.