Package com.atlassian.jira.project
Class CachingProjectManager
java.lang.Object
com.atlassian.jira.project.AbstractProjectManager
com.atlassian.jira.project.CachingProjectManager
- All Implemented Interfaces:
InitializingComponent,ProjectManager
public class CachingProjectManager
extends AbstractProjectManager
implements ProjectManager, InitializingComponent
-
Constructor Summary
ConstructorsConstructorDescriptionCachingProjectManager(ProjectManager delegateProjectManager, ProjectComponentManager projectComponentManager, ProjectFactory projectFactory, UserManager userManager, ApplicationProperties applicationProperties, ProjectKeyStore projectKeyStore, com.atlassian.cache.CacheManager cacheManager, NodeAssociationStore nodeAssociationStore) -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled after all the beans are constructed and the ApplicationContext is fully populated.voidClears the 'createdby' field from all projects that were created by the specified user.voidClears the 'updatedby' field from all projects that were last updated by the specified user.createProject(ApplicationUser user, ProjectCreationData projectCreationData) Creates the project in the database, and adds default project roles for this project.createProjectCategory(String name, String description) Creates a new ProjectCategory with the given name and description.Returns all ProjectCategories, ordered by name.getAllProjectKeys(Long projectId) Returns all project keys that are associated withProject.Return archivedProjects ordered by name.longReturns the curremt issue counter for the given project.longGet the next issue ID from this project (transactional).getProjectByCurrentKey(String projectKey) Returns theProjectwith the given project key.getProjectByCurrentKeyIgnoreCase(String projectKey) Returns aProjectobject based on the passed in project key, not taking into account the case of the project key.Returns a single project category by id.getProjectCategoryForProject(Project project) Returns a project's category.Returns a single project category by id.longReturn the total number ofProjects.getProjectObj(Long id) Retrieves a singleProjectby its id.getProjectObjByKey(String projectKey) Returns aProjectobject based on the passed in project key.getProjectObjByKeyIgnoreCase(String projectKey) Returns aProjectobject based on the passed in project key, not taking into account the case of the project key.getProjectObjByName(String projectName) Returns aProjectobject based on the passed in project name.Return all activeProjects ordered by name.getProjectObjectsFromProjectCategory(Long projectCategoryId) Returns a list of projects in a particular category.Returns a list of projects without project category, sorted by project nameReturn all activeProjects ordered by name.getProjectsCreatedBy(ApplicationUser projectCreator) Retrieves all projects created by a specified user, sorted by the project's name.getProjectsFromProjectCategory(ProjectCategory projectCategory) Returns a list of projects in a particular category.getProjectsLastUpdatedBy(ApplicationUser projectUpdater) Retrieves all projects last updated by a specified user, sorted by the project's name.getProjectsLeadBy(ApplicationUser leadUser) Returns all the projects that leadUser is the project lead for ordered by the name of the Project.booleanisProjectCategoryUnique(String projectCategory) Checks if a project category with a given name exists.protected static <T> Collection<T>noNull(Collection<T> col) voidonClearCache(ClearCacheEvent event) voidvoidrefresh()Causes a full refresh of the project cache.voidremoveProject(Project project) Deletes the provided project from the database.voidRemoves the given ProjectCategory.voidremoveProjectIssues(Project project) Removes all issues for a particular project.voidremoveProjectIssues(Project project, Context taskContext) Removes all issues for a particular project.voidremoveProjectsCreator(Collection<Project> projects) Removes the creator id from a collection of projects, used when a user is deleted.voidremoveProjectsUpdater(Collection<Project> projects) Removes the last updater id from a collection of projects, used when a user is deleted.voidsetCurrentCounterForProject(Project project, long counter) Set the project counter.voidsetProjectCategory(Project project, ProjectCategory category) Sets a project's category.voidupdateProject(Project updatedProject, String name, String description, String leadKey, String url, Long assigneeType, Long avatarId, String projectKey) Updates the project provided with the new attributes passed in.updateProject(UpdateProjectParameters parameters) Updates the project with the given changes.voidupdateProjectCategory(ProjectCategory projectCategory) Persist an updated project category.updateProjectType(ApplicationUser user, Project project, ProjectTypeKey newProjectType) Updates the type of a project.Methods inherited from class com.atlassian.jira.project.AbstractProjectManager
convertToOptionalProjectObjects, convertToProjectObjects, getDefaultAssignee, getDefaultAssignee, getProjectCategoryObjectByName, getProjectCategoryObjectByNameIgnoreCase, getProjectsByArgs, updateProject, updateProjectMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.atlassian.jira.project.ProjectManager
convertToOptionalProjectObjects, convertToProjectObjects, getDefaultAssignee, getDefaultAssignee, getProjectCategoryObjectByName, getProjectCategoryObjectByNameIgnoreCase, getProjectsByArgs, updateProject, updateProject
-
Constructor Details
-
CachingProjectManager
public CachingProjectManager(ProjectManager delegateProjectManager, ProjectComponentManager projectComponentManager, ProjectFactory projectFactory, UserManager userManager, ApplicationProperties applicationProperties, ProjectKeyStore projectKeyStore, com.atlassian.cache.CacheManager cacheManager, NodeAssociationStore nodeAssociationStore)
-
-
Method Details
-
afterInstantiation
Description copied from interface:InitializingComponentCalled after all the beans are constructed and the ApplicationContext is fully populated. Order of execution is order of bean creation, driven by InitializingComponentProcessor.- Specified by:
afterInstantiationin interfaceInitializingComponent- Throws:
Exception
-
onClearCache
-
onProjectFKChangedEvent
-
updateCache
public void updateCache() -
getNextId
Description copied from interface:ProjectManagerGet the next issue ID from this project (transactional). Each project maintains an internal counter for the number of issues. This method may be used to construct a new issue key.- Specified by:
getNextIdin interfaceProjectManager- Parameters:
project- The Project- Returns:
- A long value representing a new issue id for the project.
-
refresh
public void refresh()Description copied from interface:ProjectManagerCauses a full refresh of the project cache.- Specified by:
refreshin interfaceProjectManager
-
getProjectObj
Description copied from interface:ProjectManagerRetrieves a singleProjectby its id.- Specified by:
getProjectObjin interfaceProjectManager- Parameters:
id- ID of the Project.- Returns:
- Project object or null if project with that id doesn't exist.
-
getProjectObjByKey
Description copied from interface:ProjectManagerReturns aProjectobject based on the passed in project key.- Specified by:
getProjectObjByKeyin interfaceProjectManager- Parameters:
projectKey- the Project key.- Returns:
- the
Projectobject specified by the key or null
-
getProjectByCurrentKey
Description copied from interface:ProjectManagerReturns theProjectwith the given project key.This method will strictly only return the project whose current project key is the one given.
This method is added to the API in anticipation of being able to edit the project key, but this feature has not actually been added in 6.0.
- Specified by:
getProjectByCurrentKeyin interfaceProjectManager- Overrides:
getProjectByCurrentKeyin classAbstractProjectManager- Parameters:
projectKey- the Project key.- Returns:
- the
Projectwith the given project key. - See Also:
-
getProjectByCurrentKeyIgnoreCase
Description copied from interface:ProjectManagerReturns aProjectobject based on the passed in project key, not taking into account the case of the project key.- Specified by:
getProjectByCurrentKeyIgnoreCasein interfaceProjectManager- Parameters:
projectKey- the project key, case does not matter.- Returns:
- the project object specified by the key or null if no such project exists.
-
getProjectObjByKeyIgnoreCase
Description copied from interface:ProjectManagerReturns aProjectobject based on the passed in project key, not taking into account the case of the project key. Matches also by previous keys that were associated with a project.- Specified by:
getProjectObjByKeyIgnoreCasein interfaceProjectManager- Parameters:
projectKey- the project key, case does not matter.- Returns:
- the project object specified by the key or null if no such project exists.
-
getAllProjectKeys
Description copied from interface:ProjectManagerReturns all project keys that are associated withProject.- Specified by:
getAllProjectKeysin interfaceProjectManager- Returns:
- all project keys (including the current one) associated with the project
-
getProjectObjByName
Description copied from interface:ProjectManagerReturns aProjectobject based on the passed in project name.- Specified by:
getProjectObjByNamein interfaceProjectManager- Parameters:
projectName- the name of the project- Returns:
- the
Projectobject specified by the supplied name or null
-
getProjects
Description copied from interface:ProjectManagerReturn all activeProjects ordered by name. A project is considered active if it is not archived.- Specified by:
getProjectsin interfaceProjectManager- Returns:
- all active projects ordered by name.
-
getArchivedProjects
Description copied from interface:ProjectManagerReturn archivedProjects ordered by name.- Specified by:
getArchivedProjectsin interfaceProjectManager- Returns:
- all projects ordered by name.
-
getProjectObjects
Description copied from interface:ProjectManagerReturn all activeProjects ordered by name. A project is considered active if it is not archived.This method does the same thing as getProjects() and exists for legacy reasons.
- Specified by:
getProjectObjectsin interfaceProjectManager- Returns:
- all projects ordered by name.
- See Also:
-
getProjectCount
Description copied from interface:ProjectManagerReturn the total number ofProjects.- Specified by:
getProjectCountin interfaceProjectManager- Returns:
- A long value representing tht total number of projects.
- Throws:
DataAccessException- if any errors occur accessing the DB.
-
noNull
-
createProject
public Project createProject(@Nonnull ApplicationUser user, @Nonnull ProjectCreationData projectCreationData) Description copied from interface:ProjectManagerCreates the project in the database, and adds default project roles for this project.If no name, key, lead or project type are provided an exception will be thrown.
- Specified by:
createProjectin interfaceProjectManager- Parameters:
user- The user creating the projectprojectCreationData- An object encapsulating all the data for the project that will get created- Returns:
- The newly created project.
- See Also:
-
updateProject
Description copied from interface:ProjectManagerUpdates the project with the given changes.- Specified by:
updateProjectin interfaceProjectManager- Parameters:
parameters- containing the changes to the project that needs to be made.- Returns:
- The updated project
-
updateProject
public Project updateProject(Project updatedProject, String name, String description, String leadKey, String url, Long assigneeType, Long avatarId, String projectKey) Description copied from interface:ProjectManagerUpdates the project provided with the new attributes passed in. This method is responsible for persisting any changes to the database.- Specified by:
updateProjectin interfaceProjectManager- Parameters:
updatedProject- The project to be updated.name- The name for the updated projectdescription- An optional description for the projectleadKey- The userkey of the lead developer for the projecturl- An optional URL for the updated projectassigneeType- The default assignee for issues created in this project. May be either project lead, or unassigned if unassigned issues are enabled.projectKey- The new project key (not updated if null)- Returns:
- The updated project
-
updateProjectType
public Project updateProjectType(ApplicationUser user, Project project, ProjectTypeKey newProjectType) Description copied from interface:ProjectManagerUpdates the type of a project.- Specified by:
updateProjectTypein interfaceProjectManager- Parameters:
user- The user performing the actionproject- The project which type needs to be updatednewProjectType- The new project type- Returns:
- The updated project
-
removeProjectIssues
Description copied from interface:ProjectManagerRemoves all issues for a particular project. A RemoveException will be thrown on any errors removing issues.- Specified by:
removeProjectIssuesin interfaceProjectManager- Parameters:
project- The project for which issues will be deleted.- Throws:
RemoveException- if there's any errors removing issues
-
removeProjectIssues
Description copied from interface:ProjectManagerRemoves all issues for a particular project. A RemoveException will be thrown on any errors removing issues.- Specified by:
removeProjectIssuesin interfaceProjectManager- Parameters:
project- The project for which issues will be deleted.taskContext- A task context for providing progress.- Throws:
RemoveException- if there's any errors removing issues
-
removeProject
Description copied from interface:ProjectManagerDeletes the provided project from the database. Please note that this method only deletes the project itself and not any related entities. UseProjectService.deleteProject(com.atlassian.jira.user.ApplicationUser, com.atlassian.jira.bc.project.ProjectService.DeleteProjectValidationResult)to properly delete a project.- Specified by:
removeProjectin interfaceProjectManager- Parameters:
project- The project to be deleted.
-
getAllProjectCategories
Description copied from interface:ProjectManagerReturns all ProjectCategories, ordered by name.- Specified by:
getAllProjectCategoriesin interfaceProjectManager- Returns:
- all ProjectCategories, ordered by name.
-
getProjectCategory
Description copied from interface:ProjectManagerReturns a single project category by id.- Specified by:
getProjectCategoryin interfaceProjectManager- Parameters:
id-ProjectCategoryid.- Returns:
- the
ProjectCategoryfor the provided id if it was found or else null
-
getProjectCategoryObject
Description copied from interface:ProjectManagerReturns a single project category by id.Legacy synonym for
ProjectManager.getProjectCategory(Long)- Specified by:
getProjectCategoryObjectin interfaceProjectManager- Parameters:
id- Project Category ID.- Returns:
- The project category
-
updateProjectCategory
Description copied from interface:ProjectManagerPersist an updated project category.- Specified by:
updateProjectCategoryin interfaceProjectManager- Parameters:
projectCategory- project category.- Throws:
DataAccessException- If any errors occur accessing the DB.
-
getProjectsFromProjectCategory
public Collection<Project> getProjectsFromProjectCategory(ProjectCategory projectCategory) throws DataAccessException Description copied from interface:ProjectManagerReturns a list of projects in a particular category.- Specified by:
getProjectsFromProjectCategoryin interfaceProjectManager- Parameters:
projectCategory- project category.- Returns:
- A collection of projects sorted by name.
- Throws:
DataAccessException- If any errors occur accessing the DB.
-
getProjectObjectsFromProjectCategory
Description copied from interface:ProjectManagerReturns a list of projects in a particular category.- Specified by:
getProjectObjectsFromProjectCategoryin interfaceProjectManager- Parameters:
projectCategoryId- project category id.- Returns:
- A collection of project
Projects sorted by name.
-
getProjectCategoryForProject
Description copied from interface:ProjectManagerReturns a project's category.- Specified by:
getProjectCategoryForProjectin interfaceProjectManager- Parameters:
project- project- Returns:
- A ProjectCategory or null if this project has no category.
-
getProjectObjectsWithNoCategory
Description copied from interface:ProjectManagerReturns a list of projects without project category, sorted by project name- Specified by:
getProjectObjectsWithNoCategoryin interfaceProjectManager- Returns:
- A collection of
Projects sorted by name - Throws:
DataAccessException- If any errors occur accessing the DB.
-
setProjectCategory
public void setProjectCategory(Project project, ProjectCategory category) throws DataAccessException Description copied from interface:ProjectManagerSets a project's category.- Specified by:
setProjectCategoryin interfaceProjectManager- Parameters:
project- projectcategory- category- Throws:
DataAccessException- If any errors occur accessing the DB.
-
getProjectsLeadBy
Description copied from interface:ProjectManagerReturns all the projects that leadUser is the project lead for ordered by the name of the Project.- Specified by:
getProjectsLeadByin interfaceProjectManager- Parameters:
leadUser- Project Lead- Returns:
- A collection of projects
-
getProjectsCreatedBy
Description copied from interface:ProjectManagerRetrieves all projects created by a specified user, sorted by the project's name.- Specified by:
getProjectsCreatedByin interfaceProjectManager- Parameters:
projectCreator- The user who created the projects.- Returns:
- A list of projects created by the specified user, ordered by project name.
-
removeProjectsCreator
Description copied from interface:ProjectManagerRemoves the creator id from a collection of projects, used when a user is deleted.- Specified by:
removeProjectsCreatorin interfaceProjectManager- Parameters:
projects- A collection of projects from which the creator information should be removed.
-
getProjectsLastUpdatedBy
Description copied from interface:ProjectManagerRetrieves all projects last updated by a specified user, sorted by the project's name.- Specified by:
getProjectsLastUpdatedByin interfaceProjectManager- Parameters:
projectUpdater- The user who last updated the projects.- Returns:
- A list of projects last updated by the specified user, ordered by project name.
-
removeProjectsUpdater
Description copied from interface:ProjectManagerRemoves the last updater id from a collection of projects, used when a user is deleted.- Specified by:
removeProjectsUpdaterin interfaceProjectManager- Parameters:
projects- A collection of projects from which the updater information should be removed.
-
clearCreatedByForUserInProjects
Description copied from interface:ProjectManagerClears the 'createdby' field from all projects that were created by the specified user. This method is typically used when a user is deleted from the system, ensuring that their identifier is removed from the projects they created.- Specified by:
clearCreatedByForUserInProjectsin interfaceProjectManager- Parameters:
user- The user whose identifier should be cleared from the 'createdby' field in projects.
-
clearLastUpdatedByForUserInProjects
Description copied from interface:ProjectManagerClears the 'updatedby' field from all projects that were last updated by the specified user. This method is typically used when a user is deleted from the system, ensuring that their identifier is removed from the projects they updated.- Specified by:
clearLastUpdatedByForUserInProjectsin interfaceProjectManager- Parameters:
user- The user whose identifier should be cleared from the 'updatedby' field in projects.
-
createProjectCategory
Description copied from interface:ProjectManagerCreates a new ProjectCategory with the given name and description.- Specified by:
createProjectCategoryin interfaceProjectManager- Parameters:
name- the Namedescription- the Description.- Returns:
- the new ProjectCategory.
-
removeProjectCategory
Description copied from interface:ProjectManagerRemoves the given ProjectCategory.- Specified by:
removeProjectCategoryin interfaceProjectManager- Parameters:
id- the ProjectCategory to remove.
-
isProjectCategoryUnique
Description copied from interface:ProjectManagerChecks if a project category with a given name exists.- Specified by:
isProjectCategoryUniquein interfaceProjectManager- Parameters:
projectCategory- the name of the project category- Returns:
- if a category with given name exists
-
getCurrentCounterForProject
Description copied from interface:ProjectManagerReturns the curremt issue counter for the given project. This value is for information only; you should not use it to predict or create issue ids, because it may change concurrently as new issues are created.- Specified by:
getCurrentCounterForProjectin interfaceProjectManager- Parameters:
id- the ID of the project for which to retrieve the counter- Returns:
- the current project counter (the id of the next issue to be created).
-
setCurrentCounterForProject
Description copied from interface:ProjectManagerSet the project counter. Warning Setting the project counter is not needed in the normal operations of JIRA, this method exist for functionality like project-import etc.- Specified by:
setCurrentCounterForProjectin interfaceProjectManager- Parameters:
project- the project for which to set the counter (required)counter- the counter value to set
-