/** * Creates the link and publishes an event for the creation * * @param validationResult the CreateValidationResult to be used to create the link * @return create result */ public RemoteIssueLinkService.RemoteIssueLinkResult createLink(final CreateValidationResult validationResult) { final RemoteIssueLinkService.RemoteIssueLinkResult result = remoteIssueLinkService.create(getLoggedInUser(), validationResult); final RemoteIssueLink link = result.getRemoteIssueLink(); eventPublisher.publish(new RemoteIssueLinkUICreateEvent(link)); return result; }
/** * Creates a remote issue link. * * @param issue the issue to create the link with * @param request the request, containing the values of the remote issue link to be created * @param contextUriInfo uri context, for building the self link * @return a Response containing a RemoteIssueLinkCreateOrUpdateResponse, or the error details if something went wrong */ private Response createRemoteIssueLink(final Issue issue, final RemoteIssueLinkCreateOrUpdateRequest request, final ContextUriInfo contextUriInfo) { final RemoteIssueLink remoteIssueLink = buildRemoteIssueLink(issue.getId(), request); final ApplicationUser user = callingUser(); final CreateValidationResult validationResult = remoteIssueLinkService.validateCreate(user, remoteIssueLink); if (!validationResult.isValid()) { throw new RESTException(ErrorCollection.of(validationResult.getErrorCollection())); } final RemoteIssueLinkResult result = remoteIssueLinkService.create(user, validationResult); if (!result.isValid()) { throw new RESTException(ErrorCollection.of(validationResult.getErrorCollection())); } final URI self = RemoteIssueLinkBeanBuilder.createSelfLink(result.getRemoteIssueLink(), issue, contextUriInfo); final RemoteIssueLinkCreateOrUpdateResponse response = newCreateOrUpdateResponse(result.getRemoteIssueLink(), self); return status(CREATED).location(self).entity(response).build(); }
public void createLinkToRemoteIssue(final Issue localIssue, final ApplicationLink applicationLink, final String remoteIssueKey, final Long remoteIssueId, final String relationship) { final String globalId = encodeGlobalId(applicationLink.getId(), remoteIssueId); final String url = buildIssueUrl(applicationLink.getDisplayUrl().toASCIIString(), remoteIssueKey); final RemoteIssueLink remoteIssueLink = new RemoteIssueLinkBuilder() .globalId(globalId) .applicationType(RemoteIssueLink.APPLICATION_TYPE_JIRA) .relationship(relationship) .url(url) .applicationName(applicationLink.getName()) .issueId(localIssue.getId()) .title(remoteIssueKey) .build(); final ApplicationUser user = callingUser(); final RemoteIssueLinkService.CreateValidationResult issueLinkValidationResult = remoteIssueLinkService.validateCreate(user, remoteIssueLink); if (issueLinkValidationResult.isValid()) { final RemoteIssueLinkService.RemoteIssueLinkResult remoteIssueLinkResult = remoteIssueLinkService.create(user, issueLinkValidationResult); } else { log.error("Failed to create issue link to remote JIRA issue with key '" + remoteIssueKey + "' Error(s): " + issueLinkValidationResult.getErrorCollection()); } }