public abstract class

AbstractSchemeManager

extends Object
implements SchemeManager
java.lang.Object
   ↳ com.atlassian.jira.scheme.AbstractSchemeManager
Known Direct Subclasses
Known Indirect Subclasses

Summary

[Expand]
Inherited Constants
From interface com.atlassian.jira.scheme.SchemeManager
Fields
protected final EventPublisher eventPublisher
protected final GroupManager groupManager
protected final ProjectManager projectManager
protected final SchemeFactory schemeFactory
protected final SecurityTypeManager securityTypeManager
Protected Constructors
AbstractSchemeManager(ProjectManager projectManager, SecurityTypeManager securityTypeManager, PermissionContextFactory permissionContextFactory, SchemeFactory schemeFactory, NodeAssociationStore nodeAssociationStore, OfBizDelegator ofBizDelegator, GroupManager groupManager, EventPublisher eventPublisher, CacheManager cacheManager)
Public Methods
void addDefaultSchemeToProject(GenericValue project)
Adds the default scheme to a particular project
void addDefaultSchemeToProject(Project project)
Adds the default scheme to a particular project
void addSchemeToProject(Project project, Scheme scheme)
Adds a scheme to a particular project
@Deprecated void addSchemeToProject(GenericValue project, GenericValue scheme)
Adds a scheme to a particular project
Scheme copyScheme(Scheme oldScheme)
Copys a scheme, giving the new scheme the same entities as the original one
GenericValue copyScheme(GenericValue oldScheme)
Copys a scheme, giving the new scheme the same entities as the original one
GenericValue createDefaultScheme()
Creates a default scheme, with an id of 0
GenericValue createScheme(String name, String description)
Creates a new scheme
Scheme createSchemeAndEntities(Scheme scheme)
Scheme createSchemeObject(String name, String description)
Creates a new scheme
void deleteEntities(Iterable<Long> ids)
Deletes a collection of entities from the database.
void deleteEntity(Long id)
Deletes an entity with the given id from the database.
void deleteScheme(Long id)
Deletes a scheme from the database
List<Scheme> getAssociatedSchemes(boolean withEntitiesComparable)
Gets all schemes of this type in the database taht are associated with at least one project.
@Deprecated String getAssociationType()
This method is deprecated. Just assume all schemes are project association schemes.
abstract String getDefaultDescriptionKey()
abstract String getDefaultNameKey()
GenericValue getDefaultScheme()
Gets the default scheme.
Scheme getDefaultSchemeObject()
Gets the default scheme.
List<GenericValue> getEntities(GenericValue scheme)
Get all Scheme entity records for a particular scheme
List<GenericValue> getEntities(String type, String parameter)
Get all entity records with a particular parameter
List<GenericValue> getEntitiesByIds(List<Long> ids)
Get all entity records for a list of ids
GenericValue getEntity(Long id)
Gets a scheme entity based on the id of the entity
abstract String getEntityName()
Collection<Group> getGroups(Long entityTypeId, GenericValue project)
Collection<Group> getGroups(Long entityTypeId, Project project)
String getNameForCopy(String originalName, Integer abbreviateTo)
List<Project> getProjects(Scheme scheme)
Gets all projects that are associated with that scheme
GenericValue getScheme(Long id)
Gets a scheme based on the Id of the scheme
GenericValue getScheme(String name)
Gets a scheme by name from the database.
abstract String getSchemeDesc()
abstract 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.
@Nullable Scheme getSchemeObject(String name)
Gets a scheme by name from the database.
@Nullable Scheme getSchemeObject(Long id)
Gets a scheme by id from the database.
List<Scheme> getSchemeObjects()
Gets all scheme objects in the database.
List<GenericValue> getSchemes()
Gets all the Schemes (of the type defined by the subclass) from the database.
List<GenericValue> getSchemes(GenericValue project)
Get all schemes of this type attached to the given project.
List<Scheme> getUnassociatedSchemes()
Will return all @link Scheme objects that are not currently associated with any projects.
Collection<ApplicationUser> getUsers(Long permissionId, PermissionContext ctx)
Collection<ApplicationUser> getUsers(Long permissionId, Project project)
Collection<ApplicationUser> getUsers(Long permissionId, GenericValue projectOrIssue)
Collection<ApplicationUser> getUsers(Long permissionId, Issue issue)
void onClearCache(ClearCacheEvent event)
boolean removeEntities(GenericValue scheme, Long entityTypeId)
Retrieves all the entites for this permission and then removes them.
boolean removeEntities(String type, String parameter)
Removes all scheme entities with this parameter and type
void removeSchemesFromProject(Project project)
Removes all schemes from a project
@Deprecated void removeSchemesFromProject(GenericValue project)
Removes all schemes from a project
boolean schemeExists(String name)
Determine if the given scheme name exists.
void swapParameterForEntitiesOfType(String type, String parameter, String resultingParameter)
Swaps all parameters of entities with the given type scheme to the given resulting parameter
void updateScheme(GenericValue entity)
Updates any changes to the given scheme
void updateScheme(Scheme scheme)
Updates any changes to the scheme object.
Protected Methods
@Nonnull abstract AbstractSchemeAddedToProjectEvent createSchemeAddedToProjectEvent(Scheme scheme, Project project)
@Nonnull abstract AbstractSchemeCopiedEvent createSchemeCopiedEvent(Scheme oldScheme, Scheme newScheme)
abstract AbstractSchemeEvent createSchemeCreatedEvent(Scheme scheme)
@Nullable abstract Object createSchemeEntityDeletedEvent(GenericValue entity)
abstract GenericValue createSchemeEntityNoEvent(GenericValue scheme, SchemeEntity schemeEntity)
GenericValue createSchemeGenericValue(Map<StringObject> values)
GenericValue createSchemeNoEvent(String name, String description)
@Nonnull abstract AbstractSchemeRemovedFromProjectEvent createSchemeRemovedFromProjectEvent(Scheme scheme, Project project)
abstract AbstractSchemeUpdatedEvent createSchemeUpdatedEvent(Scheme scheme, Scheme originalScheme)
void flushProjectSchemes()
I18nHelper getApplicationI18n()
abstract SchemeEntity makeSchemeEntity(GenericValue schemeEntityGV)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.jira.scheme.SchemeManager

