@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); }
private void cloneRemoteIssueLinks(Issue cloneIssue) throws CreateException { final List<RemoteIssueLink> originalLinks = remoteIssueLinkManager.getRemoteIssueLinksForIssue(originalIssue); for (final RemoteIssueLink originalLink : originalLinks) { final RemoteIssueLink link = new RemoteIssueLinkBuilder(originalLink).id(null).issueId(cloneIssue.getId()).build(); remoteIssueLinkManager.createRemoteIssueLink(link, getLoggedInUser()); } }
@Override public Either<NegativeResponseStatus, SuccessfulResponse> copyRemoteIssueLink(RemoteIssueLink remoteIssueLink, String remoteIssueKey) { Issue issue = issueManager.getIssueObject(remoteIssueKey); try { RemoteIssueLinkBuilder builder = new RemoteIssueLinkBuilder(remoteIssueLink).issueId(issue.getId()).id(null); remoteIssueLinkManager.createRemoteIssueLink(builder.build(), jiraAuthenticationContext.getUser()); return SuccessfulResponse.buildEither(jiraLocation); } catch (CreateException e) { return Either.left(NegativeResponseStatus.errorOccured(jiraLocation, e.getMessage())); } }