com.atlassian.jira.security.roles
Class CachingProjectRoleAndActorStore

java.lang.Object
  extended by com.atlassian.jira.security.roles.CachingProjectRoleAndActorStore
All Implemented Interfaces:
Startable, ProjectRoleAndActorStore

public class CachingProjectRoleAndActorStore
extends Object
implements ProjectRoleAndActorStore, Startable

A caching implementation of the ProjectRoleAndActorStore that delegates to another ProjectRoleAndActorStore.

This class maintains two separate unrelated caches, one for ProjectRoles and another for the actors associated with a Project/ProjectRole combination. These use separate approaches to maintain correctness under concurrent usage.

The caching of the ProjectRoleActors maintains its correctness under concurrent updates/miss population by using ConcurrentMap.putIfAbsent(Object,Object) to store the result of a retrieval operation from the database (non-mutative), but Map.put(Object,Object) to store the result of an update.


Constructor Summary
CachingProjectRoleAndActorStore(ProjectRoleAndActorStore delegate, RoleActorFactory roleActorFactory, com.atlassian.event.api.EventPublisher eventPublisher)
           
 
Method Summary
 ProjectRole addProjectRole(ProjectRole projectRole)
           
 void applyDefaultsRolesToProject(Project project)
           
 void clearCaches()
           
 void deleteProjectRole(ProjectRole projectRole)
           
 Collection<ProjectRole> getAllProjectRoles()
           
 DefaultRoleActors getDefaultRoleActors(Long projectRoleId)
           
 Collection<Long> getProjectIdsContainingRoleActorByNameAndType(String name, String type)
           
 Map<Long,List<String>> getProjectIdsForUserInGroupsBecauseOfRole(List<Long> projectsToLimitBy, ProjectRole projectRole, String projectRoleType, String userName)
           
 ProjectRole getProjectRole(Long id)
           
 ProjectRoleActors getProjectRoleActors(Long projectRoleId, Long projectId)
           
 ProjectRole getProjectRoleByName(String name)
           
 void onClearCache(ClearCacheEvent event)
           
 void removeAllRoleActorsByNameAndType(String name, String type)
           
 void removeAllRoleActorsByProject(Project project)
           
 List<Long> roleActorOfTypeExistsForProjects(List<Long> projectsToLimitBy, ProjectRole projectRole, String projectRoleType, String projectRoleParameter)
           
 void start()
          This method wil be called after the plugin system is fully initialised and all components added to the dependency injection framework.
 void updateDefaultRoleActors(DefaultRoleActors defaultRoleActors)
           
 void updateProjectRole(ProjectRole projectRole)
           
 void updateProjectRoleActors(ProjectRoleActors projectRoleActors)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingProjectRoleAndActorStore

public CachingProjectRoleAndActorStore(ProjectRoleAndActorStore delegate,
                                       RoleActorFactory roleActorFactory,
                                       com.atlassian.event.api.EventPublisher eventPublisher)
Method Detail

start

public void start()
           throws Exception
Description copied from interface: Startable
This method wil be called after the plugin system is fully initialised and all components added to the dependency injection framework.

Specified by:
start in interface Startable
Throws:
Exception - Allows implementations to throw an Exception.

onClearCache

@EventListener
public void onClearCache(ClearCacheEvent event)

addProjectRole

public ProjectRole addProjectRole(ProjectRole projectRole)
                           throws DataAccessException
Specified by:
addProjectRole in interface ProjectRoleAndActorStore
Throws:
DataAccessException

updateProjectRole

public void updateProjectRole(ProjectRole projectRole)
                       throws DataAccessException
Specified by:
updateProjectRole in interface ProjectRoleAndActorStore
Throws:
DataAccessException

getAllProjectRoles

public Collection<ProjectRole> getAllProjectRoles()
                                           throws DataAccessException
Specified by:
getAllProjectRoles in interface ProjectRoleAndActorStore
Throws:
DataAccessException

getProjectRole

public ProjectRole getProjectRole(Long id)
                           throws DataAccessException
Specified by:
getProjectRole in interface ProjectRoleAndActorStore
Throws:
DataAccessException

getProjectRoleByName

public ProjectRole getProjectRoleByName(String name)
                                 throws DataAccessException
Specified by:
getProjectRoleByName in interface ProjectRoleAndActorStore
Throws:
DataAccessException

deleteProjectRole

public void deleteProjectRole(ProjectRole projectRole)
                       throws DataAccessException
Specified by:
deleteProjectRole in interface ProjectRoleAndActorStore
Throws:
DataAccessException

getDefaultRoleActors

public DefaultRoleActors getDefaultRoleActors(Long projectRoleId)
                                       throws DataAccessException
Specified by:
getDefaultRoleActors in interface ProjectRoleAndActorStore
Throws:
DataAccessException

getProjectRoleActors

public ProjectRoleActors getProjectRoleActors(Long projectRoleId,
                                              Long projectId)
                                       throws DataAccessException
Specified by:
getProjectRoleActors in interface ProjectRoleAndActorStore
Throws:
DataAccessException

updateProjectRoleActors

public void updateProjectRoleActors(ProjectRoleActors projectRoleActors)
                             throws DataAccessException
Specified by:
updateProjectRoleActors in interface ProjectRoleAndActorStore
Throws:
DataAccessException

updateDefaultRoleActors

public void updateDefaultRoleActors(DefaultRoleActors defaultRoleActors)
                             throws DataAccessException
Specified by:
updateDefaultRoleActors in interface ProjectRoleAndActorStore
Throws:
DataAccessException

applyDefaultsRolesToProject

public void applyDefaultsRolesToProject(Project project)
                                 throws DataAccessException
Specified by:
applyDefaultsRolesToProject in interface ProjectRoleAndActorStore
Throws:
DataAccessException

removeAllRoleActorsByNameAndType

public void removeAllRoleActorsByNameAndType(String name,
                                             String type)
                                      throws DataAccessException
Specified by:
removeAllRoleActorsByNameAndType in interface ProjectRoleAndActorStore
Throws:
DataAccessException

removeAllRoleActorsByProject

public void removeAllRoleActorsByProject(Project project)
                                  throws DataAccessException
Specified by:
removeAllRoleActorsByProject in interface ProjectRoleAndActorStore
Throws:
DataAccessException

getProjectIdsContainingRoleActorByNameAndType

public Collection<Long> getProjectIdsContainingRoleActorByNameAndType(String name,
                                                                      String type)
                                                               throws DataAccessException
Specified by:
getProjectIdsContainingRoleActorByNameAndType in interface ProjectRoleAndActorStore
Throws:
DataAccessException

roleActorOfTypeExistsForProjects

public List<Long> roleActorOfTypeExistsForProjects(List<Long> projectsToLimitBy,
                                                   ProjectRole projectRole,
                                                   String projectRoleType,
                                                   String projectRoleParameter)
                                            throws DataAccessException
Specified by:
roleActorOfTypeExistsForProjects in interface ProjectRoleAndActorStore
Throws:
DataAccessException

getProjectIdsForUserInGroupsBecauseOfRole

public Map<Long,List<String>> getProjectIdsForUserInGroupsBecauseOfRole(List<Long> projectsToLimitBy,
                                                                        ProjectRole projectRole,
                                                                        String projectRoleType,
                                                                        String userName)
                                                                 throws DataAccessException
Specified by:
getProjectIdsForUserInGroupsBecauseOfRole in interface ProjectRoleAndActorStore
Throws:
DataAccessException

clearCaches

public void clearCaches()


Copyright © 2002-2012 Atlassian. All Rights Reserved.