<commit_before>package nu.studer.teamcity.buildscan.connection;

import jetbrains.buildServer.serverSide.InvalidProperty;
import jetbrains.buildServer.serverSide.PropertiesProcessor;
import jetbrains.buildServer.serverSide.oauth.OAuthConnectionDescriptor;
import jetbrains.buildServer.serverSide.oauth.OAuthProvider;
import jetbrains.buildServer.web.openapi.PluginDescriptor;
import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import static nu.studer.teamcity.buildscan.connection.GradleEnterpriseConnectionConstants.ALLOW_UNTRUSTED_SERVER;
import static nu.studer.teamcity.buildscan.connection.GradleEnterpriseConnectionConstants.COMMON_CUSTOM_USER_DATA_EXTENSION_VERSION;
import static nu.studer.teamcity.buildscan.connection.GradleEnterpriseConnectionConstants.COMMON_CUSTOM_USER_DATA_PLUGIN_VERSION;
import static nu.studer.teamcity.buildscan.connection.GradleEnterpriseConnectionConstants.GRADLE_ENTERPRISE_CONNECTION_PROVIDER;
import static nu.studer.teamcity.buildscan.connection.GradleEnterpriseConnectionConstants.GRADLE_ENTERPRISE_EXTENSION_VERSION;
import static nu.studer.teamcity.buildscan.connection.GradleEnterpriseConnectionConstants.GRADLE_ENTERPRISE_PLUGIN_VERSION;
import static nu.studer.teamcity.buildscan.connection.GradleEnterpriseConnectionConstants.GRADLE_ENTERPRISE_URL;
import static nu.studer.teamcity.buildscan.connection.GradleEnterpriseConnectionConstants.GRADLE_PLUGIN_REPOSITORY_URL;
import static nu.studer.teamcity.buildscan.connection.GradleEnterpriseConnectionConstants.INSTRUMENT_COMMAND_LINE_BUILD_STEP;

public final class GradleEnterpriseConnectionProvider extends OAuthProvider {

    private static final Logger LOGGER = Logger.getLogger("jetbrains.buildServer.BUILDSCAN");

    private static final String DEFAULT_PLUGIN_VERSIONS_RESOURCE = "default-plugin-versions.properties";

    private static final PropertiesProcessor EMPTY_PROPERTIES_PROCESSOR = new EmptyPropertiesProcessor();

    private final PluginDescriptor descriptor;

    public GradleEnterpriseConnectionProvider(PluginDescriptor pluginDescriptor) {
        this.descriptor = pluginDescriptor;
    }

    @NotNull
    @Override
    public String getType() {
        return GRADLE_ENTERPRISE_CONNECTION_PROVIDER;
    }

    @NotNull
    @Override
    public String getDisplayName() {
        return "Gradle Enterprise";
    }

    @Nullable
    @Override
    public String getEditParametersUrl() {
        return descriptor.getPluginResourcesPath("geConnectionDialog.jsp");
    }

    @NotNull
    @Override
    public String describeConnection(@NotNull OAuthConnectionDescriptor connection) {
        Map<String, String> params = connection.getParameters();
        String description = "Gradle Enterprise Connection Settings:\n";

        String geUrl = params.get(GRADLE_ENTERPRISE_URL);
        if (geUrl != null) {
            description += String.format("* Gradle Enterprise Url: %s\n", geUrl);
        }

        String allowUntrustedServer = params.get(ALLOW_UNTRUSTED_SERVER);
        if (allowUntrustedServer != null) {
            description += String.format("* Allow Untrusted Server: %s\n", allowUntrustedServer);
        }

        description += "\nGradle Settings:\n";

        String gePluginVersion = params.get(GRADLE_ENTERPRISE_PLUGIN_VERSION);
        if (gePluginVersion != null) {
            description += String.format("* Gradle Enterprise Plugin Version: %s\n", gePluginVersion);
        }

        String ccudPluginVersion = params.get(COMMON_CUSTOM_USER_DATA_PLUGIN_VERSION);
        if (ccudPluginVersion != null) {
            description += String.format("* Common Custom User Data Plugin Version: %s\n", ccudPluginVersion);
        }

        String gradlePluginRepositoryUrl = params.get(GRADLE_PLUGIN_REPOSITORY_URL);
        if (gradlePluginRepositoryUrl != null) {
            description += String.format("* Gradle Plugin Repository URL: %s\n", gradlePluginRepositoryUrl);
        }

        description += "\nMaven Settings\n";

        String geExtensionVersion = params.get(GRADLE_ENTERPRISE_EXTENSION_VERSION);
        if (geExtensionVersion != null) {
            description += String.format("* Gradle Enterprise Extension Version: %s\n", geExtensionVersion);
        }

        String ccudExtensionVersion = params.get(COMMON_CUSTOM_USER_DATA_EXTENSION_VERSION);
        if (ccudExtensionVersion != null) {
            description += String.format("* Common Custom User Data Extension Version: %s\n", ccudExtensionVersion);
        }

        description += "\nCommand Line Settings\n";
        String instrumentCommandLineBuildStep = params.get(INSTRUMENT_COMMAND_LINE_BUILD_STEP);
        if (instrumentCommandLineBuildStep != null) {
            description += String.format("* Instrument Command Line Build Step: %s\n", instrumentCommandLineBuildStep);
        }

        return description;
    }

