com.atlassian.jira.bc.projectroles
Class DefaultProjectRoleService

java.lang.Object
  extended bycom.atlassian.jira.bc.projectroles.DefaultProjectRoleService
All Implemented Interfaces:
ProjectRoleService

public class DefaultProjectRoleService
extends Object
implements ProjectRoleService

Default implementation of the ProjectRoleService


Field Summary
 
Fields inherited from interface com.atlassian.jira.bc.projectroles.ProjectRoleService
PROJECTROLE_ISSUE_SECURITY_TYPE, PROJECTROLE_NOTIFICATION_TYPE, PROJECTROLE_PERMISSION_TYPE
 
Constructor Summary
DefaultProjectRoleService(ProjectRoleManager projectRoleManager, PermissionManager permissionManager, JiraAuthenticationContext jiraAuthenticationContext, RoleActorFactory roleActorFactory, NotificationSchemeManager notificationSchemeManager, PermissionSchemeManager permissionSchemeManager, WorkflowManager workflowManager, ProjectManager projectManager, ProjectFactory projectFactory, SchemeFactory schemeFactory)
           
 
Method Summary
 void addActorsToProjectRole(User currentUser, Collection actors, ProjectRole projectRole, Project project, String actorType, ErrorCollection errorCollection)
          Will add project role actor associations based off the passed in actors and checking the currentUser has the correct permissions to perform the update operation.
 void addDefaultActorsToProjectRole(User currentUser, Collection actors, ProjectRole projectRole, String type, ErrorCollection errorCollection)
          Will add default role actor associations based off the passed in actors and checking the currentUser has the correct permissions to perform the update operation.
(package private)  boolean canRemoveCurrentUser(User currentUser, Collection actors, ProjectRole projectRole, Project project, String actorType)
          This method makes certain that the currentUser can not remove themselves from a project role if it means that they will no longer be a roleMember by the action of the removal.
 ProjectRole createProjectRole(User currentUser, ProjectRole projectRole, ErrorCollection errorCollection)
          Will create the project role based off the passed in projectRole.getName(), projectRole.getDescription() and checking the currentUser has the correct permissions to perform the create operation.
 void deleteProjectRole(User currentUser, ProjectRole projectRole, ErrorCollection errorCollection)
          Will delete the project role based off the passed in projectRole and checking the currentUser has the correct permissions to perform the delete operation.
