public class

DefaultPermissionSchemeManager

extends AbstractSchemeManager
implements GroupConfigurable Startable PermissionSchemeManager
java.lang.Object
   ↳ com.atlassian.jira.scheme.AbstractSchemeManager
     ↳ com.atlassian.jira.permission.DefaultPermissionSchemeManager
Known Direct Subclasses

Class Overview

This class is used to handle Permission Schemes.

Permission Schemes are created, removed and edited through this class

Summary

[Expand]
Inherited Constants
From interface com.atlassian.jira.scheme.SchemeManager
[Expand]
Inherited Fields
From class com.atlassian.jira.scheme.AbstractSchemeManager
Public Constructors
DefaultPermissionSchemeManager(ProjectManager projectManager, PermissionTypeManager permissionTypeManager, PermissionContextFactory permissionContextFactory, OfBizDelegator delegator, SchemeFactory schemeFactory, NodeAssociationStore nodeAssociationStore, GroupManager groupManager, EventPublisher eventPublisher, CacheManager cacheManager)
Public Methods
GenericValue createSchemeEntity(GenericValue scheme, SchemeEntity schemeEntity)
Create a new permission record in the database
void deleteEntities(Iterable<Long> ids)
Deletes a collection of entities from the database.
void deleteEntity(Long id)
Deletes a permission from the database
void deleteScheme(Long id)
Deletes a scheme from the database
void flushSchemeEntities()
String getDefaultDescriptionKey()
String getDefaultNameKey()
List<GenericValue> getEntities(GenericValue scheme, ProjectPermissionKey permissionKey)
List<GenericValue> getEntities(GenericValue scheme, String permissionKey)
Inherited from SchemeManager.
List<GenericValue> getEntities(GenericValue scheme, Long permissionId, String type, String parameter)
Get all Generic Value permission records for a particular scheme and permission Id
List<GenericValue> getEntities(GenericValue scheme)
Get all Scheme entity records for a particular scheme
List<GenericValue> getEntities(GenericValue scheme, Long permissionId, String parameter)
Get all Generic Value permission records for a particular scheme and permission Id
List<GenericValue> getEntities(GenericValue scheme, ProjectPermissionKey permissionKey, String type, String parameter)
Get all Generic Value permission records for a particular scheme and permission Id
List<GenericValue> getEntities(GenericValue scheme, ProjectPermissionKey permissionKey, String parameter)
List<GenericValue> getEntities(GenericValue scheme, String type, Long permissionId)
Get all Generic Value permission records for a particular scheme and permission Id
List<GenericValue> getEntities(GenericValue scheme, Long permissionId)
Get all Generic Value permission records for a particular scheme and permission Id
List<GenericValue> getEntitiesByType(GenericValue scheme, ProjectPermissionKey permissionKey, String type)
String getEntityName()
Collection<Group> getGroups(Long entityTypeId, GenericValue project)
Collection<Group> getGroups(ProjectPermissionKey permissionKey, Project project)
Collection<Group> getGroups(Long entityTypeId, Project project)
Collection<PermissionSchemeEntry> getPermissionSchemeEntries(Scheme scheme, ProjectPermissionKey permissionKey)
Returns the PermissionSchemeEntries for the given Permission Scheme and ProjectPermissionKey.
Collection<PermissionSchemeEntry> getPermissionSchemeEntries(long schemeId, ProjectPermissionKey permissionKey)
Returns the PermissionSchemeEntries for the given Permission Scheme and ProjectPermissionKey.
Collection<PermissionSchemeEntry> getPermissionSchemeEntries(long schemeId, ProjectPermissionKey permissionKey, String type)
Returns the PermissionSchemeEntries for the given Permission Scheme and ProjectPermissionKey.
String getSchemeDesc()
String getSchemeEntityName()
@Nullable Scheme getSchemeFor(Project project)
Get the scheme of this type attached to the given project.
@Nullable Long getSchemeIdFor(Project project)
Get the scheme of this type attached to the given project.
Collection<GenericValue> getSchemesContainingEntity(String type, String parameter)
This is a method that is meant to quickly get you all the schemes that contain an entity of the specified type and parameter.
Collection<ApplicationUser> getUsers(ProjectPermissionKey permissionKey, PermissionContext ctx)
ProjectWidePermission hasProjectWidePermission(ProjectPermissionKey permissionKey, Project project, ApplicationUser user, boolean issueCreation)
boolean hasSchemePermission(ProjectPermissionKey permissionKey, Project project)
Checks anonymous permission of the given permission type for the given project.
boolean hasSchemePermission(ProjectPermissionKey permissionKey, Issue issue)
Checks anonymous permission of the given permission type for the given issue.
boolean hasSchemePermission(ProjectPermissionKey permissionKey, Project project, ApplicationUser user, boolean issueCreation)
Checks the given user's permission of the given permission type for the given project.
boolean hasSchemePermission(ProjectPermissionKey permissionKey, Issue issue, ApplicationUser user, boolean issueCreation)
Checks the given user's permission of the given permission type for the given issue.
boolean isGroupUsed(Group group)
Determine whether configuration exists for the specified Group.
void onClearCache(ClearCacheEvent event)
boolean removeEntities(GenericValue scheme, Long permissionId)
Retrieves all the entites for this permission and then removes them.
boolean removeEntities(String type, String parameter)
Removes all scheme entities with this parameter
void start()
Registers this CachingFieldConfigContextPersister's cache in the JIRA instrumentation.
void swapParameterForEntitiesOfType(String type, String parameter, String resultingParameter)
Swaps all parameters of entities with the given type scheme to the given resulting parameter
Protected Methods
@Nonnull AbstractSchemeAddedToProjectEvent createSchemeAddedToProjectEvent(Scheme scheme, Project project)
@Nonnull AbstractSchemeCopiedEvent createSchemeCopiedEvent(Scheme oldScheme, Scheme newScheme)
AbstractSchemeEvent createSchemeCreatedEvent(Scheme scheme)
AbstractSchemeEntityEvent createSchemeEntityDeletedEvent(GenericValue entity)
GenericValue createSchemeEntityNoEvent(GenericValue scheme, SchemeEntity schemeEntity)
AbstractSchemeRemovedFromProjectEvent createSchemeRemovedFromProjectEvent(Scheme scheme, Project project)
AbstractSchemeUpdatedEvent createSchemeUpdatedEvent(Scheme scheme, Scheme originalScheme)
SchemeEntity makeSchemeEntity(GenericValue entity)
[Expand]
Inherited Methods
From class com.atlassian.jira.scheme.AbstractSchemeManager
From class java.lang.Object
From interface com.atlassian.jira.config.group.GroupConfigurable
From interface com.atlassian.jira.extension.Startable
From interface com.atlassian.jira.permission.PermissionSchemeManager
From interface com.atlassian.jira.scheme.SchemeManager

