GetServerInfo: Return archive format names as lower case

Clients can make use of the the archive format names returned by the
GetServerInfo REST endpoint to retrieve the archive in a specific
format by using the GetArchive REST endpoint. The GetArchive REST
endpoint requires the archive format in lower case. Hence the
GetServerInfo REST endpoint should return the archive format names in
lower case, so that clients don't need convert the archive format
names to lower case on their own.

Change-Id: Idce4473f0ce7bdec744b9f60116f1bbd01f76bcd
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2015-05-20 09:20:30 +02:00
parent 0ec1e17477
commit f5c887912c
2 changed files with 18 additions and 8 deletions

View File

@@ -94,10 +94,10 @@ As result a link:#server-info[ServerInfo] entity is returned.
}
],
"archives": [
"TGZ",
"TAR",
"TBZ2",
"TXZ"
"tgz",
"tar",
"tbz2",
"txz"
]
},
"gerrit": {
@@ -1001,8 +1001,8 @@ options.
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`.
List of supported archive formats. Possible values are `tgz`, `tar`,
`tbz2` and `txz`.
|=======================
[[download-scheme-info]]

View File

@@ -14,6 +14,8 @@
package com.google.gerrit.server.config;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.config.DownloadCommand;
import com.google.gerrit.extensions.config.DownloadScheme;
import com.google.gerrit.extensions.registration.DynamicMap;
@@ -30,6 +32,7 @@ import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
public class GetServerInfo implements RestReadView<ConfigResource> {
@@ -113,7 +116,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
public static class DownloadInfo {
public Map<String, DownloadSchemeInfo> schemes;
public List<ArchiveFormat> archives;
public List<String> archives;
public DownloadInfo(DownloadConfig downloadConfig,
DynamicMap<DownloadScheme> downloadSchemes,
@@ -126,7 +129,14 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
new DownloadSchemeInfo(scheme, downloadCommands));
}
}
archives = new ArrayList<>(downloadConfig.getArchiveFormats());
archives =
Lists.transform(new ArrayList<>(downloadConfig.getArchiveFormats()),
new Function<ArchiveFormat, String>() {
@Override
public String apply(ArchiveFormat archiveFormat) {
return archiveFormat.name().toLowerCase(Locale.US);
}
});
}
}