GET /config/server/info: Return download schemes as map

This is the format that is needed on client-side.

Change-Id: I19314e99f4c44cdd49c20a7d1a722d7b83cd0c1e
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
diff --git a/Documentation/rest-api-config.txt b/Documentation/rest-api-config.txt
index 0b8e2f8..4a33732 100644
--- a/Documentation/rest-api-config.txt
+++ b/Documentation/rest-api-config.txt
@@ -61,20 +61,16 @@
     },
     "download": {
       "schemes": [
-        {
-          "name": "ssh",
-          "url": "ssh://jdoe@gerrithost:29418/${project}",
-          "is_auth_required": true,
-          "is_auth_supported": true,
+        "anonymous http": {
+          "url": "http://gerrithost:8080/${project}",
           "commands": {
-            "Checkout": "git fetch ssh://jdoe@gerrithost:29418/${project} ${ref} \u0026\u0026 git checkout FETCH_HEAD",
-            "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"
+            "Checkout": "git fetch http://gerrithost:8080/${project} ${ref} \u0026\u0026 git checkout FETCH_HEAD",
+            "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"
           }
         },
-        {
-          "name": "http",
+        "http": {
           "url": "http://jdoe@gerrithost:8080/${project}",
           "is_auth_required": true,
           "is_auth_supported": true,
@@ -85,14 +81,15 @@
             "Cherry Pick": "git fetch http://jdoe@gerrithost:8080/${project} ${ref} \u0026\u0026 git cherry-pick FETCH_HEAD"
           }
         },
-        {
-          "name": "anonymous http",
-          "url": "http://gerrithost:8080/${project}",
+        "ssh": {
+          "url": "ssh://jdoe@gerrithost:29418/${project}",
+          "is_auth_required": true,
+          "is_auth_supported": true,
           "commands": {
-            "Checkout": "git fetch http://gerrithost:8080/${project} ${ref} \u0026\u0026 git checkout FETCH_HEAD",
-            "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"
+            "Checkout": "git fetch ssh://jdoe@gerrithost:29418/${project} ${ref} \u0026\u0026 git checkout FETCH_HEAD",
+            "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"
           }
         }
       ],
@@ -1001,8 +998,8 @@
 |=======================
 |Field Name |Description
 |`schemes`  |
-The supported download schemes as list of link:#download-scheme-info[
-DownloadSchemeInfo] entities.
+The supported download schemes as a map which maps the scheme name to a
+of link:#download-scheme-info[DownloadSchemeInfo] entity.
 |`archives` |
 List of supported archive formats. Possible values are `TGZ`, `TAR`,
 `TBZ2` and `TXZ`.
@@ -1016,8 +1013,6 @@
 [options="header",cols="1,^1,5"]
 |=================================
 |Field Name          ||Description
-|`name`              ||
-The name of the download scheme.
 |`url`               ||
 The URL of the download scheme, where '${project}' is used as
 placeholder for the project name.
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/config/GetServerInfo.java b/gerrit-server/src/main/java/com/google/gerrit/server/config/GetServerInfo.java
index 52bf7a5..b619efc 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/config/GetServerInfo.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/config/GetServerInfo.java
@@ -112,18 +112,18 @@
   }
 
   public static class DownloadInfo {
-    public List<DownloadSchemeInfo> schemes;
+    public Map<String, DownloadSchemeInfo> schemes;
     public List<ArchiveFormat> archives;
 
     public DownloadInfo(DownloadConfig downloadConfig,
         DynamicMap<DownloadScheme> downloadSchemes,
         DynamicMap<DownloadCommand> downloadCommands) {
-      schemes = new ArrayList<>();
+      schemes = new HashMap<>();
       for (DynamicMap.Entry<DownloadScheme> e : downloadSchemes) {
         DownloadScheme scheme = e.getProvider().get();
         if (scheme.isEnabled()) {
-          schemes.add(
-              new DownloadSchemeInfo(e.getExportName(), scheme, downloadCommands));
+          schemes.put(e.getExportName(),
+              new DownloadSchemeInfo(scheme, downloadCommands));
         }
       }
       archives = new ArrayList<>(downloadConfig.getArchiveFormats());
@@ -131,15 +131,13 @@
   }
 
   public static class DownloadSchemeInfo {
-    public String name;
     public String url;
     public Boolean isAuthRequired;
     public Boolean isAuthSupported;
     public Map<String, String> commands;
 
-    public DownloadSchemeInfo(String schemeName, DownloadScheme scheme,
+    public DownloadSchemeInfo(DownloadScheme scheme,
         DynamicMap<DownloadCommand> downloadCommands) {
-      name = schemeName;
       url = scheme.getUrl("${project}");
       isAuthRequired = toBoolean(scheme.isAuthRequired());
       isAuthSupported = toBoolean(scheme.isAuthSupported());