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
2016-12-30 09:21:32 +01:00
committed by David Pursehouse
parent 7676042a5e
commit 54664c1508
10 changed files with 250 additions and 4 deletions

View File

@@ -30,6 +30,7 @@ import com.google.gerrit.server.index.TimestampRangePredicate;
import com.google.gerrit.server.query.AndPredicate;
import com.google.gerrit.server.query.NotPredicate;
import com.google.gerrit.server.query.OrPredicate;
import com.google.gerrit.server.query.PostFilterPredicate;
import com.google.gerrit.server.query.Predicate;
import com.google.gerrit.server.query.QueryParseException;
import java.util.Date;
@@ -76,6 +77,8 @@ public class QueryBuilder<V> {
return not(p);
} else if (p instanceof IndexPredicate) {
return fieldQuery((IndexPredicate<V>) p);
} else if (p instanceof PostFilterPredicate) {
return new MatchAllDocsQuery();
} else {
throw new QueryParseException("cannot create query for index: " + p);
}