Search in sources :

Example 1 with DownloadSchemeInfo

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

the class GetServerInfo method getDownloadSchemeInfo.

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-path}/${project-base-name}");
        if (c != null) {
            c = c.replaceAll("\\$\\{project-path\\}/\\$\\{project-base-name\\}", "\\$\\{project\\}");
            info.cloneCommands.put(commandName, c);
        }
    }
    return info;
}
Also used : CloneCommand(com.google.gerrit.extensions.config.CloneCommand) DynamicMap(com.google.gerrit.extensions.registration.DynamicMap) DownloadCommand(com.google.gerrit.extensions.config.DownloadCommand) DownloadSchemeInfo(com.google.gerrit.extensions.common.DownloadSchemeInfo)

Example 2 with DownloadSchemeInfo

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

the class GetServerInfo method getDownloadSchemeInfo.

private DownloadSchemeInfo getDownloadSchemeInfo(DownloadScheme scheme) {
    DownloadSchemeInfo info = new DownloadSchemeInfo();
    info.url = scheme.getUrl("${project}");
    info.isAuthRequired = toBoolean(scheme.isAuthRequired());
    info.isAuthSupported = toBoolean(scheme.isAuthSupported());
    info.commands = new HashMap<>();
    downloadCommands.runEach(extension -> {
        String commandName = extension.getExportName();
        DownloadCommand command = extension.get();
        String c = command.getCommand(scheme, "${project}", "${ref}");
        if (c != null) {
            info.commands.put(commandName, c);
        }
    });
    info.cloneCommands = new HashMap<>();
    cloneCommands.runEach(extension -> {
        String commandName = extension.getExportName();
        CloneCommand command = extension.getProvider().get();
        String c = command.getCommand(scheme, "${project-path}/${project-base-name}");
        if (c != null) {
            c = c.replaceAll("\\$\\{project-path\\}/\\$\\{project-base-name\\}", "\\$\\{project\\}");
            info.cloneCommands.put(commandName, c);
        }
    });
    return info;
}
Also used : CloneCommand(com.google.gerrit.extensions.config.CloneCommand) DownloadCommand(com.google.gerrit.extensions.config.DownloadCommand) DownloadSchemeInfo(com.google.gerrit.extensions.common.DownloadSchemeInfo)

Aggregations

DownloadSchemeInfo (com.google.gerrit.extensions.common.DownloadSchemeInfo)2 CloneCommand (com.google.gerrit.extensions.config.CloneCommand)2 DownloadCommand (com.google.gerrit.extensions.config.DownloadCommand)2 DynamicMap (com.google.gerrit.extensions.registration.DynamicMap)1