Use new VersionedConfigFile to replace ProjectLevelConfig.Bare
Plugins can use the new VersionedConfigFile introduced in Gerrit core
to read/write a config file stored in git.
Change-Id: Ide582b4404952924632f534ac02ede9a5361a0f1
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUser.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUser.java
index c3b5add..7e2e18a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUser.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUser.java
@@ -39,8 +39,8 @@
import com.google.gerrit.server.config.PluginConfig;
import com.google.gerrit.server.config.PluginConfigFactory;
import com.google.gerrit.server.git.meta.MetaDataUpdate;
+import com.google.gerrit.server.git.meta.VersionedConfigFile;
import com.google.gerrit.server.permissions.PermissionBackendException;
-import com.google.gerrit.server.project.ProjectLevelConfig;
import com.google.gerrit.server.restapi.account.CreateAccount;
import com.google.inject.Inject;
import com.google.inject.Provider;
@@ -75,7 +75,7 @@
}
private final PluginConfig cfg;
- private final Provider<ProjectLevelConfig.Bare> configProvider;
+ private final Provider<VersionedConfigFile> configProvider;
private final CreateAccount createAccount;
private final Provider<CurrentUser> userProvider;
private final MetaDataUpdate.User metaDataUpdateFactory;
@@ -89,7 +89,7 @@
@Inject
CreateServiceUser(
PluginConfigFactory cfgFactory,
- Provider<ProjectLevelConfig.Bare> configProvider,
+ Provider<VersionedConfigFile> configProvider,
@PluginName String pluginName,
CreateAccount createAccount,
Provider<CurrentUser> userProvider,
@@ -173,7 +173,7 @@
String creationDate = rfc2822DateFormatter.format(new Date());
try (MetaDataUpdate md = metaDataUpdateFactory.create(allProjects)) {
- ProjectLevelConfig.Bare update = configProvider.get();
+ VersionedConfigFile update = configProvider.get();
update.load(md);
Config db = update.getConfig();
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/Module.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/Module.java
index 5b5df2f..85eaae7 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/Module.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/Module.java
@@ -26,8 +26,8 @@
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.extensions.restapi.RestApiModule;
import com.google.gerrit.extensions.webui.TopMenu;
+import com.google.gerrit.server.git.meta.VersionedConfigFile;
import com.google.gerrit.server.git.validators.CommitValidationListener;
-import com.google.gerrit.server.project.ProjectLevelConfig;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.assistedinject.FactoryModuleBuilder;
@@ -80,7 +80,7 @@
}
@Provides
- ProjectLevelConfig.Bare createProjectLevelConfig(@PluginName String pluginName) {
- return new ProjectLevelConfig.Bare(pluginName + ".db");
+ VersionedConfigFile createProjectLevelConfig(@PluginName String pluginName) {
+ return new VersionedConfigFile(pluginName + ".db");
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/PutOwner.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/PutOwner.java
index 32ee082..e3af6a0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/PutOwner.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/PutOwner.java
@@ -35,10 +35,10 @@
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.config.ConfigResource;
import com.google.gerrit.server.git.meta.MetaDataUpdate;
+import com.google.gerrit.server.git.meta.VersionedConfigFile;
import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.project.ProjectCache;
-import com.google.gerrit.server.project.ProjectLevelConfig;
import com.google.gerrit.server.restapi.group.GroupJson;
import com.google.gerrit.server.restapi.group.GroupsCollection;
import com.google.inject.Inject;
@@ -57,7 +57,7 @@
private final Provider<GetConfig> getConfig;
private final GroupsCollection groups;
- private final Provider<ProjectLevelConfig.Bare> configProvider;
+ private final Provider<VersionedConfigFile> configProvider;
private final Project.NameKey allProjects;
private final MetaDataUpdate.User metaDataUpdateFactory;
private final GroupJson json;
@@ -69,7 +69,7 @@
PutOwner(
Provider<GetConfig> getConfig,
GroupsCollection groups,
- Provider<ProjectLevelConfig.Bare> configProvider,
+ Provider<VersionedConfigFile> configProvider,
ProjectCache projectCache,
MetaDataUpdate.User metaDataUpdateFactory,
GroupJson json,
@@ -107,7 +107,7 @@
GroupDescription.Basic group = null;
String oldGroup;
try (MetaDataUpdate md = metaDataUpdateFactory.create(allProjects)) {
- ProjectLevelConfig.Bare update = configProvider.get();
+ VersionedConfigFile update = configProvider.get();
update.load(md);
Config db = update.getConfig();
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/RegisterServiceUser.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/RegisterServiceUser.java
index 17c8ab3..ef0d9e1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/RegisterServiceUser.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/RegisterServiceUser.java
@@ -42,10 +42,10 @@
import com.google.gerrit.server.config.AllProjectsName;
import com.google.gerrit.server.config.ConfigResource;
import com.google.gerrit.server.git.meta.MetaDataUpdate;
+import com.google.gerrit.server.git.meta.VersionedConfigFile;
import com.google.gerrit.server.group.GroupResolver;
import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException;
-import com.google.gerrit.server.project.ProjectLevelConfig;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
@@ -72,7 +72,7 @@
String owner;
}
- private final Provider<ProjectLevelConfig.Bare> configProvider;
+ private final Provider<VersionedConfigFile> configProvider;
private final AccountResolver accountResolver;
private final GroupResolver groupResolver;
private final Provider<CurrentUser> userProvider;
@@ -86,7 +86,7 @@
@Inject
RegisterServiceUser(
- Provider<ProjectLevelConfig.Bare> configProvider,
+ Provider<VersionedConfigFile> configProvider,
AccountResolver accountResolver,
GroupResolver groupResolver,
Provider<CurrentUser> userProvider,
@@ -162,7 +162,7 @@
}
try (MetaDataUpdate md = metaDataUpdateFactory.create(allProjects)) {
- ProjectLevelConfig.Bare update = configProvider.get();
+ VersionedConfigFile update = configProvider.get();
update.load(md);
Config db = update.getConfig();
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/StorageCache.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/StorageCache.java
index 0378347..d77c569 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/StorageCache.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/StorageCache.java
@@ -20,8 +20,7 @@
import com.google.gerrit.server.cache.CacheModule;
import com.google.gerrit.server.config.AllProjectsName;
import com.google.gerrit.server.git.meta.MetaDataUpdate;
-import com.google.gerrit.server.project.ProjectLevelConfig;
-import com.google.gerrit.server.project.ProjectLevelConfig.Bare;
+import com.google.gerrit.server.git.meta.VersionedConfigFile;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
@@ -67,13 +66,13 @@
}
static class Loader extends CacheLoader<Object, Config> {
- private final Provider<Bare> configProvider;
+ private final Provider<VersionedConfigFile> configProvider;
private final MetaDataUpdate.Server metaDataUpdateFactory;
private final AllProjectsName allProjects;
@Inject
Loader(
- Provider<ProjectLevelConfig.Bare> configProvider,
+ Provider<VersionedConfigFile> configProvider,
MetaDataUpdate.Server metaDataUpdateFactory,
AllProjectsName allProjects) {
this.configProvider = configProvider;
@@ -83,7 +82,7 @@
@Override
public Config load(Object key) throws Exception {
- ProjectLevelConfig.Bare storage = configProvider.get();
+ VersionedConfigFile storage = configProvider.get();
try (MetaDataUpdate md = metaDataUpdateFactory.create(allProjects)) {
storage.load(md);
}