public interface

ProjectManager

com.atlassian.jira.project.ProjectManager
Known Indirect Subclasses

Class Overview

Implementations of this interface are responsible for all management of project entities within JIRA.

Summary

Public Methods
List<Project> convertToProjectObjects(Collection<Long> projectIds)
Converts a collection of projectIds to a list of projects.
Project createProject(ApplicationUser user, ProjectCreationData projectCreationData)
Creates the project in the database, and adds default project roles for this project.
ProjectCategory createProjectCategory(String name, String description)
Creates a new ProjectCategory with the given name and description.
Collection<ProjectCategory> getAllProjectCategories()
Returns all ProjectCategories, ordered by name.
Set<String> getAllProjectKeys(Long projectId)
Returns all project keys that are associated with Project.
long getCurrentCounterForProject(Long id)
Returns the curremt issue counter for the given project.
ApplicationUser getDefaultAssignee(Project project, Collection<ProjectComponent> components)
Gets the default assignee for an issue given its project and list of Components.
ApplicationUser getDefaultAssignee(Project project, ProjectComponent component)
This method is deprecated. Use getDefaultAssignee(Project, java.util.Collection) which allows for multiple components. Since v4.4.
long getNextId(Project project)
Get the next issue ID from this project (transactional).
@ExperimentalApi Project getProjectByCurrentKey(String projectKey)
Returns the Project with the given project key.
Project getProjectByCurrentKeyIgnoreCase(String projectKey)
Returns a Project object based on the passed in project key, not taking into account the case of the project key.
ProjectCategory getProjectCategory(Long id)
Returns a single project category by id.
@Nullable ProjectCategory getProjectCategoryForProject(Project project)
Returns a project's category.
@Nullable ProjectCategory getProjectCategoryObject(Long id)
Returns a single project category by id.
ProjectCategory getProjectCategoryObjectByName(String projectCategoryName)
Find a project category by name.
ProjectCategory getProjectCategoryObjectByNameIgnoreCase(String projectCategoryName)
Find a project category by name ignoring the case of the category name.
long getProjectCount()
Return the total number of Projects.
Project getProjectObj(Long id)
Retrieves a single Project by its id.
Project getProjectObjByKey(String projectKey)
Returns a Project object based on the passed in project key.
Project getProjectObjByKeyIgnoreCase(String projectKey)
Returns a Project object based on the passed in project key, not taking into account the case of the project key.
Project getProjectObjByName(String projectName)
Returns a Project object based on the passed in project name.
@Nonnull List<Project> getProjectObjects()
Return all Projects ordered by name.
Collection<Project> getProjectObjectsFromProjectCategory(Long projectCategoryId)
Returns a list of projects in a particular category.
Collection<Project> getProjectObjectsWithNoCategory()
Returns a list of projects without project category, sorted by project name
@Nonnull List<Project> getProjects()
Return all Projects ordered by name.
Collection<Project> getProjectsFromProjectCategory(ProjectCategory projectCategory)
Returns a list of projects in a particular category.
List<Project> getProjectsLeadBy(ApplicationUser leadUser)
Returns all the projects that leadUser is the project lead for ordered by the name of the Project.
boolean isProjectCategoryUnique(String projectCategory)
Checks if a project category with a given name exists.
void refresh()
Causes a full refresh of the project cache.
void removeProject(Project project)
Deletes the provided project from the database.
void removeProjectCategory(Long id)
Removes the given ProjectCategory.
void removeProjectIssues(Project project)
Removes all issues for a particular project.
void setCurrentCounterForProject(Project project, long counter)
Set the project counter.
void setProjectCategory(Project project, ProjectCategory category)
Sets a project's category.
Project updateProject(Project originalProject, String name, String description, String leadKey, String url, Long assigneeType)
Updates the project provided with the new attributes passed in.
Project updateProject(Project originalProject, String name, String description, String leadKey, String url, Long assigneeType, Long avatarId, String projectKey)
Updates the project provided with the new attributes passed in.
Project updateProject(Project originalProject, String name, String description, String leadKey, String url, Long assigneeType, Long avatarId)
Updates the project provided with the new attributes passed in.
void updateProjectCategory(ProjectCategory projectCategory)
Persist an updated project category.
Project updateProjectType(ApplicationUser user, Project project, ProjectTypeKey newProjectType)
Updates the type of a project.

Public Methods

public List<Project> convertToProjectObjects (Collection<Long> projectIds)

Converts a collection of projectIds to a list of projects.

Will return null if incoming collection is null.

The returned list of Project Objects will have the same sort order as the incoming collection of IDs.

