com.atlassian.jira.bc.project.component
Class CachingProjectComponentStore

java.lang.Object
  extended by com.atlassian.jira.bc.project.component.CachingProjectComponentStore
All Implemented Interfaces:
ProjectComponentStore

public class CachingProjectComponentStore
extends Object
implements ProjectComponentStore

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


Constructor Summary
CachingProjectComponentStore(ProjectComponentStore delegateStore)
          Creates a new instance of this class backed by given delegateStore.
 
Method Summary
 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.
 MutableProjectComponent find(Long id)
          Looks up the project component by the given ID and returns it.
 Collection findAll()
          Retrieve all ProjectComponent objects stored.
 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 findComponentsBylead(String userName)
          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.
 MutableProjectComponent store(MutableProjectComponent component)
          Persist the component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingProjectComponentStore

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
Method Detail

find

public MutableProjectComponent find(Long id)
                             throws EntityNotFoundException
Looks up the project component by the given ID and returns it. If not found, throws the EntityNotFoundException, it never returns null.

Specified by:
find in interface ProjectComponentStore
Parameters:
id - project component ID
Returns:
project component found by a given ID
Throws:
EntityNotFoundException - if the component not found

findAllForProject

public Collection findAllForProject(Long projectId)
Looks up all components that are related to the project with given ID.

Specified by:
findAllForProject in interface ProjectComponentStore
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:
findByComponentName in interface ProjectComponentStore
Parameters:
projectId - id of the project.
componentName - name of the component.
Returns:
the component.
Throws:
EntityNotFoundException - if no such component can be found.

findProjectIdForComponent

public Long findProjectIdForComponent(Long componentId)
                               throws EntityNotFoundException
Looks up the project ID for the given component ID. If project is not found, throws EntityNotFoundException.

Specified by:
findProjectIdForComponent in interface ProjectComponentStore
Parameters:
componentId - component ID
Returns:
project ID
Throws:
EntityNotFoundException - if project not found for the given component ID

containsName

public boolean containsName(String name,
                            Long projectId)
Checks whether component with specified name is stored.

Specified by:
containsName in interface ProjectComponentStore
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. Note: this method doesn't need to be synchronized because it just delegates to others that are.

Specified by:
store in interface ProjectComponentStore
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

public void delete(Long componentId)
            throws EntityNotFoundException
Removes the component from the persistent storage and a cache.

Specified by:
delete in interface ProjectComponentStore
Parameters:
componentId -
Throws:
EntityNotFoundException - if component does not exist (maybe was removed previously :-)

findComponentsBylead

public Collection findComponentsBylead(String userName)
Retrieves all ProjectComponents that have the given user as their lead.

Specified by:
findComponentsBylead in interface ProjectComponentStore
Parameters:
userName -
Returns:
possibly empty Collection of ProjectComponents.

findAll

public Collection findAll()
Retrieve all ProjectComponent objects stored.

Specified by:
findAll in interface ProjectComponentStore
Returns:
all ProjectComponent objects stored


Copyright © 2002-2009 Atlassian. All Rights Reserved.