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()); } }
public Option<RemoteIssueLink> apply(Long id) { try { return option(remoteIssueLinkManager.getRemoteIssueLink(id)); } catch (DataAccessException e) { log.error("Error retrieving remote issue link", e); return none(); } } };
try remoteIssueLinks = remoteIssueLinkManager.findRemoteIssueLinksByGlobalIds(args);
private void removeIssueLinks(ApplicationUser user, Issue issue) { // test if the issue is a sub-task // NOTE: This has to be done BEFORE removing the issue link as the sub-task issue link is // used to determine if the issue is a sub-task if (issue.isSubTask()) { // Get the parent issue before removing the links, as we need the link to determine the parent issue Issue parentIssue = issue.getParentObject(); // Remove the links issueLinkManager.removeIssueLinksNoChangeItems(issue); // We need to reorder the parent's links as the its sub-task link for this issue has been removed subTaskManager.resetSequences(parentIssue); } else { // If there are no sub-tasks so all we need to do is delete the issue's links issueLinkManager.removeIssueLinksNoChangeItems(issue); } for (RemoteIssueLink remoteIssueLink : remoteIssueLinkManager.getRemoteIssueLinksForIssue(issue)) { remoteIssueLinkManager.removeRemoteIssueLink(remoteIssueLink.getId(), user); } }
public void copyRemoteIssueLinks(final Issue localIssue, final String copiedIssueKey) { Iterable<RemoteIssueLink> remoteIssueLinksForIssue = Iterables.filter(remoteIssueLinkManager.getRemoteIssueLinksForIssue(localIssue), isNotSpecifiedRemoteLinkType(clonerIssueLinkType)); for (final RemoteIssueLink remoteIssueLink : remoteIssueLinksForIssue) { remoteJira.copyRemoteIssueLink(remoteIssueLink, copiedIssueKey); } }
@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 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); } }
@Override public void delete(final ApplicationUser user, final DeleteValidationResult deleteValidationResult) { if (deleteValidationResult == null) { throw new IllegalArgumentException("You cannot delete a remote issue link with a null validation result."); } if (!deleteValidationResult.isValid()) { throw new IllegalStateException("You cannot delete a remote issue link with an invalid validation result."); } final Long remoteIssueLinkId = deleteValidationResult.getRemoteIssueLinkId(); if (remoteIssueLinkId == null) { throw new IllegalArgumentException("You cannot delete with a null remote issue link id."); } remoteIssueLinkManager.removeRemoteIssueLink(remoteIssueLinkId, user); }
@Override public void deleteByGlobalId(final ApplicationUser user, final DeleteByGlobalIdValidationResult validationResult) { if (validationResult == null) { throw new IllegalArgumentException("You cannot delete a remote link with a null validation result."); } if (!validationResult.isValid()) { throw new IllegalStateException("You cannot delete a remote link with an invalid validation result."); } final Issue issue = validationResult.getIssue(); if (issue == null) { throw new IllegalArgumentException("You cannot delete with a null issue."); } final String globalId = validationResult.getGlobalId(); if (globalId == null) { throw new IllegalArgumentException("You cannot delete with a null remote link global id."); } remoteIssueLinkManager.removeRemoteIssueLinkByGlobalId(issue, globalId, user); }
@Override public RemoteIssueLinkResult update(final ApplicationUser user, final UpdateValidationResult updateValidationResult) { if (updateValidationResult == null) { throw new IllegalArgumentException("You cannot update a remote issue link with a null validation result."); } if (!updateValidationResult.isValid()) { throw new IllegalStateException("You cannot update a remote issue link with an invalid validation result."); } final RemoteIssueLink remoteIssueLink = updateValidationResult.getRemoteIssueLink(); if (remoteIssueLink == null) { throw new IllegalArgumentException("You cannot update a null remote issue link."); } final ErrorCollection errors = new SimpleErrorCollection(); RemoteIssueLink updatedRemoteIssueLink = null; try { remoteIssueLinkManager.updateRemoteIssueLink(remoteIssueLink, user); updatedRemoteIssueLink = remoteIssueLink; } catch (final UpdateException e) { handleUpdateException(getI18n(user), errors, e); } return new RemoteIssueLinkResult(updatedRemoteIssueLink, errors); }
public boolean isIssueWithLinks() { final MutableIssue issue = getMutableIssue(); if (issueLinkManager.isLinkingEnabled()) { //checking if there are any not-subtask issue links (inward or outward) return Iterables.any(issueLinkManager.getOutwardLinks(issue.getId()), IssueLinkCopier.isNotSubtaskIssueLink) || Iterables.any(issueLinkManager.getInwardLinks(issue.getId()), IssueLinkCopier.isNotSubtaskIssueLink) || !remoteIssueLinkManager.getRemoteIssueLinksForIssue(issue).isEmpty(); } return false; }
@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())); } }
private RemoteIssueLink validateExistsByGlobalId(final Issue issue, final String globalId, final I18nHelper i18n, final ErrorCollection errors) { if (issue == null) { errors.addError("id", i18n.getText("admin.common.words.is.required", "issue"), Reason.VALIDATION_FAILED); return null; } if (globalId == null) { errors.addError("id", i18n.getText("admin.common.words.is.required", "globalId"), Reason.VALIDATION_FAILED); return null; } final RemoteIssueLink remoteIssueLink = remoteIssueLinkManager.getRemoteIssueLinkByGlobalId(issue, globalId); if (remoteIssueLink == null) { errors.addError("globalId", i18n.getText("remotelink.service.globalid.does.not.exist.in.issue", globalId, issue.getId().toString()), Reason.NOT_FOUND); } return remoteIssueLink; }
@Override public RemoteIssueLinkListResult getRemoteIssueLinksForIssue(final ApplicationUser user, final Issue issue) { final ErrorCollection errors = new SimpleErrorCollection(); final I18nHelper i18n = getI18n(user); validateLinkingEnabled(i18n, errors); if (!errors.hasAnyErrors()) { validatePermissionToView(user, issue, errors, i18n); } List<RemoteIssueLink> remoteIssueLinks = null; if (!errors.hasAnyErrors()) { remoteIssueLinks = remoteIssueLinkManager.getRemoteIssueLinksForIssue(issue); } return new RemoteIssueLinkListResult((errors.hasAnyErrors() ? null : remoteIssueLinks), errors); }
private RemoteIssueLink validateExists(final Long remoteIssueLinkId, final I18nHelper i18n, final ErrorCollection errors) { if (remoteIssueLinkId == null) { errors.addError("id", i18n.getText("admin.common.words.is.required", "id"), Reason.VALIDATION_FAILED); return null; } final RemoteIssueLink remoteIssueLink = remoteIssueLinkManager.getRemoteIssueLink(remoteIssueLinkId); if (remoteIssueLink == null) { errors.addError("id", i18n.getText("remotelink.service.id.does.not.exist", remoteIssueLinkId.toString()), Reason.NOT_FOUND); } return remoteIssueLink; }
@Override public RemoteIssueLinkResult getRemoteIssueLinkByGlobalId(final ApplicationUser user, final Issue issue, final String globalId) { final ErrorCollection errors = new SimpleErrorCollection(); final I18nHelper i18n = getI18n(user); validateLinkingEnabled(i18n, errors); if (!errors.hasAnyErrors()) { validatePermissionToView(user, issue, errors, i18n); } RemoteIssueLink remoteIssueLink = null; if (!errors.hasAnyErrors()) { remoteIssueLink = remoteIssueLinkManager.getRemoteIssueLinkByGlobalId(issue, globalId); if (remoteIssueLink == null) { errors.addErrorMessage(i18n.getText("remotelink.service.does.not.exist"), Reason.NOT_FOUND); } } return new RemoteIssueLinkResult((errors.hasAnyErrors() ? null : remoteIssueLink), errors); }
remoteIssueLinks = remoteIssueLinkManager.findRemoteIssueLinksByGlobalIds(globalIds);
@Override public RemoteIssueLinkResult getRemoteIssueLink(final ApplicationUser user, final Long remoteIssueLinkId) { final ErrorCollection errors = new SimpleErrorCollection(); final I18nHelper i18n = getI18n(user); validateLinkingEnabled(i18n, errors); RemoteIssueLink remoteIssueLink = null; if (!errors.hasAnyErrors()) { remoteIssueLink = remoteIssueLinkManager.getRemoteIssueLink(remoteIssueLinkId); if (remoteIssueLink == null) { errors.addErrorMessage(i18n.getText("remotelink.service.does.not.exist"), Reason.NOT_FOUND); } } if (!errors.hasAnyErrors()) { validatePermissionToView(user, remoteIssueLink, errors, i18n); } return new RemoteIssueLinkResult((errors.hasAnyErrors() ? null : remoteIssueLink), errors); }