com.atlassian.jira.scheme
Class AbstractSchemeManager

java.lang.Object
  extended by com.atlassian.jira.scheme.AbstractSchemeManager
All Implemented Interfaces:
SchemeManager
Direct Known Subclasses:
DefaultNotificationSchemeManager, DefaultPermissionSchemeManager, DefaultWorkflowSchemeManager, IssueSecuritySchemeManagerImpl

public abstract class AbstractSchemeManager
extends Object
implements SchemeManager


Field Summary
protected  ProjectManager projectManager
           
 
Fields inherited from interface com.atlassian.jira.scheme.SchemeManager
PROJECT_ASSOCIATION
 
Constructor Summary
protected AbstractSchemeManager(ProjectManager projectManager, AbstractSchemeTypeManager typeManager, PermissionContextFactory permissionContextFactory, SchemeFactory schemeFactory, com.atlassian.core.ofbiz.association.AssociationManager associationManager, OfBizDelegator ofBizDelegator)
           
 
Method Summary
 void addDefaultSchemeToProject(org.ofbiz.core.entity.GenericValue project)
          Adds the default scheme to a particular project
 void addDefaultSchemeToProject(Project project)
           
 void addSchemeToProject(org.ofbiz.core.entity.GenericValue project, org.ofbiz.core.entity.GenericValue scheme)
          Deprecated. should use addSchemeToProject(Project, Scheme) instead
 void addSchemeToProject(Project project, Scheme scheme)
          Adds a scheme to a particular project
 org.ofbiz.core.entity.GenericValue copyScheme(org.ofbiz.core.entity.GenericValue scheme)
          Copys a scheme, giving the new scheme the same entities as the original one
abstract  org.ofbiz.core.entity.GenericValue copySchemeEntity(org.ofbiz.core.entity.GenericValue scheme, org.ofbiz.core.entity.GenericValue entity)
           
 org.ofbiz.core.entity.GenericValue createDefaultScheme()
          Creates a default scheme, with an id of 0
 org.ofbiz.core.entity.GenericValue createScheme(String name, String description)
          Creates a new scheme
 Scheme createSchemeAndEntities(Scheme scheme)
           
protected  org.ofbiz.core.entity.GenericValue createSchemeGenericValue(Map<String,Object> values)
           
 void deleteEntity(Long id)
          Deletes an entity with the given id from the database.
 void deleteScheme(Long id)
          Deletes a scheme from the database
protected  void flushProjectSchemes()
           
 List<Scheme> getAssociatedSchemes(boolean withEntitiesComparable)
          Gets all associated schemes of a certain type in the database.
 String getAssociationType()
          Deprecated. Just assume all schemes are project association schemes.
abstract  String getDefaultDescriptionKey()
           
abstract  String getDefaultNameKey()
           
 org.ofbiz.core.entity.GenericValue getDefaultScheme()
          Gets the default scheme.
 List<org.ofbiz.core.entity.GenericValue> getEntities(org.ofbiz.core.entity.GenericValue scheme)
          Get all Scheme entity records for a particular scheme
 List<org.ofbiz.core.entity.GenericValue> getEntities(String type, String parameter)
          Get all entity records with a particular parameter
 org.ofbiz.core.entity.GenericValue getEntity(Long id)
          Gets a scheme entity based on the id of the entity
