|
|
|
@@ -17,18 +17,16 @@ package com.google.gerrit.server.query.change;
|
|
|
|
import static com.google.gerrit.server.query.change.ChangeData.asChanges;
|
|
|
|
import static com.google.gerrit.server.query.change.ChangeData.asChanges;
|
|
|
|
|
|
|
|
|
|
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
|
|
|
|
|
|
import com.google.common.base.Function;
|
|
|
|
import com.google.common.base.Optional;
|
|
|
|
import com.google.common.base.Optional;
|
|
|
|
import com.google.common.collect.ImmutableSet;
|
|
|
|
import com.google.common.collect.ImmutableSet;
|
|
|
|
import com.google.common.collect.Iterables;
|
|
|
|
import com.google.common.collect.Iterables;
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
import com.google.gerrit.common.data.GroupDetail;
|
|
|
|
|
|
|
|
import com.google.gerrit.common.data.GroupReference;
|
|
|
|
import com.google.gerrit.common.data.GroupReference;
|
|
|
|
import com.google.gerrit.common.errors.NoSuchGroupException;
|
|
|
|
|
|
|
|
import com.google.gerrit.common.errors.NotSignedInException;
|
|
|
|
import com.google.gerrit.common.errors.NotSignedInException;
|
|
|
|
|
|
|
|
import com.google.gerrit.extensions.common.AccountInfo;
|
|
|
|
import com.google.gerrit.reviewdb.client.Account;
|
|
|
|
import com.google.gerrit.reviewdb.client.Account;
|
|
|
|
import com.google.gerrit.reviewdb.client.AccountGroup;
|
|
|
|
import com.google.gerrit.reviewdb.client.AccountGroup;
|
|
|
|
import com.google.gerrit.reviewdb.client.AccountGroupById;
|
|
|
|
|
|
|
|
import com.google.gerrit.reviewdb.client.AccountGroupMember;
|
|
|
|
|
|
|
|
import com.google.gerrit.reviewdb.client.Branch;
|
|
|
|
import com.google.gerrit.reviewdb.client.Branch;
|
|
|
|
import com.google.gerrit.reviewdb.client.Change;
|
|
|
|
import com.google.gerrit.reviewdb.client.Change;
|
|
|
|
import com.google.gerrit.reviewdb.client.RefNames;
|
|
|
|
import com.google.gerrit.reviewdb.client.RefNames;
|
|
|
|
@@ -42,8 +40,6 @@ import com.google.gerrit.server.account.GroupBackend;
|
|
|
|
import com.google.gerrit.server.account.GroupBackends;
|
|
|
|
import com.google.gerrit.server.account.GroupBackends;
|
|
|
|
import com.google.gerrit.server.account.VersionedAccountDestinations;
|
|
|
|
import com.google.gerrit.server.account.VersionedAccountDestinations;
|
|
|
|
import com.google.gerrit.server.account.VersionedAccountQueries;
|
|
|
|
import com.google.gerrit.server.account.VersionedAccountQueries;
|
|
|
|
import com.google.gerrit.server.account.GroupCache;
|
|
|
|
|
|
|
|
import com.google.gerrit.server.account.GroupDetailFactory;
|
|
|
|
|
|
|
|
import com.google.gerrit.server.change.ChangeTriplet;
|
|
|
|
import com.google.gerrit.server.change.ChangeTriplet;
|
|
|
|
import com.google.gerrit.server.config.AllProjectsName;
|
|
|
|
import com.google.gerrit.server.config.AllProjectsName;
|
|
|
|
import com.google.gerrit.server.config.AllUsersName;
|
|
|
|
import com.google.gerrit.server.config.AllUsersName;
|
|
|
|
@@ -52,6 +48,7 @@ import com.google.gerrit.server.config.GerritServerConfig;
|
|
|
|
import com.google.gerrit.server.config.TrackingFooters;
|
|
|
|
import com.google.gerrit.server.config.TrackingFooters;
|
|
|
|
import com.google.gerrit.server.git.GitRepositoryManager;
|
|
|
|
import com.google.gerrit.server.git.GitRepositoryManager;
|
|
|
|
import com.google.gerrit.server.git.strategy.SubmitStrategyFactory;
|
|
|
|
import com.google.gerrit.server.git.strategy.SubmitStrategyFactory;
|
|
|
|
|
|
|
|
import com.google.gerrit.server.group.ListMembers;
|
|
|
|
import com.google.gerrit.server.index.ChangeIndex;
|
|
|
|
import com.google.gerrit.server.index.ChangeIndex;
|
|
|
|
import com.google.gerrit.server.index.FieldDef;
|
|
|
|
import com.google.gerrit.server.index.FieldDef;
|
|
|
|
import com.google.gerrit.server.index.IndexCollection;
|
|
|
|
import com.google.gerrit.server.index.IndexCollection;
|
|
|
|
@@ -155,7 +152,6 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|
|
|
final Provider<InternalChangeQuery> queryProvider;
|
|
|
|
final Provider<InternalChangeQuery> queryProvider;
|
|
|
|
final IndexRewriter rewriter;
|
|
|
|
final IndexRewriter rewriter;
|
|
|
|
final IdentifiedUser.GenericFactory userFactory;
|
|
|
|
final IdentifiedUser.GenericFactory userFactory;
|
|
|
|
final GroupDetailFactory.Factory groupDetailFactory;
|
|
|
|
|
|
|
|
final CapabilityControl.Factory capabilityControlFactory;
|
|
|
|
final CapabilityControl.Factory capabilityControlFactory;
|
|
|
|
final ChangeControl.GenericFactory changeControlGenericFactory;
|
|
|
|
final ChangeControl.GenericFactory changeControlGenericFactory;
|
|
|
|
final ChangeData.Factory changeDataFactory;
|
|
|
|
final ChangeData.Factory changeDataFactory;
|
|
|
|
@@ -168,14 +164,14 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|
|
|
final PatchListCache patchListCache;
|
|
|
|
final PatchListCache patchListCache;
|
|
|
|
final GitRepositoryManager repoManager;
|
|
|
|
final GitRepositoryManager repoManager;
|
|
|
|
final ProjectCache projectCache;
|
|
|
|
final ProjectCache projectCache;
|
|
|
|
final GroupCache groupCache;
|
|
|
|
|
|
|
|
final Provider<ListChildProjects> listChildProjects;
|
|
|
|
final Provider<ListChildProjects> listChildProjects;
|
|
|
|
final SubmitStrategyFactory submitStrategyFactory;
|
|
|
|
final SubmitStrategyFactory submitStrategyFactory;
|
|
|
|
final ConflictsCache conflictsCache;
|
|
|
|
final ConflictsCache conflictsCache;
|
|
|
|
final TrackingFooters trackingFooters;
|
|
|
|
final TrackingFooters trackingFooters;
|
|
|
|
final boolean allowsDrafts;
|
|
|
|
|
|
|
|
final ChangeIndex index;
|
|
|
|
final ChangeIndex index;
|
|
|
|
final IndexConfig indexConfig;
|
|
|
|
final IndexConfig indexConfig;
|
|
|
|
|
|
|
|
final Provider<ListMembers> listMembers;
|
|
|
|
|
|
|
|
final boolean allowsDrafts;
|
|
|
|
|
|
|
|
|
|
|
|
private final Provider<CurrentUser> self;
|
|
|
|
private final Provider<CurrentUser> self;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -187,7 +183,6 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|
|
|
IdentifiedUser.GenericFactory userFactory,
|
|
|
|
IdentifiedUser.GenericFactory userFactory,
|
|
|
|
Provider<CurrentUser> self,
|
|
|
|
Provider<CurrentUser> self,
|
|
|
|
CapabilityControl.Factory capabilityControlFactory,
|
|
|
|
CapabilityControl.Factory capabilityControlFactory,
|
|
|
|
GroupDetailFactory.Factory groupDetailFactory,
|
|
|
|
|
|
|
|
ChangeControl.GenericFactory changeControlGenericFactory,
|
|
|
|
ChangeControl.GenericFactory changeControlGenericFactory,
|
|
|
|
ChangeData.Factory changeDataFactory,
|
|
|
|
ChangeData.Factory changeDataFactory,
|
|
|
|
FieldDef.FillArgs fillArgs,
|
|
|
|
FieldDef.FillArgs fillArgs,
|
|
|
|
@@ -199,22 +194,22 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|
|
|
PatchListCache patchListCache,
|
|
|
|
PatchListCache patchListCache,
|
|
|
|
GitRepositoryManager repoManager,
|
|
|
|
GitRepositoryManager repoManager,
|
|
|
|
ProjectCache projectCache,
|
|
|
|
ProjectCache projectCache,
|
|
|
|
GroupCache groupCache,
|
|
|
|
|
|
|
|
Provider<ListChildProjects> listChildProjects,
|
|
|
|
Provider<ListChildProjects> listChildProjects,
|
|
|
|
IndexCollection indexes,
|
|
|
|
IndexCollection indexes,
|
|
|
|
SubmitStrategyFactory submitStrategyFactory,
|
|
|
|
SubmitStrategyFactory submitStrategyFactory,
|
|
|
|
ConflictsCache conflictsCache,
|
|
|
|
ConflictsCache conflictsCache,
|
|
|
|
TrackingFooters trackingFooters,
|
|
|
|
TrackingFooters trackingFooters,
|
|
|
|
IndexConfig indexConfig,
|
|
|
|
IndexConfig indexConfig,
|
|
|
|
|
|
|
|
Provider<ListMembers> listMembers,
|
|
|
|
@GerritServerConfig Config cfg) {
|
|
|
|
@GerritServerConfig Config cfg) {
|
|
|
|
this(db, queryProvider, rewriter, userFactory, self,
|
|
|
|
this(db, queryProvider, rewriter, userFactory, self,
|
|
|
|
capabilityControlFactory, groupDetailFactory, changeControlGenericFactory,
|
|
|
|
capabilityControlFactory, changeControlGenericFactory,
|
|
|
|
changeDataFactory, fillArgs, plcUtil, accountResolver, groupBackend,
|
|
|
|
changeDataFactory, fillArgs, plcUtil, accountResolver, groupBackend,
|
|
|
|
allProjectsName, allUsersName, patchListCache, repoManager,
|
|
|
|
allProjectsName, allUsersName, patchListCache, repoManager,
|
|
|
|
projectCache, groupCache, listChildProjects, submitStrategyFactory,
|
|
|
|
projectCache, listChildProjects, submitStrategyFactory,
|
|
|
|
conflictsCache, trackingFooters,
|
|
|
|
conflictsCache, trackingFooters,
|
|
|
|
indexes != null ? indexes.getSearchIndex() : null,
|
|
|
|
indexes != null ? indexes.getSearchIndex() : null,
|
|
|
|
indexConfig,
|
|
|
|
indexConfig, listMembers,
|
|
|
|
cfg == null ? true : cfg.getBoolean("change", "allowDrafts", true));
|
|
|
|
cfg == null ? true : cfg.getBoolean("change", "allowDrafts", true));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -225,7 +220,6 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|
|
|
IdentifiedUser.GenericFactory userFactory,
|
|
|
|
IdentifiedUser.GenericFactory userFactory,
|
|
|
|
Provider<CurrentUser> self,
|
|
|
|
Provider<CurrentUser> self,
|
|
|
|
CapabilityControl.Factory capabilityControlFactory,
|
|
|
|
CapabilityControl.Factory capabilityControlFactory,
|
|
|
|
GroupDetailFactory.Factory groupDetailFactory,
|
|
|
|
|
|
|
|
ChangeControl.GenericFactory changeControlGenericFactory,
|
|
|
|
ChangeControl.GenericFactory changeControlGenericFactory,
|
|
|
|
ChangeData.Factory changeDataFactory,
|
|
|
|
ChangeData.Factory changeDataFactory,
|
|
|
|
FieldDef.FillArgs fillArgs,
|
|
|
|
FieldDef.FillArgs fillArgs,
|
|
|
|
@@ -237,13 +231,13 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|
|
|
PatchListCache patchListCache,
|
|
|
|
PatchListCache patchListCache,
|
|
|
|
GitRepositoryManager repoManager,
|
|
|
|
GitRepositoryManager repoManager,
|
|
|
|
ProjectCache projectCache,
|
|
|
|
ProjectCache projectCache,
|
|
|
|
GroupCache groupCache,
|
|
|
|
|
|
|
|
Provider<ListChildProjects> listChildProjects,
|
|
|
|
Provider<ListChildProjects> listChildProjects,
|
|
|
|
SubmitStrategyFactory submitStrategyFactory,
|
|
|
|
SubmitStrategyFactory submitStrategyFactory,
|
|
|
|
ConflictsCache conflictsCache,
|
|
|
|
ConflictsCache conflictsCache,
|
|
|
|
TrackingFooters trackingFooters,
|
|
|
|
TrackingFooters trackingFooters,
|
|
|
|
ChangeIndex index,
|
|
|
|
ChangeIndex index,
|
|
|
|
IndexConfig indexConfig,
|
|
|
|
IndexConfig indexConfig,
|
|
|
|
|
|
|
|
Provider<ListMembers> listMembers,
|
|
|
|
boolean allowsDrafts) {
|
|
|
|
boolean allowsDrafts) {
|
|
|
|
this.db = db;
|
|
|
|
this.db = db;
|
|
|
|
this.queryProvider = queryProvider;
|
|
|
|
this.queryProvider = queryProvider;
|
|
|
|
@@ -251,7 +245,6 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|
|
|
this.userFactory = userFactory;
|
|
|
|
this.userFactory = userFactory;
|
|
|
|
this.self = self;
|
|
|
|
this.self = self;
|
|
|
|
this.capabilityControlFactory = capabilityControlFactory;
|
|
|
|
this.capabilityControlFactory = capabilityControlFactory;
|
|
|
|
this.groupDetailFactory = groupDetailFactory;
|
|
|
|
|
|
|
|
this.changeControlGenericFactory = changeControlGenericFactory;
|
|
|
|
this.changeControlGenericFactory = changeControlGenericFactory;
|
|
|
|
this.changeDataFactory = changeDataFactory;
|
|
|
|
this.changeDataFactory = changeDataFactory;
|
|
|
|
this.fillArgs = fillArgs;
|
|
|
|
this.fillArgs = fillArgs;
|
|
|
|
@@ -263,24 +256,25 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|
|
|
this.patchListCache = patchListCache;
|
|
|
|
this.patchListCache = patchListCache;
|
|
|
|
this.repoManager = repoManager;
|
|
|
|
this.repoManager = repoManager;
|
|
|
|
this.projectCache = projectCache;
|
|
|
|
this.projectCache = projectCache;
|
|
|
|
this.groupCache = groupCache;
|
|
|
|
|
|
|
|
this.listChildProjects = listChildProjects;
|
|
|
|
this.listChildProjects = listChildProjects;
|
|
|
|
this.submitStrategyFactory = submitStrategyFactory;
|
|
|
|
this.submitStrategyFactory = submitStrategyFactory;
|
|
|
|
this.conflictsCache = conflictsCache;
|
|
|
|
this.conflictsCache = conflictsCache;
|
|
|
|
this.trackingFooters = trackingFooters;
|
|
|
|
this.trackingFooters = trackingFooters;
|
|
|
|
this.allowsDrafts = allowsDrafts;
|
|
|
|
|
|
|
|
this.index = index;
|
|
|
|
this.index = index;
|
|
|
|
this.indexConfig = indexConfig;
|
|
|
|
this.indexConfig = indexConfig;
|
|
|
|
|
|
|
|
this.listMembers = listMembers;
|
|
|
|
|
|
|
|
this.allowsDrafts = allowsDrafts;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Arguments asUser(CurrentUser otherUser) {
|
|
|
|
Arguments asUser(CurrentUser otherUser) {
|
|
|
|
return new Arguments(db, queryProvider, rewriter, userFactory,
|
|
|
|
return new Arguments(db, queryProvider, rewriter, userFactory,
|
|
|
|
Providers.of(otherUser),
|
|
|
|
Providers.of(otherUser),
|
|
|
|
capabilityControlFactory, groupDetailFactory, changeControlGenericFactory,
|
|
|
|
capabilityControlFactory, changeControlGenericFactory,
|
|
|
|
changeDataFactory, fillArgs, plcUtil, accountResolver, groupBackend,
|
|
|
|
changeDataFactory, fillArgs, plcUtil, accountResolver, groupBackend,
|
|
|
|
allProjectsName, allUsersName, patchListCache, repoManager,
|
|
|
|
allProjectsName, allUsersName, patchListCache, repoManager,
|
|
|
|
projectCache, groupCache, listChildProjects, submitStrategyFactory,
|
|
|
|
projectCache, listChildProjects, submitStrategyFactory,
|
|
|
|
conflictsCache, trackingFooters, index, indexConfig, allowsDrafts);
|
|
|
|
conflictsCache, trackingFooters, index, indexConfig, listMembers,
|
|
|
|
|
|
|
|
allowsDrafts);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Arguments asUser(Account.Id otherId) {
|
|
|
|
Arguments asUser(Account.Id otherId) {
|
|
|
|
@@ -603,8 +597,15 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|
|
|
|
|
|
|
|
|
|
|
// expand a group predicate into multiple user predicates
|
|
|
|
// expand a group predicate into multiple user predicates
|
|
|
|
if (group != null) {
|
|
|
|
if (group != null) {
|
|
|
|
Set<Account.Id> allMembers = getMemberIds(
|
|
|
|
Set<Account.Id> allMembers =
|
|
|
|
group, new HashSet<AccountGroup.UUID>());
|
|
|
|
new HashSet<>(Lists.transform(
|
|
|
|
|
|
|
|
args.listMembers.get().setRecursive(true).apply(group),
|
|
|
|
|
|
|
|
new Function<AccountInfo, Account.Id>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public Account.Id apply(AccountInfo accountInfo) {
|
|
|
|
|
|
|
|
return new Account.Id(accountInfo._accountId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}));
|
|
|
|
int maxTerms = args.indexConfig.maxLimit();
|
|
|
|
int maxTerms = args.indexConfig.maxLimit();
|
|
|
|
if (allMembers.size() > maxTerms) {
|
|
|
|
if (allMembers.size() > maxTerms) {
|
|
|
|
// limit the number of query terms otherwise Gerrit will barf
|
|
|
|
// limit the number of query terms otherwise Gerrit will barf
|
|
|
|
@@ -951,39 +952,6 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|
|
|
return g;
|
|
|
|
return g;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Set<Account.Id> getMemberIds(AccountGroup.UUID groupUUID,
|
|
|
|
|
|
|
|
Set<AccountGroup.UUID> seenGroups) throws OrmException {
|
|
|
|
|
|
|
|
seenGroups.add(groupUUID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Set<Account.Id> members = new HashSet<>();
|
|
|
|
|
|
|
|
AccountGroup group = args.groupCache.get(groupUUID);
|
|
|
|
|
|
|
|
if (group != null) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
GroupDetail groupDetail =
|
|
|
|
|
|
|
|
args.groupDetailFactory.create(group.getId()).call();
|
|
|
|
|
|
|
|
if (groupDetail.members != null) {
|
|
|
|
|
|
|
|
for (AccountGroupMember m : groupDetail.members) {
|
|
|
|
|
|
|
|
if (!members.contains(m.getAccountId())) {
|
|
|
|
|
|
|
|
members.add(m.getAccountId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get members of subgroups
|
|
|
|
|
|
|
|
if (groupDetail.includes != null) {
|
|
|
|
|
|
|
|
for (AccountGroupById includedGroup : groupDetail.includes) {
|
|
|
|
|
|
|
|
if (!seenGroups.contains(includedGroup.getIncludeUUID())) {
|
|
|
|
|
|
|
|
members.addAll(
|
|
|
|
|
|
|
|
getMemberIds(includedGroup.getIncludeUUID(), seenGroups));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (NoSuchGroupException e) {
|
|
|
|
|
|
|
|
// The included group is not visible
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return members;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<Change> parseChange(String value) throws OrmException,
|
|
|
|
private List<Change> parseChange(String value) throws OrmException,
|
|
|
|
QueryParseException {
|
|
|
|
QueryParseException {
|
|
|
|
if (PAT_LEGACY_ID.matcher(value).matches()) {
|
|
|
|
if (PAT_LEGACY_ID.matcher(value).matches()) {
|
|
|
|
|