Public Constructors

public DefaultPermissionSchemeManager (ProjectManager projectManager, PermissionTypeManager permissionTypeManager, PermissionContextFactory permissionContextFactory, OfBizDelegator delegator, SchemeFactory schemeFactory, NodeAssociationStore nodeAssociationStore, GroupManager groupManager, EventPublisher eventPublisher, CacheManager cacheManager)

Public Methods

public GenericValue createSchemeEntity (GenericValue scheme, SchemeEntity schemeEntity)

Create a new permission record in the database

Parameters
scheme The scheme that the permission record is associated with
schemeEntity The scheme entity object that is to be added to the scheme
Returns
  • The permission object
Throws
GenericEntityException

public void deleteEntities (Iterable<Long> ids)

Deletes a collection of entities from the database.

Parameters
ids a collection entity ids to be deleted.

public void deleteEntity (Long id)

Deletes a permission from the database

Parameters
id The id of the permission to be deleted

public void deleteScheme (Long id)

Deletes a scheme from the database

Parameters
id Id of the scheme to be deleted
Throws
GenericEntityException

public void flushSchemeEntities ()

public String getDefaultDescriptionKey ()

public String getDefaultNameKey ()

public List<GenericValue> getEntities (GenericValue scheme, ProjectPermissionKey permissionKey)

Throws
GenericEntityException

