final I18nHelper i18n = getI18n(user); validateLinkingEnabled(i18n, errors);
@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); }
@Override public RemoteIssueLinkListResult getRemoteIssueLinksForIssue(final ApplicationUser user, final Issue issue) { final ErrorCollection errors = new SimpleErrorCollection(); final I18nHelper i18n = getI18n(user); validateLinkingEnabled(i18n, errors); if (!errors.hasAnyErrors()) { validatePermissionToView(user, issue, errors, i18n); } List<RemoteIssueLink> remoteIssueLinks = null; if (!errors.hasAnyErrors()) { remoteIssueLinks = remoteIssueLinkManager.getRemoteIssueLinksForIssue(issue); } return new RemoteIssueLinkListResult((errors.hasAnyErrors() ? null : remoteIssueLinks), errors); }
@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); }
@Override public RemoteIssueLinkResult getRemoteIssueLink(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 = remoteIssueLinkManager.getRemoteIssueLink(remoteIssueLinkId); if (remoteIssueLink == null) { errors.addErrorMessage(i18n.getText("remotelink.service.does.not.exist"), Reason.NOT_FOUND); } } if (!errors.hasAnyErrors()) { validatePermissionToView(user, remoteIssueLink, errors, i18n); } return new RemoteIssueLinkResult((errors.hasAnyErrors() ? null : remoteIssueLink), errors); }
@Override public RemoteIssueLinkResult getRemoteIssueLinkByGlobalId(final ApplicationUser user, final Issue issue, final String globalId) { final ErrorCollection errors = new SimpleErrorCollection(); final I18nHelper i18n = getI18n(user); validateLinkingEnabled(i18n, errors); if (!errors.hasAnyErrors()) { validatePermissionToView(user, issue, errors, i18n); } RemoteIssueLink remoteIssueLink = null; if (!errors.hasAnyErrors()) { remoteIssueLink = remoteIssueLinkManager.getRemoteIssueLinkByGlobalId(issue, globalId); if (remoteIssueLink == null) { errors.addErrorMessage(i18n.getText("remotelink.service.does.not.exist"), Reason.NOT_FOUND); } } return new RemoteIssueLinkResult((errors.hasAnyErrors() ? null : remoteIssueLink), errors); }
@Override public CreateValidationResult validateCreate(final ApplicationUser user, final RemoteIssueLink remoteIssueLink) { final ErrorCollection errors = new SimpleErrorCollection(); final I18nHelper i18n = getI18n(user); validateLinkingEnabled(i18n, errors); Issue issue = null; if (!errors.hasAnyErrors()) { issue = validateIssueExists(remoteIssueLink, errors, i18n); } if (!errors.hasAnyErrors()) { validatePermissionToCreate(user, issue, errors, i18n); } if (!errors.hasAnyErrors()) { validateMandatoryFields(remoteIssueLink, i18n, errors); validateFieldLengths(remoteIssueLink, i18n, errors); validateUrls(remoteIssueLink, i18n, errors); validateGlobalId(remoteIssueLink, issue, errors, i18n); } return new CreateValidationResult((errors.hasAnyErrors() ? null : remoteIssueLink), errors); }
@Override public UpdateValidationResult validateUpdate(final ApplicationUser user, final RemoteIssueLink remoteIssueLink) { final ErrorCollection errors = new SimpleErrorCollection(); final I18nHelper i18n = getI18n(user); validateLinkingEnabled(i18n, errors); Issue issue = null; if (!errors.hasAnyErrors()) { issue = validateIssueExists(remoteIssueLink, errors, i18n); } if (!errors.hasAnyErrors()) { validatePermissionToUpdate(user, issue, errors, i18n); } RemoteIssueLink found = null; if (!errors.hasAnyErrors()) { found = validateExists(remoteIssueLink.getId(), i18n, errors); } if (!errors.hasAnyErrors()) { validateMandatoryFields(remoteIssueLink, i18n, errors); validateFieldLengths(remoteIssueLink, i18n, errors); validateUrls(remoteIssueLink, i18n, errors); validateGlobalIdForUpdate(issue, found, remoteIssueLink, errors, i18n); } return new UpdateValidationResult((errors.hasAnyErrors() ? null : remoteIssueLink), errors); }