com.atlassian.jira.permission
Class DefaultPermissionSchemeManager

java.lang.Object
  extended by com.atlassian.jira.scheme.AbstractSchemeManager
      extended by com.atlassian.jira.permission.DefaultPermissionSchemeManager
All Implemented Interfaces:
Startable, PermissionSchemeManager, SchemeManager
Direct Known Subclasses:
WorkflowBasedPermissionSchemeManager

public class DefaultPermissionSchemeManager
extends AbstractSchemeManager
implements PermissionSchemeManager, Startable

This class is used to handle Permission Schemes.

Permission Schemes are created, removed and edited through this class


Field Summary
 
Fields inherited from class com.atlassian.jira.scheme.AbstractSchemeManager
eventPublisher, projectManager, schemeFactory, securityTypeManager
 
Fields inherited from interface com.atlassian.jira.scheme.SchemeManager
PROJECT_ASSOCIATION
 
Constructor Summary
DefaultPermissionSchemeManager(ProjectManager projectManager, PermissionTypeManager permissionTypeManager, PermissionContextFactory permissionContextFactory, OfBizDelegator delegator, SchemeFactory schemeFactory, NodeAssociationStore nodeAssociationStore, GroupManager groupManager, com.atlassian.event.api.EventPublisher eventPublisher, com.atlassian.cache.CacheManager cacheManager)
           
 
Method Summary
protected  AbstractSchemeCopiedEvent createSchemeCopiedEvent(Scheme oldScheme, Scheme newScheme)
           
protected  AbstractSchemeEvent createSchemeCreatedEvent(Scheme scheme)
           
 org.ofbiz.core.entity.GenericValue createSchemeEntity(org.ofbiz.core.entity.GenericValue scheme, SchemeEntity schemeEntity)
          Create a new permission record in the database
protected  AbstractSchemeEntityEvent createSchemeEntityDeletedEvent(org.ofbiz.core.entity.GenericValue entity)
           
protected  org.ofbiz.core.entity.GenericValue createSchemeEntityNoEvent(org.ofbiz.core.entity.GenericValue scheme, SchemeEntity schemeEntity)
           
protected  AbstractSchemeRemovedFromProjectEvent createSchemeRemovedFromProjectEvent(Long schemeId, Long projectId)
           
protected  AbstractSchemeUpdatedEvent createSchemeUpdatedEvent(Scheme scheme, Scheme originalScheme)
           
 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<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(org.ofbiz.core.entity.GenericValue scheme, Long permissionId)
          Get all Generic Value permission records for a particular scheme and permission Id
 List<org.ofbiz.core.entity.GenericValue> getEntities(org.ofbiz.core.entity.GenericValue scheme, Long permissionId, String parameter)
          Get all Generic Value permission records for a particular scheme and permission Id
 List<org.ofbiz.core.entity.GenericValue> getEntities(org.ofbiz.core.entity.GenericValue scheme, Long permissionId, String type, String parameter)
          Get all Generic Value permission records for a particular scheme and permission Id
 List<org.ofbiz.core.entity.GenericValue> getEntities(org.ofbiz.core.entity.GenericValue scheme, String entityTypeId)
           
 List<org.ofbiz.core.entity.GenericValue> getEntities(org.ofbiz.core.entity.GenericValue scheme, String type, Long permissionId)
          Get all Generic Value permission records for a particular scheme and permission Id
 String getEntityName()
           
 Collection<com.atlassian.crowd.embedded.api.Group> getGroups(Long entityTypeId, org.ofbiz.core.entity.GenericValue project)
           
 Collection<com.atlassian.crowd.embedded.api.Group> getGroups(Long entityTypeId, Project project)
           
 String getSchemeDesc()
           
 String getSchemeEntityName()
           
 Collection<org.ofbiz.core.entity.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.
 boolean hasSchemeAuthority(Long permissionId, org.ofbiz.core.entity.GenericValue project)
          Checks to see if there is an anyone permission for that permission type.
 boolean hasSchemeAuthority(Long permissionId, org.ofbiz.core.entity.GenericValue project, com.atlassian.crowd.embedded.api.User user, boolean issueCreation)
          Checks to see if the user has any specific permissions for that permission type.
