@Override public void delete(final ApplicationUser user, final DeleteValidationResult deleteValidationResult) { if (deleteValidationResult == null) { throw new IllegalArgumentException("You cannot delete a remote issue link with a null validation result."); } if (!deleteValidationResult.isValid()) { throw new IllegalStateException("You cannot delete a remote issue link with an invalid validation result."); } final Long remoteIssueLinkId = deleteValidationResult.getRemoteIssueLinkId(); if (remoteIssueLinkId == null) { throw new IllegalArgumentException("You cannot delete with a null remote issue link id."); } remoteIssueLinkManager.removeRemoteIssueLink(remoteIssueLinkId, user); }
if (deleteValidationResult.isValid()) { remoteIssueLinkService.delete(user, deleteValidationResult);
if (!deleteValidationResult.isValid()) addErrorMessages(deleteValidationResult.getErrorCollection().getErrorMessages()); for (String error : deleteValidationResult.getErrorCollection().getErrors().values())
@RequiresXsrfCheck protected String doExecute() throws Exception { if (confirm) { remoteIssueLinkService.delete(getLoggedInUser(), deleteValidationResult); eventPublisher.publish(new RemoteIssueLinkUIDeleteEvent(deleteValidationResult.getRemoteIssueLinkId())); boolean hasRemoteIssueLinks = remoteIssueLinkService.getRemoteIssueLinksForIssue(getLoggedInUser(), getIssueObject()).getRemoteIssueLinks().iterator().hasNext(); String targetID = hasRemoteIssueLinks ? "#linkingmodule" : ""; final String redirectUrl = "/browse/" + getIssueObject().getKey() + targetID; if (isInlineDialogMode()) { return returnCompleteWithInlineRedirect(redirectUrl); } return returnComplete(redirectUrl); } else { // No confirmation supplied - ask for one return INPUT; } }
/** * Deletes a remote issue link. * * @param issue the issue * @param idString the id of the remote issue link * @return a Response with no content, or the error details if something went wrong */ public Response deleteRemoteIssueLinkById(final Issue issue, final String idString) { // Get the remote issue link to validate that it exists and belongs to the given issue final RemoteIssueLink remoteIssueLink = getRemoteIssueLinkPrivate(issue, idString); final ApplicationUser user = callingUser(); final DeleteValidationResult validationResult = remoteIssueLinkService.validateDelete(user, remoteIssueLink.getId()); if (!validationResult.isValid()) { throw new RESTException(ErrorCollection.of(validationResult.getErrorCollection())); } remoteIssueLinkService.delete(user, validationResult); return Response.noContent().cacheControl(never()).build(); }
@Override public DeleteValidationResult validateDelete(final ApplicationUser user, final Long remoteIssueLinkId) { final ErrorCollection errors = new SimpleErrorCollection(); final I18nHelper i18n = getI18n(user); validateLinkingEnabled(i18n, errors); RemoteIssueLink remoteIssueLink = null; if (!errors.hasAnyErrors()) { remoteIssueLink = validateExists(remoteIssueLinkId, i18n, errors); } if (!errors.hasAnyErrors()) { validatePermissionToDelete(user, remoteIssueLink, errors, i18n); } return new DeleteValidationResult((errors.hasAnyErrors() ? null : remoteIssueLinkId), errors); }