Deleting an issue
In this recipe, let us look at deleting an issue programmatically.
How to do it...
Let us assume that we have an existing issue object. For deletion as well, we will use the IssueService class. Following are the steps to do it:
Validate the delete operation on the issue using
IssueService:DeleteValidationResult deleteValidationResult = issueService.validateDelete(user, issue.getId());
Here, the issue is the existing issue object that needs to be deleted.
If
deleteValidationResultis valid, invoke the delete operation:if (deleteValidationResult.isValid()) { ErrorCollection deleteErrors = issueService.delete(user, deleteValidationResult); }If the
deleteValidationResultis invalid, handle the errors appropriately.Confirm whether the deletion was successful by checking
deleteErrorsErrorCollection:if (deleteErrors.hasAnyErrors()){ Collection<String> errorMessages = ...