Merge "Add NoteDb info to GetServerInfo"
This commit is contained in:
commit
d06786334e
@ -75,7 +75,7 @@ public class ServerInfoIT extends AbstractDaemonTest {
|
||||
})
|
||||
public void serverConfig() throws Exception {
|
||||
RestResponse r = adminRestSession.get("/config/server/info/");
|
||||
ServerInfo i = newGson().fromJson(r.getReader(), ServerInfo.class);
|
||||
ServerInfo i = getServerConfig();
|
||||
|
||||
// auth
|
||||
assertThat(i.auth.authType).isEqualTo(AuthType.HTTP);
|
||||
@ -119,6 +119,12 @@ public class ServerInfoIT extends AbstractDaemonTest {
|
||||
|
||||
// user
|
||||
assertThat(i.user.anonymousCowardName).isEqualTo("Unnamed User");
|
||||
|
||||
// notedb
|
||||
notesMigration.setReadChanges(true);
|
||||
assertThat(getServerConfig().noteDbEnabled).isTrue();
|
||||
notesMigration.setReadChanges(false);
|
||||
assertThat(getServerConfig().noteDbEnabled).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -129,8 +135,7 @@ public class ServerInfoIT extends AbstractDaemonTest {
|
||||
Files.write(jsplugin, "Gerrit.install(function(self){});\n".getBytes(UTF_8));
|
||||
adminSshSession.exec("gerrit plugin reload");
|
||||
|
||||
RestResponse r = adminRestSession.get("/config/server/info/");
|
||||
ServerInfo i = newGson().fromJson(r.getReader(), ServerInfo.class);
|
||||
ServerInfo i = getServerConfig();
|
||||
|
||||
// plugin
|
||||
assertThat(i.plugin.jsResourcePaths).hasSize(1);
|
||||
@ -138,8 +143,7 @@ public class ServerInfoIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void serverConfigWithDefaults() throws Exception {
|
||||
RestResponse r = adminRestSession.get("/config/server/info/");
|
||||
ServerInfo i = newGson().fromJson(r.getReader(), ServerInfo.class);
|
||||
ServerInfo i = getServerConfig();
|
||||
|
||||
// auth
|
||||
assertThat(i.auth.authType).isEqualTo(AuthType.OPENID);
|
||||
@ -185,4 +189,9 @@ public class ServerInfoIT extends AbstractDaemonTest {
|
||||
// user
|
||||
assertThat(i.user.anonymousCowardName).isEqualTo(AnonymousCowardNameProvider.DEFAULT);
|
||||
}
|
||||
|
||||
private ServerInfo getServerConfig() throws Exception {
|
||||
RestResponse r = adminRestSession.get("/config/server/info/");
|
||||
return newGson().fromJson(r.getReader(), ServerInfo.class);
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ import com.google.gerrit.server.change.ArchiveFormat;
|
||||
import com.google.gerrit.server.change.GetArchive;
|
||||
import com.google.gerrit.server.change.Submit;
|
||||
import com.google.gerrit.server.documentation.QueryDocumentationExecutor;
|
||||
import com.google.gerrit.server.notedb.NotesMigration;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
@ -68,6 +69,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
||||
private final DynamicItem<AvatarProvider> avatar;
|
||||
private final boolean enableSignedPush;
|
||||
private final QueryDocumentationExecutor docSearcher;
|
||||
private final NotesMigration migration;
|
||||
|
||||
@Inject
|
||||
public GetServerInfo(
|
||||
@ -84,7 +86,8 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
||||
@AnonymousCowardName String anonymousCowardName,
|
||||
DynamicItem<AvatarProvider> avatar,
|
||||
@EnableSignedPush boolean enableSignedPush,
|
||||
QueryDocumentationExecutor docSearcher) {
|
||||
QueryDocumentationExecutor docSearcher,
|
||||
NotesMigration migration) {
|
||||
this.config = config;
|
||||
this.authConfig = authConfig;
|
||||
this.realm = realm;
|
||||
@ -99,6 +102,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
||||
this.avatar = avatar;
|
||||
this.enableSignedPush = enableSignedPush;
|
||||
this.docSearcher = docSearcher;
|
||||
this.migration = migration;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -110,6 +114,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
||||
getDownloadInfo(downloadSchemes, downloadCommands, cloneCommands,
|
||||
archiveFormats);
|
||||
info.gerrit = getGerritInfo(config, allProjectsName, allUsersName);
|
||||
info.noteDbEnabled = isNoteDbEnabled(config);
|
||||
info.plugin = getPluginInfo();
|
||||
info.sshd = getSshdInfo(config);
|
||||
info.suggest = getSuggestInfo(config);
|
||||
@ -258,6 +263,10 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
||||
return CharMatcher.is('/').trimTrailingFrom(docUrl) + '/';
|
||||
}
|
||||
|
||||
private boolean isNoteDbEnabled(Config cfg) {
|
||||
return migration.readChanges();
|
||||
}
|
||||
|
||||
private PluginConfigInfo getPluginInfo() {
|
||||
PluginConfigInfo info = new PluginConfigInfo();
|
||||
info.hasAvatars = toBoolean(avatar.get() != null);
|
||||
@ -320,6 +329,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
||||
public ChangeConfigInfo change;
|
||||
public DownloadInfo download;
|
||||
public GerritInfo gerrit;
|
||||
public Boolean noteDbEnabled;
|
||||
public PluginConfigInfo plugin;
|
||||
public SshdInfo sshd;
|
||||
public SuggestInfo suggest;
|
||||
|
Loading…
Reference in New Issue
Block a user