Fields

protected final EventPublisher eventPublisher

protected final GroupManager groupManager

protected final ProjectManager projectManager

protected final SchemeFactory schemeFactory

protected final SecurityTypeManager securityTypeManager

Protected Constructors

protected AbstractSchemeManager (ProjectManager projectManager, SecurityTypeManager securityTypeManager, PermissionContextFactory permissionContextFactory, SchemeFactory schemeFactory, NodeAssociationStore nodeAssociationStore, OfBizDelegator ofBizDelegator, GroupManager groupManager, EventPublisher eventPublisher, CacheManager cacheManager)

Public Methods

public void addDefaultSchemeToProject (GenericValue project)

Adds the default scheme to a particular project

Parameters
project The project that the scheme is to be added to
Throws
GenericEntityException

public void addDefaultSchemeToProject (Project project)

Adds the default scheme to a particular project

Parameters
project The project that the scheme is to be added to

public void addSchemeToProject (Project project, Scheme scheme)

Adds a scheme to a particular project

Parameters
project The project that the scheme is to be added to
scheme The scheme to be added

@Deprecated public void addSchemeToProject (GenericValue project, GenericValue scheme)

Adds a scheme to a particular project

Parameters
project The project that the scheme is to be added to
scheme The scheme to be added
Throws
GenericEntityException

public Scheme copyScheme (Scheme oldScheme)

Copys a scheme, giving the new scheme the same entities as the original one

Parameters
oldScheme The permission scheme to be copied
Returns
  • The new permission scheme

public GenericValue copyScheme (GenericValue oldScheme)

Copys a scheme, giving the new scheme the same entities as the original one

Parameters
oldScheme The permission scheme to be copied
Returns
  • The new permission scheme
Throws
GenericEntityException

public GenericValue createDefaultScheme ()

Creates a default scheme, with an id of 0

Returns
  • The new permission scheme object
Throws
GenericEntityException

public GenericValue createScheme (String name, String description)

Creates a new scheme

Parameters
name The name of the new scheme
description The description of the new scheme
Returns
  • The new scheme object
Throws
GenericEntityException

public Scheme createSchemeAndEntities (Scheme scheme)

public Scheme createSchemeObject (String name, String description)

Creates a new scheme

Parameters
name The name of the new scheme
description The description of the new scheme
Returns
  • The new scheme object

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 an entity with the given id from the database.

Parameters
id The id of the entity 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 List<Scheme> getAssociatedSchemes (boolean withEntitiesComparable)

Gets all schemes of this type in the database taht are associated with at least one project.

Parameters
withEntitiesComparable if true then the scheme entites will be logically comparable (they will not include database specific information such as the pk id). Otherwise the object will be a full representation of the row stored in the database.
Returns
  • List of associated schemes

@Deprecated public String getAssociationType ()

This method is deprecated.
Just assume all schemes are project association schemes.

Identifies whether this scheme manager makes its schemes associated with projects or something else. This is here for historic reasons as schemes are now always associated with projects. This means you should not override this.

public abstract String getDefaultDescriptionKey ()

public abstract String getDefaultNameKey ()

public GenericValue getDefaultScheme ()

Gets the default scheme. This should have an id of 0

This does not work for the Default Notification scheme as it does not have an id of 0.

Returns
  • The default scheme
Throws
GenericEntityException

public Scheme getDefaultSchemeObject ()

Gets the default scheme. This should have an id of 0

This does not work for the Default Notification scheme as it does not have an id of 0.

