Add account predicate that checks if user can see a certain change

This predicate is useful if account queries are used to suggest users
in the context of a change, because then users that can't see the
change should be filtered out. E.g. this predicate should be used when
suggesting assignees for a change.

Change-Id: I2c43d04c65718e1e6419cf94c4bbfb21aaf7d9f8
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2018-03-13 11:06:39 +01:00
committed by David Pursehouse
parent 0f9ae13ad2
commit 1815347a33
10 changed files with 252 additions and 4 deletions

View File

@@ -21,6 +21,7 @@ import com.google.gerrit.index.query.IndexPredicate;
import com.google.gerrit.index.query.IntegerRangePredicate;
import com.google.gerrit.index.query.NotPredicate;
import com.google.gerrit.index.query.OrPredicate;
import com.google.gerrit.index.query.PostFilterPredicate;
import com.google.gerrit.index.query.Predicate;
import com.google.gerrit.index.query.QueryParseException;
import com.google.gerrit.index.query.RegexPredicate;
@@ -43,6 +44,8 @@ public class ElasticQueryBuilder {
return not(p);
} else if (p instanceof IndexPredicate) {
return fieldQuery((IndexPredicate<T>) p);
} else if (p instanceof PostFilterPredicate) {
return QueryBuilders.matchAllQuery();
} else {
throw new QueryParseException("cannot create query for index: " + p);
}