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()); }
public AbstractRemoteIssueLinkEvent(RemoteIssueLink remoteIssueLink) { this.remoteIssueLinkId = remoteIssueLink.getId(); this.globalId = remoteIssueLink.getGlobalId(); }
public RemoteIssueLinkBean build() { final URI self = createSelfLink(remoteIssueLink); return new RemoteIssueLinkBean( remoteIssueLink.getId(), self, remoteIssueLink.getGlobalId(), remoteIssueLink.getApplicationType(), remoteIssueLink.getApplicationName(), remoteIssueLink.getRelationship(), remoteIssueLink.getUrl(), remoteIssueLink.getTitle(), remoteIssueLink.getSummary(), remoteIssueLink.getIconUrl(), remoteIssueLink.getIconTitle(), remoteIssueLink.isResolved(), remoteIssueLink.getStatusIconUrl(), remoteIssueLink.getStatusIconTitle(), remoteIssueLink.getStatusIconLink() ); }
private void validateGlobalId(final RemoteIssueLink remoteIssueLink, final Issue issue, final ErrorCollection errors, final I18nHelper i18n) { if (remoteIssueLink.getGlobalId() == null) { // No need to check for duplicates if it is null return; } // Check for duplicate globalId final RemoteIssueLink found = remoteIssueLinkManager.getRemoteIssueLinkByGlobalId(issue, remoteIssueLink.getGlobalId()); if (found != null) { errors.addError("globalId", i18n.getText("remotelink.service.globalid.duplicate", remoteIssueLink.getTitle()), Reason.VALIDATION_FAILED); } }
return new RemoteIssueLink( remoteIssueLink.getId(), remoteIssueLink.getIssueId(), remoteIssueLink.getGlobalId(), remoteJiraIssue.getKey(), remoteJiraIssue.getSummary(), BaseUrlSwapper.swapRpcUrlToDisplayUrl(remoteJiraIssue.getIconUrl(), jiraAppLink), remoteJiraIssue.getIconTitle(), remoteIssueLink.getRelationship(), remoteJiraIssue.isResolved(), BaseUrlSwapper.swapRpcUrlToDisplayUrl(remoteJiraIssue.getStatusIconUrl(), jiraAppLink), remoteJiraIssue.getStatusIconTitle(), BaseUrlSwapper.swapRpcUrlToDisplayUrl(remoteIssueLink.getStatusIconLink(), jiraAppLink), remoteIssueLink.getApplicationType(), jiraAppLink.getName(), remoteJiraIssue.getStatusName(),
private Result validateFieldLengths(final RemoteIssueLink remoteIssueLink) { if (isLongerThan(remoteIssueLink.getGlobalId(), MAX_LONG_VARCHAR_LENGTH)) { return new Result(false, tooLongFieldMessage("globalId", MAX_LONG_VARCHAR_LENGTH)); } if (isLongerThan(remoteIssueLink.getTitle(), MAX_LONG_VARCHAR_LENGTH)) { return new Result(false, tooLongFieldMessage("title", MAX_LONG_VARCHAR_LENGTH)); } if (isLongerThan(remoteIssueLink.getRelationship(), MAX_LONG_VARCHAR_LENGTH)) { return new Result(false, tooLongFieldMessage("relationship", MAX_LONG_VARCHAR_LENGTH)); } if (isLongerThan(remoteIssueLink.getApplicationType(), MAX_LONG_VARCHAR_LENGTH)) { return new Result(false, tooLongFieldMessage("applicationType", MAX_LONG_VARCHAR_LENGTH)); } if (isLongerThan(remoteIssueLink.getApplicationName(), MAX_LONG_VARCHAR_LENGTH)) { return new Result(false, tooLongFieldMessage("applicationName", MAX_LONG_VARCHAR_LENGTH)); } return TRUE; }
@Override public void updateRemoteIssueLink(final RemoteIssueLink remoteIssueLink, final ApplicationUser user) throws UpdateException { validateMandatoryFieldsForUpdate(remoteIssueLink); validateFieldLengthsForUpdate(remoteIssueLink); validateUrlsForUpdate(remoteIssueLink); final Issue issue = issueManager.getIssueObject(remoteIssueLink.getIssueId()); if (issue == null) { throw new UpdateException("Issue with id '" + remoteIssueLink.getIssueId() + "' does not exist."); } // Make sure remote issue link exists final RemoteIssueLink found = getRemoteIssueLink(remoteIssueLink.getId()); if (found == null) { throw new UpdateException("Remote link with id '" + remoteIssueLink.getId() + "' does not exist."); } else { validateGlobalIdForUpdate(issue, found.getGlobalId(), remoteIssueLink.getGlobalId()); } remoteIssueLinkStore.updateRemoteIssueLink(remoteIssueLink); if (found.getGlobalId() != null && !found.getGlobalId().equals(remoteIssueLink.getGlobalId()) && hasDuplicateGlobalId(issue, remoteIssueLink)) { remoteIssueLinkStore.updateRemoteIssueLink(found); throw new UpdateException("A remote issue link already exists on this issue with the globalId '" + remoteIssueLink.getGlobalId() + "'"); } createChangeItemForUpdate(found, remoteIssueLink, issue, user); eventPublisher.publish(new RemoteIssueLinkUpdateEvent(remoteIssueLink)); }
if (RemoteIssueLink.APPLICATION_TYPE_JIRA.equals(remoteIssueLink.getApplicationType())) { final Map<String, String> values = GlobalIdFactory.decode(remoteIssueLink.getGlobalId(), GLOBAL_ID_KEYS); if (internalHostApplication.getId().get().equals(values.get("appId"))) { createIssueLink(user, issue, issueToLinkTo, remoteIssueLink.getRelationship()); } catch(IssueLinkCreationException e){ errors.addErrorCollection(e.getErrorCollection()); } finally { final RemoteIssueLinkService.DeleteValidationResult deleteValidationResult = remoteIssueLinkService.validateDelete(user, remoteIssueLink.getId()); if (deleteValidationResult.isValid()) { remoteIssueLinkService.delete(user, deleteValidationResult);
private Result validateUrls(final RemoteIssueLink remoteIssueLink) { if (!isValidUrl(remoteIssueLink.getUrl())) { return new Result(false, invalidUrlMessage("url")); } if (!isValidUrl(remoteIssueLink.getIconUrl())) { return new Result(false, invalidUrlMessage("iconUrl")); } if (!isValidUrl(remoteIssueLink.getStatusIconUrl())) { return new Result(false, invalidUrlMessage("statusIconUrl")); } if (!isValidUrl(remoteIssueLink.getStatusIconLink())) { return new Result(false, invalidUrlMessage("statusIconLink")); } return TRUE; }
private Result validateMandatoryFields(final RemoteIssueLink remoteIssueLink) { if (remoteIssueLink.getIssueId() == null) { return new Result(false, missingMandatoryFieldMessage("issueId")); } if (StringUtils.isBlank(remoteIssueLink.getTitle())) { return new Result(false, missingMandatoryFieldMessage("title")); } if (StringUtils.isBlank(remoteIssueLink.getUrl())) { return new Result(false, missingMandatoryFieldMessage("url")); } return TRUE; }
@Override public void updateRemoteIssueLink(RemoteIssueLink remoteIssueLink) { remoteIssueLinks.put(remoteIssueLink.getId(), remoteIssueLink); }
@Override public Long apply(final RemoteIssueLink remoteIssueLink) { return remoteIssueLink.getIssueId(); } });
@Override public boolean apply(@Nullable final RemoteIssueLink ril) { return ril.getGlobalId() == null; } })));
private void removeRemoteIssueLink(RemoteIssueLink remoteIssueLink, ApplicationUser user) { remoteIssueLinkStore.removeRemoteIssueLink(remoteIssueLink.getId()); final Issue issue = issueManager.getIssueObject(remoteIssueLink.getIssueId()); createChangeItemForRemove(remoteIssueLink, issue, user); eventPublisher.publish(new RemoteIssueLinkDeleteEvent(remoteIssueLink)); }
@Override public RemoteIssueLink decorate(final RemoteIssueLink remoteIssueLink) throws CredentialsRequiredException, IOException, PermissionException { if (!RemoteIssueLink.APPLICATION_TYPE_JIRA.equals(remoteIssueLink.getApplicationType())) { throw new IllegalArgumentException("Remote link is not to JIRA"); } final RemoteJiraGlobalId remoteJiraGlobalId = remoteJiraGlobalIdFactory.decode(remoteIssueLink.getGlobalId()); final ApplicationLink jiraAppLink = remoteJiraGlobalId.getApplicationLink(); final String remoteIssueID = String.valueOf(remoteJiraGlobalId.getRemoteIssueId()); try { final RemoteResponse<RemoteJiraIssue> response = remoteJiraRestService.getIssue(jiraAppLink, remoteIssueID, RemoteJiraRestService.RestVersion.VERSION_2); return handleJiraResponse(response, remoteIssueLink, jiraAppLink); } catch (final ResponseException exception) { throw new IOException("Failed to load JIRA issue from remote server", exception); } // TODO: Retrieval of non-AppLinked issues was here. See r163408. }
@Override public ConfluenceGlobalId create(final RemoteIssueLink link) { final Map<String, String> values = GlobalIdFactory.decode(link.getGlobalId(), KEYS); // Get application link final String appId = values.get(APP_ID_KEY); final ApplicationLink appLink = getApplicationLink(appId, link.getUrl()); if (appLink == null) { throw new IllegalArgumentException("No Application Link found for the given Application Id: " + appId + " or URL: " + link.getUrl()); } // Get issue id final String pageId = values.get(PAGE_ID_KEY); return new ConfluenceGlobalId(appLink, pageId); }
public RemoteIssueLinkUICreateEvent(RemoteIssueLink remoteIssueLink) { super(remoteIssueLink); this.applicationType = remoteIssueLink.getApplicationType(); }
if (StringUtils.isBlank(remoteIssueLink.getIconTitle())) if (StringUtils.isBlank(remoteIssueLink.getRelationship()))
private String getChangeItemDescription(final RemoteIssueLink remoteIssueLink, final ApplicationUser remoteUser) { final I18nHelper i18nHelper = i18nBeanFactory.getInstance(remoteUser); final String applicationName = StringUtils.defaultIfEmpty(remoteIssueLink.getApplicationName(), i18nHelper.getText("remotelink.manager.changeitem.applicationname.default")); return i18nHelper.getText("remotelink.manager.changeitem", remoteIssueLink.getTitle(), applicationName); }
public String getRelationship() { return (remoteIssueLink == null ? null : remoteIssueLink.getRelationship()); }