Returns
  • The default scheme

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 (String type, String parameter)

Get all entity records with a particular parameter

Parameters
type The type of entity you wish to retrieve, eg 'user', 'group', 'projectrole'
parameter The parameter in the entity
Returns
  • List of (GenericValue) entities
Throws
GenericEntityException

public List<GenericValue> getEntitiesByIds (List<Long> ids)

Get all entity records for a list of ids

Parameters
ids a collection of entity ids that should be retrieved
Returns
  • List of (GenericValue) entities - can be an empty list if no entities match the given ids

public GenericValue getEntity (Long id)

Gets a scheme entity based on the id of the entity

Parameters
id The id of the entity
Returns
  • The scheme entity object

public abstract String getEntityName ()

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

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

public String getNameForCopy (String originalName, Integer abbreviateTo)

public List<Project> getProjects (Scheme scheme)

Gets all projects that are associated with that scheme

Parameters
scheme The scheme used to get all projects
Returns

public GenericValue getScheme (Long id)

Gets a scheme based on the Id of the scheme

Parameters
id Id of the scheme
Returns
  • The scheme

public GenericValue getScheme (String name)

Gets a scheme by name from the database.

Parameters
name the name of the scheme to get.
Returns
  • the Scheme

public abstract String getSchemeDesc ()

public abstract 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.

@Nullable public Scheme getSchemeObject (String name)

Gets a scheme by name from the database.

Parameters
name the name of the scheme to get.
Returns
  • the Scheme

@Nullable public Scheme getSchemeObject (Long id)

Gets a scheme by id from the database.

Parameters
id the id of the scheme to get.
Returns
  • the Scheme

public List<Scheme> getSchemeObjects ()

Gets all scheme objects in the database.

Returns
  • the schemes.

public List<GenericValue> getSchemes ()

Gets all the Schemes (of the type defined by the subclass) from the database.

Returns
  • the schemes.

public List<GenericValue> getSchemes (GenericValue project)

Get all schemes of this type attached to the given project.

Parameters
project The project that the schemes are attached to
Returns
  • List of schemes
Throws
GenericEntityException

public List<Scheme> getUnassociatedSchemes ()

Will return all @link Scheme objects that are not currently associated with any projects.

Returns
  • list of @link Scheme objects

public Collection<ApplicationUser> getUsers (Long permissionId, PermissionContext ctx)

public Collection<ApplicationUser> getUsers (Long permissionId, Project project)

public Collection<ApplicationUser> getUsers (Long permissionId, GenericValue projectOrIssue)

public Collection<ApplicationUser> getUsers (Long permissionId, Issue issue)

public void onClearCache (ClearCacheEvent event)

public boolean removeEntities (GenericValue scheme, Long entityTypeId)

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

Parameters
scheme to remove entites from must NOT be null
entityTypeId to remove
Returns
  • True all the time (legacy)

public boolean removeEntities (String type, String parameter)

Removes all scheme entities with this parameter and type

Parameters
type the 'type' of entity you are deleting, eg 'group', 'user', 'projectrole'
parameter must NOT be null
Returns
  • true always (legacy)

public void removeSchemesFromProject (Project project)

Removes all schemes from a project

Parameters
project The project that all schemes are to be deleted from

@Deprecated public void removeSchemesFromProject (GenericValue project)

Removes all schemes from a project

Parameters
project The project that all schemes are to be deleted from
Throws
GenericEntityException

public boolean schemeExists (String name)

Determine if the given scheme name exists.

Parameters
name The name of the scheme
Returns
  • true is the schem exists.

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

public void updateScheme (GenericValue entity)

Updates any changes to the given scheme

Parameters
entity The modified scheme
Throws
GenericEntityException

public void updateScheme (Scheme scheme)

Updates any changes to the scheme object. This does not include changes to the scheme entities.

Parameters
scheme The modified scheme object

Protected Methods

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

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

protected abstract AbstractSchemeEvent createSchemeCreatedEvent (Scheme scheme)

@Nullable protected abstract Object createSchemeEntityDeletedEvent (GenericValue entity)

protected abstract GenericValue createSchemeEntityNoEvent (GenericValue scheme, SchemeEntity schemeEntity)

Throws
GenericEntityException

protected GenericValue createSchemeGenericValue (Map<StringObject> values)

Throws
GenericEntityException

protected GenericValue createSchemeNoEvent (String name, String description)

Throws
GenericEntityException

@Nonnull protected abstract AbstractSchemeRemovedFromProjectEvent createSchemeRemovedFromProjectEvent (Scheme scheme, Project project)

protected abstract AbstractSchemeUpdatedEvent createSchemeUpdatedEvent (Scheme scheme, Scheme originalScheme)

protected void flushProjectSchemes ()

protected I18nHelper getApplicationI18n ()

protected abstract SchemeEntity makeSchemeEntity (GenericValue schemeEntityGV)