Merge changes from topic 'remove-gerrit-config-from-client'

* changes:
  Check with HEAD request if docs are available and remove GerritConfig
  Remove usage of GerritConfig from GitWebServlet
  Add acceptance test for /config/server/info REST endpoint
  Return info about SSHD with /config/server/info REST endpoint
  Retrieve clone commands from /config/server/info REST endpoint
  Add new extension point for clone commands
  Make *Info classes in GetServerInfo movable to extension package
  Expose more config parameters via REST
  Expose GitWeb config via /config/server/info REST endpoint
  Gerrit Client: Retrieve archives formats via REST
  Expose all auth config params that are needed by client over REST
  For clone commands rely on scheme URLs from the server
This commit is contained in:
David Pursehouse 2015-06-10 00:14:15 +00:00 committed by Gerrit Code Review
commit f842745065
60 changed files with 1255 additions and 1045 deletions

View File

@ -1767,15 +1767,17 @@ discover and bind the implementation.
[[download-commands]]
== Download Commands
Gerrit offers commands for downloading changes using different
download schemes (e.g. for downloading via different network
protocols). Plugins can contribute download schemes and download
commands by implementing
`com.google.gerrit.extensions.config.DownloadScheme` and
`com.google.gerrit.extensions.config.DownloadCommand`.
Gerrit offers commands for downloading changes and cloning projects
using different download schemes (e.g. for downloading via different
network protocols). Plugins can contribute download schemes, download
commands and clone commands by implementing
`com.google.gerrit.extensions.config.DownloadScheme`,
`com.google.gerrit.extensions.config.DownloadCommand` and
`com.google.gerrit.extensions.config.CloneCommand`.
The download schemes and download commands which are used most often
are provided by the Gerrit core plugin `download-commands`.
The download schemes, download commands and clone commands which are
used most often are provided by the Gerrit core plugin
`download-commands`.
[[included-in]]
== Included In

View File

