Class AbstractSchemeManager

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

public abstract class AbstractSchemeManager extends Object implements SchemeManager, InitializingComponent
  • Field Details

    • projectManager

      protected final ProjectManager projectManager
    • securityTypeManager

      protected final SecurityTypeManager securityTypeManager
    • schemeFactory

      protected final SchemeFactory schemeFactory
    • groupManager

      protected final GroupManager groupManager
    • eventPublisher

      protected final com.atlassian.event.api.EventPublisher eventPublisher
    • cacheManager

      protected final com.atlassian.cache.CacheManager cacheManager
  • Constructor Details

  • Method Details

    • afterInstantiation

      public void afterInstantiation() throws Exception
      Description copied from interface: InitializingComponent
      Called after all the beans are constructed and the ApplicationContext is fully populated. Order of execution is order of bean creation, driven by InitializingComponentProcessor.
      Specified by:
      afterInstantiation in interface InitializingComponent
      Throws:
      Exception
    • 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}
    • createSchemeEntityNoEvent

      protected abstract org.ofbiz.core.entity.GenericValue createSchemeEntityNoEvent(org.ofbiz.core.entity.GenericValue scheme, SchemeEntity schemeEntity) throws org.ofbiz.core.entity.GenericEntityException
      Throws:
      org.ofbiz.core.entity.GenericEntityException
    • getScheme

      public org.ofbiz.core.entity.GenericValue getScheme(Long id)
      Description copied from interface: SchemeManager
      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
    • getSchemeObject

      @Nullable public Scheme getSchemeObject(Long id) throws DataAccessException
      Description copied from interface: SchemeManager
      Gets a scheme by id from the database.
      Specified by:
      getSchemeObject in interface SchemeManager
      Parameters:
      id - the id of the scheme to get.
      Returns:
      the Scheme
      Throws:
      DataAccessException - if there is trouble retrieving from the database.
    • getSchemeObject

      @Nullable public Scheme getSchemeObject(String name) throws DataAccessException
      Description copied from interface: SchemeManager
      Gets a scheme by name from the database.
      Specified by:
      getSchemeObject in interface SchemeManager
      Parameters:
      name - the name of the scheme to get.
      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
      Description copied from interface: SchemeManager
      Gets a scheme by name from the database.
      Specified by:
      getScheme in interface SchemeManager
      Parameters:
      name - the name of the scheme to get.
      Returns:
      the Scheme
      Throws:
      DataAccessException
    • getSchemes

      public List<org.ofbiz.core.entity.GenericValue> getSchemes() throws DataAccessException
      Description copied from interface: SchemeManager
      Gets all the Schemes (of the type defined by the subclass) from the database.
      Specified by:
      getSchemes in interface SchemeManager
      Returns:
      the 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
      Description copied from interface: SchemeManager
      Gets all schemes of this type in the database taht are associated with at least one project.
      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 associated schemes
      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
      Description copied from interface: SchemeManager
      Get all schemes of this type attached to the given project.
      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 - If a DB error occurs
    • getSchemeFor

      @Nullable public Scheme getSchemeFor(Project project)
      Description copied from interface: SchemeManager
      Get the scheme of this type attached to the given project.
      Specified by:
      getSchemeFor in interface SchemeManager
      Parameters:
      project - The project
      Returns:
      The scheme associated with this project.
      See Also:
    • getSchemeIdFor

      @Nullable public Long getSchemeIdFor(Project project)
      Description copied from interface: SchemeManager
      Get the scheme of this type attached to the given project.
      Specified by:
      getSchemeIdFor in interface SchemeManager
      Parameters:
      project - The project
      Returns:
      The ID of the scheme associated with this project.
      See Also:
    • getEntity

      public org.ofbiz.core.entity.GenericValue getEntity(Long id)
      Description copied from interface: SchemeManager
      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
    • getEntities

      public List<org.ofbiz.core.entity.GenericValue> getEntities(String type, String parameter) throws org.ofbiz.core.entity.GenericEntityException
      Description copied from interface: SchemeManager
      Get all entity records with a particular parameter
      Specified by:
      getEntities in interface SchemeManager
      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:
      org.ofbiz.core.entity.GenericEntityException - If a DB error occurs
    • getEntitiesByIds

      public List<org.ofbiz.core.entity.GenericValue> getEntitiesByIds(List<Long> ids)
      Description copied from interface: SchemeManager
      Get all entity records for a list of ids
      Specified by:
      getEntitiesByIds in interface SchemeManager
      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
    • 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
      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
    • schemeExists

      public boolean schemeExists(String name)
      Description copied from interface: SchemeManager
      Determine if the given scheme name exists.
      Specified by:
      schemeExists in interface SchemeManager
      Parameters:
      name - The name of the scheme
      Returns:
      true is the schem exists.
    • createScheme

      public org.ofbiz.core.entity.GenericValue createScheme(String name, String description) throws org.ofbiz.core.entity.GenericEntityException
      Description copied from interface: SchemeManager
      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 - If a DB error occurs
    • createSchemeNoEvent

      protected org.ofbiz.core.entity.GenericValue createSchemeNoEvent(String name, String description) throws org.ofbiz.core.entity.GenericEntityException
      Throws:
      org.ofbiz.core.entity.GenericEntityException
    • createSchemeCreatedEvent

      protected abstract AbstractSchemeEvent createSchemeCreatedEvent(Scheme scheme)
    • createSchemeObject

      public Scheme createSchemeObject(String name, String description)
      Description copied from interface: SchemeManager
      Creates a new scheme
      Specified by:
      createSchemeObject in interface SchemeManager
      Parameters:
      name - The name of the new scheme
      description - The description of the new scheme
      Returns:
      The new scheme object
    • createSchemeAndEntities

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

      protected abstract AbstractSchemeUpdatedEvent createSchemeUpdatedEvent(Scheme scheme, Scheme originalScheme)
    • updateScheme

      public void updateScheme(org.ofbiz.core.entity.GenericValue entity) throws org.ofbiz.core.entity.GenericEntityException
      Description copied from interface: SchemeManager
      Updates any changes to the given scheme
      Specified by:
      updateScheme in interface SchemeManager
      Parameters:
      entity - The modified scheme
      Throws:
      org.ofbiz.core.entity.GenericEntityException - If a DB error occurs
    • updateScheme

      public void updateScheme(Scheme scheme) throws DataAccessException
      Description copied from interface: SchemeManager
      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
      Description copied from interface: SchemeManager
      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 - If a DB error occurs
    • addSchemeToProject

      @Deprecated public void addSchemeToProject(org.ofbiz.core.entity.GenericValue project, org.ofbiz.core.entity.GenericValue scheme) throws org.ofbiz.core.entity.GenericEntityException
      Deprecated.
      Description copied from interface: SchemeManager
      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 - If a DB error occurs
    • addSchemeToProject

      public void addSchemeToProject(Project project, Scheme scheme) throws DataAccessException
      Description copied from interface: SchemeManager
      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
    • createSchemeAddedToProjectEvent

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

      public void removeSchemesFromProject(Project project) throws DataAccessException
      Description copied from interface: SchemeManager
      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.
      Description copied from interface: SchemeManager
      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 - If a DB error occurs
    • createSchemeRemovedFromProjectEvent

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

      public void deleteEntity(Long id) throws DataAccessException
      Description copied from interface: SchemeManager
      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
    • deleteEntities

      public void deleteEntities(Iterable<Long> ids) throws DataAccessException
      Description copied from interface: SchemeManager
      Deletes a collection of entities from the database.
      Specified by:
      deleteEntities in interface SchemeManager
      Parameters:
      ids - a collection entity ids to be deleted.
      Throws:
      DataAccessException
    • swapParameterForEntitiesOfType

      public void swapParameterForEntitiesOfType(String type, String parameter, String resultingParameter)
      Description copied from interface: SchemeManager
      Swaps all parameters of entities with the given type scheme to the given resulting parameter
      Specified by:
      swapParameterForEntitiesOfType in interface SchemeManager
      Parameters:
      type - the 'type' of entity you are swapping, eg 'group', 'user', 'projectrole'
      parameter - must NOT be null
    • makeSchemeEntity

      protected abstract SchemeEntity makeSchemeEntity(org.ofbiz.core.entity.GenericValue schemeEntityGV)
    • createSchemeEntityDeletedEvent

      @Nullable protected abstract Object createSchemeEntityDeletedEvent(org.ofbiz.core.entity.GenericValue entity)
    • getProjects

      public List<Project> getProjects(Scheme scheme) throws DataAccessException
      Description copied from interface: SchemeManager
      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
      Description copied from interface: SchemeManager
      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 - If a DB error occurs
    • removeEntities

      public boolean removeEntities(String type, String parameter) throws RemoveException
      Description copied from interface: SchemeManager
      Removes all scheme entities with this parameter and type
      Specified by:
      removeEntities in interface SchemeManager
      Parameters:
      type - the 'type' of entity you are deleting, eg 'group', 'user', 'projectrole'
      parameter - must NOT be null
      Returns:
      true always (legacy)
      Throws:
      RemoveException - if the delete fails (DB error)
    • removeEntitiesReturningAffectedEntities

      public Collection<org.ofbiz.core.entity.GenericValue> removeEntitiesReturningAffectedEntities(String type, String parameter) throws RemoveException
      Description copied from interface: SchemeManager
      Removes all scheme entities with this parameter and type
      Specified by:
      removeEntitiesReturningAffectedEntities in interface SchemeManager
      Parameters:
      type - the 'type' of entity you are deleting, eg 'group', 'user', 'projectrole'
      parameter - must NOT be null
      Returns:
      a collection of the entities that were removed
      Throws:
      RemoveException - if the delete fails (DB error)
    • removeEntities

      public boolean removeEntities(org.ofbiz.core.entity.GenericValue scheme, Long entityTypeId) throws RemoveException
      Description copied from interface: SchemeManager
      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 - if the delete fails (DB error)
    • getDefaultScheme

      public org.ofbiz.core.entity.GenericValue getDefaultScheme() throws org.ofbiz.core.entity.GenericEntityException
      Description copied from interface: SchemeManager
      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 - If a DB error occurs
    • getDefaultSchemeObject

      public Scheme getDefaultSchemeObject()
      Description copied from interface: SchemeManager
      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:
      getDefaultSchemeObject in interface SchemeManager
      Returns:
      The default scheme
    • addDefaultSchemeToProject

      public void addDefaultSchemeToProject(org.ofbiz.core.entity.GenericValue project) throws org.ofbiz.core.entity.GenericEntityException
      Description copied from interface: SchemeManager
      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 - If a DB error occurs
    • addDefaultSchemeToProject

      public void addDefaultSchemeToProject(Project project) throws DataAccessException
      Description copied from interface: SchemeManager
      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:
      DataAccessException
    • copyScheme

      public org.ofbiz.core.entity.GenericValue copyScheme(org.ofbiz.core.entity.GenericValue oldScheme) throws org.ofbiz.core.entity.GenericEntityException
      Description copied from interface: SchemeManager
      Copys a scheme, giving the new scheme the same entities as the original one
      Specified by:
      copyScheme in interface SchemeManager
      Parameters:
      oldScheme - The permission scheme to be copied
      Returns:
      The new permission scheme
      Throws:
      org.ofbiz.core.entity.GenericEntityException - If a DB error occurs
    • getNameForCopy

      public String getNameForCopy(String originalName, Integer abbreviateTo)
    • createSchemeCopiedEvent

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

      public Scheme copyScheme(Scheme oldScheme)
      Description copied from interface: SchemeManager
      Copys a scheme, giving the new scheme the same entities as the original one
      Specified by:
      copyScheme in interface SchemeManager
      Parameters:
      oldScheme - The permission scheme to be copied
      Returns:
      The new permission scheme
    • flushProjectSchemes

      protected void flushProjectSchemes()
    • getGroups

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

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

      public Collection<ApplicationUser> getUsers(Long permissionId, org.ofbiz.core.entity.GenericValue projectOrIssue)
      Specified by:
      getUsers in interface SchemeManager
    • getUsers

      public Collection<ApplicationUser> getUsers(Long permissionId, Project project)
      Specified by:
      getUsers in interface SchemeManager
    • getUsers

      public Collection<ApplicationUser> getUsers(Long permissionId, Issue issue)
      Specified by:
      getUsers in interface SchemeManager
    • getUsers

      public Collection<ApplicationUser> getUsers(Long permissionId, PermissionContext ctx)
      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
    • getApplicationI18n

      protected I18nHelper getApplicationI18n()