use of com.google.gerrit.index.query.QueryRequiresAuthException in project gerrit by GerritCodeReview.
the class ChangeQueryBuilder method visibleto.
@Operator
public Predicate<ChangeData> visibleto(String who) throws QueryParseException, IOException, ConfigInvalidException {
if (isSelf(who)) {
return isVisible();
}
Set<Account.Id> accounts = null;
try {
accounts = parseAccount(who);
} catch (QueryParseException e) {
if (e instanceof QueryRequiresAuthException) {
throw e;
}
}
if (accounts != null) {
if (accounts.size() == 1) {
return visibleto(args.userFactory.create(Iterables.getOnlyElement(accounts)));
} else if (accounts.size() > 1) {
throw error(String.format("\"%s\" resolves to multiple accounts", who));
}
}
// If its not an account, maybe its a group?
Collection<GroupReference> suggestions = args.groupBackend.suggest(who, null);
if (!suggestions.isEmpty()) {
HashSet<AccountGroup.UUID> ids = new HashSet<>();
for (GroupReference ref : suggestions) {
ids.add(ref.getUUID());
}
return visibleto(new GroupBackedUser(ids));
}
throw error("No user or group matches \"" + who + "\".");
}
Aggregations