Class DefaultIssueService

java.lang.Object
com.atlassian.jira.bc.issue.DefaultIssueService
All Implemented Interfaces:
IssueService

public class DefaultIssueService extends Object implements IssueService
The default implementation of the IssueService.
Since:
v4.1
  • Constructor Details

  • Method Details

    • getIssue

      public IssueService.IssueResult getIssue(@Nullable ApplicationUser user, Long issueId)
      Description copied from interface: IssueService
      This method will retrieve the issue with the provided issue id if the current user has permission to view the issue.
      Specified by:
      getIssue in interface IssueService
      Parameters:
      user - who the permission checks will be run against (can be null, indicating an anonymous user).
      issueId - the database ID of the issue.
      Returns:
      a result containing an Issue for the provided id if the user has the ProjectPermissions.BROWSE_PROJECTS permission for the issue, the issue will be null if the issue does not exist or the user does not have permission. The result also contains an error collection that will contain any error messages that may have been generated when performing the operation.
    • getIssue

      public IssueService.IssueResult getIssue(@Nullable ApplicationUser user, String issueKey)
      Description copied from interface: IssueService
      This method will retrieve the issue with the provided issue id if the current user has permission to view the issue.
      Specified by:
      getIssue in interface IssueService
      Parameters:
      user - who the permission checks will be run against (can be null, indicating an anonymous user).
      issueKey - the key (e.g. TST-1) of the issue.
      Returns:
      a result containing an Issue for the provided id if the user has the ProjectPermissions.BROWSE_PROJECTS permission for the issue, the issue will be null if the issue does not exist or the user does not have permission. The result also contains an error collection that will contain any error messages that may have been generated when performing the operation.
    • validateCreate

      public IssueService.CreateValidationResult validateCreate(ApplicationUser user, IssueInputParameters issueInputParameters)
      Description copied from interface: IssueService
      This method will validate parameters and check permissions and if all checks pass it will create an Issue that can be passed to the IssueService.create(ApplicationUser, CreateValidationResult) method.

      This method will validate that the provided parameters are valid for the fields that are specified by the configured create screen for the provided project/issue type, unless over-ridden with the provided fields collection in the IssueInputParameters. Any fields that are not included on the create screen or provided fields will be populated with their default values and have those values validated. If any validation fails then this method will return a null Issue. Whether the methods validation is a success or a failure the fieldValuesHolder in the result will be populated with the data that is needed for the fields to render the inputted raw parameters.

      Specified by:
      validateCreate in interface IssueService
      Parameters:
      user - who the permission checks will be run against (can be null, indicating an anonymous user).
      issueInputParameters - this represents the issue values we want to validate. It contains access to a raw map of "web" style input parameters. These parameters are used to allow the fields to attain the user inputted values. If you would like to specify some seed values for the field values holder that will be passed to the JIRA fields, then you should set your map on this input values. Also, if you want to specify which fields have been provided for user input, set the provided fields on this input, if not set this method will use the system defaults. Fields not in the provided fields collection will not be validated but they will have their defaults set.
      Returns:
      a result object containing a fully populated and validated MutableIssue if all validation passes and the user has permission to create such an issue in the provided project, otherwise the issue will be null. The result also contains an error collection that will contain any error messages that may have been generated when performing the operation. It also contains a populated FieldValuesHolder that can be used by the fields to re-render the user inputted values.
    • validateSubTaskCreate

      public IssueService.CreateValidationResult validateSubTaskCreate(ApplicationUser user, Long parentId, IssueInputParameters issueInputParameters)
      Description copied from interface: IssueService
      This method does the same as IssueService.validateCreate(ApplicationUser, IssueInputParameters) and it allows you to specify a parentId such that the created issue will be a subtask of the provided parent id.
      Specified by:
      validateSubTaskCreate in interface IssueService
      Parameters:
      user - who the permission checks will be run against (can be null, indicating an anonymous user).
      parentId - the id of the parent Issue for this subtask.
      issueInputParameters - this represents the issue values we want to validate. It contains access to a raw map of "web" style input parameters. These parameters are used to allow the fields to attain the user inputted values. If you would like to specify some seed values for the field values holder that will be passed to the JIRA fields, then you should set your map on this input values. Also, if you want to specify which fields have been provided for user input, set the provided fields on this input, if not set this method will use the system defaults. Fields not in the provided fields collection will not be validated but they will have their defaults set.
      Returns:
      a result object containing a fully populated and validated MutableIssue if all validation passes and the user has permission to create such an issue in the provided project, otherwise the issue will be null. The result also contains an error collection that will contain any error messages that may have been generated when performing the operation. It also contains a populated FieldValuesHolder that can be used by the fields to re-render the user inputted values.
    • create

      public IssueService.IssueResult create(ApplicationUser user, IssueService.CreateValidationResult createValidationResult)
      Description copied from interface: IssueService
      This method will store the provided issue to the JIRA datastore. This method will only do so if the current user has the create permission within the specified project. The issue will be created and indexed and placed into the correct initial workflow step. All workflow post-functions associated with the workflows initial action will be executed.

      This method will fire the EventType.ISSUE_CREATED_ID event, thus triggering any notifications that may need to be sent.

      Specified by:
      create in interface IssueService
      Parameters:
      user - who the permission checks will be run against (can be null, indicating an anonymous user).
      createValidationResult - contains the issue to store. This should have been created by one of the validateCreate methods. The result must have ServiceResult.isValid() return true. If false this method will throw an IllegalStateException.
      Returns:
      the a result object containing the persisted Issue if all went. If there was an error creating the issue then the issue will be null and the error collection will contain details of what went wrong.
    • create

      public IssueService.IssueResult create(ApplicationUser user, IssueService.CreateValidationResult createValidationResult, String initialWorkflowActionName)
      Description copied from interface: IssueService
      This method will store the provided issue to the JIRA datastore. This method will only do so if the current user has the create permission within the specified project. The issue will be created and indexed and placed into the correct initial workflow step. All workflow post-functions associated with the workflows initial action will be executed.

      This method should only be used if you have a very complicated custom workflow where you have defined more than one initial action. In this case the auxilarySubmitButtonValue will indicate to the workflow manager which initial action should be executed.

      This method will fire the EventType.ISSUE_CREATED_ID event, thus triggering any notifications that may need to be sent.

      Specified by:
      create in interface IssueService
      Parameters:
      user - who the permission checks will be run against (can be null, indicating an anonymous user).
      createValidationResult - contains the issue to store. This should have been created by one of the validateCreate methods. The result must have ServiceResult.isValid() return true. If false this method will throw an IllegalStateException.
      initialWorkflowActionName - indicates which initial action to execute.
      Returns:
      the a result object containing the persisted Issue if all went. If there was an error creating the issue then the issue will be null and the error collection will contain details of what went wrong.
    • validateUpdate

      public IssueService.UpdateValidationResult validateUpdate(ApplicationUser user, Long issueId, IssueInputParameters issueInputParameters)
      Description copied from interface: IssueService
      This method will validate parameters and check permissions and if all checks pass it will construct a new instance of the Issue and will update it with the new parameters. This object can then be passed to the IssueService.update(ApplicationUser, UpdateValidationResult) method.

      This method will validate that the provided parameters are valid for the fields that are specified by the configured edit screen for the issues project/issue type. Any fields that are not included on the edit screen will not be validated or populated.

      If any validation fails then this method will return a null Issue. Whether the methods validation is a success or a failure the fieldValuesHolder will be populated with the data that is needed for the fields to render the inputted raw parameters.

      The issue must also be in a open workflow state for this call to succeed.

      Specified by:
      validateUpdate in interface IssueService
      Parameters:
      user - who the permission checks will be run against (can be null, indicating an anonymous user).
      issueId - the unique identifer for the issue to update, this must be an issue that exists in JIRA with a valid project/issue type.
      issueInputParameters - this represents the issue values we want to validate. It contains access to a raw map of "web" style input parameters. These parameters are used to allow the fields to attain the user inputted values. If you would like to specify some seed values for the field values holder that will be passed to the JIRA fields, then you should set your map on this input values. Also, if you want to specify which fields have been provided for user input, set the provided fields on this input, if not set this method will use the system defaults. Fields not in the provided fields collection will not be validated but they will have their defaults set.
      Returns:
      a result that can be passed to the IssueService.update(ApplicationUser, UpdateValidationResult) method which contains an MutableIssue populated with the updated values and the error collection that contains any validation errors that may have occurred. It also contains a populated FieldValuesHolder that can be used by the fields to re-render the user inputted values.
    • update

      Description copied from interface: IssueService
      This method will store the provided issue to the JIRA datastore. Use this method to perform the default behavior for updating an issue in JIRA. This method will only update the issue if the current user has the edit permission within the specified project. The issue will be saved and re-indexed.

      This method will fire the EventType.ISSUE_UPDATED_ID event, thus triggering any notifications that may need to be sent.

      Specified by:
      update in interface IssueService
      Parameters:
      user - who the permission checks will be run against (can be null, indicating an anonymous user).
      issueValidationResult - that contains the issue to update, this should have been created via the IssueService.validateUpdate(ApplicationUser, Long, IssueInputParameters) method. The result must have ServiceResult.isValid() return true. If false this method will throw an IllegalStateException.
      Returns:
      the a result object containing the persisted Issue if all went. If there was an error updating the issue then the issue will be null and the error collection will contain details of what went wrong.
    • update

      public IssueService.IssueResult update(ApplicationUser user, IssueService.UpdateValidationResult issueValidationResult, EventDispatchOption eventDispatchOption, boolean sendMail)
      Description copied from interface: IssueService
      This method will store the provided issue to the JIRA datastore. This method will only update the issue if the current user has the edit permission within the specified project. The issue will be saved and re-indexed.

      This method should be used if you want to exert more control over what happens when JIRA updates an issue. This method will allow you to specify if an event is dispatched and if so which event is dispatched, see EventDispatchOption. This method also allows you to specify if email notifications should be send to notify users of the update.

      Specified by:
      update in interface IssueService
      Parameters:
      user - who the permission checks will be run against (can be null, indicating an anonymous user).
      issueValidationResult - contains the issue to update, this should have been created via the IssueService.validateUpdate(ApplicationUser, Long, com.atlassian.jira.issue.IssueInputParameters) method. The result must have ServiceResult.isValid() return true. If false this method will throw an IllegalStateException.
      eventDispatchOption - specifies if an event should be sent and if so which should be sent.
      sendMail - if true mail notifications will be sent, otherwise mail notifications will be suppressed.
      Returns:
      the a result object containing the persisted Issue if all went. If there was an error updating the issue then the issue will be null and the error collection will contain details of what went wrong.
    • validateDelete

      public IssueService.DeleteValidationResult validateDelete(ApplicationUser user, Long issueId)
      Description copied from interface: IssueService
      This method will check permissions to see if a user has the ProjectPermissions.DELETE_ISSUES permission in relation to the provided issue. If the current user does not have permission then an error will be added to the service contexts error collection.
      Specified by:
      validateDelete in interface IssueService
      Parameters:
      user - who the permission checks will be run against (can be null, indicating an anonymous user).
      issueId - the unique identifier of the issue to delete
      Returns:
      a result that can be passed to the IssueService.delete(ApplicationUser, com.atlassian.jira.bc.issue.IssueService.DeleteValidationResult) method which contains an MutableIssue and the error collection that contains any validation errors that may have occurred.
    • delete

      public ErrorCollection delete(ApplicationUser user, IssueService.DeleteValidationResult issueValidationResult)
      Description copied from interface: IssueService
      This method will delete an issue from JIRA. This will happen only if the current user has the ProjectPermissions.DELETE_ISSUES permission. This will clean up all issue associations in JIRA and will de-index the issue.

      This method will dispatch the EventType.ISSUE_DELETED_ID event and will generate email notifications.

      Specified by:
      delete in interface IssueService
      Parameters:
      user - who the permission checks will be run against (can be null, indicating an anonymous user).
      issueValidationResult - contains the issue to delete, this should have been created via the IssueService.validateDelete(ApplicationUser, Long) method. The result must have ServiceResult.isValid() return true. If false this method will throw an IllegalStateException.
      Returns:
      If there was an error deleting the issue then the error collection will contain details of what went wrong.
    • delete

      public ErrorCollection delete(ApplicationUser user, IssueService.DeleteValidationResult issueValidationResult, EventDispatchOption eventDispatchOption, boolean sendMail)
      Description copied from interface: IssueService
      This method will delete an issue from JIRA. This will happen only if the current user has the ProjectPermissions.DELETE_ISSUES permission. This will clean up all issue associations in JIRA and will de-index the issue.

      This method should be used if you want to exert more control over what happens when JIRA deletes an issue. This method will allow you to specify if an event is dispatched and if so which event is dispatched, see EventDispatchOption. This method also allows you to specify if email notifications should be send to notify users of the deletion.

      Specified by:
      delete in interface IssueService
      Parameters:
      user - who the permission checks will be run against (can be null, indicating an anonymous user).
      issueValidationResult - contains the issue to delete, this should have been created via the IssueService.validateDelete(ApplicationUser, Long) method. The result must have ServiceResult.isValid() return true. If false this method will throw an IllegalStateException.
      eventDispatchOption - specifies if an event should be sent and if so which should be sent.
      sendMail - if true mail notifications will be sent, otherwise mail notifications will be suppressed.
      Returns:
      If there was an error deleting the issue then the error collection will contain details of what went wrong.
    • isEditable

      public boolean isEditable(Issue issue, ApplicationUser user)
      Description copied from interface: IssueService
      Returns true if the issue can be edited by the current user. This is determined by looking at both the user's permissions and the workflow step the issue is in.
      Specified by:
      isEditable in interface IssueService
      Parameters:
      issue - the issue you want to edit
      user - the user who will be performing the edit
      Returns:
      true if the user has permission and the issue is in an editable workflow step
    • validateTransition

      public IssueService.TransitionValidationResult validateTransition(ApplicationUser user, Long issueId, int actionId, IssueInputParameters issueInputParameters)
      Description copied from interface: IssueService
      This method will validate parameters and check the transition conditions and if all checks pass it will construct a new instance of the Issue and will update it with the new parameters. This object can then be passed to the IssueService.transition(ApplicationUser, TransitionValidationResult) method.

      This method will validate that the provided parameters are valid for the fields that are specified by the configured workflow transition screen for the issues project/issue type. Any fields that are not included on the screen will not be validated or populated. If the transition has no view then the issue fields will not be validated.

      If any validation fails then this method will return a null TransitionResult. Whether the methods validation is a success or a failure the fieldValuesHolder will be populated with the data that is needed for the fields to render the inputted raw parameters.

      This will call validateTransition below with TransitionOptions.defaults().

      Specified by:
      validateTransition in interface IssueService
      Parameters:
      user - who the permission checks will be run against (can be null, indicating an anonymous user).
      issueId - the unique identifier for the issue to update, this must be an issue that exists in JIRA with a valid project/issue type.
      actionId - is the id of the workflow action that you would like to transition the issue through.
      issueInputParameters - this represents the issue values we want to validate. It contains access to a raw map of "web" style input parameters. These parameters are used to allow the fields to attain the user inputted values. If you would like to specify some seed values for the field values holder that will be passed to the JIRA fields, then you should set your map on this input values. Also, if you want to specify which fields have been provided for user input, set the provided fields on this input, if not set this method will use the system defaults. Fields not in the provided fields collection will not be validated but they will have their defaults set.
      Returns:
      a TransitionResult that contains a MutableIssue populated with the updated values and some additional parameters that are used when transitioning the issue through workflow and the error collection that contains any validation errors that may have occurred. It also contains a populated FieldValuesHolder that can be used by the fields to re-render the user inputted values.
    • validateTransition

      public IssueService.TransitionValidationResult validateTransition(ApplicationUser user, Long issueId, int actionId, IssueInputParameters issueInputParameters, TransitionOptions transitionOptions)
      Description copied from interface: IssueService
      This method will validate parameters and check the transition conditions and if all checks pass it will construct a new instance of the Issue and will update it with the new parameters. This object can then be passed to the IssueService.transition(ApplicationUser, TransitionValidationResult) method.

      This method will validate that the provided parameters are valid for the fields that are specified by the configured workflow transition screen for the issues project/issue type. Any fields that are not included on the screen will not be validated or populated. If the transition has no view then the issue fields will not be validated.

      If any validation fails then this method will return a null TransitionResult. Whether the methods validation is a success or a failure the fieldValuesHolder will be populated with the data that is needed for the fields to render the inputted raw parameters.

      Specified by:
      validateTransition in interface IssueService
      Parameters:
      user - who the permission checks will be run against (can be null, indicating an anonymous user).
      issueId - the unique identifier for the issue to update, this must be an issue that exists in JIRA with a valid project/issue type.
      actionId - is the id of the workflow action that you would like to transition the issue through.
      issueInputParameters - this represents the issue values we want to validate. It contains access to a raw map of "web" style input parameters. These parameters are used to allow the fields to attain the user inputted values. If you would like to specify some seed values for the field values holder that will be passed to the JIRA fields, then you should set your map on this input values. Also, if you want to specify which fields have been provided for user input, set the provided fields on this input, if not set this method will use the system defaults. Fields not in the provided fields collection will not be validated but they will have their defaults set.
      transitionOptions - holds whether you wish to skip conditions or validators for this API call.
      Returns:
      a TransitionResult that contains a MutableIssue populated with the updated values and some additional parameters that are used when transitioning the issue through workflow and the error collection that contains any validation errors that may have occurred. It also contains a populated FieldValuesHolder that can be used by the fields to re-render the user inputted values.
    • transition

      Description copied from interface: IssueService
      This method will store the provided issue to the JIRA datastore and will transition it through workflow. Use this method to perform the default behavior for updating and transitioning an issue in JIRA. The issue will be saved and re-indexed, the comment, if provided, will be added and the transition will be made.

      This method will fire the event associated with the workflow transition, thus triggering any notifications that may need to be sent.

      Specified by:
      transition in interface IssueService
      Parameters:
      user - who the permission checks will be run against (can be null, indicating an anonymous user).
      transitionResult - contains the issue to transition, with any updates that need to be persisted and the action id which is the id of the workflow action that you would like to transition the issue through. The result must have ServiceResult.isValid() return true. If false this method will throw an IllegalStateException.
      Returns:
      result containing the updated transitioned issue and any errors that may have occurred.
    • validateAssign

      public IssueService.AssignValidationResult validateAssign(ApplicationUser user, Long issueId, String assignee)
      Description copied from interface: IssueService
      This method will check permissions to see if a user has the permission in relation to the provided issue, and that the assignee is assignable. If validation fails then an error will be added to the service contexts error collection.
      Specified by:
      validateAssign in interface IssueService
      Parameters:
      user - who the permission checks will be run against (can be null, indicating an anonymous user).
      issueId - the unique identifier for the issue to update, this must be an issue that exists in JIRA with a valid project/issue type.
      assignee - is the id of the user to assign the issue to.
      Returns:
      an AssignValidationResult that contains an MutableIssue populated with the updated values and the error collection that contains any validation errors that may have occurred. It also contains a populated FieldValuesHolder that can be used by the fields to re-render the user inputted values.
    • assign

      Description copied from interface: IssueService
      This method will store the provided issue to the JIRA datastore and will transition it through workflow. Use this method to perform the default behavior for updating and transitioning an issue in JIRA. The issue will be saved and re-indexed, the comment, if provided, will be added and the transition will be made.

      This method will fire the event associated with the workflow transition, thus triggering any notifications that may need to be sent.

      Specified by:
      assign in interface IssueService
      Parameters:
      user - who the permission checks will be run against (can be null, indicating an anonymous user).
      assignResult - contains the issue and assigneeId for the assignment. The result must have ServiceResult.isValid() return true. If false this method will throw an IllegalStateException.
      Returns:
      result containing the updated transitioned issue and any errors that may have occurred.
    • validateClone

      public IssueService.CloneValidationResult validateClone(@Nullable ApplicationUser user, Issue issue, String summary, boolean cloneAttachments, boolean cloneSubTasks, boolean cloneLinks, Map<CustomField,Optional<Boolean>> cloneOptionSelections)
      Description copied from interface: IssueService
      This method will validate parameters. This object can then be passed to the IssueService.clone(ApplicationUser, CloneValidationResult) method.

      If any validation fails then this method will return a null CloneValidationResult. Whether the methods validation is a success or a failure the fieldValuesHolder will be populated with the data that is needed for the fields to render the inputted raw parameters.

      Specified by:
      validateClone in interface IssueService
      Parameters:
      user - who the permission checks will be run against (can be null, indicating an anonymous user).
      issue - The issue to clone, this must be an issue that exists in JIRA with a valid project/issue type.
      summary - The new Summary field value for the new issue.
      cloneAttachments - Boolean to indicate we should clone attachments.
      cloneSubTasks - Boolean to indicate we should clone sub tasks.
      cloneLinks - Boolean to indicate we should clone issue links.
      Returns:
      a CloneValidationResult.
    • clone

      Description copied from interface: IssueService
      This method will clone the issue applying the supplied summary field.
      Specified by:
      clone in interface IssueService
      Parameters:
      user - who the permission checks will be run against (can be null, indicating an anonymous user).
      cloneValidationResult - contains the issue to clone and new summary data.
      Returns:
      result containing information about the cloning task.
    • newIssueInputParameters

      public IssueInputParameters newIssueInputParameters()
      Description copied from interface: IssueService
      Constructs a new IssueInputParameters object with no initial values.

      IssueInputParameters is used as input to many of the methods in IssueService.

      Specified by:
      newIssueInputParameters in interface IssueService
      Returns:
      a new IssueInputParameters object with no initial values.
      See Also:
    • newIssueInputParameters

      public IssueInputParameters newIssueInputParameters(Map<String,String[]> actionParameters)
      Description copied from interface: IssueService
      Constructs a new IssueInputParameters object with initial values provided by the input Map.

      This is often used to pass HTTP Parameters with Issue values eg:
         issueService.newIssueInputParameters(ActionContext.getParameters())

      IssueInputParameters is used as input to many of the methods in IssueService.

      Specified by:
      newIssueInputParameters in interface IssueService
      Parameters:
      actionParameters - Parameters as received by a HTTP Request
      Returns:
      a new IssueInputParameters object with initial values provided by the input Map.
      See Also: