Expose supported UIs in GetServerInfo

Requires moving GerritInfo into gerrit-server.

Change-Id: I447c29c553e693c4aa02665610101588bdde38c6
This commit is contained in:
Dave Borowitz
2016-09-19 21:51:51 +02:00
parent c6b9f38c47
commit f4599a001d
11 changed files with 41 additions and 7 deletions

View File

@@ -123,7 +123,10 @@ As result a link:#server-info[ServerInfo] entity is returned.
"gerrit": { "gerrit": {
"all_projects": "All-Projects", "all_projects": "All-Projects",
"all_users": "All-Users" "all_users": "All-Users"
"doc_search": true "doc_search": true,
"web_uis": [
"gwt"
]
}, },
"sshd": {}, "sshd": {},
"suggest": { "suggest": {
@@ -1469,6 +1472,9 @@ link:config-gerrit.html#gerrit.reportBugUrl[URL to report bugs].
|`report_bug_text` |optional, not set if default| |`report_bug_text` |optional, not set if default|
link:config-gerrit.html#gerrit.reportBugText[Display text for report link:config-gerrit.html#gerrit.reportBugText[Display text for report
bugs link]. bugs link].
|`web_uis` ||
List of web UIs supported by the HTTP server. Possible values are `GWT`
and `POLYGERRIT`.
|================================= |=================================
[[hit-ration-info]] [[hit-ration-info]]

View File

@@ -65,8 +65,10 @@ public class ServerInfoIT extends AbstractDaemonTest {
// gerrit // gerrit
@GerritConfig(name = "gerrit.allProjects", value = "Root"), @GerritConfig(name = "gerrit.allProjects", value = "Root"),
@GerritConfig(name = "gerrit.allUsers", value = "Users"), @GerritConfig(name = "gerrit.allUsers", value = "Users"),
@GerritConfig(name = "gerrit.reportBugUrl", value = "https://example.com/report"), @GerritConfig(name = "gerrit.enableGwtUi", value = "true"),
@GerritConfig(name = "gerrit.enablePolyGerrit", value = "true"),
@GerritConfig(name = "gerrit.reportBugText", value = "REPORT BUG"), @GerritConfig(name = "gerrit.reportBugText", value = "REPORT BUG"),
@GerritConfig(name = "gerrit.reportBugUrl", value = "https://example.com/report"),
// suggest // suggest
@GerritConfig(name = "suggest.from", value = "3"), @GerritConfig(name = "suggest.from", value = "3"),
@@ -108,6 +110,9 @@ public class ServerInfoIT extends AbstractDaemonTest {
assertThat(i.gerrit.reportBugUrl).isEqualTo("https://example.com/report"); assertThat(i.gerrit.reportBugUrl).isEqualTo("https://example.com/report");
assertThat(i.gerrit.reportBugText).isEqualTo("REPORT BUG"); assertThat(i.gerrit.reportBugText).isEqualTo("REPORT BUG");
// Acceptance tests force --headless even when UIs are specified in config.
assertThat(i.gerrit.webUis).isEmpty();
// plugin // plugin
assertThat(i.plugin.jsResourcePaths).isEmpty(); assertThat(i.plugin.jsResourcePaths).isEmpty();

View File

@@ -14,6 +14,10 @@
package com.google.gerrit.extensions.common; package com.google.gerrit.extensions.common;
import com.google.gerrit.extensions.client.UiType;
import java.util.Set;
public class GerritInfo { public class GerritInfo {
public String allProjects; public String allProjects;
public String allUsers; public String allUsers;
@@ -22,4 +26,5 @@ public class GerritInfo {
public Boolean editGpgKeys; public Boolean editGpgKeys;
public String reportBugUrl; public String reportBugUrl;
public String reportBugText; public String reportBugText;
public Set<UiType> webUis;
} }

View File

@@ -34,6 +34,7 @@ import com.google.gerrit.httpd.rpc.doc.QueryDocumentationFilter;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.config.AuthConfig; import com.google.gerrit.server.config.AuthConfig;
import com.google.gerrit.server.config.GerritOptions;
import com.google.gwtexpui.server.CacheControlFilter; import com.google.gwtexpui.server.CacheControlFilter;
import com.google.inject.Key; import com.google.inject.Key;
import com.google.inject.Provider; import com.google.inject.Provider;

View File

@@ -25,6 +25,7 @@ import com.google.gerrit.httpd.rpc.UiRpcModule;
import com.google.gerrit.lifecycle.LifecycleModule; import com.google.gerrit.lifecycle.LifecycleModule;
import com.google.gerrit.server.RemotePeer; import com.google.gerrit.server.RemotePeer;
import com.google.gerrit.server.config.AuthConfig; import com.google.gerrit.server.config.AuthConfig;
import com.google.gerrit.server.config.GerritOptions;
import com.google.gerrit.server.config.GerritRequestModule; import com.google.gerrit.server.config.GerritRequestModule;
import com.google.gerrit.server.config.GitwebCgiConfig; import com.google.gerrit.server.config.GitwebCgiConfig;
import com.google.gerrit.server.git.AsyncReceiveCommits; import com.google.gerrit.server.git.AsyncReceiveCommits;

View File

@@ -22,11 +22,11 @@ import static java.nio.file.Files.isReadable;
import com.google.common.cache.Cache; import com.google.common.cache.Cache;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.gerrit.extensions.client.UiType; import com.google.gerrit.extensions.client.UiType;
import com.google.gerrit.httpd.GerritOptions;
import com.google.gerrit.httpd.XsrfCookieFilter; import com.google.gerrit.httpd.XsrfCookieFilter;
import com.google.gerrit.httpd.raw.ResourceServlet.Resource; import com.google.gerrit.httpd.raw.ResourceServlet.Resource;
import com.google.gerrit.launcher.GerritLauncher; import com.google.gerrit.launcher.GerritLauncher;
import com.google.gerrit.server.cache.CacheModule; import com.google.gerrit.server.cache.CacheModule;
import com.google.gerrit.server.config.GerritOptions;
import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.config.SitePaths; import com.google.gerrit.server.config.SitePaths;
import com.google.inject.Inject; import com.google.inject.Inject;

View File

@@ -23,7 +23,6 @@ import com.google.gerrit.common.EventBroker;
import com.google.gerrit.extensions.client.AuthType; import com.google.gerrit.extensions.client.AuthType;
import com.google.gerrit.gpg.GpgModule; import com.google.gerrit.gpg.GpgModule;
import com.google.gerrit.httpd.AllRequestFilter; import com.google.gerrit.httpd.AllRequestFilter;
import com.google.gerrit.httpd.GerritOptions;
import com.google.gerrit.httpd.GetUserFilter; import com.google.gerrit.httpd.GetUserFilter;
import com.google.gerrit.httpd.GitOverHttpModule; import com.google.gerrit.httpd.GitOverHttpModule;
import com.google.gerrit.httpd.H2CacheBasedWebSession; import com.google.gerrit.httpd.H2CacheBasedWebSession;
@@ -56,6 +55,7 @@ import com.google.gerrit.server.config.CanonicalWebUrlModule;
import com.google.gerrit.server.config.CanonicalWebUrlProvider; import com.google.gerrit.server.config.CanonicalWebUrlProvider;
import com.google.gerrit.server.config.DownloadConfig; import com.google.gerrit.server.config.DownloadConfig;
import com.google.gerrit.server.config.GerritGlobalModule; import com.google.gerrit.server.config.GerritGlobalModule;
import com.google.gerrit.server.config.GerritOptions;
import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.config.RestCacheAdminModule; import com.google.gerrit.server.config.RestCacheAdminModule;
import com.google.gerrit.server.events.StreamEventsApiListener; import com.google.gerrit.server.events.StreamEventsApiListener;

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package com.google.gerrit.httpd; package com.google.gerrit.server.config;
import static com.google.common.base.MoreObjects.firstNonNull; import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;

View File

@@ -21,6 +21,7 @@ import com.google.common.base.Strings;
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.ContributorAgreement; import com.google.gerrit.common.data.ContributorAgreement;
import com.google.gerrit.extensions.client.UiType;
import com.google.gerrit.extensions.common.AuthInfo; import com.google.gerrit.extensions.common.AuthInfo;
import com.google.gerrit.extensions.common.ChangeConfigInfo; import com.google.gerrit.extensions.common.ChangeConfigInfo;
import com.google.gerrit.extensions.common.DownloadInfo; import com.google.gerrit.extensions.common.DownloadInfo;
@@ -56,6 +57,7 @@ import org.eclipse.jgit.lib.Config;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@@ -82,6 +84,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
private final NotesMigration migration; private final NotesMigration migration;
private final ProjectCache projectCache; private final ProjectCache projectCache;
private final AgreementJson agreementJson; private final AgreementJson agreementJson;
private final GerritOptions gerritOptions;
@Inject @Inject
public GetServerInfo( public GetServerInfo(
@@ -101,7 +104,8 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
QueryDocumentationExecutor docSearcher, QueryDocumentationExecutor docSearcher,
NotesMigration migration, NotesMigration migration,
ProjectCache projectCache, ProjectCache projectCache,
AgreementJson agreementJson) { AgreementJson agreementJson,
GerritOptions gerritOptions) {
this.config = config; this.config = config;
this.authConfig = authConfig; this.authConfig = authConfig;
this.realm = realm; this.realm = realm;
@@ -119,6 +123,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
this.migration = migration; this.migration = migration;
this.projectCache = projectCache; this.projectCache = projectCache;
this.agreementJson = agreementJson; this.agreementJson = agreementJson;
this.gerritOptions = gerritOptions;
} }
@Override @Override
@@ -280,6 +285,13 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
info.docSearch = docSearcher.isAvailable(); info.docSearch = docSearcher.isAvailable();
info.editGpgKeys = toBoolean(enableSignedPush info.editGpgKeys = toBoolean(enableSignedPush
&& cfg.getBoolean("gerrit", null, "editGpgKeys", true)); && cfg.getBoolean("gerrit", null, "editGpgKeys", true));
info.webUis = EnumSet.noneOf(UiType.class);
if (gerritOptions.enableGwtUi()) {
info.webUis.add(UiType.GWT);
}
if (gerritOptions.enablePolyGerrit()) {
info.webUis.add(UiType.POLYGERRIT);
}
return info; return info;
} }

View File

@@ -36,6 +36,7 @@ import com.google.gerrit.server.config.AnonymousCowardNameProvider;
import com.google.gerrit.server.config.CanonicalWebUrlModule; import com.google.gerrit.server.config.CanonicalWebUrlModule;
import com.google.gerrit.server.config.CanonicalWebUrlProvider; import com.google.gerrit.server.config.CanonicalWebUrlProvider;
import com.google.gerrit.server.config.GerritGlobalModule; import com.google.gerrit.server.config.GerritGlobalModule;
import com.google.gerrit.server.config.GerritOptions;
import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.config.GerritServerId; import com.google.gerrit.server.config.GerritServerId;
import com.google.gerrit.server.config.SitePath; import com.google.gerrit.server.config.SitePath;
@@ -150,6 +151,8 @@ public class InMemoryModule extends FactoryModule {
// TODO(dborowitz): Use jimfs. // TODO(dborowitz): Use jimfs.
bind(Path.class).annotatedWith(SitePath.class).toInstance(Paths.get(".")); bind(Path.class).annotatedWith(SitePath.class).toInstance(Paths.get("."));
bind(Config.class).annotatedWith(GerritServerConfig.class).toInstance(cfg); bind(Config.class).annotatedWith(GerritServerConfig.class).toInstance(cfg);
bind(GerritOptions.class)
.toInstance(new GerritOptions(cfg, false, false, false));
bind(PersonIdent.class) bind(PersonIdent.class)
.annotatedWith(GerritPersonIdent.class) .annotatedWith(GerritPersonIdent.class)
.toProvider(GerritPersonIdentProvider.class); .toProvider(GerritPersonIdentProvider.class);

View File

@@ -38,6 +38,7 @@ import com.google.gerrit.server.config.AuthConfigModule;
import com.google.gerrit.server.config.CanonicalWebUrlModule; import com.google.gerrit.server.config.CanonicalWebUrlModule;
import com.google.gerrit.server.config.DownloadConfig; import com.google.gerrit.server.config.DownloadConfig;
import com.google.gerrit.server.config.GerritGlobalModule; import com.google.gerrit.server.config.GerritGlobalModule;
import com.google.gerrit.server.config.GerritOptions;
import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.config.GerritServerConfigModule; import com.google.gerrit.server.config.GerritServerConfigModule;
import com.google.gerrit.server.config.RestCacheAdminModule; import com.google.gerrit.server.config.RestCacheAdminModule;