private void validateUrlsForUpdate(final RemoteIssueLink remoteIssueLink) throws UpdateException { final Result result = validateUrls(remoteIssueLink); if (!result.isValid()) { throw new UpdateException(result.getMessage()); } }
private void handleUpdateException(final I18nHelper i18n, final ErrorCollection errors, final UpdateException updateException) { errors.addErrorMessage(i18n.getText("remotelink.service.error.updating", updateException.getMessage()), Reason.SERVER_ERROR); }
private void validateFieldLengthsForUpdate(final RemoteIssueLink remoteIssueLink) throws UpdateException { final Result result = validateFieldLengths(remoteIssueLink); if (!result.isValid()) { throw new UpdateException(result.getMessage()); } }
/** * Mandatory fields are: * - id (the remote issue link must exist) * - issueId * - title * - url * * @param remoteIssueLink * @throws UpdateException */ private void validateMandatoryFieldsForUpdate(final RemoteIssueLink remoteIssueLink) throws UpdateException { if (remoteIssueLink.getId() == null) { throw new UpdateException(missingMandatoryFieldMessage("id")); } final Result result = validateMandatoryFields(remoteIssueLink); if (!result.isValid()) { throw new UpdateException(result.getMessage()); } }
private void validateGlobalIdForUpdate(final Issue issue, final String oldGlobalId, final String newGlobalId) throws UpdateException { // Validate only if it has changed if (!isEqual(oldGlobalId, newGlobalId)) { final Result result = validateGlobalId(issue, newGlobalId); if (!result.isValid()) { throw new UpdateException(result.getMessage()); } } }
@Override public void updateRemoteIssueLink(final RemoteIssueLink remoteIssueLink, final ApplicationUser user) throws UpdateException { validateMandatoryFieldsForUpdate(remoteIssueLink); validateFieldLengthsForUpdate(remoteIssueLink); validateUrlsForUpdate(remoteIssueLink); final Issue issue = issueManager.getIssueObject(remoteIssueLink.getIssueId()); if (issue == null) { throw new UpdateException("Issue with id '" + remoteIssueLink.getIssueId() + "' does not exist."); } // Make sure remote issue link exists final RemoteIssueLink found = getRemoteIssueLink(remoteIssueLink.getId()); if (found == null) { throw new UpdateException("Remote link with id '" + remoteIssueLink.getId() + "' does not exist."); } else { validateGlobalIdForUpdate(issue, found.getGlobalId(), remoteIssueLink.getGlobalId()); } remoteIssueLinkStore.updateRemoteIssueLink(remoteIssueLink); if (found.getGlobalId() != null && !found.getGlobalId().equals(remoteIssueLink.getGlobalId()) && hasDuplicateGlobalId(issue, remoteIssueLink)) { remoteIssueLinkStore.updateRemoteIssueLink(found); throw new UpdateException("A remote issue link already exists on this issue with the globalId '" + remoteIssueLink.getGlobalId() + "'"); } createChangeItemForUpdate(found, remoteIssueLink, issue, user); eventPublisher.publish(new RemoteIssueLinkUpdateEvent(remoteIssueLink)); }