    @Nullable
    @Override
    public Map<String, String> getDefaultProperties() {
        InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(DEFAULT_PLUGIN_VERSIONS_RESOURCE);<commit_msg>Polish connection description a bit<commit_after>package nu.studer.teamcity.buildscan.connection;

import jetbrains.buildServer.serverSide.InvalidProperty;
import jetbrains.buildServer.serverSide.PropertiesProcessor;
import jetbrains.buildServer.serverSide.oauth.OAuthConnectionDescriptor;
import jetbrains.buildServer.serverSide.oauth.OAuthProvider;
import jetbrains.buildServer.web.openapi.PluginDescriptor;
import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import static nu.studer.teamcity.buildscan.connection.GradleEnterpriseConnectionConstants.ALLOW_UNTRUSTED_SERVER;
import static nu.studer.teamcity.buildscan.connection.GradleEnterpriseConnectionConstants.COMMON_CUSTOM_USER_DATA_EXTENSION_VERSION;
import static nu.studer.teamcity.buildscan.connection.GradleEnterpriseConnectionConstants.COMMON_CUSTOM_USER_DATA_PLUGIN_VERSION;
import static nu.studer.teamcity.buildscan.connection.GradleEnterpriseConnectionConstants.GRADLE_ENTERPRISE_CONNECTION_PROVIDER;
import static nu.studer.teamcity.buildscan.connection.GradleEnterpriseConnectionConstants.GRADLE_ENTERPRISE_EXTENSION_VERSION;
import static nu.studer.teamcity.buildscan.connection.GradleEnterpriseConnectionConstants.GRADLE_ENTERPRISE_PLUGIN_VERSION;
import static nu.studer.teamcity.buildscan.connection.GradleEnterpriseConnectionConstants.GRADLE_ENTERPRISE_URL;
import static nu.studer.teamcity.buildscan.connection.GradleEnterpriseConnectionConstants.GRADLE_PLUGIN_REPOSITORY_URL;
import static nu.studer.teamcity.buildscan.connection.GradleEnterpriseConnectionConstants.INSTRUMENT_COMMAND_LINE_BUILD_STEP;

public final class GradleEnterpriseConnectionProvider extends OAuthProvider {

    private static final Logger LOGGER = Logger.getLogger("jetbrains.buildServer.BUILDSCAN");

    private static final String DEFAULT_PLUGIN_VERSIONS_RESOURCE = "default-plugin-versions.properties";

    private static final PropertiesProcessor EMPTY_PROPERTIES_PROCESSOR = new EmptyPropertiesProcessor();

    private final PluginDescriptor descriptor;

    public GradleEnterpriseConnectionProvider(PluginDescriptor pluginDescriptor) {
        this.descriptor = pluginDescriptor;
    }

    @NotNull
    @Override
    public String getType() {
        return GRADLE_ENTERPRISE_CONNECTION_PROVIDER;
    }

    @NotNull
    @Override
    public String getDisplayName() {
        return "Gradle Enterprise";
    }

    @Nullable
    @Override
    public String getEditParametersUrl() {
        return descriptor.getPluginResourcesPath("geConnectionDialog.jsp");
    }

    @NotNull
    @Override
    public String describeConnection(@NotNull OAuthConnectionDescriptor connection) {
        Map<String, String> params = connection.getParameters();

        String description = "Gradle Enterprise Connection Settings:\n";

        String geUrl = params.get(GRADLE_ENTERPRISE_URL);
        if (geUrl != null) {
            description += String.format("* Gradle Enterprise Server URL: %s\n", geUrl);
        }

        String allowUntrustedServer = params.get(ALLOW_UNTRUSTED_SERVER);
        if (allowUntrustedServer != null) {
            description += String.format("* Allow Untrusted Server: %s\n", allowUntrustedServer);
        }

        description += "\nGradle Settings:\n";

        String gePluginVersion = params.get(GRADLE_ENTERPRISE_PLUGIN_VERSION);
        if (gePluginVersion != null) {
            description += String.format("* Gradle Enterprise Gradle Plugin Version: %s\n", gePluginVersion);
        }

        String ccudPluginVersion = params.get(COMMON_CUSTOM_USER_DATA_PLUGIN_VERSION);
        if (ccudPluginVersion != null) {
            description += String.format("* Common Custom User Data Gradle Plugin Version: %s\n", ccudPluginVersion);
        }

        String gradlePluginRepositoryUrl = params.get(GRADLE_PLUGIN_REPOSITORY_URL);
        if (gradlePluginRepositoryUrl != null) {
            description += String.format("* Gradle Plugin Repository URL: %s\n", gradlePluginRepositoryUrl);
        }

        description += "\nMaven Settings:\n";

        String geExtensionVersion = params.get(GRADLE_ENTERPRISE_EXTENSION_VERSION);
        if (geExtensionVersion != null) {
            description += String.format("* Gradle Enterprise Maven Extension Version: %s\n", geExtensionVersion);
        }

        String ccudExtensionVersion = params.get(COMMON_CUSTOM_USER_DATA_EXTENSION_VERSION);
        if (ccudExtensionVersion != null) {
            description += String.format("* Common Custom User Data Maven Extension Version: %s\n", ccudExtensionVersion);
        }

        description += "\nTeamCity Build Steps Settings:\n";

        String instrumentCommandLineBuildStep = params.get(INSTRUMENT_COMMAND_LINE_BUILD_STEP);
        if (instrumentCommandLineBuildStep != null) {
            description += String.format("* Instrument Command Line Build Steps: %s\n", instrumentCommandLineBuildStep);
        }

        return description;
    }

    @Nullable
    @Override
    public Map<String, String> getDefaultProperties() {
        InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(DEFAULT_PLUGIN_VERSIONS_RESOURCE);
{'fraction_non_alphanumeric': 0.08209233060312733, 'fraction_numerical': 0.00018615040953090097, 'mean_word_length': 4.484941296579888, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3233539', 'n_tokens_mistral': 2954, 'n_tokens_neox': 2887, 'n_words': 545}