Class DefaultIssueTypeSchemeService

java.lang.Object
com.atlassian.jira.config.DefaultIssueTypeSchemeService
All Implemented Interfaces:
IssueTypeSchemeService

public class DefaultIssueTypeSchemeService extends Object implements IssueTypeSchemeService
Since:
v8.0
  • Constructor Details

  • Method Details

    • createIssueTypeScheme

      public ServiceOutcome<FieldConfigScheme> createIssueTypeScheme(ApplicationUser user, String name, String description, List<String> issueTypeIds, String defaultIssueTypeId)
      Description copied from interface: IssueTypeSchemeService
      Creates a new issue type scheme with the specified name, description, issue types, and default issue type. Newly created issue type schemes do not start out associated with any projects.

      This operation will fail validation and return an unsuccessful outcome if:

      • the user is not a Jira administrator
      • the name is null or an empty string
      • no issue type ids are specified
      • the new scheme's default issue type is not listed among the issueTypeIds

      Specified by:
      createIssueTypeScheme in interface IssueTypeSchemeService
      Parameters:
      user - user that performs the create operation. Must be a Jira administrator.
      name - what the new issue type scheme will be called. Must not be null or empty.
      description - optional additional information about the new scheme
      issueTypeIds - which issue types will be available to projects associated with this scheme. Must not be null or empty.
      defaultIssueTypeId - specifies which of the new scheme's issue types will be initially selected when creating a new issue (in a project associated with this scheme). Can be null (meaning no default), but otherwise must be an id found in issueTypeIds.
      Returns:
      a service outcome containing the created issue type scheme or an error if something went wrong during the operation.
    • getAllIssueTypeSchemes

      public ServiceOutcome<List<FieldConfigScheme>> getAllIssueTypeSchemes(ApplicationUser user)
      Description copied from interface: IssueTypeSchemeService
      Retrieves and returns all issue type schemes in the Jira.

      This operation will fail validation and return an unsuccessful outcome if:

      • the user is not a Jira administrator

      Specified by:
      getAllIssueTypeSchemes in interface IssueTypeSchemeService
      Parameters:
      user - user that performs the retrieval operation. Must be a Jira administrator.
      Returns:
      a service outcome containing the issue type schemes found in the Jira
    • getIssueTypeScheme

      public ServiceOutcome<FieldConfigScheme> getIssueTypeScheme(ApplicationUser user, long schemeId)
      Description copied from interface: IssueTypeSchemeService
      Retrieves the issue type scheme specified by the schemeId.

      This operation will fail validation and return an unsuccessful outcome if:

      • the user is not a Jira administrator
      • the schemeId does not correspond with a valid issue type scheme

      Specified by:
      getIssueTypeScheme in interface IssueTypeSchemeService
      Parameters:
      user - user that performs the retrieval operation. Must be a Jira administrator.
      schemeId - unique id that references an existing issue type scheme to retrieve.
      Returns:
      a service outcome containing the specified issue type scheme, if it exists.
    • updateIssueTypeScheme

      public ServiceOutcome<FieldConfigScheme> updateIssueTypeScheme(ApplicationUser user, long schemeId, String name, String description, List<String> issueTypeIds, String defaultIssueTypeId)
      Description copied from interface: IssueTypeSchemeService
      Updates the issue type scheme specified by schemeId to have the given name, description, issue types, and default issue type. Project associations are not within the scope of this operation; use setProjectAssociations or addProjectAssociations instead.

      This operation will fail validation and return an unsuccessful outcome if:

      • the user is not a Jira administrator
      • the schemeId does not correspond with a valid issue type scheme
      • an attempt is made to update the system's default issue type scheme
      • the name is null or an empty string
      • no issue type ids are specified
      • the new default issue type is not listed among the issueTypeIds being assigned
      • changing the scheme's issue types requires a migration of issues by any of its associated projects

      Specified by:
      updateIssueTypeScheme in interface IssueTypeSchemeService
      Parameters:
      user - user that performs the update operation. Must be a Jira administrator.
      schemeId - unique id that references an existing issue type scheme to update.
      name - what the issue type scheme will be called after the update. Must not be null or empty.
      description - optional additional information about the updated scheme
      issueTypeIds - which issue types will be available to projects associated with this scheme. Must not be null or empty.
      defaultIssueTypeId - specifies which of the scheme's issue types will be initially selected when creating a new issue (in a project associated with this scheme). Can be null (meaning no default), but otherwise must be an id found in issueTypeIds being assigned.
      Returns:
      a service outcome containing the updated issue type scheme or an error if something went wrong during the operation.
    • deleteIssueTypeScheme

      public ServiceOutcome<Void> deleteIssueTypeScheme(ApplicationUser user, long schemeId)
      Description copied from interface: IssueTypeSchemeService
      Deletes the issue type scheme specified by the schemeId. Any projects associated with this scheme will revert to the global default issue type scheme.

      This operation will fail validation and return an unsuccessful outcome if:

      • the user is not a Jira administrator
      • the schemeId does not correspond with a valid issue type scheme
      • an attempt is made to delete the system's default issue type scheme

      Specified by:
      deleteIssueTypeScheme in interface IssueTypeSchemeService
      Parameters:
      user - user that performs the delete operation. Must be a Jira administrator.
      schemeId - unique id that references an existing issue type scheme to delete.
      Returns:
      an empty service outcome indicating a successful deletion or an error if something went wrong during the operation.
    • addProjectAssociations

      public ServiceOutcome<Void> addProjectAssociations(ApplicationUser user, long schemeId, List<String> projectIdsOrKeys)
      Description copied from interface: IssueTypeSchemeService
      Adds additional project-scheme associations between the issue type scheme specified by the schemeId and the projects given by the projectIdsOrKeys collection. This operation does not modify or remove any existing project associations that the scheme has.

      This operation will fail validation and return an unsuccessful outcome if:

      • the user is not a Jira administrator
      • the schemeId does not correspond with a valid issue type scheme
      • any of the projectIdsOrKeys does not reference a valid project
      • associating the scheme with any of the specified projects requires an issue migration

      Specified by:
      addProjectAssociations in interface IssueTypeSchemeService
      Parameters:
      user - user that performs the association operation. Must be a Jira administrator.
      schemeId - unique id that references an existing issue type scheme to add project associations to.
      projectIdsOrKeys - lookup keys/ids for projects to be associated with the issue type scheme
      Returns:
      an empty service outcome indicating the successful addition of associated projects or an error if something went wrong during the operation.
    • getAssociatedProjects

      public ServiceOutcome<List<Project>> getAssociatedProjects(ApplicationUser user, long schemeId)
      Description copied from interface: IssueTypeSchemeService
      Retrieves the project-scheme associations for the issue type scheme specified by the schemeId.

      This operation will fail validation and return an unsuccessful outcome if:

      • the user is not a Jira administrator
      • the schemeId does not correspond with a valid issue type scheme

      Specified by:
      getAssociatedProjects in interface IssueTypeSchemeService
      Parameters:
      user - user that performs the association operation. Must be a Jira administrator.
      schemeId - unique id that references an existing issue type scheme
      Returns:
      the projects associated with the specified schemeId or an error if something went wrong during the operation.
    • setProjectAssociations

      public ServiceOutcome<Void> setProjectAssociations(ApplicationUser user, long schemeId, List<String> projectIdsOrKeys)
      Description copied from interface: IssueTypeSchemeService
      Replaces the project-scheme associations for the issue type scheme specified by the schemeId with the projects given by the projectIdsOrKeys collection. Again, this operation overwrites any existing project associations that the scheme has.

      This operation will fail validation and return an unsuccessful outcome if:

      • the user is not a Jira administrator
      • the schemeId does not correspond with a valid issue type scheme
      • any of the projectIdsOrKeys does not reference a valid project
      • associating the scheme with any of the specified projects requires an issue migration

      Specified by:
      setProjectAssociations in interface IssueTypeSchemeService
      Parameters:
      user - user that performs the association operation. Must be a Jira administrator.
      schemeId - unique id that references an existing issue type scheme.
      projectIdsOrKeys - lookup keys/ids for projects to be associated with the issue type scheme
      Returns:
      an empty service outcome indicating the successful replacement of associated projects or an error if something went wrong during the operation.
    • removeProjectAssociation

      public ServiceOutcome<Void> removeProjectAssociation(ApplicationUser user, long schemeId, String projKeyOrId)
      Description copied from interface: IssueTypeSchemeService
      For the issue type scheme specified by the schemeId, removes the project association given by projKeyOrId.

      This operation will fail validation and return an unsuccessful outcome if:

      • the user is not a Jira administrator
      • the schemeId does not correspond with a valid issue type scheme
      • the schemeId corresponds with the default global issue type scheme
      • the projKeyOrId doesn't correspond with a project that the issue type scheme is associated with
      • any of the projectIdsOrKeys does not reference a valid project

      Specified by:
      removeProjectAssociation in interface IssueTypeSchemeService
      Parameters:
      user - user that performs the removal operation. Must be a Jira administrator.
      schemeId - unique id that references an existing issue type scheme.
      projKeyOrId - key/id for the project that we're un-associating with the scheme
      Returns:
      an empty service outcome indicating the successful removal of the associated project or an error if something went wrong during the operation.
    • removeAllProjectAssociations

      public ServiceOutcome<Void> removeAllProjectAssociations(ApplicationUser user, long schemeId)
      Description copied from interface: IssueTypeSchemeService
      Removes all project associations for the issue type scheme specified by the schemeId.

      This operation will fail validation and return an unsuccessful outcome if:

      • the user is not a Jira administrator
      • the schemeId does not correspond with a valid issue type scheme
      • the schemeId corresponds with the default global issue type scheme

      Specified by:
      removeAllProjectAssociations in interface IssueTypeSchemeService
      Parameters:
      user - user that performs the removal operation. Must be a Jira administrator.
      schemeId - unique id that references an existing issue type scheme.
      Returns:
      an empty service outcome indicating the successful removal of the associated projects or an error if something went wrong during the operation.
    • getNumIssuesMatchingTypesInProjects

      public long getNumIssuesMatchingTypesInProjects(ApplicationUser user, Collection<Long> projectIds, Collection<String> issueTypeIds) throws SearchException
      Description copied from interface: IssueTypeSchemeService
      For the projects specified by projectIds, determines how many issues are of the types given by issueTypIds. This functionality is provided as a separate hook, as it can be implemented more efficiently this way rather than via getIssuesMatchingTypesInProjects(..).size().
      Specified by:
      getNumIssuesMatchingTypesInProjects in interface IssueTypeSchemeService
      Parameters:
      user - user that performs the lookup operation.
      projectIds - unique identifiers for the projects whose issues we'd like to inspect.
      issueTypeIds - unique identifiers for the issue types that we're looking for instances of in the projects.
      Returns:
      the number of issues in the given projects that are of the types specified by issueTypeIds
      Throws:
      SearchException
    • getIssuesMatchingTypesInProjects

      public List<Issue> getIssuesMatchingTypesInProjects(ApplicationUser user, Collection<Long> projectIds, Collection<String> issueTypeIds) throws SearchException
      Description copied from interface: IssueTypeSchemeService
      For the projects specified by projectIds, finds the issues that are of the types given by issueTypIds. Note: rather than calling .size() on the results of this method, use the more efficient getNumIssuesMatchingTypesInProjects(...) instead.
      Specified by:
      getIssuesMatchingTypesInProjects in interface IssueTypeSchemeService
      Parameters:
      user - user that performs the lookup operation.
      projectIds - unique identifiers for the projects whose issues we'd like to inspect.
      issueTypeIds - unique identifiers for the issue types that we're looking for instances of in the projects.
      Returns:
      List of Issues in the given projects that are of the types specified by issueTypeIds
      Throws:
      SearchException
    • getIssuesMatchingTypesInProjectsUnsorted

      public Stream<Issue> getIssuesMatchingTypesInProjectsUnsorted(ApplicationUser user, Collection<Long> projectIds, Collection<String> issueTypeIds) throws SearchException
      Description copied from interface: IssueTypeSchemeService
      For the projects specified by projectIds, finds the issues that are of the types given by issueTypIds.
      Specified by:
      getIssuesMatchingTypesInProjectsUnsorted in interface IssueTypeSchemeService
      Parameters:
      user - user that performs the lookup operation.
      projectIds - unique identifiers for the projects whose issues we'd like to inspect.
      issueTypeIds - unique identifiers for the issue types that we're looking for instances of in the projects.
      Returns:
      Unsorted stream of Issues in the given projects that are of the types specified by issueTypeIds. Note that it should be closed after use, e.g. using try-with-resources
      Throws:
      SearchException
    • getIssuesRequiringMigration

      public ServiceOutcome<List<Issue>> getIssuesRequiringMigration(ApplicationUser user, Collection<String> chosenIssueTypeIds, List<Long> projectIds)
      Description copied from interface: IssueTypeSchemeService
      Figures out which issues in the specified projects would require migration if only the chosenIssueTypeIds were made available to the projects.
      Specified by:
      getIssuesRequiringMigration in interface IssueTypeSchemeService
      Parameters:
      user - user that performs the lookup operation.
      chosenIssueTypeIds - collection of issue type ids against which we're checking the need for issue migrations.
      projectIds - collection of unique identifiers for the projects whose issues may require migration.
      Returns:
      a service outcome containing the list of issues requiring migration (if any) or an error if something went wrong during the operation.
    • getIssuesRequiringMigrationDueToSchemeAssociation

      public ServiceOutcome<List<Issue>> getIssuesRequiringMigrationDueToSchemeAssociation(ApplicationUser user, FieldConfigScheme issueTypeScheme, List<Long> projectIds)
      Description copied from interface: IssueTypeSchemeService
      Figures out which issues in the specified projects would require migration if the given issueTypeScheme were to be associated with them.
      Specified by:
      getIssuesRequiringMigrationDueToSchemeAssociation in interface IssueTypeSchemeService
      Parameters:
      user - user that performs the lookup operation.
      issueTypeScheme - issue type scheme against which we're checking the need for issue migrations.
      projectIds - collection of unique identifiers for the projects whose issues may require migration.
      Returns:
      a service outcome containing the list of issues requiring migration (if any) or an error if something went wrong during the operation.
    • errorCase

      public <T> ServiceOutcome<T> errorCase(String msg, ErrorCollection.Reason reason)
      Description copied from interface: IssueTypeSchemeService
      Creates a failed service outcome with the specified error msg and reason.
      Specified by:
      errorCase in interface IssueTypeSchemeService
      Type Parameters:
      T - generic type that corresponds with what the successful outcome would have been.
      Parameters:
      msg - string explanation of the failure.
      reason - Motivation/reason behind the failure.
      Returns:
      a failed service outcome with the specified error.
    • getDefaultIssueType

      public IssueType getDefaultIssueType(FieldConfigScheme issueTypeScheme)
      Description copied from interface: IssueTypeSchemeService
      Looks up and returns the default issue type (the one that is presented as the initial/selected choice to users when creating a new Issue, for instance) for the specified issue type scheme.
      Specified by:
      getDefaultIssueType in interface IssueTypeSchemeService
      Parameters:
      issueTypeScheme - scheme whose default issue type we'd like to look up.
      Returns:
      the default issue type for the specified issue type scheme--or null if it is unspecified.