Index groups that are created during init

During the initialization of a new site some default groups are
automatically created ('Administrators' and 'Non-Interactive Users').
These new groups must be added to the index so that they become
queryable. For this init must have the group index available so that
it can write the new groups to it. Reading from the index during init
is not needed and not supported.

Alternatively we could require users to run the Reindex program after
the initial site initialization, but likely many people would forget
about it and then wonder why the default groups are not available from
the group index.

Change-Id: I274b142a6efde224bba68f8b5c459736d7a1f985
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2017-01-05 09:36:37 +01:00
parent c3b5956d89
commit a4c095f171
17 changed files with 343 additions and 62 deletions

View File

@@ -40,6 +40,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gwtorm.server.OrmException;
import com.google.gwtorm.server.ResultSet;
import com.google.inject.Provider;
import com.google.inject.assistedinject.Assisted;
import com.google.inject.assistedinject.AssistedInject;
@@ -81,7 +82,7 @@ public class ElasticGroupIndex
private final Gson gson;
private final GroupMapping mapping;
private final GroupCache groupCache;
private final Provider<GroupCache> groupCache;
private final ElasticQueryBuilder queryBuilder;
@AssistedInject
@@ -89,7 +90,7 @@ public class ElasticGroupIndex
@GerritServerConfig Config cfg,
FillArgs fillArgs,
SitePaths sitePaths,
GroupCache groupCache,
Provider<GroupCache> groupCache,
@Assisted Schema<AccountGroup> schema) {
super(cfg, fillArgs, sitePaths, schema, GROUPS_PREFIX);
this.groupCache = groupCache;
@@ -221,7 +222,7 @@ public class ElasticGroupIndex
source.getAsJsonObject().get(GroupField.UUID.getName()).getAsString());
// Use the GroupCache rather than depending on any stored fields in the
// document (of which there shouldn't be any).
return groupCache.get(uuid);
return groupCache.get().get(uuid);
}
}
}