(package private)  boolean doesProjectRoleExistForAdministerProjectsPermission(Project project, ProjectRole projectRole)
          Check if the Project Role is in "Administer Projects" for the permission scheme that is associated with the Project.
 Collection getAssociatedIssueSecuritySchemes(User currentUser, ProjectRole projectRole, ErrorCollection errorCollection)
          Will get all issue security scheme's that the specified projectRole is currently used in.
 Collection getAssociatedNotificationSchemes(User currentUser, ProjectRole projectRole, ErrorCollection errorCollection)
          Will get all notification scheme's that the specified projectRole is currently used in.
 Collection getAssociatedPermissionSchemes(User currentUser, ProjectRole projectRole, ErrorCollection errorCollection)
          Will get all permission scheme's that the specified projectRole is currently used in.
 org.apache.commons.collections.MultiMap getAssociatedWorkflows(User currentUser, ProjectRole projectRole, ErrorCollection errorCollection)
          Returns workflows and their actions that are associated with the given ProjectRole.
 DefaultRoleActors getDefaultRoleActors(User currentUser, ProjectRole projectRole, ErrorCollection errorCollection)
          Will return a DefaultRoleActors object based off the passed in projectRole checking the currentUser has the correct permissions to perform the get operation.
 com.atlassian.license.LicenseManager getLicenseManager()
           
 Map getProjectIdsForUserInGroupsBecauseOfRole(User currentUser, List projectsToLimitBy, ProjectRole projectRole, String projectRoleType, String userName, ErrorCollection errorCollection)
          Returns a Map of Lists.
 ProjectRole getProjectRole(User currentUser, Long id, ErrorCollection errorCollection)
          Will return the project role based off the passed in id, and checking the currentUser has the correct permissions to perform the operation.
 ProjectRoleActors getProjectRoleActors(User currentUser, ProjectRole projectRole, Project project, ErrorCollection errorCollection)
          Will return a {@link ProjectRoleActors) object based off the passed in projectRole and project checking the currentUser has the correct permissions to perform the get operation.
 ProjectRole getProjectRoleByName(User currentUser, String name, ErrorCollection errorCollection)
          Will return the project role based off the passed in name, and checking the currentUser has the correct permissions to perform the operation.
 Collection getProjectRoles(User currentUser, ErrorCollection errorCollection)
          Get all the ProjectRoles available in JIRA.
 Collection getProjectsContainingRoleActorByNameAndType(User currentUser, String name, String type, ErrorCollection errorCollection)
          Returns the Project's which contain a role actor of the specified name and type within any role.
 boolean isProjectRoleNameUnique(User currentUser, String name, ErrorCollection errorCollection)
          Will tell you if a role name exists or not.
 void removeActorsFromProjectRole(User currentUser, Collection actors, ProjectRole projectRole, Project project, String actorType, ErrorCollection errorCollection)
          Will remove project role actor associations based off the passed in actors and checking the currentUser has the correct permissions to perform the update operation.
 void removeAllRoleActorsByNameAndType(User currentUser, String name, String type, ErrorCollection errorCollection)
          Will remove all role actors with the specified name and the specified type.
 void removeAllRoleActorsByProject(User currentUser, Project project, ErrorCollection errorCollection)
          Will remove all role actors associated with the specified project.
 void removeDefaultActorsFromProjectRole(User currentUser, Collection actors, ProjectRole projectRole, String actorType, ErrorCollection errorCollection)
          Will remove default actor associations based off the passed in actors, projectRole and actorType and checking the currentUser has the correct permissions to perform the update operation.
 List roleActorOfTypeExistsForProjects(User currentUser, List projectsToLimitBy, ProjectRole projectRole, String projectRoleType, String projectRoleParameter, ErrorCollection errorCollection)
          Returns a list of projectId's for which the role actor of the specified type exists in the project for the provided projectRole.
 void setLicenseManager(com.atlassian.license.LicenseManager licenseManager)
           
 void updateProjectRole(User currentUser, ProjectRole projectRole, ErrorCollection errorCollection)
          Will update the project role based off the passed in projectRole and checking the currentUser has the correct permissions to perform the update operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultProjectRoleService

public DefaultProjectRoleService(ProjectRoleManager projectRoleManager,
                                 PermissionManager permissionManager,
                                 JiraAuthenticationContext jiraAuthenticationContext,
                                 RoleActorFactory roleActorFactory,
                                 NotificationSchemeManager notificationSchemeManager,
                                 PermissionSchemeManager permissionSchemeManager,
                                 WorkflowManager workflowManager,
                                 ProjectManager projectManager,
                                 ProjectFactory projectFactory,
                                 SchemeFactory schemeFactory)
Method Detail

getProjectRoles

