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
deleteValidationResult
is valid, invoke the delete operation:ErrorCollection deleteErrors = issueService.delete(user, deleteValidationResult);
If the
deleteValidationResult
is invalid, handle the errors appropriately.Confirm whether the deletion was successful by checking
deleteErrors
ErrorCollection.if (deleteErrors.hasAnyErrors()){ Collection<String> errorMessages = deleteErrors.getErrorMessages(); for (String errorMessage : errorMessages) { System.out.println(errorMessage); } } else { System.out.println...