Search in sources :

Example 1 with FetchInfo

use of com.google.gerrit.extensions.common.FetchInfo 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;
}
Also used : DynamicMap(com.google.gerrit.extensions.registration.DynamicMap) FetchInfo(com.google.gerrit.extensions.common.FetchInfo) DownloadScheme(com.google.gerrit.extensions.config.DownloadScheme) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with FetchInfo

use of com.google.gerrit.extensions.common.FetchInfo in project gerrit by GerritCodeReview.

the class ChangeEditJson method fillFetchMap.

private Map<String, FetchInfo> fillFetchMap(ChangeEdit edit) {
    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;
        }
        // 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);
        ChangeJson.populateFetchMap(scheme, downloadCommands, projectName, refName, fetchInfo);
    }
    return r;
}
Also used : DynamicMap(com.google.gerrit.extensions.registration.DynamicMap) FetchInfo(com.google.gerrit.extensions.common.FetchInfo) DownloadScheme(com.google.gerrit.extensions.config.DownloadScheme) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

FetchInfo (com.google.gerrit.extensions.common.FetchInfo)2 DownloadScheme (com.google.gerrit.extensions.config.DownloadScheme)2 DynamicMap (com.google.gerrit.extensions.registration.DynamicMap)2 LinkedHashMap (java.util.LinkedHashMap)2