use of com.cloudogu.scm.review.pullrequest.service.PullRequest 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 com.cloudogu.scm.review.pullrequest.service.PullRequest in project scm-review-plugin by scm-manager.
the class CommentService method addWithoutPermissionCheck.
private String addWithoutPermissionCheck(Repository repository, String pullRequestId, Comment pullRequestComment) {
PullRequest pullRequest = pullRequestService.get(repository, pullRequestId);
initializeNewComment(pullRequestComment, pullRequest, repository.getId());
String newId = getCommentStore(repository).add(pullRequestId, pullRequestComment);
fireMentionEventIfMentionsExist(repository, pullRequest, pullRequestComment);
eventBus.post(new CommentEvent(repository, pullRequest, pullRequestComment, null, HandlerEventType.CREATE));
return newId;
}
use of com.cloudogu.scm.review.pullrequest.service.PullRequest in project scm-review-plugin by scm-manager.
the class BasicPRMailTextResolver method getMailSubject.
protected String getMailSubject(E event, String displayEventNameKey, Locale locale) {
Repository repository = event.getRepository();
PullRequest pullRequest = event.getPullRequest();
String displayEventName = SUBJECT_BUNDLES.get(locale).getString(displayEventNameKey);
return MessageFormat.format(SUBJECT_PATTERN, repository.getNamespace(), repository.getName(), displayEventName, pullRequest.getId(), pullRequest.getTitle());
}
use of com.cloudogu.scm.review.pullrequest.service.PullRequest in project scm-review-plugin by scm-manager.
the class BasicPRMailTextResolver method getPullRequestLink.
private String getPullRequestLink(String baseUrl, E event) {
Repository repository = event.getRepository();
PullRequest pullRequest = event.getPullRequest();
return MessageFormat.format(SCM_PULL_REQUEST_URL_PATTERN, baseUrl, repository.getNamespace(), repository.getName(), pullRequest.getId());
}
use of com.cloudogu.scm.review.pullrequest.service.PullRequest in project scm-review-plugin by scm-manager.
the class EmailNotificationHook method handleUpdatedPullRequest.
@Subscribe
public void handleUpdatedPullRequest(PullRequestUpdatedEvent event) {
PullRequest pullRequest = event.getPullRequest();
handleEvent(event, new PullRequestUpdatedMailTextResolver(event), pullRequest, getSubscribersWithoutCurrentUser(pullRequest));
}
Aggregations