use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class PullRequestResource method reject.
@POST
@Path("reject")
@Operation(summary = "Reject pull request", description = "Rejects a pull request.", tags = "Pull Request")
@ApiResponse(responseCode = "204", description = "update success")
@ApiResponse(responseCode = "401", description = "not authenticated / invalid credentials")
@ApiResponse(responseCode = "403", description = "not authorized, the current user does not have the \"modifyPullRequest\" privilege")
@ApiResponse(responseCode = "404", description = "not found, no pull request with the specified id is available")
@ApiResponse(responseCode = "500", description = "internal server error", content = @Content(mediaType = VndMediaType.ERROR_TYPE, schema = @Schema(implementation = ErrorDto.class)))
public void reject(@PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("pullRequestId") String pullRequestId) {
Repository repository = service.getRepository(namespace, name);
service.reject(repository, pullRequestId, PullRequestRejectedEvent.RejectionCause.REJECTED_BY_USER);
}
use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class PullRequestResource method subscribe.
@POST
@Path("subscribe")
@Operation(summary = "Subscribe", description = "Subscribes current user to a pull request.", tags = "Pull Request")
@ApiResponse(responseCode = "204", description = "update success")
@ApiResponse(responseCode = "401", description = "not authenticated / invalid credentials")
@ApiResponse(responseCode = "403", description = "not authorized, the current user does not have the \"modifyPullRequest\" privilege")
@ApiResponse(responseCode = "500", description = "internal server error", content = @Content(mediaType = VndMediaType.ERROR_TYPE, schema = @Schema(implementation = ErrorDto.class)))
public void subscribe(@Context UriInfo uriInfo, @PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("pullRequestId") String pullRequestId) {
Repository repository = service.getRepository(namespace, name);
PermissionCheck.checkRead(repository);
service.subscribe(repository, pullRequestId);
}
use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class PullRequestResource method events.
@GET
@Path("events")
@SseResponse
@Operation(summary = "Register SSE", hidden = true)
@Produces(MediaType.SERVER_SENT_EVENTS)
public void events(@Context Sse sse, @Context SseEventSink eventSink, @BeanParam EventSubscriptionRequest request) {
Repository repository = service.getRepository(request.getNamespace(), request.getName());
PermissionCheck.checkRead(repository);
PullRequest pullRequest = service.get(repository, request.getPullRequestId());
Channel channel = channelRegistry.channel(new ChannelId(repository, pullRequest));
channel.register(new Registration(request.getSessionId(), sse, eventSink));
}
use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class PullRequestResource method get.
@GET
@Path("")
@Produces(PullRequestMediaType.PULL_REQUEST)
@Operation(summary = "Get pull requests", description = "Returns a single pull request by id.", tags = "Pull Request", operationId = "review_get_pull_requests")
@ApiResponse(responseCode = "200", description = "success", content = @Content(mediaType = PullRequestMediaType.PULL_REQUEST, schema = @Schema(implementation = PullRequestDto.class)))
@ApiResponse(responseCode = "401", description = "not authenticated / invalid credentials")
@ApiResponse(responseCode = "403", description = "not authorized, the current user does not have the \"readPullRequest\" privilege")
@ApiResponse(responseCode = "500", description = "internal server error", content = @Content(mediaType = VndMediaType.ERROR_TYPE, schema = @Schema(implementation = ErrorDto.class)))
public PullRequestDto get(@Context UriInfo uriInfo, @PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("pullRequestId") String pullRequestId) {
Repository repository = service.getRepository(namespace, name);
PermissionCheck.checkRead(repository);
return mapper.using(uriInfo).map(service.get(namespace, name, pullRequestId), repository);
}
use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class PullRequestResource method getSubscription.
@GET
@Path("subscription")
@Produces(PullRequestMediaType.PULL_REQUEST)
@Operation(summary = "Evaluates which subscription link should be used", hidden = true)
@ApiResponse(responseCode = "200", description = "success")
@ApiResponse(responseCode = "401", description = "not authenticated / invalid credentials")
@ApiResponse(responseCode = "403", description = "not authorized, the current user does not have the \"readPullRequest\" privilege")
@ApiResponse(responseCode = "500", description = "internal server error", content = @Content(mediaType = VndMediaType.ERROR_TYPE, schema = @Schema(implementation = ErrorDto.class)))
public Response getSubscription(@Context UriInfo uriInfo, @PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("pullRequestId") String pullRequestId) {
Repository repository = service.getRepository(namespace, name);
PermissionCheck.checkRead(repository);
if (CurrentUserResolver.getCurrentUser() != null && Strings.isNullOrEmpty(CurrentUserResolver.getCurrentUser().getMail())) {
return Response.ok().build();
}
if (service.isUserSubscribed(repository, pullRequestId)) {
PullRequestResourceLinks resourceLinks = new PullRequestResourceLinks(uriInfo::getBaseUri);
String unsubscribe = resourceLinks.pullRequest().unsubscribe(namespace, name, pullRequestId);
Links.Builder linksBuilder = linkingTo().single(Link.link("unsubscribe", unsubscribe));
return Response.ok(new HalRepresentation(linksBuilder.build())).build();
} else {
PullRequestResourceLinks resourceLinks = new PullRequestResourceLinks(uriInfo::getBaseUri);
String subscribe = resourceLinks.pullRequest().subscribe(namespace, name, pullRequestId);
Links.Builder linksBuilder = linkingTo().single(Link.link("subscribe", subscribe));
return Response.ok(new HalRepresentation(linksBuilder.build())).build();
}
}
Aggregations