@Override public RemoteIssueLinkResult create(final ApplicationUser user, final CreateValidationResult createValidationResult) { if (createValidationResult == null) { throw new IllegalArgumentException("You cannot create a remote issue link with a null validation result."); } if (!createValidationResult.isValid()) { throw new IllegalStateException("You cannot create a remote issue link with an invalid validation result."); } final RemoteIssueLink remoteIssueLink = createValidationResult.getRemoteIssueLink(); if (remoteIssueLink == null) { throw new IllegalArgumentException("You cannot create a null remote issue link."); } final ErrorCollection errors = new SimpleErrorCollection(); RemoteIssueLink createdRemoteIssueLink = null; try { createdRemoteIssueLink = remoteIssueLinkManager.createRemoteIssueLink(remoteIssueLink, user); } catch (final CreateException e) { handleCreateException(getI18n(user), errors, e); } return new RemoteIssueLinkResult(createdRemoteIssueLink, errors); }
@Override public RemoteIssueLinkResult update(final ApplicationUser user, final UpdateValidationResult updateValidationResult) { if (updateValidationResult == null) { throw new IllegalArgumentException("You cannot update a remote issue link with a null validation result."); } if (!updateValidationResult.isValid()) { throw new IllegalStateException("You cannot update a remote issue link with an invalid validation result."); } final RemoteIssueLink remoteIssueLink = updateValidationResult.getRemoteIssueLink(); if (remoteIssueLink == null) { throw new IllegalArgumentException("You cannot update a null remote issue link."); } final ErrorCollection errors = new SimpleErrorCollection(); RemoteIssueLink updatedRemoteIssueLink = null; try { remoteIssueLinkManager.updateRemoteIssueLink(remoteIssueLink, user); updatedRemoteIssueLink = remoteIssueLink; } catch (final UpdateException e) { handleUpdateException(getI18n(user), errors, e); } return new RemoteIssueLinkResult(updatedRemoteIssueLink, 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); }