use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class CommentIndexer method handleEvent.
@Subscribe
public void handleEvent(ReplyEvent event) {
Reply comment = event.getItem();
PullRequest pullRequest = event.getPullRequest();
Repository repository = event.getRepository();
if (event.getEventType() == HandlerEventType.CREATE || event.getEventType() == HandlerEventType.MODIFY) {
updateIndexedComment(repository, pullRequest, IndexedComment.transform(pullRequest.getId(), comment));
} else if (event.getEventType() == HandlerEventType.DELETE) {
Reply deletedReply = event.getOldItem();
searchEngine.forType(IndexedComment.class).update(index -> index.delete().byId(createCommentId(deletedReply.getId(), pullRequest.getId(), repository.getId())));
}
}
use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class CommentService method modifyComment.
public void modifyComment(String namespace, String name, String pullRequestId, String commentId, Comment changedComment) {
Repository repository = repositoryResolver.resolve(new NamespaceAndName(namespace, name));
PullRequest pullRequest = pullRequestService.get(repository, pullRequestId);
Comment rootComment = findRootComment(repository, pullRequestId, commentId).<NotFoundException>orElseThrow(() -> {
throw notFound(entity(BasicComment.class, String.valueOf(changedComment.getId())).in(PullRequest.class, pullRequestId).in(repository.getNamespaceAndName()));
});
PermissionCheck.checkModifyComment(repository, rootComment);
Comment clone = rootComment.clone();
rootComment.setComment(changedComment.getComment());
handleMentions(repository, pullRequest, rootComment, clone);
rootComment.addTransition(new ExecutedTransition<>(keyGenerator.createKey(), CHANGE_TEXT, System.currentTimeMillis(), getCurrentUserId()));
getCommentStore(repository).update(pullRequestId, rootComment);
eventBus.post(new CommentEvent(repository, pullRequest, rootComment, clone, HandlerEventType.MODIFY));
}
use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class CommentService method add.
public String add(String namespace, String name, String pullRequestId, Comment pullRequestComment) {
Repository repository = repositoryResolver.resolve(new NamespaceAndName(namespace, name));
PermissionCheck.checkComment(repository);
return addWithoutPermissionCheck(repository, pullRequestId, pullRequestComment);
}
use of sonia.scm.repository.Repository 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.Repository 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();
}
Aggregations