protected  SchemeEntity makeSchemeEntity(org.ofbiz.core.entity.GenericValue entity)
           
 void onClearCache(ClearCacheEvent event)
           
 boolean removeEntities(org.ofbiz.core.entity.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.
 
Methods inherited from class com.atlassian.jira.scheme.AbstractSchemeManager
addDefaultSchemeToProject, addDefaultSchemeToProject, addSchemeToProject, addSchemeToProject, copyScheme, copyScheme, createDefaultScheme, createScheme, createSchemeAndEntities, createSchemeGenericValue, createSchemeNoEvent, createSchemeObject, flushProjectSchemes, getAssociatedSchemes, getAssociationType, getDefaultScheme, getDefaultSchemeObject, getEntities, getEntity, getNameForCopy, getProjects, getProjects, getScheme, getScheme, getSchemeFor, getSchemeObject, getSchemeObject, getSchemeObjects, getSchemes, getSchemes, getUnassociatedSchemes, getUsers, getUsers, getUsers, getUsers, removeSchemesFromProject, removeSchemesFromProject, schemeExists, updateScheme, updateScheme
 
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.permission.PermissionSchemeManager
getAssociationType
 
Methods inherited from interface com.atlassian.jira.scheme.SchemeManager
addDefaultSchemeToProject, addDefaultSchemeToProject, addSchemeToProject, addSchemeToProject, copyScheme, copyScheme, createDefaultScheme, createScheme, createSchemeAndEntities, createSchemeObject, getAssociatedSchemes, getDefaultScheme, getDefaultSchemeObject, getEntities, getEntity, getProjects, getProjects, getScheme, getScheme, getSchemeFor, getSchemeObject, getSchemeObject, getSchemeObjects, getSchemes, getSchemes, getUnassociatedSchemes, getUsers, getUsers, getUsers, getUsers, removeSchemesFromProject, removeSchemesFromProject, schemeExists, updateScheme, updateScheme
 

Constructor Detail

DefaultPermissionSchemeManager

public DefaultPermissionSchemeManager(ProjectManager projectManager,
                                      PermissionTypeManager permissionTypeManager,
                                      PermissionContextFactory permissionContextFactory,
                                      OfBizDelegator delegator,
                                      SchemeFactory schemeFactory,
                                      NodeAssociationStore nodeAssociationStore,
                                      GroupManager groupManager,
                                      com.atlassian.event.api.EventPublisher eventPublisher,
                                      com.atlassian.cache.CacheManager cacheManager)
Method Detail

start

public void start()
           throws Exception
Registers this CachingFieldConfigContextPersister's cache in the JIRA instrumentation.

Specified by:
start in interface Startable
Throws:
Exception

onClearCache

public void onClearCache(ClearCacheEvent event)
Overrides:
onClearCache in class AbstractSchemeManager

getSchemeEntityName

public String getSchemeEntityName()
Specified by:
getSchemeEntityName in interface PermissionSchemeManager
Specified by:
getSchemeEntityName in class AbstractSchemeManager

getEntityName

public String getEntityName()
Specified by:
getEntityName in interface PermissionSchemeManager
Specified by:
getEntityName in class AbstractSchemeManager

getSchemeDesc

public String getSchemeDesc()
Specified by:
getSchemeDesc in interface PermissionSchemeManager
Specified by:
getSchemeDesc in class AbstractSchemeManager

getDefaultNameKey

public String getDefaultNameKey()
Specified by:
getDefaultNameKey in class AbstractSchemeManager

getDefaultDescriptionKey

public String getDefaultDescriptionKey()
Specified by:
getDefaultDescriptionKey in class AbstractSchemeManager

createSchemeCreatedEvent

protected AbstractSchemeEvent createSchemeCreatedEvent(Scheme scheme)
Specified by:
createSchemeCreatedEvent in class AbstractSchemeManager

createSchemeCopiedEvent

protected AbstractSchemeCopiedEvent createSchemeCopiedEvent(@Nonnull
                                                            Scheme oldScheme,
                                                            @Nonnull
                                                            Scheme newScheme)
Specified by:
createSchemeCopiedEvent in class AbstractSchemeManager

createSchemeUpdatedEvent

protected AbstractSchemeUpdatedEvent createSchemeUpdatedEvent(Scheme scheme,
                                                              Scheme originalScheme)
Specified by:
createSchemeUpdatedEvent in class AbstractSchemeManager

deleteScheme

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

Specified by:
deleteScheme in interface SchemeManager
Overrides:
deleteScheme in class AbstractSchemeManager
Parameters:
id - Id of the scheme to be deleted
Throws:
org.ofbiz.core.entity.GenericEntityException - If a DB error occurs

getEntities

public List<org.ofbiz.core.entity.GenericValue> getEntities(org.ofbiz.core.entity.GenericValue scheme,
                                                            Long permissionId)
                                                     throws org.ofbiz.core.entity.GenericEntityException
Get all Generic Value permission records for a particular scheme and permission Id

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

getEntities

public List<org.ofbiz.core.entity.GenericValue> getEntities(org.ofbiz.core.entity.GenericValue scheme,
                                                            Long permissionId,
                                                            String parameter)
                                                     throws org.ofbiz.core.entity.GenericEntityException
Get all Generic Value permission records for a particular scheme and permission Id

Specified by:
getEntities in interface SchemeManager
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:
org.ofbiz.core.entity.GenericEntityException

getEntities

public List<org.ofbiz.core.entity.GenericValue> getEntities(org.ofbiz.core.entity.GenericValue scheme,
                                                            Long permissionId,
                                                            String type,
                                                            String parameter)
                                                     throws org.ofbiz.core.entity.GenericEntityException
Get all Generic Value permission records for a particular scheme and permission Id

Specified by:
getEntities in interface PermissionSchemeManager
Parameters:
scheme - The scheme that the permissions belong to
permissionId - The Id of the permission
parameter - The permission parameter (group name etc)
type - The type of the permission(Group, Current Reporter etc)
Returns:
List of (GenericValue) permissions
Throws:
org.ofbiz.core.entity.GenericEntityException

getEntities

public List<org.ofbiz.core.entity.GenericValue> getEntities(org.ofbiz.core.entity.GenericValue scheme,
                                                            String type,
                                                            Long permissionId)
                                                     throws org.ofbiz.core.entity.GenericEntityException
Get all Generic Value permission records for a particular scheme and permission Id

Specified by:
getEntities in interface SchemeManager
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:
org.ofbiz.core.entity.GenericEntityException

getEntities

public List<org.ofbiz.core.entity.GenericValue> getEntities(org.ofbiz.core.entity.GenericValue scheme,
                                                            String entityTypeId)
                                                     throws org.ofbiz.core.entity.GenericEntityException
Specified by:
getEntities in interface SchemeManager
Throws:
org.ofbiz.core.entity.GenericEntityException

createSchemeEntity

public org.ofbiz.core.entity.GenericValue createSchemeEntity(org.ofbiz.core.entity.GenericValue scheme,
                                                             SchemeEntity schemeEntity)
                                                      throws org.ofbiz.core.entity.GenericEntityException
Create a new permission record in the database

Specified by:
createSchemeEntity in interface SchemeManager
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:
org.ofbiz.core.entity.GenericEntityException

createSchemeEntityNoEvent

protected org.ofbiz.core.entity.GenericValue createSchemeEntityNoEvent(org.ofbiz.core.entity.GenericValue scheme,
                                                                       SchemeEntity schemeEntity)
                                                                throws org.ofbiz.core.entity.GenericEntityException
Specified by:
createSchemeEntityNoEvent in class AbstractSchemeManager
Throws:
org.ofbiz.core.entity.GenericEntityException

deleteEntity

public void deleteEntity(Long id)
                  throws DataAccessException
Deletes a permission from the database

Specified by:
deleteEntity in interface SchemeManager
Overrides:
deleteEntity in class AbstractSchemeManager
Parameters:
id - The id of the permission to be deleted
Throws:
DataAccessException

createSchemeEntityDeletedEvent

protected AbstractSchemeEntityEvent createSchemeEntityDeletedEvent(org.ofbiz.core.entity.GenericValue entity)
Specified by:
createSchemeEntityDeletedEvent in class AbstractSchemeManager

makeSchemeEntity

protected SchemeEntity makeSchemeEntity(org.ofbiz.core.entity.GenericValue entity)
Specified by:
makeSchemeEntity in class AbstractSchemeManager

getEntities

public List<org.ofbiz.core.entity.GenericValue> getEntities(org.ofbiz.core.entity.GenericValue scheme)
                                                     throws org.ofbiz.core.entity.GenericEntityException
Description copied from interface: SchemeManager
Get all Scheme entity records for a particular scheme

Specified by:
getEntities in interface SchemeManager
Overrides:
getEntities in class AbstractSchemeManager
Parameters:
scheme - The scheme that the entities belong to
Returns:
List of (GenericValue) entities
Throws:
org.ofbiz.core.entity.GenericEntityException - If a DB error occurs

removeEntities

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

Specified by:
removeEntities in interface SchemeManager
Overrides:
removeEntities in class AbstractSchemeManager
Parameters:
type - the type of scheme entity you wish to remove 'user', 'group', 'projectrole'
parameter - must NOT be null
Returns:
true always (legacy)
Throws:
RemoveException - if the delete fails (DB error)

removeEntities

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

Specified by:
removeEntities in interface SchemeManager
Overrides:
removeEntities in class AbstractSchemeManager
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
Throws:
RemoveException

hasSchemeAuthority

public boolean hasSchemeAuthority(Long permissionId,
                                  org.ofbiz.core.entity.GenericValue project)
Checks to see if there is an anyone permission for that permission type. Specific permissions can things such as Current Reporter, Project Lead, Single User etc.

Specified by:
hasSchemeAuthority in interface SchemeManager
Parameters:
permissionId - The permission to check against, must not be global permission
project - The entity to check for the permission. This entity must be a project
Returns:
true if the user has the permission otherwise false

hasSchemeAuthority

public boolean hasSchemeAuthority(Long permissionId,
                                  org.ofbiz.core.entity.GenericValue project,
                                  com.atlassian.crowd.embedded.api.User user,
                                  boolean issueCreation)
Checks to see if the user has any specific permissions for that permission type. Specific permissions can things such as Current Reporter, Project Lead, Single User etc.

Specified by:
hasSchemeAuthority in interface SchemeManager
Parameters:
permissionId - The permission to check against, must not be global permission
project - The entity to check for the permission. This entity must be a project
user - The user to check for the permission. The user must NOT be null
issueCreation - true if this call is for a "Create Issue" permission.
Returns:
true if the user has the permission otherwise false

getGroups

public Collection<com.atlassian.crowd.embedded.api.Group> getGroups(Long entityTypeId,
                                                                    Project project)
Specified by:
getGroups in interface SchemeManager
Overrides:
getGroups in class AbstractSchemeManager

getGroups

public Collection<com.atlassian.crowd.embedded.api.Group> getGroups(Long entityTypeId,
                                                                    org.ofbiz.core.entity.GenericValue project)
Specified by:
getGroups in interface SchemeManager
Overrides:
getGroups in class AbstractSchemeManager

createSchemeRemovedFromProjectEvent

protected AbstractSchemeRemovedFromProjectEvent createSchemeRemovedFromProjectEvent(Long schemeId,
                                                                                    Long projectId)
Specified by:
createSchemeRemovedFromProjectEvent in class AbstractSchemeManager

flushSchemeEntities

public void flushSchemeEntities()
Specified by:
flushSchemeEntities in interface PermissionSchemeManager

getSchemesContainingEntity

public Collection<org.ofbiz.core.entity.GenericValue> getSchemesContainingEntity(String type,
                                                                                 String parameter)
Description copied from interface: PermissionSchemeManager
This is a method that is meant to quickly get you all the schemes that contain an entity of the specified type and parameter.

Specified by:
getSchemesContainingEntity in interface PermissionSchemeManager
Parameters:
type - is the entity type
parameter - is the scheme entries parameter value
Returns:
Collection of GenericValues that represents a scheme


Copyright © 2002-2014 Atlassian. All Rights Reserved.