use of com.cloudogu.scm.review.PullRequestResourceLinks in project scm-review-plugin by scm-manager.
the class CommentRootResource method getAll.
@GET
@Path("")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Get all pull request comments", description = "Returns all pull request comments.", tags = "Pull Request Comment", operationId = "review_get_comments")
@ApiResponse(responseCode = "200", description = "success", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = HalRepresentation.class)))
@ApiResponse(responseCode = "401", description = "not authenticated / invalid credentials")
@ApiResponse(responseCode = "403", description = "not authorized, the current user does not have the \"commentPullRequest\" privilege")
@ApiResponse(responseCode = "500", description = "internal server error", content = @Content(mediaType = VndMediaType.ERROR_TYPE, schema = @Schema(implementation = ErrorDto.class)))
public HalRepresentation getAll(@Context UriInfo uriInfo, @PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("pullRequestId") String pullRequestId) {
PullRequestResourceLinks resourceLinks = new PullRequestResourceLinks(uriInfo::getBaseUri);
Repository repository = repositoryResolver.resolve(new NamespaceAndName(namespace, name));
PullRequest pullRequest = pullRequestService.get(namespace, name, pullRequestId);
BranchRevisionResolver.RevisionResult revisions = branchRevisionResolver.getRevisions(new NamespaceAndName(namespace, name), pullRequest);
List<Comment> list = service.getAll(namespace, name, pullRequestId);
List<CommentDto> dtoList = list.stream().map(comment -> mapper.map(comment, repository, pullRequestId, service.possibleTransitions(namespace, name, pullRequestId, comment.getId()), revisions)).collect(Collectors.toList());
boolean permission = PermissionCheck.mayComment(repository);
return createCollection(permission, resourceLinks.pullRequestComments().all(namespace, name, pullRequestId), resourceLinks.pullRequestComments().create(namespace, name, pullRequestId, revisions), dtoList, "pullRequestComments");
}
use of com.cloudogu.scm.review.PullRequestResourceLinks in project scm-review-plugin by scm-manager.
the class PullRequestRootResource method getAll.
@GET
@Path("{namespace}/{name}")
@Produces(PullRequestMediaType.PULL_REQUEST_COLLECTION)
@Operation(summary = "Collection of pull requests", description = "Returns a list of pull requests by status.", tags = "Pull Request", operationId = "review_get_pull_request_collection")
@ApiResponse(responseCode = "200", description = "success", content = @Content(mediaType = PullRequestMediaType.PULL_REQUEST_COLLECTION, schema = @Schema(implementation = HalRepresentation.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 HalRepresentation getAll(@Context UriInfo uriInfo, @PathParam("namespace") String namespace, @PathParam("name") String name, @QueryParam("status") @DefaultValue("OPEN") PullRequestSelector pullRequestSelector) {
Repository repository = service.getRepository(namespace, name);
PermissionCheck.checkRead(repository);
List<PullRequestDto> pullRequestDtos = service.getAll(namespace, name).stream().filter(pullRequestSelector).map(pr -> mapper.using(uriInfo).map(pr, repository)).sorted(Comparator.comparing(this::getLastModification).reversed()).collect(Collectors.toList());
PullRequestResourceLinks resourceLinks = new PullRequestResourceLinks(uriInfo::getBaseUri);
boolean permission = PermissionCheck.mayCreate(repository);
return createCollection(permission, resourceLinks.pullRequestCollection().all(namespace, name), resourceLinks.pullRequestCollection().create(namespace, name), pullRequestDtos, "pullRequests");
}
use of com.cloudogu.scm.review.PullRequestResourceLinks in project scm-review-plugin by scm-manager.
the class GlobalEngineConfigMapper method create.
@ObjectFactory
GlobalEngineConfigDto create(@Context UriInfo uriInfo) {
final Links.Builder linksBuilder = new Links.Builder();
PullRequestResourceLinks.WorkflowEngineGlobalConfigLinks workflowEngineGlobalConfigLinks = new PullRequestResourceLinks(uriInfo::getBaseUri).workflowEngineGlobalConfigLinks();
linksBuilder.self(workflowEngineGlobalConfigLinks.getConfig());
if (PermissionCheck.mayConfigureGlobalWorkflowConfig()) {
linksBuilder.single(link("update", workflowEngineGlobalConfigLinks.setConfig()));
}
if (PermissionCheck.mayReadGlobalWorkflowConfig() || PermissionCheck.mayConfigureGlobalWorkflowConfig()) {
linksBuilder.single(link("availableRules", workflowEngineGlobalConfigLinks.availableRules()));
}
return new GlobalEngineConfigDto(linksBuilder.build());
}
use of com.cloudogu.scm.review.PullRequestResourceLinks in project scm-review-plugin by scm-manager.
the class MergeResource method check.
@POST
@Path("{namespace}/{name}/{pullRequestId}/merge-check")
@Produces(PullRequestMediaType.MERGE_CHECK_RESULT)
@Operation(summary = "Check pull request merge", description = "Checks if the pull request can be merged.", tags = "Pull Request")
@ApiResponse(responseCode = "200", description = "update success", content = @Content(mediaType = PullRequestMediaType.MERGE_CHECK_RESULT, schema = @Schema(implementation = MergeCheckResultDto.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 = "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 MergeCheckResultDto check(@PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("pullRequestId") String pullRequestId, @Context UriInfo uriInfo) {
NamespaceAndName namespaceAndName = new NamespaceAndName(namespace, name);
MergeCheckResult mergeCheckResult = service.checkMerge(namespaceAndName, pullRequestId);
String checkLink = new PullRequestResourceLinks(uriInfo::getBaseUri).mergeLinks().check(namespace, name, pullRequestId);
return new MergeCheckResultDto(Links.linkingTo().self(checkLink).build(), mergeCheckResult.hasConflicts(), mergeCheckResult.getMergeObstacles());
}
use of com.cloudogu.scm.review.PullRequestResourceLinks in project scm-review-plugin by scm-manager.
the class PullRequestRootResource method createCheckResultLinks.
private Links createCheckResultLinks(UriInfo uriInfo, Repository repository, String source, String target) {
PullRequestResourceLinks pullRequestResourceLinks = new PullRequestResourceLinks(uriInfo::getBaseUri);
String checkLink = String.format("%s?source=%s&target=%s", pullRequestResourceLinks.pullRequestCollection().check(repository.getNamespace(), repository.getName()), source, target);
return Links.linkingTo().self(checkLink).build();
}
Aggregations