public List<GenericValue> getEntities (GenericValue scheme, String permissionKey)

Inherited from SchemeManager.

Throws
GenericEntityException

public List<GenericValue> getEntities (GenericValue scheme, Long permissionId, String type, String parameter)

Get all Generic Value permission records for a particular scheme and permission Id

Parameters
scheme The scheme that the permissions belong to
permissionId The Id of the permission
type The type of the permission(Group, Current Reporter etc)
parameter The permission parameter (group name etc)
Returns
  • List of (GenericValue) permissions
Throws
GenericEntityException

public List<GenericValue> getEntities (GenericValue scheme)

Get all Scheme entity records for a particular scheme

Parameters
scheme The scheme that the entities belong to
Returns
  • List of (GenericValue) entities
Throws
GenericEntityException

public List<GenericValue> getEntities (GenericValue scheme, Long permissionId, String parameter)

Get all Generic Value permission records for a particular scheme and permission Id

Parameters
scheme The scheme that the permissions belong to
permissionId The Id of the permission
parameter The permission parameter (group name etc)
Returns
  • List of (GenericValue) permissions
Throws
GenericEntityException

public List<GenericValue> getEntities (GenericValue scheme, ProjectPermissionKey permissionKey, String type, String parameter)

Get all Generic Value permission records for a particular scheme and permission Id

Parameters
scheme The scheme that the permissions belong to
permissionKey The key of the permission
type The type of the permission(Group, Current Reporter etc)
parameter The permission parameter (group name etc)
Returns
  • List of (GenericValue) permissions
Throws
GenericEntityException

public List<GenericValue> getEntities (GenericValue scheme, ProjectPermissionKey permissionKey, String parameter)

Throws
GenericEntityException

public List<GenericValue> getEntities (GenericValue scheme, String type, Long permissionId)

Get all Generic Value permission records for a particular scheme and permission Id

Parameters
scheme The scheme that the permissions belong to
type The type of the permission(Group, Current Reporter etc)
permissionId The Id of the permission
Returns
  • List of (GenericValue) permissions
Throws
GenericEntityException

public List<GenericValue> getEntities (GenericValue scheme, Long permissionId)

Get all Generic Value permission records for a particular scheme and permission Id

Parameters
scheme The scheme that the permissions belong to
permissionId The Id of the permission
Returns
  • List of (GenericValue) permissions
Throws
GenericEntityException

public List<GenericValue> getEntitiesByType (GenericValue scheme, ProjectPermissionKey permissionKey, String type)

Throws
GenericEntityException

public String getEntityName ()

public Collection<Group> getGroups (Long entityTypeId, GenericValue project)

public Collection<Group> getGroups (ProjectPermissionKey permissionKey, Project project)

public Collection<Group> getGroups (Long entityTypeId, Project project)

public Collection<PermissionSchemeEntry> getPermissionSchemeEntries (Scheme scheme, ProjectPermissionKey permissionKey)

Returns the PermissionSchemeEntries for the given Permission Scheme and ProjectPermissionKey.

Parameters
scheme The permission scheme
permissionKey The permission type
Returns
  • the PermissionSchemeEntries for the given Permission Scheme and ProjectPermissionKey.

public Collection<PermissionSchemeEntry> getPermissionSchemeEntries (long schemeId, ProjectPermissionKey permissionKey)

Returns the PermissionSchemeEntries for the given Permission Scheme and ProjectPermissionKey.

Parameters
schemeId The permission scheme
permissionKey The permission type
Returns
  • the PermissionSchemeEntries for the given Permission Scheme and ProjectPermissionKey.

public Collection<PermissionSchemeEntry> getPermissionSchemeEntries (long schemeId, ProjectPermissionKey permissionKey, String type)

Returns the PermissionSchemeEntries for the given Permission Scheme and ProjectPermissionKey.

Parameters
schemeId The permission scheme
permissionKey The permission type
Returns
  • the PermissionSchemeEntries for the given Permission Scheme and ProjectPermissionKey.

public String getSchemeDesc ()

public String getSchemeEntityName ()

@Nullable public Scheme getSchemeFor (Project project)

Get the scheme of this type attached to the given project.

