/** * 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()); } }
protected void doValidation() { super.doValidation(); validateUrl(pageUrl); if (hasAnyErrors()) { return; } pageUrl = ConfluencePageUrl.build(pageUrl, appLink).getUrlRebasedToRpcUrl(); String pageId = getPageId(pageUrl, appLink); if (!hasAnyErrors()) { if (pageId == null) { addErrorMessage(getText("addconfluencelink.error.pageid.notfound")); } } if (!hasAnyErrors()) { RemoteIssueLink remoteIssueLink = new ConfluenceRemoteIssueLinkBuilder().build(appLink, pageId, getIssue().getLong("id")); validationResult = remoteIssueLinkService.validateCreate(getLoggedInUser(), remoteIssueLink); if (!validationResult.isValid()) { mapErrors(validationResult.getErrorCollection()); addErrorCollection(validationResult.getErrorCollection()); } } }
private CreateValidationResult validateCreateRemote(final RemoteJiraIssue remoteJiraIssue) { final String globalId = RemoteJiraGlobalIdFactoryImpl.encode(new RemoteJiraGlobalId(getJiraAppLink(), remoteJiraIssue.getId())); // Only store the bare minimum information, the rest will be shown using the renderer plugin final RemoteIssueLink remoteIssueLink = new RemoteIssueLinkBuilder() .url(remoteJiraIssue.getBrowseUrl()) .title(remoteJiraIssue.getKey()) .globalId(globalId) .issueId(id) .relationship(linkDesc) .applicationName(getJiraAppLink().getName()) .applicationType(RemoteIssueLink.APPLICATION_TYPE_JIRA) .build(); final CreateValidationResult validationResult = remoteIssueLinkService.validateCreate(getLoggedInUser(), remoteIssueLink); if (!validationResult.isValid()) { mapErrors(validationResult.getErrorCollection()); addErrorCollection(validationResult.getErrorCollection()); } return validationResult; }