/** * Generates a RemoteIssueLink from an Issue and a RemoteIssueLinkCreateRequest. * * @param issueId the id of the issue * @param request the request * @param id the id of the remote issue link * @return a RemoteIssueLink */ private RemoteIssueLink buildRemoteIssueLink(final Long issueId, final RemoteIssueLinkCreateOrUpdateRequest request, final Long id) { return new RemoteIssueLinkBuilder() .issueId(issueId) .id(id) .globalId(request.globalId()) .title(request.title()) .summary(request.summary()) .url(request.url()) .iconUrl(request.iconUrl()) .iconTitle(request.iconTitle()) .relationship(request.relationship()) .resolved(request.resolved()) .statusIconUrl(request.statusIconUrl()) .statusIconTitle(request.statusIconTitle()) .statusIconLink(request.statusIconLink()) .applicationType(request.applicationType()) .applicationName(request.applicationName()) .build(); }
/** * Builds a RemoteIssueLink pointing to a page in Confluence. * @param appLink The application link to the Confluence instance. * @param pageId The identifier of the page. * @param issueId The JIRA issue that is being linked to the Confluence page. * @return A RemoteIssueLink pointing the JIRA issue to the Confluence page. */ public RemoteIssueLink build(final ApplicationLink appLink, final String pageId, final Long issueId) { final String globalId = ConfluenceGlobalIdFactoryImpl.encode(appLink.getId(), pageId); return new RemoteIssueLinkBuilder() .issueId(issueId) .url(buildPageUrl(appLink, pageId)) .title(TITLE) .globalId(globalId) .relationship(RELATIONSHIP) .applicationType(RemoteIssueLink.APPLICATION_TYPE_CONFLUENCE) .applicationName(appLink.getName()) .build(); }
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()); } }
return new RemoteIssueLinkBuilder(remoteIssueLink) .url(buildPageUrlWithSrc(BaseUrlSwapper.swapRpcUrlToDisplayUrl(confluencePage.getUrl(), appLink), "jira")) .title(confluencePage.getTitle()) .iconUrl(iconUrl) .applicationName(appLink.getName()) .build();
finalContext.put("appLinkId", applicationLink.getId()); finalContext.put("applicationUrl", applicationLink.getDisplayUrl()); remoteIssueLink = new RemoteIssueLinkBuilder(remoteIssueLink).applicationName(applicationName).build(); finalContext.put("applicationName", applicationName); finalContext.put("applicationUrl", applicationLink.getDisplayUrl()); remoteIssueLink = new RemoteIssueLinkBuilder(remoteIssueLink).applicationName(applicationName).build(); remoteIssueLink = new RemoteIssueLinkBuilder(remoteIssueLink) .iconTitle("Page") .build(); remoteIssueLink = new RemoteIssueLinkBuilder(remoteIssueLink) .relationship("mentioned in") .build();
finalContext.put("appLinkId", applicationLink.getId()); finalContext.put("applicationUrl", applicationLink.getDisplayUrl()); remoteIssueLink = new RemoteIssueLinkBuilder(remoteIssueLink).applicationName(applicationName).build(); finalContext.put("applicationName", applicationName); finalContext.put("applicationUrl", applicationLink.getDisplayUrl()); remoteIssueLink = new RemoteIssueLinkBuilder(remoteIssueLink).applicationName(applicationName).build();
private RemoteIssueLinkBuilder createBuilder(final RemoteIssueLink remoteIssueLink) { return new RemoteIssueLinkBuilder(remoteIssueLink); }
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()); } }
@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())); } }
@Override public RemoteIssueLink build(final GenericValue genericValue) { if (genericValue == null) { return null; } final RemoteIssueLinkBuilder builder = new RemoteIssueLinkBuilder(); builder.id(genericValue.getLong("id")); builder.issueId(genericValue.getLong("issueid")); builder.globalId(genericValue.getString("globalid")); builder.title(genericValue.getString("title")); builder.summary(genericValue.getString("summary")); builder.url(genericValue.getString("url")); builder.iconUrl(genericValue.getString("iconurl")); builder.iconTitle(genericValue.getString("icontitle")); builder.relationship(genericValue.getString("relationship")); builder.resolved(genericValue.getBoolean("resolved")); builder.statusName(genericValue.getString("statusname")); builder.statusDescription(genericValue.getString("statusdescription")); builder.statusIconUrl(genericValue.getString("statusiconurl")); builder.statusIconTitle(genericValue.getString("statusicontitle")); builder.statusIconLink(genericValue.getString("statusiconlink")); builder.statusCategoryKey(genericValue.getString("statuscategorykey")); builder.statusCategoryColorName(genericValue.getString("statuscategorycolorname")); builder.applicationType(genericValue.getString("applicationtype")); builder.applicationName(genericValue.getString("applicationname")); return builder.build(); }
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; }
public RemoteIssueLinkBuilder(final RemoteIssueLink remoteIssueLink) { id(remoteIssueLink.getId()); issueId(remoteIssueLink.getIssueId()); globalId(remoteIssueLink.getGlobalId()); title(remoteIssueLink.getTitle()); summary(remoteIssueLink.getSummary()); url(remoteIssueLink.getUrl()); iconUrl(remoteIssueLink.getIconUrl()); iconTitle(remoteIssueLink.getIconTitle()); relationship(remoteIssueLink.getRelationship()); resolved(remoteIssueLink.isResolved()); statusName(remoteIssueLink.getStatusName()); statusDescription(remoteIssueLink.getStatusDescription()); statusIconUrl(remoteIssueLink.getStatusIconUrl()); statusIconTitle(remoteIssueLink.getStatusIconTitle()); statusIconLink(remoteIssueLink.getStatusIconLink()); statusCategoryKey(remoteIssueLink.getStatusCategoryKey()); statusCategoryColorName(remoteIssueLink.getStatusCategoryColorName()); applicationType(remoteIssueLink.getApplicationType()); applicationName(remoteIssueLink.getApplicationName()); }