Parameters
projectIds a Collection of Project IDs
Returns
  • List of Projects, or null if input is null

public Project createProject (ApplicationUser user, ProjectCreationData projectCreationData)

Creates 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.

Parameters
user The user creating the project
projectCreationData An object encapsulating all the data for the project that will get created
Returns
  • The newly created project.

public ProjectCategory createProjectCategory (String name, String description)

Creates a new ProjectCategory with the given name and description.

Parameters
name the Name
description the Description.
Returns
  • the new ProjectCategory.

public Collection<ProjectCategory> getAllProjectCategories ()

Returns all ProjectCategories, ordered by name.

Returns
  • all ProjectCategories, ordered by name.
Throws
DataAccessException If any errors occur accessing the DB.

public Set<String> getAllProjectKeys (Long projectId)

Returns all project keys that are associated with Project.

Returns
  • all project keys (including the current one) associated with the project

public long getCurrentCounterForProject (Long id)

Returns 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.

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).

public ApplicationUser getDefaultAssignee (Project project, Collection<ProjectComponent> components)

Gets the default assignee for an issue given its project and list of Components.

If the default assignee configuration is invalid, then a DefaultAssigneeException is thrown. This could be because the default is unassigned, and unassigned issues are not allowed, or because the default user does not have permission to be assigned to issues in this project.

Parameters
project project
components The components
Returns
  • the default assignee for this project/components
Throws
DefaultAssigneeException If the default assignee is invalid (eg user does not have assign permission) .

public ApplicationUser getDefaultAssignee (Project project, ProjectComponent component)

This method is deprecated.
Use getDefaultAssignee(Project, java.util.Collection) which allows for multiple components. Since v4.4.

Gets the default assignee for a project and/or component depending on if a component was specified.

Parameters
project project
component component
Returns
  • the default assignee for this project/component
Throws
DefaultAssigneeException If the default assignee does NOT have ASSIGNABLE permission OR Unassigned issues are turned off.

public long getNextId (Project project)

Get 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.

Parameters
project The Project
Returns
  • A long value representing a new issue id for the project.
Throws
DataAccessException If any errors occur accessing the DB.

@ExperimentalApi public Project getProjectByCurrentKey (String projectKey)

@ExperimentalApi

This method is considered usable by external developers but its contracts have not stabilized.

Experimental APIs may be changed at any time before being marked @Internal or @PublicApi.

Returns the Project with 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.

Parameters
projectKey the Project key.
Returns
  • the Project with the given project key.

public Project getProjectByCurrentKeyIgnoreCase (String projectKey)

Returns a Project object based on the passed in project key, not taking into account the case of the project key.

Parameters
projectKey the project key, case does not matter.
Returns
  • the project object specified by the key or null if no such project exists.

public ProjectCategory getProjectCategory (Long id)

Returns a single project category by id.

Parameters
id Project Category ID.
Returns
  • The project category

@Nullable public ProjectCategory getProjectCategoryForProject (Project project)

Returns a project's category.

Parameters
project project
Returns
  • A ProjectCategory or null if this project has no category.
Throws
DataAccessException If any errors occur accessing the DB.

@Nullable public ProjectCategory getProjectCategoryObject (Long id)

Returns a single project category by id.

Legacy synonym for getProjectCategory(Long)

Parameters
id Project Category ID.
Returns
  • The project category

public ProjectCategory getProjectCategoryObjectByName (String projectCategoryName)

Find a project category by name.

Parameters
projectCategoryName Name of the Project Category
Returns
  • The ProjectCategory or null if none found

public ProjectCategory getProjectCategoryObjectByNameIgnoreCase (String projectCategoryName)

Find a project category by name ignoring the case of the category name.

Parameters
projectCategoryName Name of the Project Category
Returns
  • The ProjectCategory or null if none found

public long getProjectCount ()

Return the total number of Projects.

Returns
  • A long value representing tht total number of projects.
Throws
DataAccessException if any errors occur accessing the DB.

public Project getProjectObj (Long id)

Retrieves a single Project by its id.

Parameters
id ID of the Project.
Returns
  • Project object or null if project with that id doesn't exist.
Throws
DataAccessException If any errors occur accessing the DB.

public Project getProjectObjByKey (String projectKey)

Returns a Project object based on the passed in project key.

Parameters
projectKey the Project key.
Returns
  • the Project object specified by the key or null

public Project getProjectObjByKeyIgnoreCase (String projectKey)

Returns a Project object 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.

Parameters
projectKey the project key, case does not matter.
Returns
  • the project object specified by the key or null if no such project exists.

