@Override public Long apply(final RemoteIssueLink remoteIssueLink) { return remoteIssueLink.getIssueId(); } });
@Override public Long apply(final RemoteIssueLink remoteIssueLink) { return remoteIssueLink.getIssueId(); } }));
@Override public boolean apply(final RemoteIssueLink input) { final Issue issue = issueMap.get(input.getIssueId()); return issue != null && (permissionManager.hasPermission(Permissions.BROWSE, issue, user)); } }));
@Override public List<RemoteIssueLink> getRemoteIssueLinksForIssue(Issue issue) { final List<RemoteIssueLink> result = new ArrayList<RemoteIssueLink>(); for (final RemoteIssueLink remoteIssueLink : remoteIssueLinks.values()) { if (issue.getId().equals(remoteIssueLink.getIssueId())) { result.add(remoteIssueLink); } } return result; }
private Issue validateIssueExists(final RemoteIssueLink remoteIssueLink, final ErrorCollection errors, final I18nHelper i18n) { final Issue issue = issueManager.getIssueObject(remoteIssueLink.getIssueId()); if (issue == null) { errors.addError("issueId", i18n.getText("remotelink.service.issue.does.not.exist", String.valueOf(remoteIssueLink.getIssueId())), Reason.VALIDATION_FAILED); } return issue; }
private URI createSelfLink(final RemoteIssueLink remoteIssueLink) { final Issue issue = issueManager.getIssueObject(remoteIssueLink.getIssueId()); return createSelfLink(remoteIssueLink, issue, contextUriInfo); }
private void validatePermissionToDelete(final ApplicationUser user, final RemoteIssueLink remoteIssueLink, final ErrorCollection errors, final I18nHelper i18n) { final IssueService.IssueResult result = issueService.getIssue(user, remoteIssueLink.getIssueId()); if (result.isValid()) { final Issue issue = result.getIssue(); hasLinkIssuePermission(user, issue, errors, i18n); } }
private void validatePermissionToView(final ApplicationUser user, final RemoteIssueLink remoteIssueLink, final ErrorCollection errors, final I18nHelper i18n) { final IssueService.IssueResult result = issueService.getIssue(user, remoteIssueLink.getIssueId()); if (result.isValid()) { validatePermissionToView(user, result.getIssue(), errors, i18n); } }
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; }
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)); }
private void validateMandatoryFields(final RemoteIssueLink remoteIssueLink, final I18nHelper i18n, final ErrorCollection errors) { if (remoteIssueLink.getIssueId() == null) { errors.addError("issueId", i18n.getText("admin.common.words.is.required", "issueId"), Reason.VALIDATION_FAILED); } if (StringUtils.isBlank(remoteIssueLink.getTitle())) { errors.addError("title", i18n.getText("admin.common.words.is.required", i18n.getText("remotelink.service.title")), Reason.VALIDATION_FAILED); } if (StringUtils.isBlank(remoteIssueLink.getUrl())) { errors.addError("url", i18n.getText("admin.common.words.is.required", i18n.getText("remotelink.service.url")), Reason.VALIDATION_FAILED); } }
@Override public boolean shouldDisplay(RemoteIssueLink remoteIssueLink) { ApplicationUser user = jiraAuthenticationContext.getLoggedInUser(); Issue issue = issueManager.getIssueObject(remoteIssueLink.getIssueId()); return isIssueDefined(issue) && isProjectDefined(issue.getProjectObject()) && softwareLicenseVerifier.isAllowedForSoftwareUsers(issue.getProjectObject(), user) && permissionChecker.hasVersionControlPermissions(issue, user); }
@Override public RemoteIssueLink createRemoteIssueLink(final RemoteIssueLink remoteIssueLink, final ApplicationUser user) throws CreateException { validateMandatoryFieldsForCreate(remoteIssueLink); validateFieldLengthsForCreate(remoteIssueLink); validateUrlsForCreate(remoteIssueLink); final Issue issue = issueManager.getIssueObject(remoteIssueLink.getIssueId()); if (issue == null) { throw new CreateException("Issue with id '" + remoteIssueLink.getIssueId() + "' does not exist."); } validateGlobalIdForCreate(issue, remoteIssueLink.getGlobalId()); final RemoteIssueLink created = remoteIssueLinkStore.createRemoteIssueLink(remoteIssueLink); if (hasDuplicateGlobalId(issue, created)) { remoteIssueLinkStore.removeRemoteIssueLink(created.getId()); throw new CreateException("A remote issue link already exists on this issue with the globalId '" + created.getGlobalId() + "'"); } createChangeItemForCreate(created, issue, user); eventPublisher.publish(new RemoteIssueLinkCreateEvent(remoteIssueLink)); return created; }
@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)); }
/** * Gets the remote issue link with the given id, and performs some error checking. An exception will be thrown if the id * is invalid, the remote issue link does not exist, or the remote issue link does not belong to the given issue. * * @param issue the issue * @param idString the remote issue link id * @return a RemoteIssueLink */ private RemoteIssueLink getRemoteIssueLinkPrivate(final Issue issue, final String idString) { final Long remoteIssueLinkId = getRemoteIssueLinkId(idString); final RemoteIssueLinkResult result = remoteIssueLinkService.getRemoteIssueLink(callingUser(), remoteIssueLinkId); if (!result.isValid()) { throw new RESTException(ErrorCollection.of(result.getErrorCollection())); } // Check if remote issue link exists final RemoteIssueLink remoteIssueLink = result.getRemoteIssueLink(); if (remoteIssueLink == null) { throw new RESTException(Response.Status.NOT_FOUND, ErrorCollection.of(i18n.getText("rest.issue.remotelink.with.id.not.found", idString))); } // Check that the remote issue link belongs to this issue if (!issue.getId().equals(remoteIssueLink.getIssueId())) { throw new RESTException(Response.Status.BAD_REQUEST, ErrorCollection.of(i18n.getText("rest.issue.remotelink.not.for.issue", idString, issue.getKey()))); } return remoteIssueLink; }
/** * Updates a remote issue link. * * @param oldRemoteIssueLink the remote issue link to update * @param request the request, containing the values of the remote issue link to be updated */ private void updateRemoteIssueLinkPrivate(final RemoteIssueLink oldRemoteIssueLink, final RemoteIssueLinkCreateOrUpdateRequest request) { final RemoteIssueLink remoteIssueLink = buildRemoteIssueLink(oldRemoteIssueLink.getIssueId(), request, oldRemoteIssueLink.getId()); final ApplicationUser user = callingUser(); final RemoteIssueLinkService.UpdateValidationResult validationResult = remoteIssueLinkService.validateUpdate(user, remoteIssueLink); if (!validationResult.isValid()) { throw new RESTException(ErrorCollection.of(validationResult.getErrorCollection())); } final RemoteIssueLinkResult result = remoteIssueLinkService.update(user, validationResult); if (!result.isValid()) { throw new RESTException(ErrorCollection.of(validationResult.getErrorCollection())); } }
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()); }
@Override public FieldMap fieldMapFrom(final RemoteIssueLink value) { return new FieldMap("id", value.getId()) .add("issueid", value.getIssueId()) .add("globalid", value.getGlobalId()) .add("title", value.getTitle()) .add("summary", value.getSummary()) .add("url", value.getUrl()) .add("iconurl", value.getIconUrl()) .add("icontitle", value.getIconTitle()) .add("relationship", value.getRelationship()) .add("resolved", booleanToString(value.isResolved())) .add("statusname", value.getStatusName()) .add("statusdescription", value.getStatusDescription()) .add("statusiconurl", value.getStatusIconUrl()) .add("statusicontitle", value.getStatusIconTitle()) .add("statusiconlink", value.getStatusIconLink()) .add("statuscategorykey", value.getStatusCategoryKey()) .add("statuscategorycolorname", value.getStatusCategoryColorName()) .add("applicationtype", value.getApplicationType()) .add("applicationname", value.getApplicationName()); }
return new RemoteIssueLink( remoteIssueLink.getId(), remoteIssueLink.getIssueId(), remoteIssueLink.getGlobalId(), remoteJiraIssue.getKey(),