use of com.google.gerrit.extensions.config.DownloadScheme in project gerrit by GerritCodeReview.
the class GetServerInfo method getDownloadInfo.
private DownloadInfo getDownloadInfo(DynamicMap<DownloadScheme> downloadSchemes, DynamicMap<DownloadCommand> downloadCommands, DynamicMap<CloneCommand> cloneCommands, 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 = archiveFormats.getAllowed().stream().map(ArchiveFormat::getShortName).collect(toList());
return info;
}
use of com.google.gerrit.extensions.config.DownloadScheme in project gerrit by GerritCodeReview.
the class ChangeJson method makeFetchMap.
private Map<String, FetchInfo> makeFetchMap(ChangeControl ctl, PatchSet in) throws OrmException {
Map<String, FetchInfo> r = new LinkedHashMap<>();
for (DynamicMap.Entry<DownloadScheme> e : downloadSchemes) {
String schemeName = e.getExportName();
DownloadScheme scheme = e.getProvider().get();
if (!scheme.isEnabled() || (scheme.isAuthRequired() && !userProvider.get().isIdentifiedUser())) {
continue;
}
if (!scheme.isAuthSupported() && !ctl.forUser(anonymous).isPatchVisible(in, db.get())) {
continue;
}
String projectName = ctl.getProject().getNameKey().get();
String url = scheme.getUrl(projectName);
String refName = in.getRefName();
FetchInfo fetchInfo = new FetchInfo(url, refName);
r.put(schemeName, fetchInfo);
if (has(DOWNLOAD_COMMANDS)) {
populateFetchMap(scheme, downloadCommands, projectName, refName, fetchInfo);
}
}
return r;
}
use of com.google.gerrit.extensions.config.DownloadScheme in project gerrit by GerritCodeReview.
the class ChangeEditJson method fillFetchMap.
private Map<String, FetchInfo> fillFetchMap(ChangeEdit edit) {
Map<String, FetchInfo> r = new LinkedHashMap<>();
for (Extension<DownloadScheme> e : downloadSchemes) {
String schemeName = e.getExportName();
DownloadScheme scheme = e.getProvider().get();
if (!scheme.isEnabled() || (scheme.isAuthRequired() && !userProvider.get().isIdentifiedUser())) {
continue;
}
// No fluff, just stuff
if (!scheme.isAuthSupported()) {
continue;
}
String projectName = edit.getChange().getProject().get();
String refName = edit.getRefName();
FetchInfo fetchInfo = new FetchInfo(scheme.getUrl(projectName), refName);
r.put(schemeName, fetchInfo);
DownloadCommandsJson.populateFetchMap(scheme, downloadCommands, projectName, refName, fetchInfo);
}
return r;
}
use of com.google.gerrit.extensions.config.DownloadScheme in project gerrit by GerritCodeReview.
the class RevisionJson method makeFetchMap.
private Map<String, FetchInfo> makeFetchMap(ChangeData cd, PatchSet in) throws PermissionBackendException {
Map<String, FetchInfo> r = new LinkedHashMap<>();
for (Extension<DownloadScheme> e : downloadSchemes) {
String schemeName = e.getExportName();
DownloadScheme scheme = e.getProvider().get();
if (!scheme.isEnabled() || (scheme.isAuthRequired() && !userProvider.get().isIdentifiedUser())) {
continue;
}
if (!scheme.isAuthSupported() && !isWorldReadable(cd)) {
continue;
}
String projectName = cd.project().get();
String url = scheme.getUrl(projectName);
String refName = in.refName();
FetchInfo fetchInfo = new FetchInfo(url, refName);
r.put(schemeName, fetchInfo);
if (has(DOWNLOAD_COMMANDS)) {
DownloadCommandsJson.populateFetchMap(scheme, downloadCommands, projectName, refName, fetchInfo);
}
}
return r;
}
use of com.google.gerrit.extensions.config.DownloadScheme in project gerrit by GerritCodeReview.
the class GetServerInfo method getDownloadInfo.
private DownloadInfo getDownloadInfo() {
DownloadInfo info = new DownloadInfo();
info.schemes = new HashMap<>();
downloadSchemes.runEach(extension -> {
DownloadScheme scheme = extension.get();
if (scheme.isEnabled() && scheme.getUrl("${project}") != null) {
info.schemes.put(extension.getExportName(), getDownloadSchemeInfo(scheme));
}
});
info.archives = archiveFormats.getAllowed().stream().map(ArchiveFormatInternal::getShortName).collect(toList());
return info;
}
Aggregations