public Project getProjectObjByName (String projectName)

Returns a Project object based on the passed in project name.

Parameters
projectName the name of the project
Returns
  • the Project object specified by the supplied name or null

@Nonnull public List<Project> getProjectObjects ()

Return all Projects ordered by name.

This method does the same thing as getProjects() and exists for legacy reasons.

Returns
  • all projects ordered by name.
Throws
DataAccessException If any errors occur accessing the DB.
See Also

public Collection<Project> getProjectObjectsFromProjectCategory (Long projectCategoryId)

Returns a list of projects in a particular category.

Parameters
projectCategoryId project category id.
Returns
  • A collection of project Projects sorted by name.
Throws
DataAccessException If any errors occur accessing the DB.

public Collection<Project> getProjectObjectsWithNoCategory ()

Returns a list of projects without project category, sorted by project name

Returns
  • A collection of Projects sorted by name
Throws
DataAccessException If any errors occur accessing the DB.

@Nonnull public List<Project> getProjects ()

Return all Projects ordered by name.

Returns
  • all projects ordered by name.

public Collection<Project> getProjectsFromProjectCategory (ProjectCategory projectCategory)

Returns a list of projects in a particular category.

Parameters
projectCategory project category.
Returns
  • A collection of projects sorted by name.
Throws
DataAccessException If any errors occur accessing the DB.

public List<Project> getProjectsLeadBy (ApplicationUser leadUser)

Returns all the projects that leadUser is the project lead for ordered by the name of the Project.

Parameters
leadUser Project Lead
Returns
  • A collection of projects

public boolean isProjectCategoryUnique (String projectCategory)

Checks if a project category with a given name exists.

Parameters
projectCategory the name of the project category
Returns
  • if a category with given name exists

public void refresh ()

Causes a full refresh of the project cache.

public void removeProject (Project project)

Deletes the provided project from the database. Please note that this method only deletes the project itself and not any related entities. Use deleteProject(ApplicationUser, ProjectService.DeleteProjectValidationResult) to properly delete a project.

Parameters
project The project to be deleted.

public void removeProjectCategory (Long id)

Removes the given ProjectCategory.

Parameters
id the ProjectCategory to remove.

public void removeProjectIssues (Project project)

Removes all issues for a particular project. A RemoveException will be thrown on any errors removing issues.

Parameters
project The project for which issues will be deleted.
Throws
RemoveException if there's any errors removing issues

public void setCurrentCounterForProject (Project project, long counter)

Set 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.

Parameters
project the project for which to set the counter (required)
counter the counter value to set

public void setProjectCategory (Project project, ProjectCategory category)

Sets a project's category.

Parameters
project project
category category
Throws
DataAccessException If any errors occur accessing the DB.
IllegalArgumentException if the project provided is null

public Project updateProject (Project originalProject, String name, String description, String leadKey, String url, Long assigneeType)

Updates the project provided with the new attributes passed in. This method is responsible for persisting any changes to the database.

Parameters
originalProject The project to be updated.
name The name for the updated project
description An optional description for the project
leadKey The userkey of the lead developer for the project
url An optional URL for the updated project
assigneeType The default assignee for issues created in this project. May be either project lead, or unassigned if unassigned issues are enabled.
Returns
  • The updated project

public Project updateProject (Project originalProject, String name, String description, String leadKey, String url, Long assigneeType, Long avatarId, String projectKey)

Updates the project provided with the new attributes passed in. This method is responsible for persisting any changes to the database.

Parameters
originalProject The project to be updated.
name The name for the updated project
description An optional description for the project
leadKey The userkey of the lead developer for the project
url An optional URL for the updated project
assigneeType 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

public Project updateProject (Project originalProject, String name, String description, String leadKey, String url, Long assigneeType, Long avatarId)

Updates the project provided with the new attributes passed in. This method is responsible for persisting any changes to the database.

Parameters
originalProject The project to be updated.
name The name for the updated project
description An optional description for the project
leadKey The userkey of the lead developer for the project
url An optional URL for the updated project
assigneeType The default assignee for issues created in this project. May be either project lead, or unassigned if unassigned issues are enabled.
avatarId the id of an existing avatar.
Returns
  • The updated project

public void updateProjectCategory (ProjectCategory projectCategory)

Persist an updated project category.

Parameters
projectCategory project category.
Throws
DataAccessException If any errors occur accessing the DB.

public Project updateProjectType (ApplicationUser user, Project project, ProjectTypeKey newProjectType)

Updates the type of a project.

Parameters
user The user performing the action
project The project which type needs to be updated
newProjectType The new project type
Returns
  • The updated project