use of com.github.legman.Subscribe in project scm-review-plugin by scm-manager.
the class CommentIndexer method handleEvent.
@Subscribe
public void handleEvent(CommentEvent event) {
Comment 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) {
Comment deletedComment = event.getOldItem();
searchEngine.forType(IndexedComment.class).update(index -> index.delete().byId(createCommentId(deletedComment.getId(), pullRequest.getId(), repository.getId())));
}
}
use of com.github.legman.Subscribe 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 com.github.legman.Subscribe in project scm-review-plugin by scm-manager.
the class EmailNotificationHook method handleCommentEvents.
@Subscribe
public void handleCommentEvents(CommentEvent event) {
if (!isSystemComment(event)) {
PullRequest pullRequest = event.getPullRequest();
handleEvent(event, new CommentEventMailTextResolver(event), pullRequest, getSubscribersWithoutCurrentUser(pullRequest));
}
}
use of com.github.legman.Subscribe in project scm-review-plugin by scm-manager.
the class EventListener method handle.
@Subscribe
public void handle(BasicPullRequestEvent event) {
Channel channel = channel(event);
channel.broadcast(message(event));
}
use of com.github.legman.Subscribe in project scm-review-plugin by scm-manager.
the class BranchProtectionHook method onEvent.
@Subscribe(async = false)
public void onEvent(PreReceiveRepositoryHookEvent event) {
HookContext context = event.getContext();
Repository repository = event.getRepository();
if (ignoreHook(context, repository)) {
return;
}
if (!service.isEnabled(repository)) {
log.trace("branch protection is disabled.");
return;
}
log.trace("received hook for repository {}", repository.getName());
for (String branch : context.getBranchProvider().getCreatedOrModified()) {
if (service.isBranchProtected(repository, branch)) {
context.getChangesetProvider().getChangesets().forEach(changeset -> {
if (changeset.getBranches().contains(branch) && !changeset.getParents().isEmpty()) {
throw new BranchOnlyWritableByMergeException(repository, branch);
}
});
}
}
for (String branch : context.getBranchProvider().getDeletedOrClosed()) {
if (service.isBranchProtected(repository, branch)) {
throw new BranchOnlyWritableByMergeException(repository, branch);
}
}
}
Aggregations