abstract  String getEntityName()
           
 Collection<Group> getGroups(Long entityTypeId, org.ofbiz.core.entity.GenericValue project)
           
 List<org.ofbiz.core.entity.GenericValue> getProjects(org.ofbiz.core.entity.GenericValue scheme)
          Deprecated. you should now use getProject(Scheme)
 List<Project> getProjects(Scheme scheme)
          Gets all projects that are associated with that scheme
 org.ofbiz.core.entity.GenericValue getScheme(Long id)
          Deprecated. use {link #getSchemeObject(Long)}
 org.ofbiz.core.entity.GenericValue getScheme(String name)
          Deprecated. use getSchemeObject(String)
abstract  String getSchemeDesc()
           
abstract  String getSchemeEntityName()
           
 Scheme getSchemeObject(Long id)
          Gets the given scheme by id from the underlying permanent store.
 Scheme getSchemeObject(String name)
          Gets the given scheme by name from the underlying permanent store.
 List<Scheme> getSchemeObjects()
          Gets all scheme objects in the database.
 List<org.ofbiz.core.entity.GenericValue> getSchemes()
          Gets all the Schemes (of the type defined by the subclass) from the database.
 List<org.ofbiz.core.entity.GenericValue> getSchemes(org.ofbiz.core.entity.GenericValue project)
          Get all schemes of a certain type attached to a project.
 List<Scheme> getUnassociatedSchemes()
          Will return all @link Scheme objects that are not currently associated with any projects.
 Collection<User> getUsers(Long permissionId, org.ofbiz.core.entity.GenericValue projectOrIssue)
          Deprecated. Use getUsers(Long, com.atlassian.jira.permission.PermissionContext) instead.
 Collection<User> getUsers(Long permissionId, PermissionContext ctx)
          Retrieves a list of Users that have current permission in a project (e.g.
 void onClearCache(ClearCacheEvent event)
           
 boolean removeEntities(org.ofbiz.core.entity.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
 void removeSchemesFromProject(org.ofbiz.core.entity.GenericValue project)
          Deprecated. should use removeSchemesFromProject(Project) instead
 void removeSchemesFromProject(Project project)
          Removes all schemes from a project
 boolean schemeExists(String name)
          Determine if the scheme exists
 void updateScheme(org.ofbiz.core.entity.GenericValue entity)
          Updates any changes to the scheme
 void updateScheme(Scheme scheme)
          Updates any changes to the scheme object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.jira.scheme.SchemeManager
createSchemeEntity, getEntities, getEntities, getEntities, getEntities, hasSchemeAuthority, hasSchemeAuthority
 

Field Detail

projectManager

protected final ProjectManager projectManager
Constructor Detail

AbstractSchemeManager

protected AbstractSchemeManager(ProjectManager projectManager,
                                AbstractSchemeTypeManager typeManager,
                                PermissionContextFactory permissionContextFactory,
                                SchemeFactory schemeFactory,
                                com.atlassian.core.ofbiz.association.AssociationManager associationManager,
                                OfBizDelegator ofBizDelegator)
Method Detail

onClearCache

public void onClearCache(ClearCacheEvent event)

getSchemeEntityName

public abstract String getSchemeEntityName()

getEntityName

public abstract String getEntityName()

getSchemeDesc

public abstract String getSchemeDesc()

getDefaultNameKey

public abstract String getDefaultNameKey()

getDefaultDescriptionKey

public abstract String getDefaultDescriptionKey()

getAssociationType

@Deprecated
public String getAssociationType()
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.

Returns:
@{link SchemeManager#PROJECT_ASSOCIATION}

copySchemeEntity

public abstract org.ofbiz.core.entity.GenericValue copySchemeEntity(org.ofbiz.core.entity.GenericValue scheme,
                                                                    org.ofbiz.core.entity.GenericValue entity)
                                                             throws org.ofbiz.core.entity.GenericEntityException
Throws:
org.ofbiz.core.entity.GenericEntityException

getScheme

public org.ofbiz.core.entity.GenericValue getScheme(Long id)
                                             throws org.ofbiz.core.entity.GenericEntityException
Deprecated. use {link #getSchemeObject(Long)}

Gets a scheme based on the Id of the scheme

Specified by:
getScheme in interface SchemeManager
Parameters:
id - Id of the scheme
Returns:
The scheme
Throws:
org.ofbiz.core.entity.GenericEntityException

getSchemeObject

public Scheme getSchemeObject(Long id)
                       throws DataAccessException
Gets the given scheme by id from the underlying permanent store.

Specified by:
getSchemeObject in interface SchemeManager
Parameters:
id - the id of the scheme.
Returns:
the scheme.
Throws:
DataAccessException - if there is trouble retrieving from the database.

getSchemeObject

public Scheme getSchemeObject(String name)
                       throws DataAccessException
Gets the given scheme by name from the underlying permanent store.

Specified by:
getSchemeObject in interface SchemeManager
Parameters:
name - the name of the scheme.
Returns:
the scheme.
Throws:
DataAccessException - if there is trouble retrieving from the database.

getScheme

public org.ofbiz.core.entity.GenericValue getScheme(String name)
                                             throws DataAccessException
Deprecated. use getSchemeObject(String)

Gets a scheme based on the name of the scheme

Specified by:
getScheme in interface SchemeManager
Parameters:
name - Name of the scheme
Returns:
The scheme
Throws:
DataAccessException

getSchemes

public List<org.ofbiz.core.entity.GenericValue> getSchemes()
                                                    throws DataAccessException
Gets all the Schemes (of the type defined by the subclass) from the database.

Specified by:
getSchemes in interface SchemeManager
Returns:
List of schemes
Throws:
DataAccessException

getSchemeObjects

public List<Scheme> getSchemeObjects()
                              throws DataAccessException
Description copied from interface: SchemeManager
Gets all scheme objects in the database.

Specified by:
getSchemeObjects in interface SchemeManager
Returns:
the schemes.
Throws:
DataAccessException - if the database is down or equivalent.

getAssociatedSchemes

public List<Scheme> getAssociatedSchemes(boolean withEntitiesComparable)
                                  throws DataAccessException
Gets all associated schemes of a certain type in the database.

Specified by:
getAssociatedSchemes in interface SchemeManager
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 @link Scheme objects
Throws:
DataAccessException

getUnassociatedSchemes

public List<Scheme> getUnassociatedSchemes()
                                    throws DataAccessException
Description copied from interface: SchemeManager
Will return all @link Scheme objects that are not currently associated with any projects.

Specified by:
getUnassociatedSchemes in interface SchemeManager
Returns:
list of @link Scheme objects
Throws:
DataAccessException - if the database is down or equivalent.

getSchemes

public List<org.ofbiz.core.entity.GenericValue> getSchemes(org.ofbiz.core.entity.GenericValue project)
                                                    throws org.ofbiz.core.entity.GenericEntityException
Get all schemes of a certain type attached to a project.

This method may be overridden if you want to return a default value for projects without a scheme associated.

Specified by:
getSchemes in interface SchemeManager
Parameters:
project - The project that the schemes are attached to
Returns:
List of schemes
Throws:
org.ofbiz.core.entity.GenericEntityException

getEntity

public org.ofbiz.core.entity.GenericValue getEntity(Long id)
                                             throws org.ofbiz.core.entity.GenericEntityException
Gets a scheme entity based on the id of the entity

Specified by:
getEntity in interface SchemeManager
Parameters:
id - The id of the entity
Returns:
The scheme entity object
Throws:
org.ofbiz.core.entity.GenericEntityException

getEntities

public List<org.ofbiz.core.entity.GenericValue> getEntities(String type,
                                                            String parameter)
                                                     throws org.ofbiz.core.entity.GenericEntityException
Get all entity records with a particular parameter

Specified by:
getEntities in interface SchemeManager
Parameters:
type - The type of the scheme you wish to get, eg. 'user', 'group', 'projectrole'
parameter - The parameter in the entity
Returns:
List of (GenericValue) entities
Throws:
org.ofbiz.core.entity.GenericEntityException

getEntities

public List<org.ofbiz.core.entity.GenericValue> getEntities(org.ofbiz.core.entity.GenericValue scheme)
                                                     throws org.ofbiz.core.entity.GenericEntityException
Get all Scheme entity records for a particular scheme

Specified by:
getEntities in interface SchemeManager
Parameters:
scheme - The scheme that the entities belong to
Returns:
List of (GenericValue) entities
Throws:
org.ofbiz.core.entity.GenericEntityException

schemeExists

public boolean schemeExists(String name)
                     throws org.ofbiz.core.entity.GenericEntityException
Determine if the scheme exists

Specified by:
schemeExists in interface SchemeManager
Parameters:
name - The name of the scheme
Returns:
True / False
Throws:
org.ofbiz.core.entity.GenericEntityException

createScheme

public org.ofbiz.core.entity.GenericValue createScheme(String name,
                                                       String description)
                                                throws org.ofbiz.core.entity.GenericEntityException
Creates a new scheme

Specified by:
createScheme in interface SchemeManager
Parameters:
name - The name of the new scheme
description - The description of the new scheme
Returns:
The new scheme object
Throws:
org.ofbiz.core.entity.GenericEntityException

createSchemeAndEntities

public Scheme createSchemeAndEntities(Scheme scheme)
                               throws DataAccessException
Specified by:
createSchemeAndEntities in interface SchemeManager
Throws:
DataAccessException

updateScheme

public void updateScheme(org.ofbiz.core.entity.GenericValue entity)
                  throws org.ofbiz.core.entity.GenericEntityException
Updates any changes to the scheme

Specified by:
updateScheme in interface SchemeManager
Parameters:
entity - The modified scheme
Throws:
org.ofbiz.core.entity.GenericEntityException

updateScheme

public void updateScheme(Scheme scheme)
                  throws DataAccessException
Updates any changes to the scheme object. This does not include changes to the scheme entities.

Specified by:
updateScheme in interface SchemeManager
Parameters:
scheme - The modified scheme object
Throws:
DataAccessException

deleteScheme

public void deleteScheme(Long id)
                  throws org.ofbiz.core.entity.GenericEntityException
Deletes a scheme from the database

Specified by:
deleteScheme in interface SchemeManager
Parameters:
id - Id of the scheme to be deleted
Throws:
org.ofbiz.core.entity.GenericEntityException

addSchemeToProject

@Deprecated
public void addSchemeToProject(org.ofbiz.core.entity.GenericValue project,
                                          org.ofbiz.core.entity.GenericValue scheme)
                        throws org.ofbiz.core.entity.GenericEntityException
Deprecated. should use addSchemeToProject(Project, Scheme) instead

Adds a scheme to a particular project

Specified by:
addSchemeToProject in interface SchemeManager
Parameters:
project - The project that the scheme is to be added to
scheme - The scheme to be added
Throws:
org.ofbiz.core.entity.GenericEntityException

addSchemeToProject

public void addSchemeToProject(Project project,
                               Scheme scheme)
                        throws DataAccessException
Adds a scheme to a particular project

Specified by:
addSchemeToProject in interface SchemeManager
Parameters:
project - The project that the scheme is to be added to
scheme - The scheme to be added
Throws:
DataAccessException

removeSchemesFromProject

public void removeSchemesFromProject(Project project)
                              throws DataAccessException
Removes all schemes from a project

Specified by:
removeSchemesFromProject in interface SchemeManager
Parameters:
project - The project that all schemes are to be deleted from
Throws:
DataAccessException

removeSchemesFromProject

@Deprecated
public void removeSchemesFromProject(org.ofbiz.core.entity.GenericValue project)
                              throws org.ofbiz.core.entity.GenericEntityException
Deprecated. should use removeSchemesFromProject(Project) instead

Removes all schemes from a project

Specified by:
removeSchemesFromProject in interface SchemeManager
Parameters:
project - The project that all schemes are to be deleted from
Throws:
org.ofbiz.core.entity.GenericEntityException

deleteEntity

public void deleteEntity(Long id)
                  throws DataAccessException
Deletes an entity with the given id from the database.

Specified by:
deleteEntity in interface SchemeManager
Parameters:
id - The id of the entity to be deleted
Throws:
DataAccessException

getProjects

@Deprecated
public List<org.ofbiz.core.entity.GenericValue> getProjects(org.ofbiz.core.entity.GenericValue scheme)
                                                     throws org.ofbiz.core.entity.GenericEntityException
Deprecated. you should now use getProject(Scheme)

Gets all projects that are associated with that scheme

Specified by:
getProjects in interface SchemeManager
Parameters:
scheme - The scheme used to get all projects
Returns:
List of (GenericValue) projects
Throws:
org.ofbiz.core.entity.GenericEntityException

getProjects

public List<Project> getProjects(Scheme scheme)
                          throws DataAccessException
Gets all projects that are associated with that scheme

Specified by:
getProjects in interface SchemeManager
Parameters:
scheme - The scheme used to get all projects
Returns:
List of Project's
Throws:
DataAccessException

createDefaultScheme

public org.ofbiz.core.entity.GenericValue createDefaultScheme()
                                                       throws org.ofbiz.core.entity.GenericEntityException
Creates a default scheme, with an id of 0

Specified by:
createDefaultScheme in interface SchemeManager
Returns:
The new permission scheme object
Throws:
org.ofbiz.core.entity.GenericEntityException

removeEntities

public boolean removeEntities(String type,
                              String parameter)
                       throws RemoveException
Removes all scheme entities with this parameter

Specified by:
removeEntities in interface SchemeManager
Parameters:
parameter - must NOT be null
type - the 'type' of entity you are deleting, eg 'group', 'user', 'projectrole'
Returns:
true always (legacy)
Throws:
RemoveException

removeEntities

public boolean removeEntities(org.ofbiz.core.entity.GenericValue scheme,
                              Long entityTypeId)
                       throws RemoveException
Retrieves all the entites for this permission and then removes them.

Specified by:
removeEntities in interface SchemeManager
Parameters:
scheme - to remove entites from must NOT be null
entityTypeId - to remove
Returns:
True all the time (legacy)
Throws:
RemoveException

getDefaultScheme

public org.ofbiz.core.entity.GenericValue getDefaultScheme()
                                                    throws org.ofbiz.core.entity.GenericEntityException
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.

Specified by:
getDefaultScheme in interface SchemeManager
Returns:
The default scheme
Throws:
org.ofbiz.core.entity.GenericEntityException

addDefaultSchemeToProject

public void addDefaultSchemeToProject(org.ofbiz.core.entity.GenericValue project)
                               throws org.ofbiz.core.entity.GenericEntityException
Adds the default scheme to a particular project

Specified by:
addDefaultSchemeToProject in interface SchemeManager
Parameters:
project - The project that the scheme is to be added to
Throws:
org.ofbiz.core.entity.GenericEntityException

addDefaultSchemeToProject

public void addDefaultSchemeToProject(Project project)
                               throws DataAccessException
Throws:
DataAccessException

copyScheme

public org.ofbiz.core.entity.GenericValue copyScheme(org.ofbiz.core.entity.GenericValue scheme)
                                              throws org.ofbiz.core.entity.GenericEntityException
Copys a scheme, giving the new scheme the same entities as the original one

Specified by:
copyScheme in interface SchemeManager
Parameters:
scheme - The permission scheme to be copied
Returns:
The new permission scheme
Throws:
org.ofbiz.core.entity.GenericEntityException

flushProjectSchemes

protected void flushProjectSchemes()

getGroups

public Collection<Group> getGroups(Long entityTypeId,
                                   org.ofbiz.core.entity.GenericValue project)
Specified by:
getGroups in interface SchemeManager

getUsers

public Collection<User> getUsers(Long permissionId,
                                 PermissionContext ctx)
Retrieves a list of Users that have current permission in a project (e.g. projects schemes)

Specified by:
getUsers in interface SchemeManager
Parameters:
permissionId - Permission ID.
ctx - Context for evaluating permission request. Includes issue or project object.
Returns:
A collection of User objects.

getUsers

@Deprecated
public Collection<User> getUsers(Long permissionId,
                                            org.ofbiz.core.entity.GenericValue projectOrIssue)
Deprecated. Use getUsers(Long, com.atlassian.jira.permission.PermissionContext) instead.

Specified by:
getUsers in interface SchemeManager

createSchemeGenericValue

protected org.ofbiz.core.entity.GenericValue createSchemeGenericValue(Map<String,Object> values)
                                                               throws org.ofbiz.core.entity.GenericEntityException
Throws:
org.ofbiz.core.entity.GenericEntityException


Copyright © 2002-2011 Atlassian. All Rights Reserved.