Class DefaultProjectRoleManager
java.lang.Object
com.atlassian.jira.security.roles.DefaultProjectRoleManager
- All Implemented Interfaces:
GroupConfigurable,ProjectRoleManager
public class DefaultProjectRoleManager
extends Object
implements ProjectRoleManager, GroupConfigurable
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.atlassian.jira.security.roles.ProjectRoleManager
ProjectRoleManager.ProjectIdToProjectRoleIdsMap -
Constructor Summary
ConstructorsConstructorDescriptionDefaultProjectRoleManager(ProjectRoleAndActorStore projectRoleAndActorStore) -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyDefaultsRolesToProject(Project project) This method will insert all the default roles into the role associations for the provided project.createProjectIdToProjectRolesMap(ApplicationUser user, Collection<Long> projectIds) Deprecated.createProjectIdToProjectRolesMapWithGroups(ApplicationUser user, Set<String> groups) Returns a ProjectIdToProjectRoleIdsMap, which is a map of project IDs to their corresponding collections of project role IDs, optimized for performance at scale.createRole(ProjectRole projectRole) Creates a project role objectvoiddeleteRole(ProjectRole projectRole) Deletes a project role objectgetDefaultRoleActors(ProjectRole projectRole) This method will return the default role actors for aProjectRoleReturns the project id's which contain a role actor of the specified name and type within any role.getProjectIdsForUserInGroupsBecauseOfRole(List<Long> projectsToLimitBy, ProjectRole projectRole, String projectRoleType, String userName) Returns a Map of Lists.getProjectRole(Long id) Retrieves a project role objectgetProjectRole(String name) Retrieves a project role object by namegetProjectRoleActors(ProjectRole projectRole, Project project) This method will retrieve the object that represents the actors associate with the givenprojectRoleandprojectcontextGet all the ProjectRoles available in JIRA.getProjectRoles(ApplicationUser user, Project project) This will return all theProjectRoles that the user is currently a member of for the given project.booleanisGroupUsed(com.atlassian.crowd.embedded.api.Group group) Determine whether configuration exists for the specifiedGroup.booleanisRoleNameUnique(String name) Will tell you if a role name exists or not.booleanisUserInProjectRole(ApplicationUser user, ProjectRole projectRole, Project project) Returns true only if the given user is in the given project role for the given project.voidremoveAllRoleActorsByNameAndType(String key, String type) This will remove all role actors with the specified name and the specified type.voidremoveAllRoleActorsByProject(Project project) Will remove all role actors associated with the specified project.roleActorOfTypeExistsForProjects(List<Long> projectsToLimitBy, ProjectRole projectRole, String projectRoleType, String projectRoleParameter) Returns a list of projectId's for which the role actor of the specified type exists in the project for the provided projectRole.voidupdateDefaultRoleActors(DefaultRoleActors defaultRoleActors) This method will update the associations of actors for the default projectRole, specified by the given defaultRoleActors object.voidupdateProjectRoleActors(ProjectRoleActors projectRoleActors) Commits the given ProjectRoleActors to permanent store, saving any updates made.voidupdateRole(ProjectRole projectRole) Updates a project role objectMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.atlassian.jira.config.group.GroupConfigurable
isGroupUsed
-
Constructor Details
-
DefaultProjectRoleManager
-
-
Method Details
-
getProjectRoles
Description copied from interface:ProjectRoleManagerGet all the ProjectRoles available in JIRA. Currently this list is global.- Specified by:
getProjectRolesin interfaceProjectRoleManager- Returns:
- The global list of project roles in JIRA
-
getProjectRoles
Description copied from interface:ProjectRoleManagerThis will return all theProjectRoles that the user is currently a member of for the given project. An anonymous or null user will not belong to any project roles and therefore this collection will be empty.- Specified by:
getProjectRolesin interfaceProjectRoleManager- Parameters:
user- the userproject- the project- Returns:
- a Collection of ProjectRoles.
-
getProjectRole
Description copied from interface:ProjectRoleManagerRetrieves a project role object- Specified by:
getProjectRolein interfaceProjectRoleManager- Returns:
- the project role based on the id or null if it doesn't exist.
-
getProjectRole
Description copied from interface:ProjectRoleManagerRetrieves a project role object by name- Specified by:
getProjectRolein interfaceProjectRoleManager- Returns:
- the project role based on the name or null if it doesn't exist.
-
createRole
Description copied from interface:ProjectRoleManagerCreates a project role object- Specified by:
createRolein interfaceProjectRoleManager- Parameters:
projectRole- the project role to create, if the id field is non-null then this will be ignored. Only the roles name and description are used by this method.- Returns:
- the created project role object
-
isRoleNameUnique
Description copied from interface:ProjectRoleManagerWill tell you if a role name exists or not.- Specified by:
isRoleNameUniquein interfaceProjectRoleManager- Parameters:
name- the name of the project role to check- Returns:
- true if unique, false if one already exists with that name
-
deleteRole
Description copied from interface:ProjectRoleManagerDeletes a project role object- Specified by:
deleteRolein interfaceProjectRoleManager
-
updateRole
Description copied from interface:ProjectRoleManagerUpdates a project role object- Specified by:
updateRolein interfaceProjectRoleManager
-
getProjectRoleActors
Description copied from interface:ProjectRoleManagerThis method will retrieve the object that represents the actors associate with the givenprojectRoleandprojectcontext- Specified by:
getProjectRoleActorsin interfaceProjectRoleManager- Returns:
- the projectRoleActors object for the given projectRole and project context
-
updateProjectRoleActors
Description copied from interface:ProjectRoleManagerCommits the given ProjectRoleActors to permanent store, saving any updates made.- Specified by:
updateProjectRoleActorsin interfaceProjectRoleManager
-
getDefaultRoleActors
Description copied from interface:ProjectRoleManagerThis method will return the default role actors for aProjectRole- Specified by:
getDefaultRoleActorsin interfaceProjectRoleManager
-
updateDefaultRoleActors
Description copied from interface:ProjectRoleManagerThis method will update the associations of actors for the default projectRole, specified by the given defaultRoleActors object. The actors will be updated to reflect the state of the roleActors set contained within the given defaultRoleActors object.- Specified by:
updateDefaultRoleActorsin interfaceProjectRoleManager
-
applyDefaultsRolesToProject
Description copied from interface:ProjectRoleManagerThis method will insert all the default roles into the role associations for the provided project. If one of the default actors is already associated with the project, we will leave that association. NOTE: This method is meant to only be called immediatly after a project is created.- Specified by:
applyDefaultsRolesToProjectin interfaceProjectRoleManager- Parameters:
project- the project to associate the role defaults with
-
removeAllRoleActorsByNameAndType
Description copied from interface:ProjectRoleManagerThis 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:
removeAllRoleActorsByNameAndTypein interfaceProjectRoleManagertype- this is the role type parameter, (ex. GroupRoleActor.TYPE, UserRoleActor.TYPE)
-
removeAllRoleActorsByProject
Description copied from interface:ProjectRoleManagerWill 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:
removeAllRoleActorsByProjectin interfaceProjectRoleManager- Parameters:
project- this is the project that the role actors are associated with
-
isUserInProjectRole
Description copied from interface:ProjectRoleManagerReturns true only if the given user is in the given project role for the given project. This could be because they are a member of a particular group (groups can be in roles) as well as being a user in a role.- Specified by:
isUserInProjectRolein interfaceProjectRoleManager- Parameters:
user- The user to check. If user is null, this will implicitly return false.projectRole- The role.project- The project.- Returns:
- true if the User is in the role.
-
getProjectIdsContainingRoleActorByNameAndType
Description copied from interface:ProjectRoleManagerReturns the project id'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:
getProjectIdsContainingRoleActorByNameAndTypein interfaceProjectRoleManager- Parameters:
key- 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)- Returns:
- a collection of Long project id's which have a role which contains the role actor with the specified name and type.
-
roleActorOfTypeExistsForProjects
public List<Long> roleActorOfTypeExistsForProjects(List<Long> projectsToLimitBy, ProjectRole projectRole, String projectRoleType, String projectRoleParameter) Description copied from interface:ProjectRoleManagerReturns 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:
roleActorOfTypeExistsForProjectsin interfaceProjectRoleManager- Parameters:
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.- 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<Long,List<String>> getProjectIdsForUserInGroupsBecauseOfRole(List<Long> projectsToLimitBy, ProjectRole projectRole, String projectRoleType, String userName) Description copied from interface:ProjectRoleManagerReturns 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:
getProjectIdsForUserInGroupsBecauseOfRolein interfaceProjectRoleManager- Parameters:
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- 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.
-
createProjectIdToProjectRolesMap
@Deprecated public ProjectRoleManager.ProjectIdToProjectRoleIdsMap createProjectIdToProjectRolesMap(ApplicationUser user, Collection<Long> projectIds) Deprecated.- Specified by:
createProjectIdToProjectRolesMapin interfaceProjectRoleManager
-
createProjectIdToProjectRolesMapWithGroups
public ProjectRoleManager.ProjectIdToProjectRoleIdsMap createProjectIdToProjectRolesMapWithGroups(@Nonnull ApplicationUser user, @Nonnull Set<String> groups) Description copied from interface:ProjectRoleManagerReturns a ProjectIdToProjectRoleIdsMap, which is a map of project IDs to their corresponding collections of project role IDs, optimized for performance at scale. This method takes in groups of the user and queries project role actors by the group keys and the user key directly.- Specified by:
createProjectIdToProjectRolesMapWithGroupsin interfaceProjectRoleManager- Parameters:
user- the ApplicationUser for which the mapping is requiredgroups- the Set of group keys of the user- Returns:
- a ProjectIdToProjectRoleIdsMap containing the mapping of project IDs to their collections of project role IDs
-
isGroupUsed
public boolean isGroupUsed(@Nonnull com.atlassian.crowd.embedded.api.Group group) Description copied from interface:GroupConfigurableDetermine whether configuration exists for the specifiedGroup.- Specified by:
isGroupUsedin interfaceGroupConfigurable- Parameters:
group- that may or may not exist.- Returns:
- true if the group is used in the components configuration.
-