updateRemoteIssueLinkPrivate(result.getRemoteIssueLink(), request); final URI self = RemoteIssueLinkBeanBuilder.createSelfLink(result.getRemoteIssueLink(), issue, contextUriInfo); final RemoteIssueLinkCreateOrUpdateResponse response = newCreateOrUpdateResponse(result.getRemoteIssueLink(), self); return status(OK).entity(response).build();
/** * 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(); }
entity = convertToBean(result.getRemoteIssueLink());
remoteIssueLink = remoteIssueLinkResult.getRemoteIssueLink();
/** * 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; }
/** * Creates the link and publishes an event for the creation * * @param validationResult the CreateValidationResult to be used to create the link * @return create result */ public RemoteIssueLinkService.RemoteIssueLinkResult createLink(final CreateValidationResult validationResult) { final RemoteIssueLinkService.RemoteIssueLinkResult result = remoteIssueLinkService.create(getLoggedInUser(), validationResult); final RemoteIssueLink link = result.getRemoteIssueLink(); eventPublisher.publish(new RemoteIssueLinkUICreateEvent(link)); return result; }