use of sonia.scm.repository.NamespaceAndName in project scm-review-plugin by scm-manager.
the class CommentService method markAsOutdated.
public void markAsOutdated(String namespace, String name, String pullRequestId, String commentId) {
Repository repository = repositoryResolver.resolve(new NamespaceAndName(namespace, name));
Comment rootComment = findRootComment(repository, pullRequestId, commentId).<NotFoundException>orElseThrow(() -> {
throw notFound(entity(BasicComment.class, commentId).in(PullRequest.class, pullRequestId).in(repository.getNamespaceAndName()));
});
if (!rootComment.isOutdated()) {
rootComment.setOutdated(true);
getCommentStore(repository).update(pullRequestId, rootComment);
}
}
use of sonia.scm.repository.NamespaceAndName in project scm-review-plugin by scm-manager.
the class CommentService method reply.
public String reply(String namespace, String name, String pullRequestId, String rootCommentId, Reply reply) {
Repository repository = repositoryResolver.resolve(new NamespaceAndName(namespace, name));
PermissionCheck.checkComment(repository);
PullRequest pullRequest = pullRequestService.get(repository, pullRequestId);
Comment originalRootComment = get(repository, pullRequestId, rootCommentId);
reply.setId(keyGenerator.createKey());
initializeNewComment(reply, pullRequest, repository.getId());
originalRootComment.addReply(reply);
getCommentStore(repository).update(pullRequestId, originalRootComment);
fireMentionEventIfMentionsExist(repository, pullRequest, reply);
eventBus.post(new ReplyEvent(repository, pullRequest, reply, null, originalRootComment, HandlerEventType.CREATE));
return reply.getId();
}
use of sonia.scm.repository.NamespaceAndName in project scm-review-plugin by scm-manager.
the class CommentService method modifyReply.
public void modifyReply(String namespace, String name, String pullRequestId, String replyId, Reply changedReply) {
Repository repository = repositoryResolver.resolve(new NamespaceAndName(namespace, name));
PullRequest pullRequest = pullRequestService.get(repository, pullRequestId);
findReplyWithParent(repository, pullRequestId, replyId).<NotFoundException>orElseThrow(() -> {
throw notFound(entity(Reply.class, String.valueOf(changedReply.getId())).in(PullRequest.class, pullRequestId).in(repository.getNamespaceAndName()));
}).execute((parent, reply) -> {
PermissionCheck.checkModifyComment(repository, reply);
Reply clone = reply.clone();
reply.setComment(changedReply.getComment());
reply.addTransition(new ExecutedTransition<>(keyGenerator.createKey(), CHANGE_TEXT, System.currentTimeMillis(), getCurrentUserId()));
handleMentions(repository, pullRequest, reply, clone);
getCommentStore(repository).update(pullRequestId, parent);
eventBus.post(new ReplyEvent(repository, pullRequest, reply, clone, parent, HandlerEventType.MODIFY));
});
}
use of sonia.scm.repository.NamespaceAndName in project scm-review-plugin by scm-manager.
the class CommentService method transform.
public ExecutedTransition<CommentTransition> transform(String namespace, String name, String pullRequestId, String commentId, CommentTransition transition) {
Comment comment = get(namespace, name, pullRequestId, commentId);
Repository repository = repositoryResolver.resolve(new NamespaceAndName(namespace, name));
PullRequest pullRequest = pullRequestService.get(repository, pullRequestId);
Comment clone = comment.clone();
transition.accept(clone);
ExecutedTransition<CommentTransition> executedTransition = new ExecutedTransition<>(keyGenerator.createKey(), transition, System.currentTimeMillis(), getCurrentUserId());
clone.addCommentTransition(executedTransition);
getCommentStore(repository).update(pullRequestId, clone);
eventBus.post(new CommentEvent(repository, pullRequest, comment, clone, HandlerEventType.MODIFY));
return executedTransition;
}
use of sonia.scm.repository.NamespaceAndName in project scm-review-plugin by scm-manager.
the class RepositoryConfigResource method setRepositoryConfig.
@PUT
@Path("{namespace}/{name}/config")
@Consumes(MediaType.APPLICATION_JSON)
@Operation(summary = "Update Repository pull request configuration", description = "Modifies the repository-specific pull request configuration.", tags = "Pull Request Configuration", operationId = "review_put_repo_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 \"configurePullRequest\" privilege")
@ApiResponse(responseCode = "500", description = "internal server error", content = @Content(mediaType = VndMediaType.ERROR_TYPE, schema = @Schema(implementation = ErrorDto.class)))
public void setRepositoryConfig(@PathParam("namespace") String namespace, @PathParam("name") String name, @Valid PullRequestConfigDto configDto) {
Repository repository = repositoryManager.get(new NamespaceAndName(namespace, name));
if (repository == null) {
throw notFound(entity(new NamespaceAndName(namespace, name)));
}
PermissionCheck.checkConfigure(repository);
configService.setRepositoryPullRequestConfig(repository, repositoryConfigMapper.map(configDto));
}
Aggregations