Expose more config parameters via REST
The /config/server/info REST endpoint now provides almost all configuration parameters which are needed by the Gerrit Client. GerritConfig still contains 3 values. 2 cannot easily be exposed via REST due to missing Guice bindings in the REST API layer (sshdAddress, documentationAvailable), 1 is not used on client-side (gitDaemonUrl). Further cleanups will be done in follow-up changes. Change-Id: I660db7aa63253cb6a448079228301461dd1aa06f Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
committed by
Edwin Kempin
parent
7023f47c4b
commit
5057054a9b
@@ -103,6 +103,12 @@ As result a link:#server-info[ServerInfo] entity is returned.
|
||||
"gerrit": {
|
||||
"all_projects": "All-Projects",
|
||||
"all_users": "All-Users"
|
||||
},
|
||||
"suggest": {
|
||||
"from": 0
|
||||
},
|
||||
"user": {
|
||||
"anonymous_coward_name": "Anonymous Coward"
|
||||
}
|
||||
}
|
||||
----
|
||||
@@ -1009,6 +1015,32 @@ The `CapabilityInfo` entity contains information about a capability.
|
||||
|`name` |capability name
|
||||
|=================================
|
||||
|
||||
[[change-config-info]]
|
||||
=== ChangeConfigInfo
|
||||
The `ChangeConfigInfo` entity contains information about Gerrit
|
||||
configuration from the link:config-gerrit.html#change[change]
|
||||
section.
|
||||
|
||||
[options="header",cols="1,^1,5"]
|
||||
|=============================
|
||||
|Field Name ||Description
|
||||
|`allow_drafts` |not set if `false`|
|
||||
link:config-gerrit.html#change.allowDrafts[Whether draft workflow is
|
||||
allowed].
|
||||
|`large_change` ||
|
||||
link:config-gerrit.html#change.largeChange[Number of changed lines from
|
||||
which on a change is considered as a large change].
|
||||
|`reply_label` ||
|
||||
link:config-gerrit.html#change.replyTooltip[Label name for the reply
|
||||
button].
|
||||
|`reply_tooltip` ||
|
||||
link:config-gerrit.html#change.replyTooltip[Tooltip for the reply
|
||||
button].
|
||||
|`update_delay` ||
|
||||
link:config-gerrit.html#change.updateDelay[How often in seconds the web
|
||||
interface should poll for updates to the currently open change].
|
||||
|=============================
|
||||
|
||||
[[contact-store-info]]
|
||||
=== ContactStoreInfo
|
||||
The `ContactStoreInfo` entity contains information about the contact
|
||||
@@ -1085,15 +1117,20 @@ with a unit abbreviation (`k`: kilobytes, `m`: megabytes,
|
||||
The `GerritInfo` entity contains information about Gerrit
|
||||
configuration from the link:config-gerrit.html#gerrit[gerrit] section.
|
||||
|
||||
[options="header",cols="1,6"]
|
||||
|================================
|
||||
|Field Name |Description
|
||||
|`all_projects_name` |
|
||||
[options="header",cols="1,^1,5"]
|
||||
|=================================
|
||||
|Field Name ||Description
|
||||
|`all_projects_name` ||
|
||||
Name of the link:config-gerrit.html#gerrit.allProjects[root project].
|
||||
|`all_users_name` |
|
||||
|`all_users_name` ||
|
||||
Name of the link:config-gerrit.html#gerrit.allUsers[project in which
|
||||
meta data of all users is stored].
|
||||
|================================
|
||||
|`report_bug_url` |optional|
|
||||
link:config-gerrit.html#gerrit.reportBugUrl[URL to report bugs].
|
||||
|`report_bug_text` |optional, not set if default|
|
||||
link:config-gerrit.html#gerrit.reportBugText[Display text for report
|
||||
bugs link].
|
||||
|=================================
|
||||
|
||||
[[git-web-info]]
|
||||
=== GitWebInfo
|
||||
@@ -1216,6 +1253,10 @@ the Gerrit server.
|
||||
|`auth` ||
|
||||
Information about the authentication configuration as
|
||||
link:#auth-info[AuthInfo] entity.
|
||||
|`change` ||
|
||||
Information about the configuration from the
|
||||
link:config-gerrit.html#change[change] section as
|
||||
link:#change-config-info[ChangeConfigInfo] entity.
|
||||
|`contact_store` |optional|
|
||||
Information about the contact store configuration as
|
||||
link:#contact-store-info[ContactStoreInfo] entity.
|
||||
@@ -1230,8 +1271,30 @@ GerritInfo] entity.
|
||||
|`git_web` |optional|
|
||||
Information about the link:config-gerrit.html#gitweb[GitWeb]
|
||||
configuration as link:#git-web-info[GitWebInfo] entity.
|
||||
|`suggest` ||
|
||||
Information about the configuration from the
|
||||
link:config-gerrit.html#suggest[suggest] section as link:#suggest-info[
|
||||
SuggestInfo] entity.
|
||||
|`user` ||
|
||||
Information about the configuration from the
|
||||
link:config-gerrit.html#user[user] section as link:#user-config-info[
|
||||
UserConfigInfo] entity.
|
||||
|=======================================
|
||||
|
||||
[[suggest-info]]
|
||||
=== SuggestInfo
|
||||
The `SuggestInfo` entity contains information about Gerrit
|
||||
configuration from the link:config-gerrit.html#suggest[suggest]
|
||||
section.
|
||||
|
||||
[options="header",cols="1,6"]
|
||||
|=======================
|
||||
|Field Name |Description
|
||||
|`from` |
|
||||
The link:config-gerrit.html#suggest.from[number of characters] that a
|
||||
user must have typed before suggestions are provided.
|
||||
|=======================
|
||||
|
||||
[[summary-info]]
|
||||
=== SummaryInfo
|
||||
The `SummaryInfo` entity contains information about the current state
|
||||
@@ -1343,6 +1406,21 @@ a top menu entry.
|
||||
|`id` |optional|The `id` attribute of the menu item link.
|
||||
|========================
|
||||
|
||||
[[user-config-info]]
|
||||
=== UserConfigInfo
|
||||
The `UserConfigInfo` entity contains information about Gerrit
|
||||
configuration from the link:config-gerrit.html#user[user] section.
|
||||
|
||||
[options="header",cols="1,6"]
|
||||
|====================================
|
||||
|Field Name |Description
|
||||
|`anonymous_coward_name` |
|
||||
link:config-gerrit.html#user.anonymousCoward[Username] that is
|
||||
displayed in the Gerrit Web UI and in e-mail notifications if the full
|
||||
name of the user is not set.
|
||||
|====================================
|
||||
|
||||
|
||||
GERRIT
|
||||
------
|
||||
Part of link:index.html[Gerrit Code Review]
|
||||
|
||||
@@ -16,35 +16,9 @@ package com.google.gerrit.common.data;
|
||||
|
||||
|
||||
public class GerritConfig implements Cloneable {
|
||||
protected String reportBugUrl;
|
||||
protected String reportBugText;
|
||||
|
||||
protected String gitDaemonUrl;
|
||||
protected String sshdAddress;
|
||||
protected boolean documentationAvailable;
|
||||
protected String anonymousCowardName;
|
||||
protected int suggestFrom;
|
||||
protected int changeUpdateDelay;
|
||||
protected int largeChangeSize;
|
||||
protected String replyLabel;
|
||||
protected String replyTitle;
|
||||
protected boolean allowDraftChanges;
|
||||
|
||||
public String getReportBugUrl() {
|
||||
return reportBugUrl;
|
||||
}
|
||||
|
||||
public void setReportBugUrl(String u) {
|
||||
reportBugUrl = u;
|
||||
}
|
||||
|
||||
public String getReportBugText() {
|
||||
return reportBugText;
|
||||
}
|
||||
|
||||
public void setReportBugText(String t) {
|
||||
reportBugText = t;
|
||||
}
|
||||
|
||||
public String getGitDaemonUrl() {
|
||||
return gitDaemonUrl;
|
||||
@@ -72,60 +46,4 @@ public class GerritConfig implements Cloneable {
|
||||
public void setDocumentationAvailable(final boolean available) {
|
||||
documentationAvailable = available;
|
||||
}
|
||||
|
||||
public String getAnonymousCowardName() {
|
||||
return anonymousCowardName;
|
||||
}
|
||||
|
||||
public void setAnonymousCowardName(final String anonymousCowardName) {
|
||||
this.anonymousCowardName = anonymousCowardName;
|
||||
}
|
||||
|
||||
public int getSuggestFrom() {
|
||||
return suggestFrom;
|
||||
}
|
||||
|
||||
public void setSuggestFrom(final int suggestFrom) {
|
||||
this.suggestFrom = suggestFrom;
|
||||
}
|
||||
|
||||
public int getChangeUpdateDelay() {
|
||||
return changeUpdateDelay;
|
||||
}
|
||||
|
||||
public void setChangeUpdateDelay(int seconds) {
|
||||
changeUpdateDelay = seconds;
|
||||
}
|
||||
|
||||
public int getLargeChangeSize() {
|
||||
return largeChangeSize;
|
||||
}
|
||||
|
||||
public void setLargeChangeSize(int largeChangeSize) {
|
||||
this.largeChangeSize = largeChangeSize;
|
||||
}
|
||||
|
||||
public String getReplyTitle() {
|
||||
return replyTitle;
|
||||
}
|
||||
|
||||
public void setReplyTitle(String r) {
|
||||
replyTitle = r;
|
||||
}
|
||||
|
||||
public String getReplyLabel() {
|
||||
return replyLabel;
|
||||
}
|
||||
|
||||
public void setReplyLabel(String r) {
|
||||
replyLabel = r;
|
||||
}
|
||||
|
||||
public boolean isAllowDraftChanges() {
|
||||
return allowDraftChanges;
|
||||
}
|
||||
|
||||
public void setAllowDraftChanges(boolean b) {
|
||||
allowDraftChanges = b;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public class FormatUtil {
|
||||
public static String nameEmail(AccountInfo info) {
|
||||
String name = info.name();
|
||||
if (name == null || name.trim().isEmpty()) {
|
||||
name = Gerrit.getConfig().getAnonymousCowardName();
|
||||
name = Gerrit.info().user().anonymousCowardName();
|
||||
}
|
||||
|
||||
StringBuilder b = new StringBuilder().append(name);
|
||||
|
||||
@@ -480,9 +480,9 @@ public class Gerrit implements EntryPoint {
|
||||
|
||||
btmmenu.add(new InlineHTML(M.poweredBy(vs)));
|
||||
|
||||
String reportBugUrl = getConfig().getReportBugUrl();
|
||||
String reportBugUrl = info().gerrit().reportBugUrl();
|
||||
if (reportBugUrl != null) {
|
||||
String reportBugText = getConfig().getReportBugText();
|
||||
String reportBugText = info().gerrit().reportBugText();
|
||||
Anchor a = new Anchor(
|
||||
reportBugText == null ? C.reportBug() : reportBugText,
|
||||
reportBugUrl);
|
||||
|
||||
@@ -297,10 +297,10 @@ public class ChangeScreen extends Screen {
|
||||
|
||||
private void initReplyButton(ChangeInfo info, String revision) {
|
||||
if (!info.revision(revision).isEdit()) {
|
||||
reply.setTitle(Gerrit.getConfig().getReplyTitle());
|
||||
reply.setTitle(Gerrit.info().change().replyLabel());
|
||||
reply.setHTML(new SafeHtmlBuilder()
|
||||
.openDiv()
|
||||
.append(Gerrit.getConfig().getReplyLabel())
|
||||
.append(Gerrit.info().change().replyLabel())
|
||||
.closeDiv());
|
||||
if (hasDraftComments) {
|
||||
reply.setStyleName(style.highlight());
|
||||
@@ -1189,7 +1189,7 @@ public class ChangeScreen extends Screen {
|
||||
// TODO info card hover
|
||||
String name = info.owner().name() != null
|
||||
? info.owner().name()
|
||||
: Gerrit.getConfig().getAnonymousCowardName();
|
||||
: Gerrit.info().user().anonymousCowardName();
|
||||
|
||||
if (info.owner().avatar(AvatarInfo.DEFAULT_SIZE) != null) {
|
||||
ownerPanel.insert(new AvatarImage(info.owner()), 0);
|
||||
@@ -1291,7 +1291,7 @@ public class ChangeScreen extends Screen {
|
||||
}
|
||||
|
||||
private void startPoller() {
|
||||
if (Gerrit.isSignedIn() && 0 < Gerrit.getConfig().getChangeUpdateDelay()) {
|
||||
if (Gerrit.isSignedIn() && 0 < Gerrit.info().change().updateDelay()) {
|
||||
updateCheck = new UpdateCheckTimer(this);
|
||||
updateCheck.schedule();
|
||||
handlers.add(UserActivityMonitor.addValueChangeHandler(updateCheck));
|
||||
|
||||
@@ -204,7 +204,7 @@ class Message extends Composite {
|
||||
if (info.author().name() != null) {
|
||||
return info.author().name();
|
||||
}
|
||||
return Gerrit.getConfig().getAnonymousCowardName();
|
||||
return Gerrit.info().user().anonymousCowardName();
|
||||
}
|
||||
return Util.C.messageNoAuthor();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class UpdateCheckTimer extends Timer implements ValueChangeHandler<Boolean> {
|
||||
private static final int MAX_PERIOD = 3 * 60 * 1000;
|
||||
private static final int IDLE_PERIOD = 2 * 3600 * 1000;
|
||||
private static final int POLL_PERIOD =
|
||||
Gerrit.getConfig().getChangeUpdateDelay() * 1000;
|
||||
Gerrit.info().change().updateDelay() * 1000;
|
||||
|
||||
private final ChangeScreen screen;
|
||||
private int delay;
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ChangeApi {
|
||||
input.subject(emptyToNull(subject));
|
||||
input.baseChange(emptyToNull(base));
|
||||
|
||||
if (Gerrit.getConfig().isAllowDraftChanges()) {
|
||||
if (Gerrit.info().change().allowDrafts()) {
|
||||
input.status(Change.Status.DRAFT.toString());
|
||||
}
|
||||
|
||||
|
||||
@@ -373,7 +373,7 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
|
||||
}
|
||||
|
||||
private static Widget getSizeWidget(ChangeInfo c) {
|
||||
int largeChangeSize = Gerrit.getConfig().getLargeChangeSize();
|
||||
int largeChangeSize = Gerrit.info().change().largeChange();
|
||||
int changedLines = c.insertions() + c.deletions();
|
||||
int p = 100;
|
||||
if (changedLines < largeChangeSize) {
|
||||
|
||||
@@ -36,6 +36,8 @@ public class GerritInfo extends JavaScriptObject {
|
||||
|
||||
public final native String allProjects() /*-{ return this.all_projects; }-*/;
|
||||
public final native String allUsers() /*-{ return this.all_users; }-*/;
|
||||
public final native String reportBugUrl() /*-{ return this.report_bug_url; }-*/;
|
||||
public final native String reportBugText() /*-{ return this.report_bug_text; }-*/;
|
||||
|
||||
protected GerritInfo() {
|
||||
}
|
||||
|
||||
@@ -18,10 +18,13 @@ import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
public class ServerInfo extends JavaScriptObject {
|
||||
public final native AuthInfo auth() /*-{ return this.auth; }-*/;
|
||||
public final native ChangeConfigInfo change() /*-{ return this.change; }-*/;
|
||||
public final native ContactStoreInfo contactStore() /*-{ return this.contact_store; }-*/;
|
||||
public final native DownloadInfo download() /*-{ return this.download; }-*/;
|
||||
public final native GerritInfo gerrit() /*-{ return this.gerrit; }-*/;
|
||||
public final native GitWebInfo gitWeb() /*-{ return this.git_web; }-*/;
|
||||
public final native SuggestInfo suggest() /*-{ return this.suggest; }-*/;
|
||||
public final native UserConfigInfo user() /*-{ return this.user; }-*/;
|
||||
|
||||
public final boolean hasContactStore() {
|
||||
return contactStore() != null;
|
||||
@@ -30,10 +33,35 @@ public class ServerInfo extends JavaScriptObject {
|
||||
protected ServerInfo() {
|
||||
}
|
||||
|
||||
public static class ChangeConfigInfo extends JavaScriptObject {
|
||||
public final native boolean allowDrafts() /*-{ return this.allow_drafts || false; }-*/;
|
||||
public final native int largeChange() /*-{ return this.large_change || 0; }-*/;
|
||||
public final native String replyLabel() /*-{ return this.reply_label; }-*/;
|
||||
public final native String replyTooltip() /*-{ return this.reply_tooltip; }-*/;
|
||||
public final native int updateDelay() /*-{ return this.update_delay || 0; }-*/;
|
||||
|
||||
protected ChangeConfigInfo() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ContactStoreInfo extends JavaScriptObject {
|
||||
public final native String url() /*-{ return this.url; }-*/;
|
||||
|
||||
protected ContactStoreInfo() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class SuggestInfo extends JavaScriptObject {
|
||||
public final native int from() /*-{ return this.from || 0; }-*/;
|
||||
|
||||
protected SuggestInfo() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class UserConfigInfo extends JavaScriptObject {
|
||||
public final native String anonymousCowardName() /*-{ return this.anonymous_coward_name; }-*/;
|
||||
|
||||
protected UserConfigInfo() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ class PublishedBox extends CommentBox {
|
||||
if (info.author().name() != null) {
|
||||
return info.author().name();
|
||||
}
|
||||
return Gerrit.getConfig().getAnonymousCowardName();
|
||||
return Gerrit.info().user().anonymousCowardName();
|
||||
}
|
||||
return Util.C.messageNoAuthor();
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public abstract class SuggestAfterTypingNCharsOracle extends HighlightSuggestOra
|
||||
|
||||
@Override
|
||||
protected void onRequestSuggestions(Request req, Callback cb) {
|
||||
if (req.getQuery().length() >= Gerrit.getConfig().getSuggestFrom()) {
|
||||
if (req.getQuery().length() >= Gerrit.info().suggest().from()) {
|
||||
_onRequestSuggestions(req, cb);
|
||||
} else {
|
||||
List<Suggestion> none = Collections.emptyList();
|
||||
|
||||
@@ -14,10 +14,7 @@
|
||||
|
||||
package com.google.gerrit.httpd;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.gerrit.common.data.GerritConfig;
|
||||
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||
import com.google.gerrit.server.config.ConfigUtil;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.ssh.SshInfo;
|
||||
import com.google.inject.Inject;
|
||||
@@ -27,7 +24,6 @@ import com.google.inject.ProvisionException;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
@@ -36,18 +32,15 @@ class GerritConfigProvider implements Provider<GerritConfig> {
|
||||
private final SshInfo sshInfo;
|
||||
|
||||
private final ServletContext servletContext;
|
||||
private final String anonymousCowardName;
|
||||
|
||||
@Inject
|
||||
GerritConfigProvider(
|
||||
@GerritServerConfig Config gsc,
|
||||
SshInfo si,
|
||||
ServletContext sc,
|
||||
@AnonymousCowardName String acn) {
|
||||
ServletContext sc) {
|
||||
cfg = gsc;
|
||||
sshInfo = si;
|
||||
servletContext = sc;
|
||||
anonymousCowardName = acn;
|
||||
}
|
||||
|
||||
private GerritConfig create() throws MalformedURLException {
|
||||
@@ -55,32 +48,11 @@ class GerritConfigProvider implements Provider<GerritConfig> {
|
||||
config.setGitDaemonUrl(cfg.getString("gerrit", null, "canonicalgiturl"));
|
||||
config.setDocumentationAvailable(servletContext
|
||||
.getResource("/Documentation/index.html") != null);
|
||||
config.setAnonymousCowardName(anonymousCowardName);
|
||||
config.setSuggestFrom(cfg.getInt("suggest", "from", 0));
|
||||
config.setChangeUpdateDelay((int) ConfigUtil.getTimeUnit(
|
||||
cfg, "change", null, "updateDelay", 30, TimeUnit.SECONDS));
|
||||
config.setLargeChangeSize(cfg.getInt("change", "largeChange", 500));
|
||||
|
||||
config.setReportBugUrl(cfg.getString("gerrit", null, "reportBugUrl"));
|
||||
config.setReportBugText(cfg.getString("gerrit", null, "reportBugText"));
|
||||
|
||||
if (sshInfo != null && !sshInfo.getHostKeys().isEmpty()) {
|
||||
config.setSshdAddress(sshInfo.getHostKeys().get(0).getHost());
|
||||
}
|
||||
|
||||
String replyTitle =
|
||||
Optional.fromNullable(cfg.getString("change", null, "replyTooltip"))
|
||||
.or("Reply and score")
|
||||
+ " (Shortcut: a)";
|
||||
String replyLabel =
|
||||
Optional.fromNullable(cfg.getString("change", null, "replyLabel"))
|
||||
.or("Reply")
|
||||
+ "\u2026";
|
||||
config.setReplyTitle(replyTitle);
|
||||
config.setReplyLabel(replyLabel);
|
||||
|
||||
config.setAllowDraftChanges(cfg.getBoolean("change", "allowDrafts", true));
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.config;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.common.data.GitWebType;
|
||||
@@ -36,6 +37,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class GetServerInfo implements RestReadView<ConfigResource> {
|
||||
private final Config config;
|
||||
@@ -46,6 +48,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
||||
private final GetArchive.AllowedFormats archiveFormats;
|
||||
private final AllProjectsName allProjectsName;
|
||||
private final AllUsersName allUsersName;
|
||||
private final String anonymousCowardName;
|
||||
private final GitWebConfig gitWebConfig;
|
||||
|
||||
@Inject
|
||||
@@ -58,6 +61,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
||||
GetArchive.AllowedFormats archiveFormats,
|
||||
AllProjectsName allProjectsName,
|
||||
AllUsersName allUsersName,
|
||||
@AnonymousCowardName String anonymousCowardName,
|
||||
GitWebConfig gitWebConfig) {
|
||||
this.config = config;
|
||||
this.authConfig = authConfig;
|
||||
@@ -67,6 +71,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
||||
this.archiveFormats = archiveFormats;
|
||||
this.allProjectsName = allProjectsName;
|
||||
this.allUsersName = allUsersName;
|
||||
this.anonymousCowardName = anonymousCowardName;
|
||||
this.gitWebConfig = gitWebConfig;
|
||||
}
|
||||
|
||||
@@ -74,11 +79,29 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
||||
public ServerInfo apply(ConfigResource rsrc) throws MalformedURLException {
|
||||
ServerInfo info = new ServerInfo();
|
||||
info.auth = new AuthInfo(authConfig, realm);
|
||||
info.change = getChangeInfo(config);
|
||||
info.contactStore = getContactStoreInfo();
|
||||
info.download =
|
||||
new DownloadInfo(downloadSchemes, downloadCommands, archiveFormats);
|
||||
info.gerrit = new GerritInfo(allProjectsName, allUsersName);
|
||||
info.gerrit = getGerritInfo(config, allProjectsName, allUsersName);
|
||||
info.gitWeb = getGitWebInfo(gitWebConfig);
|
||||
info.suggest = getSuggestInfo(config);
|
||||
info.user = getUserInfo(anonymousCowardName);
|
||||
return info;
|
||||
}
|
||||
|
||||
private ChangeConfigInfo getChangeInfo(Config cfg) {
|
||||
ChangeConfigInfo info = new ChangeConfigInfo();
|
||||
info.allowDrafts = toBoolean(cfg.getBoolean("change", "allowDrafts", true));
|
||||
info.largeChange = cfg.getInt("change", "largeChange", 500);
|
||||
info.replyTooltip =
|
||||
Optional.fromNullable(cfg.getString("change", null, "replyTooltip"))
|
||||
.or("Reply and score") + " (Shortcut: a)";
|
||||
info.replyLabel =
|
||||
Optional.fromNullable(cfg.getString("change", null, "replyLabel"))
|
||||
.or("Reply") + "\u2026";
|
||||
info.updateDelay = (int) ConfigUtil.getTimeUnit(
|
||||
cfg, "change", null, "updateDelay", 30, TimeUnit.SECONDS);
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -93,9 +116,37 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
||||
return contactStore;
|
||||
}
|
||||
|
||||
private GerritInfo getGerritInfo(Config cfg, AllProjectsName allProjectsName,
|
||||
AllUsersName allUsersName) {
|
||||
GerritInfo info = new GerritInfo();
|
||||
info.allProjects = allProjectsName.get();
|
||||
info.allUsers = allUsersName.get();
|
||||
info.reportBugUrl = cfg.getString("gerrit", null, "reportBugUrl");
|
||||
info.reportBugText = cfg.getString("gerrit", null, "reportBugText");
|
||||
return info;
|
||||
}
|
||||
|
||||
private GitWebInfo getGitWebInfo(GitWebConfig cfg) {
|
||||
return cfg.getUrl() != null && cfg.getGitWebType() != null
|
||||
? new GitWebInfo(cfg) : null;
|
||||
if (cfg.getUrl() == null || cfg.getGitWebType() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
GitWebInfo info = new GitWebInfo();
|
||||
info.url = cfg.getUrl();
|
||||
info.type = cfg.getGitWebType();
|
||||
return info;
|
||||
}
|
||||
|
||||
private SuggestInfo getSuggestInfo(Config cfg) {
|
||||
SuggestInfo info = new SuggestInfo();
|
||||
info.from = cfg.getInt("suggest", "from", 0);
|
||||
return info;
|
||||
}
|
||||
|
||||
private UserConfigInfo getUserInfo(String anonymousCowardName) {
|
||||
UserConfigInfo info = new UserConfigInfo();
|
||||
info.anonymousCowardName = anonymousCowardName;
|
||||
return info;
|
||||
}
|
||||
|
||||
private static Boolean toBoolean(boolean v) {
|
||||
@@ -104,10 +155,13 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
||||
|
||||
public static class ServerInfo {
|
||||
public AuthInfo auth;
|
||||
public ChangeConfigInfo change;
|
||||
public ContactStoreInfo contactStore;
|
||||
public DownloadInfo download;
|
||||
public GerritInfo gerrit;
|
||||
public GitWebInfo gitWeb;
|
||||
public SuggestInfo suggest;
|
||||
public UserConfigInfo user;
|
||||
}
|
||||
|
||||
public static class AuthInfo {
|
||||
@@ -161,6 +215,14 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ChangeConfigInfo {
|
||||
public Boolean allowDrafts;
|
||||
public int largeChange;
|
||||
public String replyLabel;
|
||||
public String replyTooltip;
|
||||
public int updateDelay;
|
||||
}
|
||||
|
||||
public static class ContactStoreInfo {
|
||||
public String url;
|
||||
}
|
||||
@@ -218,20 +280,20 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
||||
public static class GerritInfo {
|
||||
public String allProjects;
|
||||
public String allUsers;
|
||||
|
||||
public GerritInfo(AllProjectsName allProjectsName, AllUsersName allUsersName) {
|
||||
allProjects = allProjectsName.get();
|
||||
allUsers = allUsersName.get();
|
||||
}
|
||||
public String reportBugUrl;
|
||||
public String reportBugText;
|
||||
}
|
||||
|
||||
public static class GitWebInfo {
|
||||
public String url;
|
||||
public GitWebType type;
|
||||
}
|
||||
|
||||
public GitWebInfo(GitWebConfig cfg) {
|
||||
url = cfg.getUrl();
|
||||
type = cfg.getGitWebType();
|
||||
}
|
||||
public static class SuggestInfo {
|
||||
public int from;
|
||||
}
|
||||
|
||||
public static class UserConfigInfo {
|
||||
public String anonymousCowardName;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user