Search in sources :

Example 1 with ProjectEvent

use of com.google.gerrit.server.events.ProjectEvent in project gerrit by GerritCodeReview.

the class EventBroker method isVisibleTo.

protected boolean isVisibleTo(Event event, CurrentUser user) throws OrmException {
    if (event instanceof RefEvent) {
        RefEvent refEvent = (RefEvent) event;
        String ref = refEvent.getRefName();
        if (PatchSet.isChangeRef(ref)) {
            Change.Id cid = PatchSet.Id.fromRef(ref).getParentKey();
            try {
                Change change = notesFactory.createChecked(dbProvider.get(), refEvent.getProjectNameKey(), cid).getChange();
                return isVisibleTo(change, user);
            } catch (NoSuchChangeException e) {
                log.debug("Change {} cannot be found, falling back on ref visibility check", cid.id);
            }
        }
        return isVisibleTo(refEvent.getBranchNameKey(), user);
    } else if (event instanceof ProjectEvent) {
        return isVisibleTo(((ProjectEvent) event).getProjectNameKey(), user);
    }
    return true;
}
Also used : RefEvent(com.google.gerrit.server.events.RefEvent) NoSuchChangeException(com.google.gerrit.server.project.NoSuchChangeException) Change(com.google.gerrit.reviewdb.client.Change) ProjectEvent(com.google.gerrit.server.events.ProjectEvent)

Aggregations

Change (com.google.gerrit.reviewdb.client.Change)1 ProjectEvent (com.google.gerrit.server.events.ProjectEvent)1 RefEvent (com.google.gerrit.server.events.RefEvent)1 NoSuchChangeException (com.google.gerrit.server.project.NoSuchChangeException)1