public class

CachingProjectComponentStore

extends Object
implements ProjectComponentStore Startable
java.lang.Object
   ↳ com.atlassian.jira.bc.project.component.CachingProjectComponentStore

Class Overview

Decorates an implementation of the project component delegateStore with caching. The actual delegateStore implementation is delegated so this class is a Composite and also a Decorator.

Summary

Public Constructors
CachingProjectComponentStore(ProjectComponentStore delegateStore, CacheManager cacheManager, ClusterLockService clusterLockService)
Public Methods
boolean containsName(String name, Long projectId)
Checks whether component with specified name is stored.
void delete(Long componentId)
Removes the component from the persistent storage and a cache.
void deleteAllComponents(Long projectId)
Deletes all components in given project.
MutableProjectComponent find(Long id)
Looks up the project component by the given ID and returns it.
Collection findAll()
Retrieve all ProjectComponent objects stored.
Collection<MutableProjectComponent> findAllForProject(Long projectId)
Looks up all components that are related to the project with given ID.
MutableProjectComponent findByComponentName(Long projectId, String componentName)
Looks up the component with the given name in the project with the given id.
Collection<MutableProjectComponent> findByComponentNameCaseInSensitive(String componentName)
Finds one or more ProjectComponent with a given name.
Collection findComponentsBylead(String userKey)
Retrieves all ProjectComponents that have the given user as their lead.
Long findProjectIdForComponent(Long componentId)
Looks up the project ID for the given component ID.
ProjectComponent getProjectComponent(Long projectComponentId)
Returns the ProjectComponent for the given ID, or null.
@EventListener void onClearCache(ClearCacheEvent event)
void start()
This method will be called after the plugin system is fully initialised and all components added to the dependency injection framework.
MutableProjectComponent store(MutableProjectComponent component)
Persist the component.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.jira.bc.project.component.ProjectComponentStore
From interface com.atlassian.jira.extension.Startable

Public Constructors

public CachingProjectComponentStore (ProjectComponentStore delegateStore, CacheManager cacheManager, ClusterLockService clusterLockService)

Public Methods

public boolean containsName (String name, Long projectId)

Checks whether component with specified name is stored.

Parameters
name component name, null will cause IllegalArgumentException
Returns
  • true if new name is stored
Throws
IllegalArgumentException if name or projectId is null

public void delete (Long componentId)

Removes the component from the persistent storage and a cache.

Parameters
componentId the id of the component to delete
Throws
EntityNotFoundException if component does not exist (maybe was removed previously :-)

public void deleteAllComponents (Long projectId)

Deletes all components in given project.

Parameters
projectId id of the project in which components will be deleted.

public MutableProjectComponent find (Long id)

Looks up the project component by the given ID and returns it. If not found, throws the EntityNotFoundException, it never returns null.

Parameters
id project component ID
Returns
  • project component found by a given ID
Throws
EntityNotFoundException if the component not found

public Collection findAll ()

Retrieve all ProjectComponent objects stored.

Returns
  • all ProjectComponent objects stored

public Collection<MutableProjectComponent> findAllForProject (Long projectId)

Looks up all components that are related to the project with given ID.

Parameters
projectId project ID
Returns
  • a collection of ProjectComponent objects that are related to the project with given ID

public MutableProjectComponent findByComponentName (Long projectId, String componentName)

Looks up the component with the given name in the project with the given id.

Parameters
projectId id of the project.
componentName name of the component.
Returns
  • the component.
Throws
EntityNotFoundException if no such component can be found.

public Collection<MutableProjectComponent> findByComponentNameCaseInSensitive (String componentName)

Finds one or more ProjectComponent with a given name.

Parameters
componentName the name of the component to find.
Returns
  • a Collection of Components with the given name.

public Collection findComponentsBylead (String userKey)

Retrieves all ProjectComponents that have the given user as their lead. Not synchronised, because findAll() returns a private copy of all components.

Parameters
userKey key of the lead user
Returns
  • possibly empty Collection of ProjectComponents.

public Long findProjectIdForComponent (Long componentId)

Looks up the project ID for the given component ID. If project is not found, throws EntityNotFoundException.

Parameters
componentId component ID
Returns
  • project ID
Throws
EntityNotFoundException if project not found for the given component ID

public ProjectComponent getProjectComponent (Long projectComponentId)

Returns the ProjectComponent for the given ID, or null.

Parameters
projectComponentId the ID
Returns
  • the ProjectComponent for the given ID, or null.

@EventListener public void onClearCache (ClearCacheEvent event)

public void start ()

This method will be called after the plugin system is fully initialised and all components added to the dependency injection framework.

public MutableProjectComponent store (MutableProjectComponent component)

Persist the component. If component has no ID (null) it is inserted to the database and added to the cache, otherwise an update operation is performed on both cache and database.

Parameters
component component to persist
Throws
EntityNotFoundException in case of update if the component does not exist (maybe was deleted :-)
DataAccessException if cannot persist the component