@ -68,6 +68,10 @@ As result a link:#server-info[ServerInfo] entity is returned.
"Format Patch": "git fetch http://gerrithost:8080/${project} ${ref} \u0026\u0026 git format-patch -1 --stdout FETCH_HEAD",
"Pull": "git pull http://gerrithost:8080/${project} ${ref}",
"Cherry Pick": "git fetch http://gerrithost:8080/${project} ${ref} \u0026\u0026 git cherry-pick FETCH_HEAD"
},
"clone_commands": {
"Clone": "git clone http://gerrithost:8080/${project}"
"Clone with commit-msg hook": "git clone http://gerrithost:8080/${project} \u0026\u0026 scp -p -P 29418 jdoe@gerrithost:hooks/commit-msg ${project}/.git/hooks/"
}
},
"http": {
@ -79,6 +83,10 @@ As result a link:#server-info[ServerInfo] entity is returned.
"Format Patch": "git fetch http://jdoe@gerrithost:8080/${project} ${ref} \u0026\u0026 git format-patch -1 --stdout FETCH_HEAD",
"Pull": "git pull http://jdoe@gerrithost:8080/${project} ${ref}",
"Cherry Pick": "git fetch http://jdoe@gerrithost:8080/${project} ${ref} \u0026\u0026 git cherry-pick FETCH_HEAD"
},
"clone_commands": {
"Clone": "git clone http://jdoe@gerrithost:8080/${project}",
"Clone with commit-msg hook": "git clone http://jdoe@gerrithost:8080/${project} \u0026\u0026 scp -p -P 29418 jdoe@gerrithost:hooks/commit-msg ${project}/.git/hooks/"
}
},
"ssh": {
@ -90,6 +98,10 @@ As result a link:#server-info[ServerInfo] entity is returned.
"Format Patch": "git fetch ssh://jdoe@gerrithost:29418/${project} ${ref} \u0026\u0026 git format-patch -1 --stdout FETCH_HEAD",
"Pull": "git pull ssh://jdoe@gerrithost:29418/${project} ${ref}",
"Cherry Pick": "git fetch ssh://jdoe@gerrithost:29418/${project} ${ref} \u0026\u0026 git cherry-pick FETCH_HEAD"
},
"clone_commands": {
"Clone": "git clone ssh://jdoe@gerrithost:29418/${project}",
"Clone with commit-msg hook": "git clone ssh://jdoe@gerrithost:29418/${project} \u0026\u0026 scp -p -P 29418 jdoe@gerrithost:hooks/commit-msg ${project}/.git/hooks/"
}
}
],
@ -103,6 +115,13 @@ As result a link:#server-info[ServerInfo] entity is returned.
"gerrit": {
"all_projects": "All-Projects",
"all_users": "All-Users"
},
"sshd": {},
"suggest": {
"from": 0
},
"user": {
"anonymous_coward_name": "Anonymous Coward"
}
}
----
@ -919,6 +938,38 @@ agreements] are required.
|`editable_account_fields` ||
List of account fields that are editable. Possible values are
`FULL_NAME`, `USER_NAME` and `REGISTER_NEW_EMAIL`.
|`login_url` |optional|
The link:config-gerrit.html#auth.loginUrl[login URL]. Only set if
link:config-gerrit.html#auth.type[authentication type] is `HTTP` or
`HTTP_LDAP`.
|`login_text` |optional|
The link:config-gerrit.html#auth.loginText[login text]. Only set if
link:config-gerrit.html#auth.type[authentication type] is `HTTP` or
`HTTP_LDAP`.
|`switch_account_url` |optional|
The link:config-gerrit.html#auth.switchAccountUrl[URL to switch
accounts].
|`register_url` |optional|
The link:config-gerrit.html#auth.registerUrl[register URL]. Only set if
link:config-gerrit.html#auth.type[authentication type] is `LDAP`,
`LDAP_BIND` or `CUSTOM_EXTENSION`.
|`register_text` |optional|
The link:config-gerrit.html#auth.registerText[register text]. Only set
if link:config-gerrit.html#auth.type[authentication type] is `LDAP`,
`LDAP_BIND` or `CUSTOM_EXTENSION`.
|`edit_full_name_url` |optional|
The link:config-gerrit.html#auth.editFullNameUrl[URL to edit the full
name]. Only set if link:config-gerrit.html#auth.type[authentication
type] is `LDAP`, `LDAP_BIND` or `CUSTOM_EXTENSION`.
|`http_password_url` |optional|
The link:config-gerrit.html#auth.httpPasswordUrl[URL to obtain an HTTP
password]. Only set if link:config-gerrit.html#auth.type[authentication
type] is `CUSTOM_EXTENSION`.
|`is_git_basic_auth` |optional, not set if `false`|
Whether link:config-gerrit.html#auth.gitBasicAuth[basic authentication
is used for Git over HTTP/HTTPS]. Only set if
link:config-gerrit.html#auth.type[authentication type] is is `LDAP` or
`LDAP_BIND`.
|==========================================
[[cache-info]]
@ -977,6 +1028,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
@ -1026,6 +1103,13 @@ command. In the download command '${project}' is used as
placeholder for the project name, and '${ref}' is used as
placeholder for the (change) ref.
Empty, if accessed anonymously and the download scheme requires
authentication.
|`clone_commands` ||
Clone commands as a map which maps the command name to the clone
command. In the clone command '${project}' is used as
placeholder for the project name.
Empty, if accessed anonymously and the download scheme requires
authentication.
|=================================
@ -1053,15 +1137,68 @@ 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
The `GitWebInfo` entity contains information about the
link:config-gerrit.html#gitweb[GitWeb] configuration.
[options="header",cols="1,6"]
|=======================
|Field Name |Description
|`url` |
The link:config-gerrit.html#gitweb.url[GitWeb base URL].
|`type` |
The link:config-gerrit.html#gitweb.type[GitWeb type] as
link:#git-web-type-info[GitWebTypeInfo] entity.
|=======================
[[git-web-type-info]]
=== GitWebTypeInfo
The `GitWebTypeInfo` entity contains information about the
link:config-gerrit.html#gitweb[GitWeb] configuration.
[options="header",cols="1,^1,5"]
|=============================
|Field Name ||Description
|`name` ||
The link:config-gerrit.html#gitweb.linkname[GitWeb link name].
|`revision` |optional|
The link:config-gerrit.html#gitweb.revision[GitWeb revision pattern].
|`project` |optional|
The link:config-gerrit.html#gitweb.project[GitWeb project pattern].
|`branch` |optional|
The link:config-gerrit.html#gitweb.branch[GitWeb branch pattern].
|`root_tree` |optional|
The link:config-gerrit.html#gitweb.roottree[GitWeb root tree pattern].
|`file` |optional|
The link:config-gerrit.html#gitweb.file[GitWeb file pattern].
|`file_history` |optional|
The link:config-gerrit.html#gitweb.filehistory[GitWeb file history
pattern].
|`path_separator`||
The link:config-gerrit.html#gitweb.pathSeparator[GitWeb path separator].
|`link_drafts` |optional|
link:config-gerrit.html#gitweb.linkDrafts[Whether Gerrit should provide
links to GitWeb on draft patch set.]
|`url_encode` |optional|
link:config-gerrit.html#gitweb.urlEncode[Whether Gerrit should encode
the generated viewer URL.]
|=============================
[[hit-ration-info]]
=== HitRatioInfo
@ -1136,6 +1273,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.
@ -1147,8 +1288,47 @@ information about Gerrit
Information about the configuration from the
link:config-gerrit.html#gerrit[gerrit] section as link:#gerrit-info[
GerritInfo] entity.
|`git_web` |optional|
Information about the link:config-gerrit.html#gitweb[GitWeb]
configuration as link:#git-web-info[GitWebInfo] entity.
|`sshd` |optional|
Information about the configuration from the
link:config-gerrit.html#sshd[sshd] section as link:#sshd-info[SshdInfo]
entity. Not set if SSHD is disabled.
|`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.
|=======================================
[[sshd-info]]
=== SshdInfo
The `SshdInfo` entity contains information about Gerrit
configuration from the link:config-gerrit.html#sshd[sshd]
section.
This entity doesn't contain any data, but the presence of this (empty)
entity in the link:#server-info[ServerInfo] entity means that SSHD is
enabled on the server.
[[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
@ -1260,6 +1440,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]

View File

@ -0,0 +1,175 @@
// Copyright (C) 2015 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.acceptance.rest.config;
import static com.google.common.truth.Truth.assertThat;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.GerritConfig;
import com.google.gerrit.acceptance.GerritConfigs;
import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AuthType;
import com.google.gerrit.server.config.AllProjectsNameProvider;
import com.google.gerrit.server.config.AllUsersNameProvider;
import com.google.gerrit.server.config.AnonymousCowardNameProvider;
import com.google.gerrit.server.config.GetServerInfo.ServerInfo;
import org.junit.Test;
public class ServerInfoIT extends AbstractDaemonTest {
@Test
@GerritConfigs({
// auth
@GerritConfig(name = "auth.type", value = "HTTP"),
@GerritConfig(name = "auth.contributorAgreements", value = "true"),
@GerritConfig(name = "auth.loginUrl", value = "https://example.com/login"),
@GerritConfig(name = "auth.loginText", value = "LOGIN"),
@GerritConfig(name = "auth.switchAccountUrl", value = "https://example.com/switch"),
// auth fields ignored when auth == HTTP
@GerritConfig(name = "auth.registerUrl", value = "https://example.com/register"),
@GerritConfig(name = "auth.registerText", value = "REGISTER"),
@GerritConfig(name = "auth.editFullNameUrl", value = "https://example.com/editname"),
@GerritConfig(name = "auth.httpPasswordUrl", value = "https://example.com/password"),
// change
@GerritConfig(name = "change.allowDrafts", value = "false"),
@GerritConfig(name = "change.largeChange", value = "300"),
@GerritConfig(name = "change.replyTooltip", value = "Publish votes and draft comments"),
@GerritConfig(name = "change.replyLabel", value = "Vote"),
@GerritConfig(name = "change.updateDelay", value = "50s"),
// download
@GerritConfig(name = "download.archive", values = {"tar",
"tbz2", "tgz", "txz"}),
// gerrit
@GerritConfig(name = "gerrit.allProjects", value = "Root"),
@GerritConfig(name = "gerrit.allUsers", value = "Users"),
@GerritConfig(name = "gerrit.reportBugUrl", value = "https://example.com/report"),
@GerritConfig(name = "gerrit.reportBugText", value = "REPORT BUG"),
// suggest
@GerritConfig(name = "suggest.from", value = "3"),
// user
@GerritConfig(name = "user.anonymousCoward", value = "Unnamed User"),
})
public void serverConfig() throws Exception {
RestResponse r = adminSession.get("/config/server/info/");
ServerInfo i = newGson().fromJson(r.getReader(), ServerInfo.class);
// auth
assertThat(i.auth.authType).isEqualTo(AuthType.HTTP);
assertThat(i.auth.editableAccountFields).containsExactly(
Account.FieldName.REGISTER_NEW_EMAIL, Account.FieldName.FULL_NAME);
assertThat(i.auth.useContributorAgreements).isTrue();
assertThat(i.auth.loginUrl).isEqualTo("https://example.com/login");
assertThat(i.auth.loginText).isEqualTo("LOGIN");
assertThat(i.auth.switchAccountUrl).isEqualTo("https://example.com/switch");
assertThat(i.auth.registerUrl).isNull();
assertThat(i.auth.registerText).isNull();
assertThat(i.auth.editFullNameUrl).isNull();
assertThat(i.auth.httpPasswordUrl).isNull();
assertThat(i.auth.isGitBasicAuth).isNull();
// change
assertThat(i.change.allowDrafts).isNull();
assertThat(i.change.largeChange).isEqualTo(300);
assertThat(i.change.replyTooltip).startsWith("Publish votes and draft comments");
assertThat(i.change.replyLabel).isEqualTo("Vote\u2026");
assertThat(i.change.updateDelay).isEqualTo(50);
// contactstore
assertThat(i.contactStore).isNull();
// download
assertThat(i.download.archives).containsExactly("tar", "tbz2", "tgz", "txz");
assertThat(i.download.schemes).isEmpty();
// gerrit
assertThat(i.gerrit.allProjects).isEqualTo("Root");
assertThat(i.gerrit.allUsers).isEqualTo("Users");
assertThat(i.gerrit.reportBugUrl).isEqualTo("https://example.com/report");
assertThat(i.gerrit.reportBugText).isEqualTo("REPORT BUG");
// gitweb
assertThat(i.gitWeb).isNull();
// sshd
assertThat(i.sshd).isNotNull();
// suggest
assertThat(i.suggest.from).isEqualTo(3);
// user
assertThat(i.user.anonymousCowardName).isEqualTo("Unnamed User");
}
@Test
public void serverConfigWithDefaults() throws Exception {
RestResponse r = adminSession.get("/config/server/info/");
ServerInfo i = newGson().fromJson(r.getReader(), ServerInfo.class);
// auth
assertThat(i.auth.authType).isEqualTo(AuthType.OPENID);
assertThat(i.auth.editableAccountFields).containsExactly(
Account.FieldName.REGISTER_NEW_EMAIL, Account.FieldName.FULL_NAME,
Account.FieldName.USER_NAME);
assertThat(i.auth.useContributorAgreements).isNull();
assertThat(i.auth.loginUrl).isNull();
assertThat(i.auth.loginText).isNull();
assertThat(i.auth.switchAccountUrl).isNull();
assertThat(i.auth.registerUrl).isNull();
assertThat(i.auth.registerText).isNull();
assertThat(i.auth.editFullNameUrl).isNull();
assertThat(i.auth.httpPasswordUrl).isNull();
assertThat(i.auth.isGitBasicAuth).isNull();
// change
assertThat(i.change.allowDrafts).isTrue();
assertThat(i.change.largeChange).isEqualTo(500);
assertThat(i.change.replyTooltip).startsWith("Reply and score");
assertThat(i.change.replyLabel).isEqualTo("Reply\u2026");
assertThat(i.change.updateDelay).isEqualTo(30);
// contactstore
assertThat(i.contactStore).isNull();
// download
assertThat(i.download.archives).containsExactly("tar", "tbz2", "tgz", "txz");
assertThat(i.download.schemes).isEmpty();
// gerrit
assertThat(i.gerrit.allProjects).isEqualTo(AllProjectsNameProvider.DEFAULT);
assertThat(i.gerrit.allUsers).isEqualTo(AllUsersNameProvider.DEFAULT);
assertThat(i.gerrit.reportBugUrl).isNull();
assertThat(i.gerrit.reportBugText).isNull();
// gitweb
assertThat(i.gitWeb).isNull();
// sshd
assertThat(i.sshd).isNotNull();
// suggest
assertThat(i.suggest.from).isEqualTo(0);
// user
assertThat(i.user.anonymousCowardName).isEqualTo(AnonymousCowardNameProvider.DEFAULT);
}
}

View File

@ -1,258 +0,0 @@
// Copyright (C) 2008 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.common.data;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Account.FieldName;
import com.google.gerrit.reviewdb.client.AuthType;
import java.util.List;
import java.util.Set;
public class GerritConfig implements Cloneable {
protected String registerUrl;
protected String registerText;
protected String loginUrl;
protected String loginText;
protected String switchAccountUrl;
protected String httpPasswordUrl;
protected String reportBugUrl;
protected String reportBugText;
protected boolean httpPasswordSettingsEnabled = true;
protected GitwebConfig gitweb;
protected AuthType authType;
protected String gitDaemonUrl;
protected String gitHttpUrl;
protected String sshdAddress;
protected String editFullNameUrl;
protected Set<Account.FieldName> editableAccountFields;
protected boolean documentationAvailable;
protected String anonymousCowardName;
protected int suggestFrom;
protected int changeUpdateDelay;
protected List<String> archiveFormats;
protected int largeChangeSize;
protected String replyLabel;
protected String replyTitle;
protected boolean allowDraftChanges;
public String getLoginUrl() {
return loginUrl;
}
public void setLoginUrl(final String u) {
loginUrl = u;
}
public String getLoginText() {
return loginText;
}
public void setLoginText(String signinText) {
this.loginText = signinText;
}
public String getRegisterUrl() {
return registerUrl;
}
public void setRegisterUrl(final String u) {
registerUrl = u;
}
public String getSwitchAccountUrl() {
return switchAccountUrl;
}
public void setSwitchAccountUrl(String u) {
switchAccountUrl = u;
}
public String getRegisterText() {
return registerText;
}
public void setRegisterText(final String t) {
registerText = t;
}
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 boolean isHttpPasswordSettingsEnabled() {
return httpPasswordSettingsEnabled;
}
public void setHttpPasswordSettingsEnabled(boolean httpPasswordSettingsEnabled) {
this.httpPasswordSettingsEnabled = httpPasswordSettingsEnabled;
}
public String getEditFullNameUrl() {
return editFullNameUrl;
}
public void setEditFullNameUrl(String u) {
editFullNameUrl = u;
}
public String getHttpPasswordUrl() {
return httpPasswordUrl;
}
public void setHttpPasswordUrl(String url) {
httpPasswordUrl = url;
}
public void setAuthType(final AuthType t) {
authType = t;
}
public GitwebConfig getGitwebLink() {
return gitweb;
}
public void setGitwebLink(final GitwebConfig w) {
gitweb = w;
}
public String getGitDaemonUrl() {
return gitDaemonUrl;
}
public void setGitDaemonUrl(String url) {
if (url != null && !url.endsWith("/")) {
url += "/";
}
gitDaemonUrl = url;
}
public String getGitHttpUrl() {
return gitHttpUrl;
}
public void setGitHttpUrl(String url) {
if (url != null && !url.endsWith("/")) {
url += "/";
}
gitHttpUrl = url;
}
public String getSshdAddress() {
return sshdAddress;
}
public void setSshdAddress(final String addr) {
sshdAddress = addr;
}
public void setEditableAccountFields(final Set<Account.FieldName> af) {
editableAccountFields = af;
}
public boolean isDocumentationAvailable() {
return documentationAvailable;
}
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 boolean siteHasUsernames() {
if (authType == AuthType.CUSTOM_EXTENSION
&& getHttpPasswordUrl() != null
&& !editableAccountFields.contains(FieldName.USER_NAME)) {
return false;
}
return true;
}
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 List<String> getArchiveFormats() {
return archiveFormats;
}
public void setArchiveFormats(List<String> formats) {
archiveFormats = formats;
}
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;
}
}

View File

@ -1,29 +0,0 @@
// Copyright (C) 2008 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.common.data;
/** Link to an external gitweb server. */
public class GitwebConfig {
public String baseUrl;
public GitWebType type;
protected GitwebConfig() {
}
public GitwebConfig(final String base, final GitWebType gitWebType) {
baseUrl = base;
type = gitWebType;
}
}

View File

@ -26,7 +26,6 @@ public class HostPageData {
public Account account;
public AccountDiffPreference accountDiffPref;
public String xGerritAuth;
public GerritConfig config;
public Theme theme;
public List<String> plugins;
public List<Message> messages;

View File

@ -33,6 +33,4 @@ public interface SystemInfoService extends RemoteJsonService {
void contributorAgreements(AsyncCallback<List<ContributorAgreement>> callback);
void clientError(String message, AsyncCallback<VoidResult> callback);
public void gerritConfig(final AsyncCallback<GerritConfig> callback);
}

View File

@ -0,0 +1,30 @@
// Copyright (C) 2015 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.extensions.config;
import com.google.gerrit.extensions.annotations.ExtensionPoint;
@ExtensionPoint
public abstract class CloneCommand {
/**
* Returns the clone command for the given download scheme and project.
*
* @param scheme the download scheme for which the command should be returned
* @param project the name of the project for which the clone command
* should be returned
* @return the clone command
*/
public abstract String getCommand(DownloadScheme scheme, String project);
}

View File

@ -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);

View File

@ -27,8 +27,10 @@ import com.google.gerrit.client.api.ApiGlue;
import com.google.gerrit.client.api.PluginLoader;
import com.google.gerrit.client.changes.ChangeConstants;
import com.google.gerrit.client.changes.ChangeListScreen;
import com.google.gerrit.client.config.AuthInfo;
import com.google.gerrit.client.config.ConfigServerApi;
import com.google.gerrit.client.config.ServerInfo;
import com.google.gerrit.client.documentation.DocInfo;
import com.google.gerrit.client.extensions.TopMenu;
import com.google.gerrit.client.extensions.TopMenuItem;
import com.google.gerrit.client.extensions.TopMenuList;
@ -42,8 +44,6 @@ import com.google.gerrit.client.ui.MorphingTabPanel;
import com.google.gerrit.client.ui.ProjectLinkMenuItem;
import com.google.gerrit.client.ui.Screen;
import com.google.gerrit.common.PageLinks;
import com.google.gerrit.common.data.GerritConfig;
import com.google.gerrit.common.data.GitwebConfig;
import com.google.gerrit.common.data.HostPageData;
import com.google.gerrit.common.data.SystemInfoService;
import com.google.gerrit.extensions.client.GerritTopMenu;
@ -65,6 +65,11 @@ import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.event.shared.SimpleEventBus;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;
import com.google.gwt.http.client.URL;
import com.google.gwt.http.client.UrlBuilder;
import com.google.gwt.user.client.Command;
@ -103,10 +108,11 @@ public class Gerrit implements EntryPoint {
public static final EventBus EVENT_BUS = GWT.create(SimpleEventBus.class);
public static final Themer THEMER = GWT.create(Themer.class);
public static final String PROJECT_NAME_MENU_VAR = "${projectName}";
public static final String INDEX = "Documentation/index.html";
private static String myHost;
private static GerritConfig myConfig;
private static ServerInfo myServerInfo;
private static boolean hasDocumentation;
private static HostPageData.Theme myTheme;
private static Account myAccount;
private static String defaultScreenToken;
@ -284,21 +290,11 @@ public class Gerrit implements EntryPoint {
return bottomMenu;
}
/** Get the public configuration data used by this Gerrit instance. */
public static GerritConfig getConfig() {
return myConfig;
}
/** Get the public configuration data used by this Gerrit instance. */
public static ServerInfo info() {
return myServerInfo;
}
public static GitwebLink getGitwebLink() {
GitwebConfig gw = getConfig().getGitwebLink();
return gw != null && gw.type != null ? new GitwebLink(gw) : null;
}
/** Site theme information (site specific colors)/ */
public static HostPageData.Theme getTheme() {
return myTheme;
@ -434,6 +430,12 @@ public class Gerrit implements EntryPoint {
RpcStatus.INSTANCE = new RpcStatus();
CallbackGroup cbg = new CallbackGroup();
getDocIndex(cbg.add(new GerritCallback<DocInfo>() {
@Override
public void onSuccess(DocInfo indexInfo) {
hasDocumentation = indexInfo != null;
}
}));
ConfigServerApi.serverInfo(cbg.add(new GerritCallback<ServerInfo>() {
@Override
public void onSuccess(ServerInfo info) {
@ -445,7 +447,6 @@ public class Gerrit implements EntryPoint {
@Override
public void onSuccess(final HostPageData result) {
Document.get().getElementById("gerrit_hostpagedata").removeFromParent();
myConfig = result.config;
myTheme = result.theme;
isNoteDbEnabled = result.isNoteDbEnabled;
if (result.account != null) {
@ -485,9 +486,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);
@ -623,8 +624,8 @@ public class Gerrit implements EntryPoint {
menuBars = new HashMap<>();
final boolean signedIn = isSignedIn();
final GerritConfig cfg = getConfig();
boolean signedIn = isSignedIn();
AuthInfo authInfo = info().auth();
LinkMenuBar m;
m = new LinkMenuBar();
@ -705,7 +706,7 @@ public class Gerrit implements EntryPoint {
}, CREATE_PROJECT, CREATE_GROUP, VIEW_PLUGINS);
}
if (getConfig().isDocumentationAvailable()) {
if (hasDocumentation) {
m = new LinkMenuBar();
menuBars.put(GerritTopMenu.DOCUMENTATION.menuName, m);
addDocLink(m, C.menuDocumentationTOC(), "index.html");
@ -718,9 +719,9 @@ public class Gerrit implements EntryPoint {
}
if (signedIn) {
whoAmI(!info().auth().isClientSslCertLdap());
whoAmI(!authInfo.isClientSslCertLdap());
} else {
switch (info().auth().authType()) {
switch (authInfo.authType()) {
case CLIENT_SSL_CERT_LDAP:
break;
@ -763,18 +764,22 @@ public class Gerrit implements EntryPoint {
case HTTP:
case HTTP_LDAP:
if (cfg.getLoginUrl() != null) {
final String signinText = cfg.getLoginText() == null ? C.menuSignIn() : cfg.getLoginText();
menuRight.add(anchor(signinText, cfg.getLoginUrl()));
if (authInfo.loginUrl() != null) {
String signinText = authInfo.loginText() == null
? C.menuSignIn()
: authInfo.loginText();
menuRight.add(anchor(signinText, authInfo.loginUrl()));
}
break;
case LDAP:
case LDAP_BIND:
case CUSTOM_EXTENSION:
if (cfg.getRegisterUrl() != null) {
final String registerText = cfg.getRegisterText() == null ? C.menuRegister() : cfg.getRegisterText();
menuRight.add(anchor(registerText, cfg.getRegisterUrl()));
if (authInfo.registerUrl() != null) {
String registerText = authInfo.registerText() == null
? C.menuRegister()
: authInfo.registerText();
menuRight.add(anchor(registerText, authInfo.registerUrl()));
}
menuRight.addItem(C.menuSignIn(), new Command() {
@Override
@ -810,6 +815,32 @@ public class Gerrit implements EntryPoint {
});
}
private static void getDocIndex(final AsyncCallback<DocInfo> cb) {
RequestBuilder req =
new RequestBuilder(RequestBuilder.HEAD, GWT.getHostPageBaseURL()
+ INDEX);
req.setCallback(new RequestCallback() {
@Override
public void onResponseReceived(Request req, Response resp) {
if (resp.getStatusCode() == Response.SC_OK) {
cb.onSuccess(DocInfo.create());
} else {
cb.onSuccess(null);
}
}
@Override
public void onError(Request request, Throwable e) {
cb.onFailure(e);
}
});
try {
req.send();
} catch (RequestException e) {
cb.onFailure(e);
}
}
private static AsyncCallback<Preferences> createMyMenuBarCallback() {
return new GerritCallback<Preferences>() {
@Override

View File

@ -1,115 +0,0 @@
// Copyright (C) 2008 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.client;
import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo;
import com.google.gerrit.common.data.GitWebType;
import com.google.gerrit.common.data.ParameterizedString;
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gwt.http.client.URL;
import java.util.HashMap;
import java.util.Map;
/** Link to an external gitweb server. */
public class GitwebLink {
protected String baseUrl;
protected GitWebType type;
public GitwebLink(com.google.gerrit.common.data.GitwebConfig link) {
baseUrl = link.baseUrl;
type = link.type;
}
/**
* Can we link to a patch set if it's a draft
*
* @param ps Patch set to check draft status
* @return true if it's not a draft, or we can link to drafts
*/
public boolean canLink(final PatchSet ps) {
return !ps.isDraft() || type.getLinkDrafts();
}
public boolean canLink(RevisionInfo revision) {
return revision.draft() || type.getLinkDrafts();
}
public String getLinkName() {
return "(" + type.getLinkName() + ")";
}
public String toRevision(String project, String commit) {
ParameterizedString pattern = new ParameterizedString(type.getRevision());
Map<String, String> p = new HashMap<>();
p.put("project", encode(project));
p.put("commit", encode(commit));
return baseUrl + pattern.replace(p);
}
public String toRevision(final Project.NameKey project, final PatchSet ps) {
return toRevision(project.get(), ps.getRevision().get());
}
public String toProject(final Project.NameKey project) {
ParameterizedString pattern = new ParameterizedString(type.getProject());
final Map<String, String> p = new HashMap<>();
p.put("project", encode(project.get()));
return baseUrl + pattern.replace(p);
}
public String toBranch(final Branch.NameKey branch) {
ParameterizedString pattern = new ParameterizedString(type.getBranch());
final Map<String, String> p = new HashMap<>();
p.put("project", encode(branch.getParentKey().get()));
p.put("branch", encode(branch.get()));
return baseUrl + pattern.replace(p);
}
public String toFile(String project, String commit, String file) {
Map<String, String> p = new HashMap<>();
p.put("project", encode(project));
p.put("commit", encode(commit));
p.put("file", encode(file));
ParameterizedString pattern = (file == null || file.isEmpty())
? new ParameterizedString(type.getRootTree())
: new ParameterizedString(type.getFile());
return baseUrl + pattern.replace(p);
}
public String toFileHistory(final Branch.NameKey branch, final String file) {
ParameterizedString pattern = new ParameterizedString(type.getFileHistory());
final Map<String, String> p = new HashMap<>();
p.put("project", encode(branch.getParentKey().get()));
p.put("branch", encode(branch.get()));
p.put("file", encode(file));
return baseUrl + pattern.replace(p);
}
private String encode(String segment) {
if (type.isUrlEncode()) {
return URL.encodeQueryString(type.replacePathSeparator(segment));
} else {
return segment;
}
}
}

View File

@ -50,8 +50,8 @@ public class UserPopupPanel extends PluginSafePopupPanel {
userEmail.setText(account.email());
}
if (showSettingsLink) {
if (Gerrit.getConfig().getSwitchAccountUrl() != null) {
switchAccount.setHref(Gerrit.getConfig().getSwitchAccountUrl());
if (Gerrit.info().auth().switchAccountUrl() != null) {
switchAccount.setHref(Gerrit.info().auth().switchAccountUrl());
} else if (Gerrit.info().auth().isDev()
|| Gerrit.info().auth().isOpenId()) {
switchAccount.setHref(Gerrit.selfRedirect("/login/"));

View File

@ -101,7 +101,7 @@ class ContactPanelShort extends Composite {
int row = 0;
if (!Gerrit.info().auth().canEdit(FieldName.USER_NAME)
&& Gerrit.getConfig().siteHasUsernames()) {
&& Gerrit.info().auth().siteHasUsernames()) {
infoPlainText.resizeRows(infoPlainText.getRowCount() + 1);
row(infoPlainText, row++, Util.C.userName(), new UsernameField());
}
@ -109,12 +109,12 @@ class ContactPanelShort extends Composite {
if (!canEditFullName()) {
FlowPanel nameLine = new FlowPanel();
nameLine.add(nameTxt);
if (Gerrit.getConfig().getEditFullNameUrl() != null) {
if (Gerrit.info().auth().editFullNameUrl() != null) {
Button edit = new Button(Util.C.linkEditFullName());
edit.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Window.open(Gerrit.getConfig().getEditFullNameUrl(), "_blank", null);
Window.open(Gerrit.info().auth().editFullNameUrl(), "_blank", null);
}
});
nameLine.add(edit);

View File

@ -40,7 +40,7 @@ public class MyPasswordScreen extends SettingsScreen {
protected void onInitUI() {
super.onInitUI();
String url = Gerrit.getConfig().getHttpPasswordUrl();
String url = Gerrit.info().auth().httpPasswordUrl();
if (url != null) {
Anchor link = new Anchor();
link.setText(Util.C.linkObtainPassword());

View File

@ -61,13 +61,13 @@ public class MyProfileScreen extends SettingsScreen {
fieldIdx = 1;
}
info = new Grid((Gerrit.getConfig().siteHasUsernames() ? 1 : 0) + 4, 2);
info = new Grid((Gerrit.info().auth().siteHasUsernames() ? 1 : 0) + 4, 2);
info.setStyleName(Gerrit.RESOURCES.css().infoBlock());
info.addStyleName(Gerrit.RESOURCES.css().accountInfoBlock());
h.add(info);
int row = 0;
if (Gerrit.getConfig().siteHasUsernames()) {
if (Gerrit.info().auth().siteHasUsernames()) {
infoRow(row++, Util.C.userName());
}
infoRow(row++, Util.C.fullName());
@ -110,7 +110,7 @@ public class MyProfileScreen extends SettingsScreen {
});
int row = 0;
if (Gerrit.getConfig().siteHasUsernames()) {
if (Gerrit.info().auth().siteHasUsernames()) {
info.setWidget(row++, fieldIdx, new UsernameField());
}
info.setText(row++, fieldIdx, account.getFullName());

View File

@ -99,7 +99,7 @@ public class RegisterScreen extends AccountScreen {
formBody.add(fp);
}
if (Gerrit.getConfig().getSshdAddress() != null) {
if (Gerrit.info().hasSshd()) {
final FlowPanel sshKeyGroup = new FlowPanel();
sshKeyGroup.setStyleName(Gerrit.RESOURCES.css().registerScreenSection());
sshKeyGroup.add(new SmallHeading(Util.C.welcomeSshKeyHeading()));

View File

@ -26,10 +26,10 @@ public abstract class SettingsScreen extends MenuScreen {
link(Util.C.tabPreferences(), PageLinks.SETTINGS_PREFERENCES);
link(Util.C.tabWatchedProjects(), PageLinks.SETTINGS_PROJECTS);
link(Util.C.tabContactInformation(), PageLinks.SETTINGS_CONTACT);
if (Gerrit.getConfig().getSshdAddress() != null) {
if (Gerrit.info().hasSshd()) {
link(Util.C.tabSshKeys(), PageLinks.SETTINGS_SSHKEYS);
}
if (Gerrit.getConfig().isHttpPasswordSettingsEnabled()) {
if (Gerrit.info().auth().isHttpPasswordSettingsEnabled()) {
link(Util.C.tabHttpAccess(), PageLinks.SETTINGS_HTTP_PASSWORD);
}
link(Util.C.tabWebIdentities(), PageLinks.SETTINGS_WEBIDENT);

View File

@ -16,7 +16,7 @@ package com.google.gerrit.client.admin;
import com.google.gerrit.client.Dispatcher;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.GitwebLink;
import com.google.gerrit.client.config.GitWebInfo;
import com.google.gerrit.client.ui.Hyperlink;
import com.google.gerrit.client.ui.ParentProjectBox;
import com.google.gerrit.common.data.AccessSection;
@ -121,7 +121,7 @@ public class ProjectAccessEditor extends Composite implements
inheritsFrom.getStyle().setDisplay(Display.NONE);
}
final GitwebLink c = Gerrit.getGitwebLink();
GitWebInfo c = Gerrit.info().gitWeb();
if (value.isConfigVisible() && c != null) {
history.getStyle().setDisplay(Display.BLOCK);
gitweb.setText(c.getLinkName());

View File

@ -20,13 +20,13 @@ import com.google.gerrit.client.ConfirmationCallback;
import com.google.gerrit.client.ConfirmationDialog;
import com.google.gerrit.client.ErrorDialog;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.GitwebLink;
import com.google.gerrit.client.VoidResult;
import com.google.gerrit.client.WebLinkInfo;
import com.google.gerrit.client.access.AccessMap;
import com.google.gerrit.client.access.ProjectAccessInfo;
import com.google.gerrit.client.actions.ActionButton;
import com.google.gerrit.client.actions.ActionInfo;
import com.google.gerrit.client.config.GitWebInfo;
import com.google.gerrit.client.projects.BranchInfo;
import com.google.gerrit.client.projects.ProjectApi;
import com.google.gerrit.client.rpc.GerritCallback;
@ -457,7 +457,7 @@ public class ProjectBranchesScreen extends ProjectScreen {
}
void populate(int row, BranchInfo k) {
final GitwebLink c = Gerrit.getGitwebLink();
GitWebInfo c = Gerrit.info().gitWeb();
if (k.canDelete()) {
CheckBox sel = new CheckBox();

View File

@ -21,6 +21,8 @@ import com.google.gerrit.client.access.ProjectAccessInfo;
import com.google.gerrit.client.actions.ActionButton;
import com.google.gerrit.client.actions.ActionInfo;
import com.google.gerrit.client.change.Resources;
import com.google.gerrit.client.config.DownloadInfo.DownloadCommandInfo;
import com.google.gerrit.client.config.DownloadInfo.DownloadSchemeInfo;
import com.google.gerrit.client.download.DownloadPanel;
import com.google.gerrit.client.projects.ConfigInfo;
import com.google.gerrit.client.projects.ConfigInfo.ConfigParameterInfo;
@ -65,6 +67,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
public class ProjectInfoScreen extends ProjectScreen {
private boolean isOwner;
@ -677,23 +680,11 @@ public class ProjectInfoScreen extends ProjectScreen {
}
@Override
public void populateDownloadCommandLinks() {
if (!urls.isEmpty()) {
commands.add(cmdLinkfactory.new CloneCommandLink());
if (Gerrit.getConfig().getSshdAddress() != null && hasUserName()) {
commands.add(
cmdLinkfactory.new CloneWithCommitMsgHookCommandLink(getProjectKey()));
}
}
protected Set<DownloadCommandInfo> getCommands(DownloadSchemeInfo schemeInfo) {
return schemeInfo.cloneCommands(project);
}
}
private static boolean hasUserName() {
return Gerrit.isSignedIn()
&& Gerrit.getUserAccount().getUserName() != null
&& Gerrit.getUserAccount().getUserName().length() > 0;
}
private static class LabeledWidgetsGrid extends FlexTable {
private String labelSuffix;

View File

@ -18,8 +18,8 @@ import static com.google.gerrit.common.PageLinks.ADMIN_PROJECTS;
import com.google.gerrit.client.Dispatcher;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.GitwebLink;
import com.google.gerrit.client.WebLinkInfo;
import com.google.gerrit.client.config.GitWebInfo;
import com.google.gerrit.client.projects.ProjectInfo;
import com.google.gerrit.client.projects.ProjectMap;
import com.google.gerrit.client.rpc.GerritCallback;
@ -185,7 +185,7 @@ public class ProjectListScreen extends Screen {
}
private void addWebLinks(int row, ProjectInfo k) {
GitwebLink gitWebLink = Gerrit.getGitwebLink();
GitWebInfo gitWebLink = Gerrit.info().gitWeb();
List<WebLinkInfo> webLinks = Natives.asList(k.webLinks());
if (gitWebLink != null || (webLinks != null && !webLinks.isEmpty())) {
FlowPanel p = new FlowPanel();

View File

@ -310,10 +310,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());
@ -1201,7 +1201,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);
@ -1303,7 +1303,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));

View File

@ -17,13 +17,13 @@ package com.google.gerrit.client.change;
import com.google.gerrit.client.AvatarImage;
import com.google.gerrit.client.FormatUtil;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.GitwebLink;
import com.google.gerrit.client.WebLinkInfo;
import com.google.gerrit.client.account.AccountInfo;
import com.google.gerrit.client.changes.ChangeInfo;
import com.google.gerrit.client.changes.ChangeInfo.CommitInfo;
import com.google.gerrit.client.changes.ChangeInfo.GitPerson;
import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo;
import com.google.gerrit.client.config.GitWebInfo;
import com.google.gerrit.client.rpc.Natives;
import com.google.gerrit.client.ui.CommentLinkProcessor;
import com.google.gerrit.client.ui.InlineHyperlink;
@ -135,7 +135,7 @@ class CommitBox extends Composite {
private void setWebLinks(ChangeInfo change, String revision,
RevisionInfo revInfo) {
GitwebLink gw = Gerrit.getGitwebLink();
GitWebInfo gw = Gerrit.info().gitWeb();
if (gw != null && gw.canLink(revInfo)) {
toAnchor(gw.toRevision(change.project(), revision),
gw.getLinkName());
@ -184,7 +184,7 @@ class CommitBox extends Composite {
}
private void addLinks(String project, CommitInfo c, FlowPanel panel) {
GitwebLink gw = Gerrit.getGitwebLink();
GitWebInfo gw = Gerrit.info().gitWeb();
if (gw != null) {
Anchor a =
new Anchor(gw.getLinkName(), gw.toRevision(project, c.commit()));

View File

@ -164,7 +164,7 @@ class DownloadBox extends VerticalPanel {
}
private void insertArchive() {
List<String> activated = Gerrit.getConfig().getArchiveFormats();
List<String> activated = Gerrit.info().download().archives();
if (activated.isEmpty()) {
return;
}

View File

@ -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();
}

View File

@ -15,10 +15,10 @@
package com.google.gerrit.client.change;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.GitwebLink;
import com.google.gerrit.client.change.RelatedChanges.ChangeAndCommit;
import com.google.gerrit.client.changes.ChangeInfo.CommitInfo;
import com.google.gerrit.client.changes.Util;
import com.google.gerrit.client.config.GitWebInfo;
import com.google.gerrit.common.PageLinks;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gwt.core.client.GWT;
@ -301,7 +301,7 @@ class RelatedChangesTab implements IsWidget {
sb.closeSpan();
sb.openSpan();
GitwebLink gw = Gerrit.getGitwebLink();
GitWebInfo gw = Gerrit.info().gitWeb();
if (gw != null && (!info.hasChangeNumber() || !info.hasRevisionNumber())) {
sb.setStyleName(RelatedChanges.R.css().gitweb());
sb.setAttribute("title", gw.getLinkName());
@ -335,7 +335,7 @@ class RelatedChangesTab implements IsWidget {
id.getId());
}
GitwebLink gw = Gerrit.getGitwebLink();
GitWebInfo gw = Gerrit.info().gitWeb();
if (gw != null && project != null) {
return gw.toRevision(project, info.commit().commit());
}

View File

@ -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;

View File

@ -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());
}

View File

@ -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) {

View File

@ -17,6 +17,7 @@ package com.google.gerrit.client.config;
import com.google.gerrit.client.rpc.Natives;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AuthType;
import com.google.gerrit.reviewdb.client.Account.FieldName;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArrayString;
@ -28,6 +29,9 @@ public class AuthInfo extends JavaScriptObject {
return AuthType.valueOf(authTypeRaw());
}
public final boolean isLdap() {
return authType() == AuthType.LDAP || authType() == AuthType.LDAP_BIND;
}
public final boolean isOpenId() {
return authType() == AuthType.OPENID;
}
@ -60,8 +64,32 @@ public class AuthInfo extends JavaScriptObject {
return fields;
}
public final boolean siteHasUsernames() {
if (isCustomExtension()
&& httpPasswordUrl() != null
&& !canEdit(FieldName.USER_NAME)) {
return false;
}
return true;
}
public final boolean isHttpPasswordSettingsEnabled() {
if (isLdap() && isGitBasicAuth()) {
return false;
}
return true;
}
public final native boolean useContributorAgreements()
/*-{ return this.use_contributor_agreements || false; }-*/;
public final native String loginUrl() /*-{ return this.login_url; }-*/;
public final native String loginText() /*-{ return this.login_text; }-*/;
public final native String switchAccountUrl() /*-{ return this.switch_account_url; }-*/;
public final native String registerUrl() /*-{ return this.register_url; }-*/;
public final native String registerText() /*-{ return this.register_text; }-*/;
public final native String editFullNameUrl() /*-{ return this.edit_full_name_url; }-*/;
public final native String httpPasswordUrl() /*-{ return this.http_password_url; }-*/;
public final native boolean isGitBasicAuth() /*-{ return this.is_git_basic_auth || false; }-*/;
private final native String authTypeRaw() /*-{ return this.auth_type; }-*/;
private final native JsArrayString _editableAccountFields()
/*-{ return this.editable_account_fields; }-*/;

View File

@ -18,16 +18,29 @@ import com.google.gerrit.client.rpc.NativeMap;
import com.google.gerrit.client.rpc.NativeString;
import com.google.gerrit.client.rpc.Natives;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArrayString;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class DownloadInfo extends JavaScriptObject {
public final Set<String> schemes() {
return Natives.keys(_schemes());
}
public final List<String> archives() {
List<String> archives = new ArrayList<>();
for (String f : Natives.asList(_archives())) {
archives.add(f);
}
return archives;
}
public final native DownloadSchemeInfo scheme(String n) /*-{ return this.schemes[n]; }-*/;
private final native NativeMap<DownloadSchemeInfo> _schemes() /*-{ return this.schemes; }-*/;
private final native JsArrayString _archives() /*-{ return this.archives; }-*/;
protected DownloadInfo() {
}
@ -50,6 +63,23 @@ public class DownloadInfo extends JavaScriptObject {
return command(commandName).replaceAll("\\$\\{project\\}", project);
}
public final Set<String> cloneCommandNames() {
return Natives.keys(_cloneCommands());
}
public final Set<DownloadCommandInfo> cloneCommands(String project) {
Set<DownloadCommandInfo> commands = new HashSet<>();
for (String commandName : cloneCommandNames()) {
commands.add(new DownloadCommandInfo(commandName, cloneCommand(
commandName, project)));
}
return commands;
}
public final String cloneCommand(String commandName, String project) {
return cloneCommand(commandName).replaceAll("\\$\\{project\\}", project);
}
public final String getUrl(String project) {
return url().replaceAll("\\$\\{project\\}", project);
}
@ -59,7 +89,9 @@ public class DownloadInfo extends JavaScriptObject {
public final native boolean isAuthRequired() /*-{ return this.is_auth_required || false; }-*/;
public final native boolean isAuthSupported() /*-{ return this.is_auth_supported || false; }-*/;
public final native String command(String n) /*-{ return this.commands[n]; }-*/;
public final native String cloneCommand(String n) /*-{ return this.clone_commands[n]; }-*/;
private final native NativeMap<NativeString> _commands() /*-{ return this.commands; }-*/;
private final native NativeMap<NativeString> _cloneCommands() /*-{ return this.clone_commands; }-*/;
protected DownloadSchemeInfo() {
}

View File

@ -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() {
}

View File

@ -0,0 +1,169 @@
// Copyright (C) 2008 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.client.config;
import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo;
import com.google.gerrit.common.data.ParameterizedString;
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.http.client.URL;
import java.util.HashMap;
import java.util.Map;
public class GitWebInfo extends JavaScriptObject {
public final native String url() /*-{ return this.url; }-*/;
public final native GitWebTypeInfo type() /*-{ return this.type; }-*/;
/**
* Checks whether the given patch set can be linked.
*
* Draft patch sets can only be linked if linking of drafts was enabled by
* configuration.
*
* @param ps patch set to check whether it can be linked
* @return true if the patch set can be linked, otherwise false
*/
public final boolean canLink(PatchSet ps) {
return !ps.isDraft() || type().linkDrafts();
}
/**
* Checks whether the given revision can be linked.
*
* Draft revisions can only be linked if linking of drafts was enabled by
* configuration.
*
* @param revision revision to check whether it can be linked
* @return true if the revision can be linked, otherwise false
*/
public final boolean canLink(RevisionInfo revision) {
return revision.draft() || type().linkDrafts();
}
/**
* Returns the name for GitWeb links.
*
* @return the name for GitWeb links
*/
public final String getLinkName() {
return "(" + type().name() + ")";
}
/**
* Returns the GitWeb link to a revision.
*
* @param project the name of the project
* @param commit the commit ID
* @return GitWeb link to a revision
*/
public final String toRevision(String project, String commit) {
ParameterizedString pattern = new ParameterizedString(type().revision());
Map<String, String> p = new HashMap<>();
p.put("project", encode(project));
p.put("commit", encode(commit));
return url() + pattern.replace(p);
}
/**
* Returns the GitWeb link to a revision.
*
* @param project the name of the project
* @param ps the patch set
* @return GitWeb link to a revision
*/
public final String toRevision(Project.NameKey project, PatchSet ps) {
return toRevision(project.get(), ps.getRevision().get());
}
/**
* Returns the GitWeb link to a project.
*
* @param project the project name key
* @return GitWeb link to a project
*/
public final String toProject(Project.NameKey project) {
ParameterizedString pattern = new ParameterizedString(type().project());
Map<String, String> p = new HashMap<>();
p.put("project", encode(project.get()));
return url() + pattern.replace(p);
}
/**
* Returns the GitWeb link to a branch.
*
* @param branch the branch name key
* @return GitWeb link to a branch
*/
public final String toBranch(Branch.NameKey branch) {
ParameterizedString pattern = new ParameterizedString(type().branch());
Map<String, String> p = new HashMap<>();
p.put("project", encode(branch.getParentKey().get()));
p.put("branch", encode(branch.get()));
return url() + pattern.replace(p);
}
/**
* Returns the GitWeb link to a file.
*
* @param project the branch name key
* @param commit the commit ID
* @param file the path of the file
* @return GitWeb link to a file
*/
public final String toFile(String project, String commit, String file) {
Map<String, String> p = new HashMap<>();
p.put("project", encode(project));
p.put("commit", encode(commit));
p.put("file", encode(file));
ParameterizedString pattern = (file == null || file.isEmpty())
? new ParameterizedString(type().rootTree())
: new ParameterizedString(type().file());
return url() + pattern.replace(p);
}
/**
* Returns the GitWeb link to a file history.
*
* @param branch the branch name key
* @param file the path of the file
* @return GitWeb link to a file history
*/
public final String toFileHistory(Branch.NameKey branch, String file) {
ParameterizedString pattern = new ParameterizedString(type().fileHistory());
Map<String, String> p = new HashMap<>();
p.put("project", encode(branch.getParentKey().get()));
p.put("branch", encode(branch.get()));
p.put("file", encode(file));
return url() + pattern.replace(p);
}
private final String encode(String segment) {
if (type().urlEncode()) {
return URL.encodeQueryString(type().replacePathSeparator(segment));
} else {
return segment;
}
}
protected GitWebInfo() {
}
}

View File

@ -0,0 +1,48 @@
// Copyright (C) 2015 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.client.config;
import com.google.gwt.core.client.JavaScriptObject;
public class GitWebTypeInfo extends JavaScriptObject {
/**
* Replace the standard path separator ('/') in a branch name or project
* name with a custom path separator configured by the property
* gitweb.pathSeparator.
* @param urlSegment The branch or project to replace the path separator in
* @return the urlSegment with the standard path separator replaced by the
* custom path separator
*/
public final String replacePathSeparator(String urlSegment) {
if (!"/".equals(pathSeparator())) {
return urlSegment.replace("/", pathSeparator());
}
return urlSegment;
}
public final native String name() /*-{ return this.name; }-*/;
public final native String revision() /*-{ return this.revision; }-*/;
public final native String project() /*-{ return this.project; }-*/;
public final native String branch() /*-{ return this.branch; }-*/;
public final native String rootTree() /*-{ return this.root_tree; }-*/;
public final native String file() /*-{ return this.file; }-*/;
public final native String fileHistory() /*-{ return this.file_history; }-*/;
public final native String pathSeparator() /*-{ return this.path_separator; }-*/;
public final native boolean linkDrafts() /*-{ return this.link_drafts || false; }-*/;
public final native boolean urlEncode() /*-{ return this.url_encode || false; }-*/;
protected GitWebTypeInfo() {
}
}

View File

@ -18,21 +18,60 @@ 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 SshdInfo sshd() /*-{ return this.sshd; }-*/;
public final native SuggestInfo suggest() /*-{ return this.suggest; }-*/;
public final native UserConfigInfo user() /*-{ return this.user; }-*/;
public final boolean hasContactStore() {
return contactStore() != null;
}
public final boolean hasSshd() {
return sshd() != null;
}
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 SshdInfo extends JavaScriptObject {
protected SshdInfo() {
}
}
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() {
}
}
}

View File

@ -16,13 +16,13 @@ package com.google.gerrit.client.diff;
import com.google.gerrit.client.Dispatcher;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.GitwebLink;
import com.google.gerrit.client.WebLinkInfo;
import com.google.gerrit.client.changes.ChangeApi;
import com.google.gerrit.client.changes.ChangeInfo;
import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo;
import com.google.gerrit.client.changes.ReviewInfo;
import com.google.gerrit.client.changes.Util;
import com.google.gerrit.client.config.GitWebInfo;
import com.google.gerrit.client.diff.DiffInfo.Region;
import com.google.gerrit.client.patches.PatchUtil;
import com.google.gerrit.client.rpc.CallbackGroup;
@ -115,7 +115,8 @@ public class Header extends Composite {
return b.append(Util.C.commitMessage());
}
GitwebLink gw = (project != null && commit != null) ? Gerrit.getGitwebLink() : null;
GitWebInfo gw = (project != null && commit != null)
? Gerrit.info().gitWeb() : null;
int s = path.lastIndexOf('/') + 1;
if (gw != null && s > 0) {
String base = path.substring(0, s - 1);
@ -192,7 +193,7 @@ public class Header extends Composite {
}
void setChangeInfo(ChangeInfo info) {
GitwebLink gw = Gerrit.getGitwebLink();
GitWebInfo gw = Gerrit.info().gitWeb();
if (gw != null) {
for (RevisionInfo rev : Natives.asList(info.revisions().values())) {
if (patchSetId.getId().equals(rev.id())) {

View File

@ -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();
}

View File

@ -22,6 +22,10 @@ public class DocInfo extends JavaScriptObject {
public final native String title() /*-{ return this.title; }-*/;
public final native String url() /*-{ return this.url; }-*/;
public static DocInfo create() {
return (DocInfo) createObject();
}
protected DocInfo() {
}

View File

@ -15,92 +15,24 @@
package com.google.gerrit.client.download;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.client.config.DownloadInfo.DownloadCommandInfo;
import com.google.gwt.aria.client.Roles;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwtexpui.clippy.client.CopyableLabel;
public abstract class DownloadCommandLink extends Anchor implements ClickHandler {
public static class CopyableCommandLinkFactory {
protected CopyableLabel copyLabel = null;
protected Widget widget;
public class DownloadCommandLink extends Anchor implements ClickHandler {
private final CopyableLabel copyLabel;
private final String command;
public class CloneCommandLink extends DownloadCommandLink {
public CloneCommandLink() {
super("clone");
}
public DownloadCommandLink(CopyableLabel copyLabel,
DownloadCommandInfo commandInfo) {
super(commandInfo.name());
this.copyLabel = copyLabel;
this.command = commandInfo.command();
@Override
protected void setCurrentUrl(DownloadUrlLink link) {
widget.setVisible(true);
copyLabel.setText("git clone " + link.getUrlData());
}
}
public class CloneWithCommitMsgHookCommandLink extends DownloadCommandLink {
private final Project.NameKey project;
public CloneWithCommitMsgHookCommandLink(Project.NameKey project) {
super("clone with commit-msg hook");
this.project = project;
}
@Override
protected void setCurrentUrl(DownloadUrlLink link) {
widget.setVisible(true);
String sshPort = null;
String sshAddr = Gerrit.getConfig().getSshdAddress();
int p = sshAddr.lastIndexOf(':');
if (p != -1 && !sshAddr.endsWith(":")) {
sshPort = sshAddr.substring(p + 1);
}
StringBuilder cmd = new StringBuilder();
cmd.append("git clone ");
cmd.append(link.getUrlData());
cmd.append(" && scp -p ");
if (sshPort != null) {
cmd.append("-P ");
cmd.append(sshPort);
cmd.append(" ");
}
cmd.append(Gerrit.getUserAccount().getUserName());
cmd.append("@");
if (sshAddr.startsWith("*:") || p == -1) {
cmd.append(Window.Location.getHostName());
} else {
cmd.append(sshAddr.substring(0, p));
}
cmd.append(":hooks/commit-msg ");
p = project.get().lastIndexOf('/');
if (p != -1) {
cmd.append(project.get().substring(p + 1));
} else {
cmd.append(project.get());
}
cmd.append("/.git/hooks/");
copyLabel.setText(cmd.toString());
}
}
public CopyableCommandLinkFactory(CopyableLabel label, Widget widget) {
copyLabel = label;
this.widget = widget;
}
}
public DownloadCommandLink(String text) {
super(text);
setStyleName(Gerrit.RESOURCES.css().downloadLink());
Roles.getTabRole().set(getElement());
addClickHandler(this);
@ -115,6 +47,8 @@ public abstract class DownloadCommandLink extends Anchor implements ClickHandler
}
void select() {
copyLabel.setText(command);
DownloadCommandPanel parent = (DownloadCommandPanel) getParent();
for (Widget w : parent) {
if (w != this && w instanceof DownloadCommandLink) {
@ -124,6 +58,4 @@ public abstract class DownloadCommandLink extends Anchor implements ClickHandler
parent.setCurrentCommand(this);
addStyleName(Gerrit.RESOURCES.css().downloadLink_Active());
}
protected abstract void setCurrentUrl(DownloadUrlLink link);
}

View File

@ -21,7 +21,6 @@ import com.google.gwt.user.client.ui.Widget;
public class DownloadCommandPanel extends FlowPanel {
private DownloadCommandLink currentCommand;
private DownloadUrlLink currentUrl;
public DownloadCommandPanel() {
setStyleName(Gerrit.RESOURCES.css().downloadLinkList());
@ -37,7 +36,12 @@ public class DownloadCommandPanel extends FlowPanel {
for (Widget w : this) {
if (w instanceof DownloadCommandLink) {
final DownloadCommandLink d = (DownloadCommandLink) w;
DownloadCommandLink d = (DownloadCommandLink) w;
if (currentCommand != null
&& d.getText().equals(currentCommand.getText())) {
d.select();
return;
}
if (first == null) {
first = d;
}
@ -51,19 +55,7 @@ public class DownloadCommandPanel extends FlowPanel {
}
}
void setCurrentUrl(DownloadUrlLink link) {
currentUrl = link;
update();
}
void setCurrentCommand(DownloadCommandLink cmd) {
currentCommand = cmd;
update();
}
private void update() {
if (currentCommand != null && currentUrl != null) {
currentCommand.setCurrentUrl(currentUrl);
}
}
}

View File

@ -15,34 +15,32 @@
package com.google.gerrit.client.download;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.config.DownloadInfo.DownloadCommandInfo;
import com.google.gerrit.client.config.DownloadInfo.DownloadSchemeInfo;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.InlineLabel;
import com.google.gwtexpui.clippy.client.CopyableLabel;
import java.util.Set;
public abstract class DownloadPanel extends FlowPanel {
protected String projectName;
protected final String project;
protected DownloadCommandLink.CopyableCommandLinkFactory cmdLinkfactory;
protected DownloadCommandPanel commands = new DownloadCommandPanel();
protected DownloadUrlPanel urls = new DownloadUrlPanel(commands);
protected CopyableLabel copyLabel = new CopyableLabel("");
private final DownloadCommandPanel commands = new DownloadCommandPanel();
private final DownloadUrlPanel urls = new DownloadUrlPanel();
private final CopyableLabel copyLabel = new CopyableLabel("");
public DownloadPanel(String project, boolean allowAnonymous) {
this.projectName = project;
this.project = project;
copyLabel.setStyleName(Gerrit.RESOURCES.css().downloadLinkCopyLabel());
urls.add(DownloadUrlLink.createDownloadUrlLinks(project, allowAnonymous));
cmdLinkfactory = new DownloadCommandLink.CopyableCommandLinkFactory(
copyLabel, urls);
urls.add(DownloadUrlLink.createDownloadUrlLinks(allowAnonymous, this));
populateDownloadCommandLinks();
setupWidgets();
}
protected void setupWidgets() {
if (!commands.isEmpty()) {
private void setupWidgets() {
if (!urls.isEmpty()) {
final AccountGeneralPreferences pref;
if (Gerrit.isSignedIn()) {
pref = Gerrit.getUserAccount().getGeneralPreferences();
@ -50,7 +48,6 @@ public abstract class DownloadPanel extends FlowPanel {
pref = new AccountGeneralPreferences();
pref.resetToDefaults();
}
commands.select();
urls.select(pref.getDownloadUrl());
FlowPanel p = new FlowPanel();
@ -66,5 +63,14 @@ public abstract class DownloadPanel extends FlowPanel {
}
}
protected abstract void populateDownloadCommandLinks();
void populateDownloadCommandLinks(DownloadSchemeInfo schemeInfo) {
commands.clear();
for (DownloadCommandInfo cmd : getCommands(schemeInfo)) {
commands.add(new DownloadCommandLink(copyLabel, cmd));
}
commands.select();
}
protected abstract Set<DownloadCommandInfo> getCommands(
DownloadSchemeInfo schemeInfo);
}

View File

@ -15,13 +15,12 @@
package com.google.gerrit.client.download;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.config.DownloadInfo.DownloadSchemeInfo;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadScheme;
import com.google.gwt.aria.client.Roles;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwtjsonrpc.common.AsyncCallback;
@ -29,164 +28,77 @@ import com.google.gwtjsonrpc.common.VoidResult;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public class DownloadUrlLink extends Anchor implements ClickHandler {
public static class AnonGitLink extends DownloadUrlLink {
public AnonGitLink(String project) {
super(DownloadScheme.ANON_GIT, Util.M.anonymousDownload("Git"), project);
private enum KnownScheme {
ANON_GIT(DownloadScheme.ANON_GIT, "git", Util.M.anonymousDownload("Git")),
ANON_HTTP(DownloadScheme.ANON_HTTP, "anonymous http", Util.M.anonymousDownload("HTTP")),
SSH(DownloadScheme.SSH, "ssh", "SSH"),
HTTP(DownloadScheme.HTTP, "http", "HTTP");
public final DownloadScheme downloadScheme;
public final String name;
public final String text;
private KnownScheme(DownloadScheme downloadScheme, String name, String text) {
this.downloadScheme = downloadScheme;
this.name = name;
this.text = text;
}
@Override
public String getUrlData() {
StringBuilder r = new StringBuilder();
r.append(Gerrit.getConfig().getGitDaemonUrl());
r.append(projectName);
return r.toString();
}
}
public static class AnonHttpLink extends DownloadUrlLink {
public AnonHttpLink(String project) {
super(DownloadScheme.ANON_HTTP, Util.M.anonymousDownload("HTTP"), project);
}
@Override
public String getUrlData() {
StringBuilder r = new StringBuilder();
if (Gerrit.getConfig().getGitHttpUrl() != null) {
r.append(Gerrit.getConfig().getGitHttpUrl());
} else {
r.append(hostPageUrl);
}
r.append(projectName);
return r.toString();
}
}
public static class SshLink extends DownloadUrlLink {
public SshLink(String project) {
super(DownloadScheme.SSH, "SSH", project);
}
@Override
public String getUrlData() {
String sshAddr = Gerrit.getConfig().getSshdAddress();
final StringBuilder r = new StringBuilder();
r.append("ssh://");
r.append(Gerrit.getUserAccount().getUserName());
r.append("@");
if (sshAddr.startsWith("*:") || "".equals(sshAddr)) {
r.append(Window.Location.getHostName());
}
if (sshAddr.startsWith("*")) {
sshAddr = sshAddr.substring(1);
}
r.append(sshAddr);
r.append("/");
r.append(projectName);
return r.toString();
}
}
public static class HttpLink extends DownloadUrlLink {
protected boolean anonymous;
public HttpLink(String project, boolean anonymous) {
super(DownloadScheme.HTTP, "HTTP", project);
this.anonymous = anonymous;
}
@Override
public String getUrlData() {
final StringBuilder r = new StringBuilder();
if (Gerrit.getConfig().getGitHttpUrl() != null
&& (anonymous || siteReliesOnHttp())) {
r.append(Gerrit.getConfig().getGitHttpUrl());
} else {
String base = hostPageUrl;
int p = base.indexOf("://");
int s = base.indexOf('/', p + 3);
if (s < 0) {
s = base.length();
static KnownScheme get(String name) {
for (KnownScheme s : values()) {
if (s.name.equals(name)) {
return s;
}
String host = base.substring(p + 3, s);
if (host.contains("@")) {
host = host.substring(host.indexOf('@') + 1);
}
r.append(base.substring(0, p + 3));
r.append(Gerrit.getUserAccount().getUserName());
r.append('@');
r.append(host);
r.append(base.substring(s));
}
r.append(projectName);
return r.toString();
return null;
}
}
public static boolean siteReliesOnHttp() {
return Gerrit.getConfig().getGitHttpUrl() != null
&& Gerrit.info().auth().isCustomExtension()
&& !Gerrit.getConfig().siteHasUsernames();
}
public static List<DownloadUrlLink> createDownloadUrlLinks(String project,
boolean allowAnonymous) {
public static List<DownloadUrlLink> createDownloadUrlLinks(
boolean allowAnonymous, DownloadPanel downloadPanel) {
List<DownloadUrlLink> urls = new ArrayList<>();
Set<String> allowedSchemes = Gerrit.info().download().schemes();
for (String s : Gerrit.info().download().schemes()) {
DownloadSchemeInfo scheme = Gerrit.info().download().scheme(s);
if (scheme.isAuthRequired() && !allowAnonymous) {
continue;
}
if (allowAnonymous
&& Gerrit.getConfig().getGitDaemonUrl() != null
&& allowedSchemes.contains("git")) {
urls.add(new DownloadUrlLink.AnonGitLink(project));
}
if (allowAnonymous
&& allowedSchemes.contains("anonymous http")) {
urls.add(new DownloadUrlLink.AnonHttpLink(project));
}
if (Gerrit.getConfig().getSshdAddress() != null
&& hasUserName()
&& allowedSchemes.contains("ssh")) {
urls.add(new DownloadUrlLink.SshLink(project));
}
if ((hasUserName() || siteReliesOnHttp())
&& allowedSchemes.contains("http")) {
urls.add(new DownloadUrlLink.HttpLink(project, allowAnonymous));
KnownScheme knownScheme = KnownScheme.get(s);
if (knownScheme != null) {
urls.add(new DownloadUrlLink(downloadPanel, scheme,
knownScheme.downloadScheme, knownScheme.text));
} else {
urls.add(new DownloadUrlLink(downloadPanel, scheme, s));
}
}
return urls;
}
private static boolean hasUserName() {
return Gerrit.isSignedIn()
&& Gerrit.getUserAccount().getUserName() != null
&& Gerrit.getUserAccount().getUserName().length() > 0;
private final DownloadPanel downloadPanel;
private final DownloadSchemeInfo schemeInfo;
private final DownloadScheme urlType;
public DownloadUrlLink(DownloadPanel downloadPanel,
DownloadSchemeInfo schemeInfo, String text) {
this(downloadPanel, schemeInfo, null, text);
}
protected DownloadScheme urlType;
protected String projectName;
protected String urlData;
protected String hostPageUrl = GWT.getHostPageBaseURL();
public DownloadUrlLink(DownloadScheme urlType, String text, String project) {
public DownloadUrlLink(DownloadPanel downloadPanel,
DownloadSchemeInfo schemeInfo, DownloadScheme urlType, String text) {
super(text);
setStyleName(Gerrit.RESOURCES.css().downloadLink());
Roles.getTabRole().set(getElement());
addClickHandler(this);
if (!hostPageUrl.endsWith("/")) {
hostPageUrl += "/";
}
this.downloadPanel = downloadPanel;
this.schemeInfo = schemeInfo;
this.urlType = urlType;
this.projectName = project;
}
public String getUrlData() {
return urlData;
public DownloadScheme getUrlType() {
return urlType;
}
@Override
@ -196,7 +108,7 @@ public class DownloadUrlLink extends Anchor implements ClickHandler {
select();
if (Gerrit.isSignedIn()) {
if (Gerrit.isSignedIn() && urlType != null) {
// If the user is signed-in, remember this choice for future panels.
//
AccountGeneralPreferences pref =
@ -216,13 +128,14 @@ public class DownloadUrlLink extends Anchor implements ClickHandler {
}
void select() {
downloadPanel.populateDownloadCommandLinks(schemeInfo);
DownloadUrlPanel parent = (DownloadUrlPanel) getParent();
for (Widget w : parent) {
if (w != this && w instanceof DownloadUrlLink) {
w.removeStyleName(Gerrit.RESOURCES.css().downloadLink_Active());
}
}
parent.setCurrentUrl(this);
addStyleName(Gerrit.RESOURCES.css().downloadLink_Active());
}
}

View File

@ -23,10 +23,8 @@ import com.google.gwt.user.client.ui.Widget;
import java.util.Collection;
public class DownloadUrlPanel extends FlowPanel {
private final DownloadCommandPanel commandPanel;
public DownloadUrlPanel(final DownloadCommandPanel commandPanel) {
this.commandPanel = commandPanel;
public DownloadUrlPanel() {
setStyleName(Gerrit.RESOURCES.css().downloadLinkList());
Roles.getTablistRole().set(getElement());
}
@ -44,7 +42,7 @@ public class DownloadUrlPanel extends FlowPanel {
if (first == null) {
first = d;
}
if (d.urlType == urlType) {
if (d.getUrlType() == urlType) {
d.select();
return;
}
@ -58,10 +56,6 @@ public class DownloadUrlPanel extends FlowPanel {
}
}
void setCurrentUrl(DownloadUrlLink link) {
commandPanel.setCurrentUrl(link);
}
public void add(Collection<DownloadUrlLink> links) {
for (Widget link: links) {
add(link);

View File

@ -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();

View File

@ -1,172 +0,0 @@
// Copyright (C) 2009 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.httpd;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.gerrit.common.data.GerritConfig;
import com.google.gerrit.common.data.GitwebConfig;
import com.google.gerrit.server.account.Realm;
import com.google.gerrit.server.change.ArchiveFormat;
import com.google.gerrit.server.change.GetArchive;
import com.google.gerrit.server.config.AnonymousCowardName;
import com.google.gerrit.server.config.AuthConfig;
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;
import com.google.inject.Provider;
import com.google.inject.ProvisionException;
import org.eclipse.jgit.lib.Config;
import java.net.MalformedURLException;
import java.util.concurrent.TimeUnit;
import javax.servlet.ServletContext;
class GerritConfigProvider implements Provider<GerritConfig> {
private final Realm realm;
private final Config cfg;
private final AuthConfig authConfig;
private final GetArchive.AllowedFormats archiveFormats;
private final GitWebConfig gitWebConfig;
private final SshInfo sshInfo;
private final ServletContext servletContext;
private final String anonymousCowardName;
@Inject
GerritConfigProvider(Realm r,
@GerritServerConfig Config gsc,
AuthConfig ac,
GitWebConfig gwc,
SshInfo si,
ServletContext sc,
GetArchive.AllowedFormats af,
@AnonymousCowardName String acn) {
realm = r;
cfg = gsc;
authConfig = ac;
archiveFormats = af;
gitWebConfig = gwc;
sshInfo = si;
servletContext = sc;
anonymousCowardName = acn;
}
private GerritConfig create() throws MalformedURLException {
final GerritConfig config = new GerritConfig();
switch (authConfig.getAuthType()) {
case LDAP:
case LDAP_BIND:
config.setRegisterUrl(cfg.getString("auth", null, "registerurl"));
config.setRegisterText(cfg.getString("auth", null, "registertext"));
config.setEditFullNameUrl(cfg.getString("auth", null, "editFullNameUrl"));
config.setHttpPasswordSettingsEnabled(!authConfig.isGitBasicAuth());
break;
case CUSTOM_EXTENSION:
config.setRegisterUrl(cfg.getString("auth", null, "registerurl"));
config.setRegisterText(cfg.getString("auth", null, "registertext"));
config.setEditFullNameUrl(cfg.getString("auth", null, "editFullNameUrl"));
config.setHttpPasswordUrl(cfg.getString("auth", null, "httpPasswordUrl"));
break;
case HTTP:
case HTTP_LDAP:
config.setLoginUrl(cfg.getString("auth", null, "loginurl"));
config.setLoginText(cfg.getString("auth", null, "logintext"));
break;
case CLIENT_SSL_CERT_LDAP:
case DEVELOPMENT_BECOME_ANY_ACCOUNT:
case OAUTH:
case OPENID:
case OPENID_SSO:
break;
}
config.setSwitchAccountUrl(cfg.getString("auth", null, "switchAccountUrl"));
config.setGitDaemonUrl(cfg.getString("gerrit", null, "canonicalgiturl"));
config.setGitHttpUrl(cfg.getString("gerrit", null, "gitHttpUrl"));
config.setAuthType(authConfig.getAuthType());
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));
// Zip is not supported because it may be interpreted by a Java plugin as a
// valid JAR file, whose code would have access to cookies on the domain.
config.setArchiveFormats(Lists.newArrayList(Iterables.transform(
Iterables.filter(
archiveFormats.getAllowed(),
new Predicate<ArchiveFormat>() {
@Override
public boolean apply(ArchiveFormat format) {
return (format != ArchiveFormat.ZIP);
}
}),
new Function<ArchiveFormat, String>() {
@Override
public String apply(ArchiveFormat in) {
return in.getShortName();
}
})));
config.setReportBugUrl(cfg.getString("gerrit", null, "reportBugUrl"));
config.setReportBugText(cfg.getString("gerrit", null, "reportBugText"));
config.setEditableAccountFields(realm.getEditableFields());
if (gitWebConfig.getUrl() != null) {
config.setGitwebLink(new GitwebConfig(gitWebConfig.getUrl(), gitWebConfig
.getGitWebType()));
}
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;
}
@Override
public GerritConfig get() {
try {
return create();
} catch (MalformedURLException e) {
throw new ProvisionException("Cannot create GerritConfig instance", e);
}
}
}

View File

@ -17,7 +17,6 @@ package com.google.gerrit.httpd;
import static com.google.gerrit.extensions.registration.PrivateInternals_DynamicTypes.registerInParentInjectors;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.data.GerritConfig;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.extensions.webui.WebUiPlugin;
import com.google.gerrit.httpd.auth.become.BecomeAnyAccountModule;
@ -31,12 +30,11 @@ import com.google.gerrit.server.RemotePeer;
import com.google.gerrit.server.config.AuthConfig;
import com.google.gerrit.server.config.CanonicalWebUrl;
import com.google.gerrit.server.config.GerritRequestModule;
import com.google.gerrit.server.config.GitWebConfig;
import com.google.gerrit.server.git.AsyncReceiveCommits;
import com.google.gerrit.server.util.GuiceRequestScopePropagator;
import com.google.gerrit.server.util.RequestScopePropagator;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.ProvisionException;
import com.google.inject.servlet.RequestScoped;
@ -49,21 +47,14 @@ public class WebModule extends LifecycleModule {
private final GerritOptions options;
@Inject
WebModule(final AuthConfig authConfig,
@CanonicalWebUrl @Nullable final String canonicalUrl,
WebModule(AuthConfig authConfig,
@CanonicalWebUrl @Nullable String canonicalUrl,
GerritOptions options,
final Injector creatingInjector) {
GitWebConfig gitWebConfig) {
this.authConfig = authConfig;
this.wantSSL = canonicalUrl != null && canonicalUrl.startsWith("https:");
this.options = options;
this.gitWebConfig =
creatingInjector.createChildInjector(new AbstractModule() {
@Override
protected void configure() {
bind(GitWebConfig.class);
}
}).getInstance(GitWebConfig.class);
this.gitWebConfig = gitWebConfig;
}
@Override
@ -84,13 +75,10 @@ public class WebModule extends LifecycleModule {
install(new GerritRequestModule());
install(new GitOverHttpServlet.Module(options.enableMasterFeatures()));
bind(GitWebConfig.class).toInstance(gitWebConfig);
if (gitWebConfig.getGitwebCGI() != null) {
install(new GitWebModule());
}
bind(GerritConfigProvider.class);
bind(GerritConfig.class).toProvider(GerritConfigProvider.class);
DynamicSet.setOf(binder(), WebUiPlugin.class);
install(new AsyncReceiveCommits.Module());

View File

@ -17,7 +17,7 @@ package com.google.gerrit.httpd.gitweb;
import static com.google.gerrit.common.FileUtil.lastModified;
import com.google.common.io.ByteStreams;
import com.google.gerrit.httpd.GitWebConfig;
import com.google.gerrit.server.config.GitWebConfig;
import com.google.gwtexpui.server.CacheHeaders;
import com.google.inject.Inject;
import com.google.inject.Singleton;

View File

@ -16,8 +16,8 @@ package com.google.gerrit.httpd.gitweb;
import static com.google.gerrit.common.FileUtil.lastModified;
import com.google.gerrit.httpd.GitWebConfig;
import com.google.gerrit.httpd.HtmlDomUtil;
import com.google.gerrit.server.config.GitWebConfig;
import com.google.gerrit.server.config.SitePaths;
import com.google.gwtexpui.server.CacheHeaders;
import com.google.gwtjsonrpc.server.RPCServletUtils;

View File

@ -17,7 +17,7 @@ package com.google.gerrit.httpd.gitweb;
import static com.google.gerrit.common.FileUtil.lastModified;
import com.google.common.io.ByteStreams;
import com.google.gerrit.httpd.GitWebConfig;
import com.google.gerrit.server.config.GitWebConfig;
import com.google.gwtexpui.server.CacheHeaders;
import com.google.inject.Inject;
import com.google.inject.Singleton;

View File

@ -32,23 +32,25 @@ package com.google.gerrit.httpd.gitweb;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.gerrit.common.PageLinks;
import com.google.gerrit.common.data.GerritConfig;
import com.google.gerrit.extensions.restapi.Url;
import com.google.gerrit.httpd.GitWebConfig;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.AnonymousUser;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.config.GitWebConfig;
import com.google.gerrit.server.config.SitePaths;
import com.google.gerrit.server.git.LocalDiskRepositoryManager;
import com.google.gerrit.server.project.NoSuchProjectException;
import com.google.gerrit.server.project.ProjectControl;
import com.google.gerrit.server.ssh.SshInfo;
import com.google.gwtexpui.server.CacheHeaders;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.Repository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -96,12 +98,14 @@ class GitWebServlet extends HttpServlet {
private final EnvList _env;
@Inject
GitWebServlet(final LocalDiskRepositoryManager repoManager,
final ProjectControl.Factory projectControl,
final Provider<AnonymousUser> anonymousUserProvider,
final Provider<CurrentUser> userProvider,
final SitePaths site,
final GerritConfig gerritConfig, final GitWebConfig gitWebConfig)
GitWebServlet(LocalDiskRepositoryManager repoManager,
ProjectControl.Factory projectControl,
Provider<AnonymousUser> anonymousUserProvider,
Provider<CurrentUser> userProvider,
SitePaths site,
@GerritServerConfig Config cfg,
SshInfo sshInfo,
GitWebConfig gitWebConfig)
throws IOException {
this.repoManager = repoManager;
this.projectControl = projectControl;
@ -128,7 +132,7 @@ class GitWebServlet extends HttpServlet {
deniedActions.add("project_index");
_env = new EnvList();
makeSiteConfig(site, gerritConfig);
makeSiteConfig(site, cfg, sshInfo);
if (!_env.envMap.containsKey("SystemRoot")) {
String os = System.getProperty("os.name");
@ -146,8 +150,8 @@ class GitWebServlet extends HttpServlet {
}
}
private void makeSiteConfig(final SitePaths site,
final GerritConfig gerritConfig) throws IOException {
private void makeSiteConfig(SitePaths site, Config cfg, SshInfo sshInfo)
throws IOException {
if (!Files.exists(site.tmp_dir)) {
Files.createDirectories(site.tmp_dir);
}
@ -231,8 +235,8 @@ class GitWebServlet extends HttpServlet {
// Generate URLs using anonymous git://
//
if (gerritConfig.getGitDaemonUrl() != null) {
String url = gerritConfig.getGitDaemonUrl();
String url = cfg.getString("gerrit", null, "canonicalGitUrl");
if (url != null) {
if (url.endsWith("/")) {
url = url.substring(0, url.length() - 1);
}
@ -245,8 +249,8 @@ class GitWebServlet extends HttpServlet {
// Generate URLs using authenticated ssh://
//
if (gerritConfig.getSshdAddress() != null) {
String sshAddr = gerritConfig.getSshdAddress();
if (sshInfo != null && !sshInfo.getHostKeys().isEmpty()) {
String sshAddr = sshInfo.getHostKeys().get(0).getHost();
p.print("if ($ENV{'GERRIT_USER_NAME'}) {\n");
p.print(" push @git_base_url_list, join('', 'ssh://'");
p.print(", $ENV{'GERRIT_USER_NAME'}");

View File

@ -22,7 +22,6 @@ import com.google.common.hash.Hasher;
import com.google.common.hash.Hashing;
import com.google.common.primitives.Bytes;
import com.google.gerrit.common.Version;
import com.google.gerrit.common.data.GerritConfig;
import com.google.gerrit.common.data.HostPageData;
import com.google.gerrit.extensions.registration.DynamicItem;
import com.google.gerrit.extensions.registration.DynamicSet;
@ -77,7 +76,6 @@ public class HostPageServlet extends HttpServlet {
private final Provider<CurrentUser> currentUser;
private final DynamicItem<WebSession> session;
private final GerritConfig config;
private final DynamicSet<WebUiPlugin> plugins;
private final DynamicSet<MessageOfTheDay> messages;
private final HostPageData.Theme signedOutTheme;
@ -92,18 +90,20 @@ public class HostPageServlet extends HttpServlet {
private volatile Page page;
@Inject
HostPageServlet(final Provider<CurrentUser> cu, final DynamicItem<WebSession> w,
final SitePaths sp, final ThemeFactory themeFactory,
final GerritConfig gc, final ServletContext servletContext,
final DynamicSet<WebUiPlugin> webUiPlugins,
final DynamicSet<MessageOfTheDay> motd,
@GerritServerConfig final Config cfg,
final StaticServlet ss,
final NotesMigration migration)
HostPageServlet(
Provider<CurrentUser> cu,
DynamicItem<WebSession> w,
SitePaths sp,
ThemeFactory themeFactory,
ServletContext servletContext,
DynamicSet<WebUiPlugin> webUiPlugins,
DynamicSet<MessageOfTheDay> motd,
@GerritServerConfig Config cfg,
StaticServlet ss,
NotesMigration migration)
throws IOException, ServletException {
currentUser = cu;
session = w;
config = gc;
plugins = webUiPlugins;
messages = motd;
signedOutTheme = themeFactory.getSignedOutTheme();
@ -323,7 +323,6 @@ public class HostPageServlet extends HttpServlet {
final HostPageData pageData = new HostPageData();
pageData.version = Version.getVersion();
pageData.config = config;
pageData.isNoteDbEnabled = isNoteDbEnabled;
pageData.pluginsLoadTimeout = pluginsLoadTimeout;

View File

@ -16,7 +16,6 @@ package com.google.gerrit.httpd.rpc;
import com.google.common.collect.Lists;
import com.google.gerrit.common.data.ContributorAgreement;
import com.google.gerrit.common.data.GerritConfig;
import com.google.gerrit.common.data.SshHostKey;
import com.google.gerrit.common.data.SystemInfoService;
import com.google.gerrit.server.project.ProjectCache;
@ -46,16 +45,14 @@ class SystemInfoServiceImpl implements SystemInfoService {
private final List<HostKey> hostKeys;
private final Provider<HttpServletRequest> httpRequest;
private final Provider<GerritConfig> config;
private final ProjectCache projectCache;
@Inject
SystemInfoServiceImpl(final SshInfo daemon,
final Provider<HttpServletRequest> hsr, final Provider<GerritConfig> cfg,
final ProjectCache pc) {
SystemInfoServiceImpl(SshInfo daemon,
Provider<HttpServletRequest> hsr,
ProjectCache pc) {
hostKeys = daemon.getHostKeys();
httpRequest = hsr;
config = cfg;
projectCache = pc;
}
@ -95,9 +92,4 @@ class SystemInfoServiceImpl implements SystemInfoService {
log.error("Client UI JavaScript error: User-Agent=" + ua + ": " + message);
callback.onSuccess(VoidResult.INSTANCE);
}
@Override
public void gerritConfig(final AsyncCallback<GerritConfig> callback) {
callback.onSuccess(config.get());
}
}

View File

@ -14,8 +14,10 @@
package com.google.gerrit.server.change;
import com.google.common.base.Predicate;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.BinaryResult;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
@ -55,7 +57,17 @@ public class GetArchive implements RestReadView<RevisionResource> {
exts.put(format.name().toLowerCase(), format);
}
extensions = ImmutableMap.copyOf(exts);
allowed = cfg.getArchiveFormats();
// Zip is not supported because it may be interpreted by a Java plugin as a
// valid JAR file, whose code would have access to cookies on the domain.
allowed = Sets.filter(
cfg.getArchiveFormats(),
new Predicate<ArchiveFormat>() {
@Override
public boolean apply(ArchiveFormat format) {
return (format != ArchiveFormat.ZIP);
}
});
}
public Set<ArchiveFormat> getAllowed() {

View File

@ -20,6 +20,7 @@ import com.google.inject.Provider;
import org.eclipse.jgit.lib.Config;
public class AnonymousCowardNameProvider implements Provider<String> {
public static final String DEFAULT = "Anonymous Coward";
private final String anonymousCoward;
@ -27,7 +28,7 @@ public class AnonymousCowardNameProvider implements Provider<String> {
public AnonymousCowardNameProvider(@GerritServerConfig final Config cfg) {
String anonymousCoward = cfg.getString("user", null, "anonymousCoward");
if (anonymousCoward == null) {
anonymousCoward = "Anonymous Coward";
anonymousCoward = DEFAULT;
}
this.anonymousCoward = anonymousCoward;
}

View File

@ -40,13 +40,19 @@ public class AuthConfig {
private final String httpEmailHeader;
private final String httpExternalIdHeader;
private final String registerPageUrl;
private final String registerUrl;
private final String registerText;
private final boolean trustContainerAuth;
private final boolean enableRunAs;
private final boolean userNameToLowerCase;
private final boolean gitBasicAuth;
private final boolean useContributorAgreements;
private final String loginUrl;
private final String loginText;
private final String logoutUrl;
private final String switchAccountUrl;
private final String editFullNameUrl;
private final String httpPasswordUrl;
private final String openIdSsoUrl;
private final List<String> openIdDomains;
private final List<OpenIdProviderPattern> trustedOpenIDs;
@ -65,8 +71,14 @@ public class AuthConfig {
httpEmailHeader = cfg.getString("auth", null, "httpemailheader");
httpExternalIdHeader = cfg.getString("auth", null, "httpexternalidheader");
loginUrl = cfg.getString("auth", null, "loginurl");
loginText = cfg.getString("auth", null, "logintext");
logoutUrl = cfg.getString("auth", null, "logouturl");
switchAccountUrl = cfg.getString("auth", null, "switchAccountUrl");
editFullNameUrl = cfg.getString("auth", null, "editFullNameUrl");
httpPasswordUrl = cfg.getString("auth", null, "httpPasswordUrl");
registerPageUrl = cfg.getString("auth", null, "registerPageUrl");
registerUrl = cfg.getString("auth", null, "registerUrl");
registerText = cfg.getString("auth", null, "registerText");
openIdSsoUrl = cfg.getString("auth", null, "openidssourl");
openIdDomains = Arrays.asList(cfg.getStringList("auth", null, "openIdDomain"));
trustedOpenIDs = toPatterns(cfg, "trustedOpenID");
@ -144,10 +156,26 @@ public class AuthConfig {
return loginUrl;
}
public String getLoginText() {
return loginText;
}
public String getLogoutURL() {
return logoutUrl;
}
public String getSwitchAccountUrl() {
return switchAccountUrl;
}
public String getEditFullNameUrl() {
return editFullNameUrl;
}
public String getHttpPasswordUrl() {
return httpPasswordUrl;
}
public String getOpenIdSsoUrl() {
return openIdSsoUrl;
}
@ -271,6 +299,14 @@ public class AuthConfig {
return registerPageUrl;
}
public String getRegisterUrl() {
return registerUrl;
}
public String getRegisterText() {
return registerText;
}
public boolean isLdapAuthType() {
return authType == AuthType.LDAP ||
authType == AuthType.LDAP_BIND;

View File

@ -20,6 +20,7 @@ import com.google.common.cache.Cache;
import com.google.gerrit.audit.AuditModule;
import com.google.gerrit.common.EventListener;
import com.google.gerrit.extensions.config.CapabilityDefinition;
import com.google.gerrit.extensions.config.CloneCommand;
import com.google.gerrit.extensions.config.DownloadCommand;
import com.google.gerrit.extensions.config.DownloadScheme;
import com.google.gerrit.extensions.config.ExternalIncludedIn;
@ -215,6 +216,7 @@ public class GerritGlobalModule extends FactoryModule {
bind(ToolsCatalog.class);
bind(EventFactory.class);
bind(TransferConfig.class);
bind(GitWebConfig.class);
bind(GcConfig.class);
@ -275,6 +277,7 @@ public class GerritGlobalModule extends FactoryModule {
DynamicSet.setOf(binder(), MessageOfTheDay.class);
DynamicMap.mapOf(binder(), DownloadScheme.class);
DynamicMap.mapOf(binder(), DownloadCommand.class);
DynamicMap.mapOf(binder(), CloneCommand.class);
DynamicMap.mapOf(binder(), ExternalIncludedIn.class);
DynamicMap.mapOf(binder(), ProjectConfigEntry.class);
DynamicSet.setOf(binder(), PatchSetWebLink.class);

View File

@ -15,7 +15,11 @@
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;
import com.google.gerrit.extensions.config.CloneCommand;
import com.google.gerrit.extensions.config.DownloadCommand;
import com.google.gerrit.extensions.config.DownloadScheme;
import com.google.gerrit.extensions.registration.DynamicMap;
@ -24,6 +28,7 @@ import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AuthType;
import com.google.gerrit.server.account.Realm;
import com.google.gerrit.server.change.ArchiveFormat;
import com.google.gerrit.server.change.GetArchive;
import com.google.inject.Inject;
import org.eclipse.jgit.lib.Config;
@ -32,47 +37,116 @@ import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.TimeUnit;
public class GetServerInfo implements RestReadView<ConfigResource> {
private final Config config;
private final AuthConfig authConfig;
private final Realm realm;
private final DownloadConfig downloadConfig;
private final DynamicMap<DownloadScheme> downloadSchemes;
private final DynamicMap<DownloadCommand> downloadCommands;
private final DynamicMap<CloneCommand> cloneCommands;
private final GetArchive.AllowedFormats archiveFormats;
private final AllProjectsName allProjectsName;
private final AllUsersName allUsersName;
private final String anonymousCowardName;
private final GitWebConfig gitWebConfig;
@Inject
public GetServerInfo(
@GerritServerConfig Config config,
AuthConfig authConfig,
Realm realm,
DownloadConfig downloadConfig,
DynamicMap<DownloadScheme> downloadSchemes,
DynamicMap<DownloadCommand> downloadCommands,
DynamicMap<CloneCommand> cloneCommands,
GetArchive.AllowedFormats archiveFormats,
AllProjectsName allProjectsName,
AllUsersName allUsersName) {
AllUsersName allUsersName,
@AnonymousCowardName String anonymousCowardName,
GitWebConfig gitWebConfig) {
this.config = config;
this.authConfig = authConfig;
this.realm = realm;
this.downloadConfig = downloadConfig;
this.downloadSchemes = downloadSchemes;
this.downloadCommands = downloadCommands;
this.cloneCommands = cloneCommands;
this.archiveFormats = archiveFormats;
this.allProjectsName = allProjectsName;
this.allUsersName = allUsersName;
this.anonymousCowardName = anonymousCowardName;
this.gitWebConfig = gitWebConfig;
}
@Override
public ServerInfo apply(ConfigResource rsrc) throws MalformedURLException {
ServerInfo info = new ServerInfo();
info.auth = new AuthInfo(authConfig, realm);
info.auth = getAuthInfo(authConfig, realm);
info.change = getChangeInfo(config);
info.contactStore = getContactStoreInfo();
info.download =
new DownloadInfo(downloadConfig, downloadSchemes, downloadCommands);
info.gerrit = new GerritInfo(allProjectsName, allUsersName);
getDownloadInfo(downloadSchemes, downloadCommands, cloneCommands,
archiveFormats);
info.gerrit = getGerritInfo(config, allProjectsName, allUsersName);
info.gitWeb = getGitWebInfo(gitWebConfig);
info.sshd = getSshdInfo(config);
info.suggest = getSuggestInfo(config);
info.user = getUserInfo(anonymousCowardName);
return info;
}
private AuthInfo getAuthInfo(AuthConfig cfg, Realm realm) {
AuthInfo info = new AuthInfo();
info.authType = cfg.getAuthType();
info.useContributorAgreements = toBoolean(cfg.isUseContributorAgreements());
info.editableAccountFields = new ArrayList<>(realm.getEditableFields());
info.switchAccountUrl = cfg.getSwitchAccountUrl();
switch (info.authType) {
case LDAP:
case LDAP_BIND:
info.registerUrl = cfg.getRegisterUrl();
info.registerText = cfg.getRegisterText();
info.editFullNameUrl = cfg.getEditFullNameUrl();
info.isGitBasicAuth = toBoolean(cfg.isGitBasicAuth());
break;
case CUSTOM_EXTENSION:
info.registerUrl = cfg.getRegisterUrl();
info.registerText = cfg.getRegisterText();
info.editFullNameUrl = cfg.getEditFullNameUrl();
info.httpPasswordUrl = cfg.getHttpPasswordUrl();
break;
case HTTP:
case HTTP_LDAP:
info.loginUrl = cfg.getLoginUrl();
info.loginText = cfg.getLoginText();
break;
case CLIENT_SSL_CERT_LDAP:
case DEVELOPMENT_BECOME_ANY_ACCOUNT:
case OAUTH:
case OPENID:
case OPENID_SSO:
break;
}
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;
}
@ -87,27 +161,145 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
return contactStore;
}
private DownloadInfo getDownloadInfo(
DynamicMap<DownloadScheme> downloadSchemes,
DynamicMap<DownloadCommand> downloadCommands,
DynamicMap<CloneCommand> cloneCommands,
GetArchive.AllowedFormats archiveFormats) {
DownloadInfo info = new DownloadInfo();
info.schemes = new HashMap<>();
for (DynamicMap.Entry<DownloadScheme> e : downloadSchemes) {
DownloadScheme scheme = e.getProvider().get();
if (scheme.isEnabled() && scheme.getUrl("${project}") != null) {
info.schemes.put(e.getExportName(),
getDownloadSchemeInfo(scheme, downloadCommands, cloneCommands));
}
}
info.archives = Lists.newArrayList(Iterables.transform(
archiveFormats.getAllowed(),
new Function<ArchiveFormat, String>() {
@Override
public String apply(ArchiveFormat in) {
return in.getShortName();
}
}));
return info;
}
private DownloadSchemeInfo getDownloadSchemeInfo(DownloadScheme scheme,
DynamicMap<DownloadCommand> downloadCommands,
DynamicMap<CloneCommand> cloneCommands) {
DownloadSchemeInfo info = new DownloadSchemeInfo();
info.url = scheme.getUrl("${project}");
info.isAuthRequired = toBoolean(scheme.isAuthRequired());
info.isAuthSupported = toBoolean(scheme.isAuthSupported());
info.commands = new HashMap<>();
for (DynamicMap.Entry<DownloadCommand> e : downloadCommands) {
String commandName = e.getExportName();
DownloadCommand command = e.getProvider().get();
String c = command.getCommand(scheme, "${project}", "${ref}");
if (c != null) {
info.commands.put(commandName, c);
}
}
info.cloneCommands = new HashMap<>();
for (DynamicMap.Entry<CloneCommand> e : cloneCommands) {
String commandName = e.getExportName();
CloneCommand command = e.getProvider().get();
String c = command.getCommand(scheme, "${project}");
if (c != null) {
info.cloneCommands.put(commandName, c);
}
}
return info;
}
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) {
if (cfg.getUrl() == null || cfg.getGitWebType() == null) {
return null;
}
GitWebInfo info = new GitWebInfo();
info.url = cfg.getUrl();
info.type = cfg.getGitWebType();
return info;
}
private SshdInfo getSshdInfo(Config cfg) {
String[] addr = cfg.getStringList("sshd", null, "listenAddress");
if (addr.length == 1 && isOff(addr[0])) {
return null;
}
return new SshdInfo();
}
private static boolean isOff(String listenHostname) {
return "off".equalsIgnoreCase(listenHostname)
|| "none".equalsIgnoreCase(listenHostname)
|| "no".equalsIgnoreCase(listenHostname);
}
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) {
return v ? v : null;
}
public static class ServerInfo {
public AuthInfo auth;
public ChangeConfigInfo change;
public ContactStoreInfo contactStore;
public DownloadInfo download;
public GerritInfo gerrit;
public GitWebInfo gitWeb;
public SshdInfo sshd;
public SuggestInfo suggest;
public UserConfigInfo user;
}
public static class AuthInfo {
public AuthType authType;
public Boolean useContributorAgreements;
public List<Account.FieldName> editableAccountFields;
public String loginUrl;
public String loginText;
public String switchAccountUrl;
public String registerUrl;
public String registerText;
public String editFullNameUrl;
public String httpPasswordUrl;
public Boolean isGitBasicAuth;
}
public AuthInfo(AuthConfig cfg, Realm realm) {
authType = cfg.getAuthType();
useContributorAgreements = toBoolean(cfg.isUseContributorAgreements());
editableAccountFields = new ArrayList<>(realm.getEditableFields());
}
public static class ChangeConfigInfo {
public Boolean allowDrafts;
public int largeChange;
public String replyLabel;
public String replyTooltip;
public int updateDelay;
}
public static class ContactStoreInfo {
@ -117,27 +309,6 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
public static class DownloadInfo {
public Map<String, DownloadSchemeInfo> schemes;
public List<String> archives;
public DownloadInfo(DownloadConfig downloadConfig,
DynamicMap<DownloadScheme> downloadSchemes,
DynamicMap<DownloadCommand> downloadCommands) {
schemes = new HashMap<>();
for (DynamicMap.Entry<DownloadScheme> e : downloadSchemes) {
DownloadScheme scheme = e.getProvider().get();
if (scheme.isEnabled() && scheme.getUrl("${project}") != null) {
schemes.put(e.getExportName(),
new DownloadSchemeInfo(scheme, downloadCommands));
}
}
archives =
Lists.transform(new ArrayList<>(downloadConfig.getArchiveFormats()),
new Function<ArchiveFormat, String>() {
@Override
public String apply(ArchiveFormat archiveFormat) {
return archiveFormat.name().toLowerCase(Locale.US);
}
});
}
}
public static class DownloadSchemeInfo {
@ -145,32 +316,29 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
public Boolean isAuthRequired;
public Boolean isAuthSupported;
public Map<String, String> commands;
public DownloadSchemeInfo(DownloadScheme scheme,
DynamicMap<DownloadCommand> downloadCommands) {
url = scheme.getUrl("${project}");
isAuthRequired = toBoolean(scheme.isAuthRequired());
isAuthSupported = toBoolean(scheme.isAuthSupported());
commands = new HashMap<>();
for (DynamicMap.Entry<DownloadCommand> e : downloadCommands) {
String commandName = e.getExportName();
DownloadCommand command = e.getProvider().get();
String c = command.getCommand(scheme, "${project}", "${ref}");
if (c != null) {
commands.put(commandName, c);
}
}
}
public Map<String, String> cloneCommands;
}
public static class GerritInfo {
public String allProjects;
public String allUsers;
public String reportBugUrl;
public String reportBugText;
}
public GerritInfo(AllProjectsName allProjectsName, AllUsersName allUsersName) {
allProjects = allProjectsName.get();
allUsers = allUsersName.get();
}
public static class GitWebInfo {
public String url;
public GitWebType type;
}
public static class SshdInfo {
}
public static class SuggestInfo {
public int from;
}
public static class UserConfigInfo {
public String anonymousCowardName;
}
}

View File

@ -12,14 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.httpd;
package com.google.gerrit.server.config;
import static java.nio.file.Files.isExecutable;
import static java.nio.file.Files.isRegularFile;
import com.google.gerrit.common.data.GitWebType;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.config.SitePaths;
import com.google.inject.Inject;
import org.eclipse.jgit.lib.Config;

View File

@ -12,7 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.httpd;
package com.google.gerrit.server.config;
import com.google.gerrit.server.config.GitWebConfig;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

@ -1 +1 @@
Subproject commit 1cf69212a7489e88d8c73377f0f77f8a5965db75
Subproject commit c0f1b84e494c8bab73f4786642dc768ae60468d9