public class

CachingProjectComponentStore

extends Object
implements ProjectComponentStore
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)
Creates a new instance of this class backed by given delegateStore.
Public Methods
synchronized boolean containsName(String name, Long projectId)
Checks whether component with specified name is stored.
synchronized void delete(Long componentId)
Removes the component from the persistent storage and a cache.
MutableProjectComponent find(Long id)
Looks up the project component by the given ID and returns it.
Collection findAll()
Retrieve all ProjectComponent objects stored.
synchronized Collection 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.
@EventListener void onClearCache(ClearCacheEvent event)
synchronized MutableProjectComponent store(MutableProjectComponent component)
Persist the component.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.jira.bc.project.component.ProjectComponentStore

Public Constructors

public CachingProjectComponentStore (ProjectComponentStore delegateStore)

Creates a new instance of this class backed by given delegateStore. Initialises the cache with the data in the persistence store.

Parameters
delegateStore underlying persistence store

Public Methods

public synchronized 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 synchronized 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 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 synchronized Collection 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. Not synchronised, because we get a private copy of the list from findAllForProject()

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. Not synchronised, because findAll() returns a private copy of all components.

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

@EventListener public void onClearCache (ClearCacheEvent event)

public synchronized 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. Note: this method doesn't need to be synchronized because it just delegates to others that are.

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