@Override public void deleteByGlobalId(final ApplicationUser user, final DeleteByGlobalIdValidationResult validationResult) { if (validationResult == null) { throw new IllegalArgumentException("You cannot delete a remote link with a null validation result."); } if (!validationResult.isValid()) { throw new IllegalStateException("You cannot delete a remote link with an invalid validation result."); } final Issue issue = validationResult.getIssue(); if (issue == null) { throw new IllegalArgumentException("You cannot delete with a null issue."); } final String globalId = validationResult.getGlobalId(); if (globalId == null) { throw new IllegalArgumentException("You cannot delete with a null remote link global id."); } remoteIssueLinkManager.removeRemoteIssueLinkByGlobalId(issue, globalId, user); }
@Override public DeleteByGlobalIdValidationResult validateDeleteByGlobalId(final ApplicationUser user, final Issue issue, final String globalId) { final ErrorCollection errors = new SimpleErrorCollection(); final I18nHelper i18n = getI18n(user); validateLinkingEnabled(i18n, errors); RemoteIssueLink remoteIssueLink = null; if (!errors.hasAnyErrors()) { remoteIssueLink = validateExistsByGlobalId(issue, globalId, i18n, errors); } if (!errors.hasAnyErrors()) { validatePermissionToDelete(user, remoteIssueLink, errors, i18n); } return new DeleteByGlobalIdValidationResult(issue, globalId, errors); }
public Response deleteRemoteIssueLinkByGlobalId(final Issue issue, final String globalId) { final ApplicationUser user = callingUser(); final DeleteByGlobalIdValidationResult validationResult = remoteIssueLinkService.validateDeleteByGlobalId(user, issue, globalId); if (!validationResult.isValid()) { throw new RESTException(ErrorCollection.of(validationResult.getErrorCollection())); } remoteIssueLinkService.deleteByGlobalId(user, validationResult); return Response.noContent().cacheControl(never()).build(); }