use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class PullRequestResource method update.
@PUT
@Path("")
@Consumes(PullRequestMediaType.PULL_REQUEST)
@Operation(summary = "Update pull request", description = "Modifies a pull request.", tags = "Pull Request", operationId = "review_put_pull_request")
@ApiResponse(responseCode = "204", description = "update success")
@ApiResponse(responseCode = "400", description = "Invalid body")
@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 Response update(@Context UriInfo uriInfo, @PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("pullRequestId") String pullRequestId, PullRequestDto pullRequestDto) {
Repository repository = service.getRepository(namespace, name);
if (!PermissionCheck.mayModifyPullRequest(repository, service.get(namespace, name, pullRequestId))) {
return Response.status(Response.Status.FORBIDDEN).build();
}
PullRequest pullRequest = mapper.map(pullRequestDto);
service.update(repository, pullRequestId, pullRequest);
return Response.noContent().build();
}
use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class DefaultPullRequestService method approve.
@Override
public void approve(NamespaceAndName namespaceAndName, String pullRequestId, User user) {
Repository repository = getRepository(namespaceAndName.getNamespace(), namespaceAndName.getName());
PermissionCheck.checkComment(repository);
PullRequest pullRequest = getPullRequestFromStore(repository, pullRequestId);
pullRequest.addApprover(user.getId());
getStore(repository).update(pullRequest);
eventBus.post(new PullRequestApprovalEvent(repository, pullRequest, APPROVED));
}
use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class DefaultPullRequestService method disapprove.
@Override
public void disapprove(NamespaceAndName namespaceAndName, String pullRequestId, User user) {
Repository repository = getRepository(namespaceAndName.getNamespace(), namespaceAndName.getName());
PermissionCheck.checkComment(repository);
PullRequest pullRequest = getPullRequestFromStore(repository, pullRequestId);
Set<String> approver = pullRequest.getReviewer().keySet();
approver.stream().filter(recipient -> user.getId().equals(recipient)).findFirst().ifPresent(approval -> {
pullRequest.removeApprover(approval);
getStore(repository).update(pullRequest);
eventBus.post(new PullRequestApprovalEvent(repository, pullRequest, APPROVAL_REMOVED));
});
}
use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class AllTasksDoneRule method getComments.
private List<Comment> getComments(Context context) {
Repository repository = context.getRepository();
PullRequest pullRequest = context.getPullRequest();
return commentService.getAll(repository.getNamespace(), repository.getName(), pullRequest.getId());
}
use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class RepositoryEngineConfigResource method setRepositoryEngineConfig.
@PUT
@Path("{namespace}/{name}/config")
@Consumes(WORKFLOW_MEDIA_TYPE)
@Operation(summary = "Update Repository workflow engine configuration", description = "Modifies the repository-specific workflow engine configuration.", tags = "Workflow Engine", operationId = "review_put_repository_workflow_config")
@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 \"repository:writeWorkflowConfig\" privilege")
@ApiResponse(responseCode = "500", description = "internal server error", content = @Content(mediaType = VndMediaType.ERROR_TYPE, schema = @Schema(implementation = ErrorDto.class)))
public void setRepositoryEngineConfig(@PathParam("namespace") String namespace, @PathParam("name") String name, @Valid RepositoryEngineConfigDto configDto) {
Repository repository = loadRepository(namespace, name);
PermissionCheck.checkWriteWorkflowConfig(repository);
configurator.setEngineConfiguration(repository, mapper.map(configDto));
}
Aggregations