Class DefaultProjectManager

java.lang.Object
com.atlassian.jira.project.AbstractProjectManager
com.atlassian.jira.project.DefaultProjectManager
All Implemented Interfaces:
ProjectManager

public class DefaultProjectManager extends AbstractProjectManager
A class to manage interactions with projects
  • Field Details

  • Constructor Details

  • Method Details

    • createProject

      public Project createProject(@Nonnull ApplicationUser user, @Nonnull ProjectCreationData projectCreationData)
      Description copied from interface: ProjectManager
      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.
      See Also:
    • getNextId

      public long getNextId(Project project)
      Description copied from interface: ProjectManager
      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.
    • updateProject

      public Project updateProject(Project updatedProject, String name, String description, String leadKey, String url, Long assigneeType, Long avatarId, String projectKey)
      Description copied from interface: ProjectManager
      Updates the project provided with the new attributes passed in. This method is responsible for persisting any changes to the database.
      Parameters:
      updatedProject - 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
    • updateProject

      public Project updateProject(UpdateProjectParameters parameters)
      Description copied from interface: ProjectManager
      Updates the project with the given changes.
      Parameters:
      parameters - containing the changes to the project that needs to be made.
      Returns:
      The updated project
    • updateProjectType

      public Project updateProjectType(ApplicationUser user, Project project, ProjectTypeKey newProjectType)
      Description copied from interface: ProjectManager
      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
    • removeProjectIssues

      public void removeProjectIssues(Project project) throws RemoveException
      Description copied from interface: ProjectManager
      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
    • removeProjectIssues

      public void removeProjectIssues(Project project, Context taskContext) throws RemoveException
      Description copied from interface: ProjectManager
      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.
      taskContext - A task context for providing progress.
      Throws:
      RemoveException - if there's any errors removing issues
    • removeProject

      public void removeProject(Project project)
      Description copied from interface: ProjectManager
      Deletes the provided project from the database. Please note that this method only deletes the project itself and not any related entities. Use ProjectService.deleteProject(com.atlassian.jira.user.ApplicationUser, com.atlassian.jira.bc.project.ProjectService.DeleteProjectValidationResult) to properly delete a project.
      Parameters:
      project - The project to be deleted.
    • getProject

      protected org.ofbiz.core.entity.GenericValue getProject(Long id)
    • getProjectObj

      public Project getProjectObj(Long id)
      Description copied from interface: ProjectManager
      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.
    • getProjectByName

      protected org.ofbiz.core.entity.GenericValue getProjectByName(String name)
    • getProjectByKey

      protected org.ofbiz.core.entity.GenericValue getProjectByKey(String key)
    • getProjectByCurrentKey

      public Project getProjectByCurrentKey(String projectKey)
      Description copied from interface: ProjectManager
      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.

      Specified by:
      getProjectByCurrentKey in interface ProjectManager
      Overrides:
      getProjectByCurrentKey in class AbstractProjectManager
      Parameters:
      projectKey - the Project key.
      Returns:
      the Project with the given project key.
      See Also:
    • getProjectObjByKey

      public Project getProjectObjByKey(String projectKey)
      Description copied from interface: ProjectManager
      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
    • getProjectByCurrentKeyIgnoreCase

      public Project getProjectByCurrentKeyIgnoreCase(String projectKey)
      Description copied from interface: ProjectManager
      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.
    • getProjectObjByKeyIgnoreCase

      public Project getProjectObjByKeyIgnoreCase(String projectKey)
      Description copied from interface: ProjectManager
      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.
    • getAllProjectKeys

      public Set<String> getAllProjectKeys(Long projectId)
      Description copied from interface: ProjectManager
      Returns all project keys that are associated with Project.
      Returns:
      all project keys (including the current one) associated with the project
    • getProjectObjByName

      public Project getProjectObjByName(String projectName)
      Description copied from interface: ProjectManager
      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
    • getProjects

      @Nonnull public List<Project> getProjects()
      Description copied from interface: ProjectManager
      Return all active Projects ordered by name. A project is considered active if it is not archived.
      Returns:
      all active projects ordered by name.
    • getArchivedProjects

      @Nonnull public List<Project> getArchivedProjects()
      Description copied from interface: ProjectManager
      Return archived Projects ordered by name.
      Returns:
      all projects ordered by name.
    • getProjectObjects

      @Nonnull public List<Project> getProjectObjects()
      Description copied from interface: ProjectManager
      Return all open Projects ordered by name.

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

      Returns:
      all projects ordered by name.
      See Also:
    • getProjectCount

      public long getProjectCount() throws DataAccessException
      Description copied from interface: ProjectManager
      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.
    • getDelegator

      protected OfBizDelegator getDelegator()
    • getAllProjectCategories

      public List<ProjectCategory> getAllProjectCategories()
      Description copied from interface: ProjectManager
      Returns all ProjectCategories, ordered by name.
      Returns:
      all ProjectCategories, ordered by name.
    • getProjectCategory

      public ProjectCategory getProjectCategory(Long id)
      Description copied from interface: ProjectManager
      Returns a single project category by id.
      Parameters:
      id - ProjectCategory id.
      Returns:
      the ProjectCategory for the provided id if it was found or else null
    • getProjectCategoryObject

      @Nullable public ProjectCategory getProjectCategoryObject(Long id)
      Description copied from interface: ProjectManager
      Returns a single project category by id.

      Legacy synonym for ProjectManager.getProjectCategory(Long)

      Parameters:
      id - Project Category ID.
      Returns:
      The project category
    • updateProjectCategory

      public void updateProjectCategory(@Nonnull ProjectCategory projectCategory) throws DataAccessException
      Description copied from interface: ProjectManager
      Persist an updated project category.
      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: ProjectManager
      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.
    • getProjectObjectsFromProjectCategory

      public Collection<Project> getProjectObjectsFromProjectCategory(Long projectCategoryId)
      Description copied from interface: ProjectManager
      Returns a list of projects in a particular category.
      Parameters:
      projectCategoryId - project category id.
      Returns:
      A collection of project Projects sorted by name.
    • getProjectObjectsWithNoCategory

      public Collection<Project> getProjectObjectsWithNoCategory() throws DataAccessException
      Description copied from interface: ProjectManager
      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.
    • getProjectCategoryForProject

      @Nullable public ProjectCategory getProjectCategoryForProject(Project project) throws DataAccessException
      Description copied from interface: ProjectManager
      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.
    • createProjectCategory

      public ProjectCategory createProjectCategory(String name, String description)
      Description copied from interface: ProjectManager
      Creates a new ProjectCategory with the given name and description.
      Parameters:
      name - the Name
      description - the Description.
      Returns:
      the new ProjectCategory.
    • removeProjectCategory

      public void removeProjectCategory(Long id)
      Description copied from interface: ProjectManager
      Removes the given ProjectCategory.
      Parameters:
      id - the ProjectCategory to remove.
    • isProjectCategoryUnique

      public boolean isProjectCategoryUnique(String name)
      Description copied from interface: ProjectManager
      Checks if a project category with a given name exists.
      Parameters:
      name - the name of the project category
      Returns:
      if a category with given name exists
    • setProjectCategory

      public void setProjectCategory(Project project, ProjectCategory projectCategory)
      Description copied from interface: ProjectManager
      Sets a project's category.
      Parameters:
      project - project
      projectCategory - category
    • getProjectsLeadBy

      public List<Project> getProjectsLeadBy(ApplicationUser leadUser)
      Description copied from interface: ProjectManager
      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
    • refresh

      public void refresh()
      Description copied from interface: ProjectManager
      Causes a full refresh of the project cache.
    • getCurrentCounterForProject

      public long getCurrentCounterForProject(Long id)
      Description copied from interface: ProjectManager
      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).
    • setCurrentCounterForProject

      public void setCurrentCounterForProject(Project project, long counter)
      Description copied from interface: ProjectManager
      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
    • shutdown

      @EventListener public void shutdown(ComponentManagerShutdownEvent shutdownEvent)