Parameters
project The project
Returns
  • The scheme associated with this project.

@Nullable public Long getSchemeIdFor (Project project)

Get the scheme of this type attached to the given project.

Parameters
project The project
Returns
  • The ID of the scheme associated with this project.

public Collection<GenericValue> getSchemesContainingEntity (String type, String parameter)

This is a method that is meant to quickly get you all the schemes that contain an entity of the specified type and parameter.

Parameters
type is the entity type
parameter is the scheme entries parameter value
Returns
  • Collection of GenericValues that represents a scheme

public Collection<ApplicationUser> getUsers (ProjectPermissionKey permissionKey, PermissionContext ctx)

public ProjectWidePermission hasProjectWidePermission (ProjectPermissionKey permissionKey, Project project, ApplicationUser user, boolean issueCreation)

public boolean hasSchemePermission (ProjectPermissionKey permissionKey, Project project)

Checks anonymous permission of the given permission type for the given project.

Parameters
permissionKey permission key.
project the project to which permission is being checked.
Returns
  • true only if the anonymous user is permitted.

public boolean hasSchemePermission (ProjectPermissionKey permissionKey, Issue issue)

Checks anonymous permission of the given permission type for the given issue.

Parameters
permissionKey permission key.
issue the issue to which permission is being checked.
Returns
  • true only if the anonymous user is permitted.

public boolean hasSchemePermission (ProjectPermissionKey permissionKey, Project project, ApplicationUser user, boolean issueCreation)

Checks the given user's permission of the given permission type for the given project.

Parameters
permissionKey permission key.
project the project to which permission is being checked.
user the user.
issueCreation whether the permission is for creating an issue.
Returns
  • true only if the user is permitted.

public boolean hasSchemePermission (ProjectPermissionKey permissionKey, Issue issue, ApplicationUser user, boolean issueCreation)

Checks the given user's permission of the given permission type for the given issue.

Parameters
permissionKey permission key.
issue the issue to check permission against
user the user.
issueCreation whether the permission is for creating an issue.
Returns
  • true only if the user is permitted.

public boolean isGroupUsed (Group group)

Determine whether configuration exists for the specified Group.

Parameters
group that may or may not exist.
Returns
  • true if the group is used in the components configuration.

public void onClearCache (ClearCacheEvent event)

public boolean removeEntities (GenericValue scheme, Long permissionId)

Retrieves all the entites for this permission and then removes them.

Parameters
scheme to remove entites from must NOT be null
permissionId to remove must NOT be a global permission
Returns
  • True is all the entities are removed

public boolean removeEntities (String type, String parameter)

Removes all scheme entities with this parameter

Parameters
type the type of scheme entity you wish to remove 'user', 'group', 'projectrole'
parameter must NOT be null
Returns
  • true always (legacy)

public void start ()

Registers this CachingFieldConfigContextPersister's cache in the JIRA instrumentation.

Throws
Exception

public void swapParameterForEntitiesOfType (String type, String parameter, String resultingParameter)

Swaps all parameters of entities with the given type scheme to the given resulting parameter

Parameters
type the 'type' of entity you are swapping, eg 'group', 'user', 'projectrole'
parameter must NOT be null

Protected Methods

@Nonnull protected AbstractSchemeAddedToProjectEvent createSchemeAddedToProjectEvent (Scheme scheme, Project project)

@Nonnull protected AbstractSchemeCopiedEvent createSchemeCopiedEvent (Scheme oldScheme, Scheme newScheme)

protected AbstractSchemeEvent createSchemeCreatedEvent (Scheme scheme)

protected AbstractSchemeEntityEvent createSchemeEntityDeletedEvent (GenericValue entity)

protected GenericValue createSchemeEntityNoEvent (GenericValue scheme, SchemeEntity schemeEntity)

Throws
GenericEntityException

protected AbstractSchemeRemovedFromProjectEvent createSchemeRemovedFromProjectEvent (Scheme scheme, Project project)

protected AbstractSchemeUpdatedEvent createSchemeUpdatedEvent (Scheme scheme, Scheme originalScheme)

protected SchemeEntity makeSchemeEntity (GenericValue entity)