public Collection getProjectRoles(User currentUser,
                                  ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Get all the ProjectRoles available in JIRA. Currently this list is global.

Specified by:
getProjectRoles in interface ProjectRoleService
Returns:
The global list of project roles in JIRA

getProjectRole

public ProjectRole getProjectRole(User currentUser,
                                  Long id,
                                  ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Will return the project role based off the passed in id, and checking the currentUser has the correct permissions to perform the operation. The passed in errorCollection will contain any errors that are generated, such as permission violations.

Specified by:
getProjectRole in interface ProjectRoleService
Parameters:
currentUser -
id -
errorCollection - will contain any errors in calling the method
Returns:
the ProjectRole for the given id, will return null if no role found

getProjectRoleByName

public ProjectRole getProjectRoleByName(User currentUser,
                                        String name,
                                        ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Will return the project role based off the passed in name, and checking the currentUser has the correct permissions to perform the operation. The passed in errorCollection will contain any errors that are generated, such as permission violations.

Specified by:
getProjectRoleByName in interface ProjectRoleService
Parameters:
currentUser -
name - the name of the project role to return
errorCollection - will contain any errors in calling the method
Returns:
the ProjectRole for the given name, will return null if no role found

createProjectRole

public ProjectRole createProjectRole(User currentUser,
                                     ProjectRole projectRole,
                                     ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Will create the project role based off the passed in projectRole.getName(), projectRole.getDescription() and checking the currentUser has the correct permissions to perform the create operation. The passed in errorCollection will contain any errors that are generated, such as permission violations.

Specified by:
createProjectRole in interface ProjectRoleService
Parameters:
currentUser -
projectRole - can not be null and will contain the name and description for the project role to create
errorCollection - will contain any errors in calling the method
Returns:
the ProjectRole object that was created

isProjectRoleNameUnique

public boolean isProjectRoleNameUnique(User currentUser,
                                       String name,
                                       ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Will tell you if a role name exists or not.

Specified by:
isProjectRoleNameUnique in interface ProjectRoleService
Parameters:
name - the name of the project role to check
Returns:
true if unique, false if one already exists with that name

deleteProjectRole

public void deleteProjectRole(User currentUser,
                              ProjectRole projectRole,
                              ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Will delete the project role based off the passed in projectRole and checking the currentUser has the correct permissions to perform the delete operation. This will also delete all ProjectRoleActor associations that it is the parent of. The passed in errorCollection will contain any errors that are generated, such as permission violations.

Specified by:
deleteProjectRole in interface ProjectRoleService
Parameters:
currentUser -
projectRole -
errorCollection - will contain any errors in calling the method

updateProjectRole

public void updateProjectRole(User currentUser,
                              ProjectRole projectRole,
                              ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Will update the project role based off the passed in projectRole and checking the currentUser has the correct permissions to perform the update operation. The passed in errorCollection will contain any errors that are generated, such as permission violations.

Specified by:
updateProjectRole in interface ProjectRoleService
Parameters:
currentUser -
projectRole -
errorCollection - will contain any errors in calling the method

getProjectRoleActors

public ProjectRoleActors getProjectRoleActors(User currentUser,
                                              ProjectRole projectRole,
                                              Project project,
                                              ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Will return a {@link ProjectRoleActors) object based off the passed in projectRole and project checking the currentUser has the correct permissions to perform the get operation. The passed in errorCollection will contain any errors that are generated, such as permission violations.

Specified by:
getProjectRoleActors in interface ProjectRoleService
Parameters:
currentUser -
projectRole -
project -
errorCollection - will contain any errors in calling the method
Returns:
the ProjectRoleActor representing the projectRole and project

addActorsToProjectRole

public void addActorsToProjectRole(User currentUser,
                                   Collection actors,
                                   ProjectRole projectRole,
                                   Project project,
                                   String actorType,
                                   ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Will add project role actor associations based off the passed in actors and checking the currentUser has the correct permissions to perform the update operation. The passed in errorCollection will contain any errors that are generated, such as permission violations.

Specified by:
addActorsToProjectRole in interface ProjectRoleService
Parameters:
currentUser -
actors - is a list of strings that they RoleActor impl should be able to handle
projectRole - is the project role to associate with
project - is the project to associate with
actorType - is a type that defines the type of role actor to instantiate (ex./ UserRoleActor.TYPE, GroupRoleActor.TYPE)
errorCollection - will contain any errors in calling the method

removeActorsFromProjectRole

public void removeActorsFromProjectRole(User currentUser,
                                        Collection actors,
                                        ProjectRole projectRole,
                                        Project project,
                                        String actorType,
                                        ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Will remove project role actor associations based off the passed in actors and checking the currentUser has the correct permissions to perform the update operation. The passed in errorCollection will contain any errors that are generated, such as permission violations.

Specified by:
removeActorsFromProjectRole in interface ProjectRoleService
Parameters:
currentUser -
actors - is a list of strings that they RoleActor impl should be able to handle
projectRole - is the project role to associate with
project - is the project to associate with
actorType - is a type that defines the type of role actor to instantiate (ex./ UserRoleActor.TYPE, GroupRoleActor.TYPE)
errorCollection - will contain any errors in calling the method

canRemoveCurrentUser

boolean canRemoveCurrentUser(User currentUser,
                             Collection actors,
                             ProjectRole projectRole,
                             Project project,
                             String actorType)
This method makes certain that the currentUser can not remove themselves from a project role if it means that they will no longer be a roleMember by the action of the removal.

Note this method is package-private for unit testing purposes.


doesProjectRoleExistForAdministerProjectsPermission

boolean doesProjectRoleExistForAdministerProjectsPermission(Project project,
                                                            ProjectRole projectRole)
Check if the Project Role is in "Administer Projects" for the permission scheme that is associated with the Project.

Note this method is package-private for unit testing purposes.


setLicenseManager

public void setLicenseManager(com.atlassian.license.LicenseManager licenseManager)

getLicenseManager

public com.atlassian.license.LicenseManager getLicenseManager()

getDefaultRoleActors

public DefaultRoleActors getDefaultRoleActors(User currentUser,
                                              ProjectRole projectRole,
                                              ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Will return a DefaultRoleActors object based off the passed in projectRole checking the currentUser has the correct permissions to perform the get operation. The passed in errorCollection will contain any errors that are generated, such as permission violations.

Specified by:
getDefaultRoleActors in interface ProjectRoleService
Parameters:
currentUser -
projectRole -
errorCollection -
Returns:
the default role actors

addDefaultActorsToProjectRole

public void addDefaultActorsToProjectRole(User currentUser,
                                          Collection actors,
                                          ProjectRole projectRole,
                                          String type,
                                          ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Will add default role actor associations based off the passed in actors and checking the currentUser has the correct permissions to perform the update operation. The passed in errorCollection will contain any errors that are generated, such as permission violations.

Specified by:
addDefaultActorsToProjectRole in interface ProjectRoleService
Parameters:
currentUser -
actors - is a list of strings that they RoleActor impl should be able to handle
projectRole - is the project role to associate with
type - is a type that defines the type of role actor to instantiate (ex./ UserRoleActor.TYPE, GroupRoleActor.TYPE)
errorCollection - will contain any errors in calling the method

removeDefaultActorsFromProjectRole

public void removeDefaultActorsFromProjectRole(User currentUser,
                                               Collection actors,
                                               ProjectRole projectRole,
                                               String actorType,
                                               ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Will remove default actor associations based off the passed in actors, projectRole and actorType and checking the currentUser has the correct permissions to perform the update operation. The passed in errorCollection will contain any errors that are generated, such as permission violations.

Specified by:
removeDefaultActorsFromProjectRole in interface ProjectRoleService
Parameters:
currentUser -
actors - is a list of strings that they RoleActor impl should be able to handle
projectRole - is the project role to associate with
actorType - is a type that defines the type of role actor to instantiate (ex./ UserRoleActor.TYPE, GroupRoleActor.TYPE)
errorCollection - will contain any errors in calling the method

removeAllRoleActorsByNameAndType

public void removeAllRoleActorsByNameAndType(User currentUser,
                                             String name,
                                             String type,
                                             ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Will remove all role actors with the specified name and the specified type. This method should be used to clean up after the actual subject of the role actor has been deleted (ex. deleting a user from the system).

Specified by:
removeAllRoleActorsByNameAndType in interface ProjectRoleService
Parameters:
currentUser -
name - this is the name that the role actor is stored under (ex. username of 'admin', group name of 'jira-users')
type - this is the role type parameter, (ex. GroupRoleActor.TYPE, UserRoleActor.TYPE)
errorCollection - will contain any errors in calling the method

removeAllRoleActorsByProject

public void removeAllRoleActorsByProject(User currentUser,
                                         Project project,
                                         ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Will remove all role actors associated with the specified project. This method should be used to clean up just before the actual project has been deleted (ex. deleting a project from the system).

Specified by:
removeAllRoleActorsByProject in interface ProjectRoleService
Parameters:
currentUser -
project -
errorCollection - will contain any errors in calling the method

getAssociatedNotificationSchemes

public Collection getAssociatedNotificationSchemes(User currentUser,
                                                   ProjectRole projectRole,
                                                   ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Will get all notification scheme's that the specified projectRole is currently used in.

Specified by:
getAssociatedNotificationSchemes in interface ProjectRoleService
Parameters:
currentUser -
projectRole -
errorCollection - will contain any errors in calling the method
Returns:
a collection of schemes, if no schemes are found this will be an empty collection.

getAssociatedIssueSecuritySchemes

public Collection getAssociatedIssueSecuritySchemes(User currentUser,
                                                    ProjectRole projectRole,
                                                    ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Will get all issue security scheme's that the specified projectRole is currently used in.

Specified by:
getAssociatedIssueSecuritySchemes in interface ProjectRoleService
Parameters:
currentUser -
projectRole -
errorCollection - will contain any errors in calling the method
Returns:
a collection of schemes, if no schemes are found this will be an empty collection.

getAssociatedPermissionSchemes

public Collection getAssociatedPermissionSchemes(User currentUser,
                                                 ProjectRole projectRole,
                                                 ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Will get all permission scheme's that the specified projectRole is currently used in.

Specified by:
getAssociatedPermissionSchemes in interface ProjectRoleService
Parameters:
currentUser -
projectRole -
errorCollection - will contain any errors in calling the method
Returns:
a collection of schemes, if no schemes are found this will be an empty collection.

getAssociatedWorkflows

public org.apache.commons.collections.MultiMap getAssociatedWorkflows(User currentUser,
                                                                      ProjectRole projectRole,
                                                                      ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Returns workflows and their actions that are associated with the given ProjectRole. e.g. InProjectRoleCondition workflow elements that block workflow transition unless the acting user is in the ProjectRole.

Specified by:
getAssociatedWorkflows in interface ProjectRoleService
Parameters:
currentUser - the acting user.
projectRole - the project role.
errorCollection - will contain any errors in calling the method
Returns:
a possibly empty MultiMap of Workflow objects to List of Actions.

getProjectsContainingRoleActorByNameAndType

public Collection getProjectsContainingRoleActorByNameAndType(User currentUser,
                                                              String name,
                                                              String type,
                                                              ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Returns the Project's which contain a role actor of the specified name and type within any role. This is a method that is provided so that you can efficiently tell which users or groups have been associated with any role within projects.

Specified by:
getProjectsContainingRoleActorByNameAndType in interface ProjectRoleService
Parameters:
currentUser - the acting user.
name - this is the name that the role actor is stored under (ex. username of 'admin', group name of 'jira-users')
type - this is the role type parameter, (ex. GroupRoleActor.TYPE, UserRoleActor.TYPE)
errorCollection - will contain any errors in calling the method
Returns:
a collection of Project's which have a role which contains the role actor with the specified name and type.

roleActorOfTypeExistsForProjects

public List roleActorOfTypeExistsForProjects(User currentUser,
                                             List projectsToLimitBy,
                                             ProjectRole projectRole,
                                             String projectRoleType,
                                             String projectRoleParameter,
                                             ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Returns a list of projectId's for which the role actor of the specified type exists in the project for the provided projectRole. This is a method that is meant to efficiently allow discovery of whether a UserRoleActor exists in a project role for a subset of projects.

Specified by:
roleActorOfTypeExistsForProjects in interface ProjectRoleService
Parameters:
currentUser - the acting user.
projectsToLimitBy - this will limit the range of projects the method queries. This is a list of Long, project id's. The returned list will be either the same as this list or a subset.
projectRole - the project role to find out if an actor is a member of.
projectRoleType - the type of role actor you want to query for, in most cases this will be UserRoleActor.TYPE.
projectRoleParameter - the parameter describing the role actor, in the case of a UserRoleActor this will be the username.
errorCollection - will contain any errors in calling the method
Returns:
A list of Long, project id's. If a projectId is in this list then the project contains has a role associated for the passed in actor and project role.

getProjectIdsForUserInGroupsBecauseOfRole

public Map getProjectIdsForUserInGroupsBecauseOfRole(User currentUser,
                                                     List projectsToLimitBy,
                                                     ProjectRole projectRole,
                                                     String projectRoleType,
                                                     String userName,
                                                     ErrorCollection errorCollection)
Description copied from interface: ProjectRoleService
Returns a Map of Lists. The key of the map is a Long, project id and the value of the map is a list of group names that the user is a member of for the project. This method is meant to provide an efficient means to discover which groups that are associated with a project role implicitly include the specified user in that project role. We allow you to specify a range of projectsToLimitBy so that you can perform only one query to find this information for many projects for a single projectRole.

Specified by:
getProjectIdsForUserInGroupsBecauseOfRole in interface ProjectRoleService
Parameters:
currentUser - the acting user.
projectsToLimitBy - this will limit the range of projects the method queries. This is a list of Long, project id's. The returned list will be either the same as this list or a subset.
projectRole - the project role to find out if an actor is a member of.
projectRoleType - the type of role actor you want to query for, in most cases this will be UserRoleActor.TYPE.
userName - the username to find out if the user is in the role because of a group
errorCollection - will contain any errors in calling the method
Returns:
Returns a Map of Lists. The key of the map is a Long, project id and the value of the map is a list of group names that the user is a member of for the project.


Copyright © 2002-2007 Atlassian. All Rights Reserved.