Search in sources :

Example 6 with GlobalProperties

use of org.sonarsource.sonarlint.core.proto.Sonarlint.GlobalProperties in project sonarlint-core by SonarSource.

the class GlobalSettingsUpdateChecker method checkForUpdates.

public void checkForUpdates(String serverVersion, DefaultStorageUpdateCheckResult result) {
    GlobalProperties serverGlobalProperties = globalPropertiesDownloader.fetchGlobalSettings(serverVersion);
    GlobalProperties storageGlobalProperties = storageReader.readGlobalProperties();
    MapDifference<String, String> propDiff = Maps.difference(filter(storageGlobalProperties.getPropertiesMap()), filter(serverGlobalProperties.getPropertiesMap()));
    if (!propDiff.areEqual()) {
        result.appendToChangelog("Global settings updated");
        for (Map.Entry<String, String> entry : propDiff.entriesOnlyOnLeft().entrySet()) {
            LOG.debug("Property '{}' removed", entry.getKey());
        }
        for (Map.Entry<String, String> entry : propDiff.entriesOnlyOnRight().entrySet()) {
            LOG.debug("Property '{}' added with value '{}'", entry.getKey(), formatValue(entry.getKey(), entry.getValue()));
        }
        for (Map.Entry<String, ValueDifference<String>> entry : propDiff.entriesDiffering().entrySet()) {
            LOG.debug("Value of property '{}' changed from '{}' to '{}'", entry.getKey(), formatLeftDiff(entry.getKey(), entry.getValue().leftValue(), entry.getValue().rightValue()), formatRightDiff(entry.getKey(), entry.getValue().leftValue(), entry.getValue().rightValue()));
        }
    }
}
Also used : GlobalProperties(org.sonarsource.sonarlint.core.proto.Sonarlint.GlobalProperties) ValueDifference(com.google.common.collect.MapDifference.ValueDifference) Map(java.util.Map)

Aggregations

GlobalProperties (org.sonarsource.sonarlint.core.proto.Sonarlint.GlobalProperties)6 Test (org.junit.Test)2 SonarLintWsClient (org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient)2 ModuleConfiguration (org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleConfiguration)2 ValueDifference (com.google.common.collect.MapDifference.ValueDifference)1 PipedInputStream (java.io.PipedInputStream)1 PipedOutputStream (java.io.PipedOutputStream)1 StringReader (java.io.StringReader)1 Collection (java.util.Collection)1 Map (java.util.Map)1 Set (java.util.Set)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 Type (org.sonar.api.batch.fs.InputFile.Type)1 ConfigurationBridge (org.sonar.api.config.internal.ConfigurationBridge)1 MapSettings (org.sonar.api.config.internal.MapSettings)1 ValuesWsResponse (org.sonarqube.ws.Settings.ValuesWsResponse)1 ExclusionFilters (org.sonarsource.sonarlint.core.container.analysis.ExclusionFilters)1