Class CachingProjectComponentStore
java.lang.Object
com.atlassian.jira.bc.project.component.CachingProjectComponentStore
- All Implemented Interfaces:
ProjectComponentStore,Startable
public class CachingProjectComponentStore
extends Object
implements ProjectComponentStore, Startable
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.
-
Constructor Summary
ConstructorsConstructorDescriptionCachingProjectComponentStore(ProjectComponentStore delegateStore, com.atlassian.beehive.ClusterLockService clusterLockService, com.atlassian.cache.CacheManager cacheManager) -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsName(String name, Long projectId) Checks whether component with specified name is stored.voidRemoves the component from the persistent storage and a cache.voiddeleteAllComponents(Long projectId) Deletes all components in given project.Looks up the project component by the given ID and returns it.findAll()Retrieve all ProjectComponent objects stored.findAllForProject(Long projectId) Looks up all components that are related to the project with given ID.findByComponentName(Long projectId, String componentName) Looks up the component with the given name in the project with the given id.findByComponentNameCaseInSensitive(String componentName) Finds one or more ProjectComponent with a given name.findComponentsBylead(String userKey) Retrieves all ProjectComponents that have the given user as their lead.findProjectIdForComponent(Long componentId) Looks up the project ID for the given component ID.getProjectComponent(Long projectComponentId) Returns the ProjectComponent for the given ID, or null.voidonClearCache(ClearCacheEvent event) voidvoidstart()This method will be called after the plugin system is fully initialised and all components added to the dependency injection framework.store(MutableProjectComponent component) Persist the component.
-
Constructor Details
-
CachingProjectComponentStore
public CachingProjectComponentStore(ProjectComponentStore delegateStore, com.atlassian.beehive.ClusterLockService clusterLockService, com.atlassian.cache.CacheManager cacheManager)
-
-
Method Details
-
onClearCache
-
onProjectComponentFKChangedEvent
-
start
public void start()Description copied from interface:StartableThis method will be called after the plugin system is fully initialised and all components added to the dependency injection framework. -
find
Looks up the project component by the given ID and returns it. If not found, throws the EntityNotFoundException, it never returns null.- Specified by:
findin interfaceProjectComponentStore- Parameters:
id- project component ID- Returns:
- project component found by a given ID
- Throws:
EntityNotFoundException- if the component not found
-
getProjectComponent
Description copied from interface:ProjectComponentStoreReturns the ProjectComponent for the given ID, or null.- Specified by:
getProjectComponentin interfaceProjectComponentStore- Parameters:
projectComponentId- the ID- Returns:
- the ProjectComponent for the given ID, or null.
-
findAllForProject
Looks up all components that are related to the project with given ID.- Specified by:
findAllForProjectin interfaceProjectComponentStore- Parameters:
projectId- project ID- Returns:
- a collection of ProjectComponent objects that are related to the project with given ID
-
findByComponentName
public MutableProjectComponent findByComponentName(Long projectId, String componentName) throws EntityNotFoundException Looks up the component with the given name in the project with the given id.- Specified by:
findByComponentNamein interfaceProjectComponentStore- Parameters:
projectId- id of the project.componentName- name of the component.- Returns:
- the component.
- Throws:
EntityNotFoundException- if no such component can be found.
-
findByComponentNameCaseInSensitive
Finds one or more ProjectComponent with a given name.- Specified by:
findByComponentNameCaseInSensitivein interfaceProjectComponentStore- Parameters:
componentName- the name of the component to find.- Returns:
- a Collection of Components with the given name.
-
findProjectIdForComponent
Looks up the project ID for the given component ID. If project is not found, throws EntityNotFoundException.- Specified by:
findProjectIdForComponentin interfaceProjectComponentStore- Parameters:
componentId- component ID- Returns:
- project ID
- Throws:
EntityNotFoundException- if project not found for the given component ID
-
containsName
Checks whether component with specified name is stored.- Specified by:
containsNamein interfaceProjectComponentStore- Parameters:
name- component name, null will cause IllegalArgumentException- Returns:
- true if new name is stored
- Throws:
IllegalArgumentException- if name or projectId is null
-
store
public MutableProjectComponent store(MutableProjectComponent component) throws EntityNotFoundException, DataAccessException 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.- Specified by:
storein interfaceProjectComponentStore- 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
-
delete
Removes the component from the persistent storage and a cache.- Specified by:
deletein interfaceProjectComponentStore- Parameters:
componentId- the id of the component to delete- Throws:
EntityNotFoundException- if component does not exist (maybe was removed previously :-)
-
deleteAllComponents
Description copied from interface:ProjectComponentStoreDeletes all components in given project.- Specified by:
deleteAllComponentsin interfaceProjectComponentStore- Parameters:
projectId- id of the project in which components will be deleted.
-
findComponentsBylead
Retrieves all ProjectComponents that have the given user as their lead. Not synchronised, because findAll() returns a private copy of all components.- Specified by:
findComponentsByleadin interfaceProjectComponentStore- Parameters:
userKey- key of the lead user- Returns:
- possibly empty Collection of ProjectComponents.
-
findAll
Retrieve all ProjectComponent objects stored.- Specified by:
findAllin interfaceProjectComponentStore- Returns:
- all ProjectComponent objects stored
-