use of sonia.scm.repository.NamespaceAndName in project scm-review-plugin by scm-manager.
the class CommentService method possibleTransitions.
public Collection<CommentTransition> possibleTransitions(String namespace, String name, String pullRequestId, String commentId) {
Repository repository = repositoryResolver.resolve(new NamespaceAndName(namespace, name));
if (!PermissionCheck.mayComment(repository)) {
return emptyList();
}
Comment comment = get(namespace, name, pullRequestId, commentId);
switch(comment.getType()) {
case COMMENT:
return singleton(MAKE_TASK);
case TASK_TODO:
return asList(SET_DONE, MAKE_COMMENT);
case TASK_DONE:
return asList(REOPEN, MAKE_COMMENT);
default:
throw new IllegalStateException("unknown type in comment: " + comment.getType());
}
}
use of sonia.scm.repository.NamespaceAndName in project scm-review-plugin by scm-manager.
the class CommentService method delete.
public void delete(String namespace, String name, String pullRequestId, String commentId) {
Repository repository = repositoryResolver.resolve(new NamespaceAndName(namespace, name));
PullRequest pullRequest = pullRequestService.get(repository, pullRequestId);
findRootComment(repository, pullRequestId, commentId).ifPresent(rootComment -> {
PermissionCheck.checkModifyComment(repository, rootComment);
doThrow().violation("Must not delete system comment").when(rootComment.isSystemComment());
doThrow().violation("Must not delete root comment with existing replies").when(!rootComment.getReplies().isEmpty());
getCommentStore(repository).delete(pullRequestId, commentId);
eventBus.post(new CommentEvent(repository, pullRequest, null, rootComment, HandlerEventType.DELETE));
});
findReplyWithParent(repository, pullRequestId, commentId).ifPresent(replyWithParent -> replyWithParent.execute((parent, reply) -> {
PermissionCheck.checkModifyComment(repository, reply);
doThrow().violation("Must not delete system reply").when(reply.isSystemReply());
parent.removeReply(reply);
getCommentStore(repository).update(pullRequestId, parent);
eventBus.post(new ReplyEvent(repository, pullRequest, null, reply, parent, HandlerEventType.DELETE));
}));
}
use of sonia.scm.repository.NamespaceAndName in project scm-review-plugin by scm-manager.
the class CommentService method getAll.
public List<Comment> getAll(String namespace, String name, String pullRequestId) {
Repository repository = repositoryResolver.resolve(new NamespaceAndName(namespace, name));
PermissionCheck.checkRead(repository);
return getCommentStore(repository).getAll(pullRequestId);
}
use of sonia.scm.repository.NamespaceAndName in project scm-review-plugin by scm-manager.
the class RepositoryConfigResource method getRepositoryConfig.
@GET
@Path("{namespace}/{name}/config")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Repository pull request configuration", description = "Returns the repository-specific pull request configuration.", tags = "Pull Request Configuration", operationId = "review_get_repo_config")
@ApiResponse(responseCode = "200", description = "success", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = PullRequestConfigDto.class)))
@ApiResponse(responseCode = "401", description = "not authenticated / invalid credentials")
@ApiResponse(responseCode = "403", description = "not authorized, the current user does not have the \"configurePullRequest\" privilege")
@ApiResponse(responseCode = "500", description = "internal server error", content = @Content(mediaType = VndMediaType.ERROR_TYPE, schema = @Schema(implementation = ErrorDto.class)))
public PullRequestConfigDto getRepositoryConfig(@Context UriInfo uriInfo, @PathParam("namespace") String namespace, @PathParam("name") String name) {
Repository repository = repositoryManager.get(new NamespaceAndName(namespace, name));
if (repository == null) {
throw notFound(entity(new NamespaceAndName(namespace, name)));
}
PermissionCheck.checkConfigure(repository);
return repositoryConfigMapper.map(configService.getRepositoryPullRequestConfig(repository), repository, uriInfo);
}
use of sonia.scm.repository.NamespaceAndName in project scm-review-plugin by scm-manager.
the class MergeResource method emergencyMerge.
@POST
@Path("{namespace}/{name}/{pullRequestId}/emergency")
@Consumes(PullRequestMediaType.MERGE_COMMAND)
@Operation(summary = "Merge pull request", description = "Merges pull request with selected strategy as emergency merge.", 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 \"performEmergencyMerge\" 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 emergencyMerge(@PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("pullRequestId") String pullRequestId, @QueryParam("strategy") MergeStrategy strategy, @NotNull @Valid MergeCommitDto mergeCommitDto) {
NamespaceAndName namespaceAndName = new NamespaceAndName(namespace, name);
service.merge(namespaceAndName, pullRequestId, mergeCommitDto, strategy, true);
}
Aggregations