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 this:
Validate the delete operation on the issue using
IssueService
:DeleteValidationResult deleteValidationResult = issueService.validateDelete(user, issue.getId());
Here,
issue
is the existing issue object that needs to be deleted.If
deleteValidationResult
is valid, invoke the delete operation:if (deleteValidationResult.isValid()) { ErrorCollection deleteErrors = issueService.delete(user, deleteValidationResult); }
If
deleteValidationResult
is invalid, handle the errors appropriately.Confirm whether the deletion was successful by checking the
deleteErrors
collection:if (deleteErrors.hasAnyErrors()){ Collection<String> errorMessages = deleteErrors.getErrorMessages(); for (String errorMessage : errorMessages) { System.out.println(errorMessage...