private void validatePermissionToView(final ApplicationUser user, final RemoteIssueLink remoteIssueLink, final ErrorCollection errors, final I18nHelper i18n) { final IssueService.IssueResult result = issueService.getIssue(user, remoteIssueLink.getIssueId()); if (result.isValid()) { validatePermissionToView(user, result.getIssue(), errors, i18n); } }
@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 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); }