From 4b2d63b7bae5230ae15406f673efaa481e5e8e12 Mon Sep 17 00:00:00 2001 From: Philippe Charles Date: Fri, 4 Oct 2024 10:20:37 +0200 Subject: [PATCH] Fix sources file property in configuration --- CHANGELOG.md | 4 +++ .../plugin/web/SdmxWebConfiguration.java | 27 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5b8ee1..d78643b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Add logging of events +### Fixed + +- Fix sources file property in configuration + ### Changed - Bump sdmx-dl from 3.0.0-beta.12 to [3.0.0-beta.13](https://github.com/nbbrd/sdmx-dl/releases/tag/v3.0.0-beta.13) diff --git a/jdplus-sdmx-desktop/jdplus-sdmx-desktop-plugin/src/main/java/jdplus/sdmx/desktop/plugin/web/SdmxWebConfiguration.java b/jdplus-sdmx-desktop/jdplus-sdmx-desktop-plugin/src/main/java/jdplus/sdmx/desktop/plugin/web/SdmxWebConfiguration.java index 9066e88..c5119e5 100644 --- a/jdplus-sdmx-desktop/jdplus-sdmx-desktop-plugin/src/main/java/jdplus/sdmx/desktop/plugin/web/SdmxWebConfiguration.java +++ b/jdplus-sdmx-desktop/jdplus-sdmx-desktop-plugin/src/main/java/jdplus/sdmx/desktop/plugin/web/SdmxWebConfiguration.java @@ -12,17 +12,24 @@ import sdmxdl.Languages; import sdmxdl.web.SdmxWebManager; import sdmxdl.web.WebSource; +import standalone_sdmxdl.nbbrd.io.text.BooleanProperty; import standalone_sdmxdl.nbbrd.io.text.Parser; +import standalone_sdmxdl.nbbrd.io.text.Property; +import standalone_sdmxdl.sdmxdl.provider.PropertiesSupport; import standalone_sdmxdl.sdmxdl.provider.ri.caching.RiCaching; import standalone_sdmxdl.sdmxdl.provider.ri.networking.RiNetworking; +import standalone_sdmxdl.sdmxdl.provider.ri.registry.RiRegistry; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.File; import java.io.IOException; import java.util.Locale; import java.util.Properties; +import java.util.function.Function; import java.util.logging.Level; +import static java.util.Collections.emptyMap; + @lombok.extern.java.Log @lombok.Data public class SdmxWebConfiguration { @@ -81,12 +88,20 @@ public static SdmxWebConfiguration copyOf(SdmxWebConfiguration bean) { public SdmxWebManager toSdmxWebManager() { Properties properties = System.getProperties(); + if (sources != null && !sources.getPath().isEmpty()) { + properties.setProperty(RiRegistry.SOURCES_FILE_PROPERTY.getKey(), sources.getPath()); + } else { + properties.remove(RiRegistry.SOURCES_FILE_PROPERTY.getKey()); + } + curlBackend.applyTo(properties, RiNetworking.URL_BACKEND_PROPERTY, "JDK", "CURL"); noCache.applyTo(properties, RiCaching.NO_CACHE_PROPERTY); autoProxy.applyTo(properties, RiNetworking.AUTO_PROXY_PROPERTY); noDefaultSSL.applyTo(properties, RiNetworking.NO_DEFAULT_SSL_PROPERTY); noSystemSSL.applyTo(properties, RiNetworking.NO_SYSTEM_SSL_PROPERTY); + logConfig(); + return SdmxWebManager.ofServiceLoader() .toBuilder() .onEvent(this::reportEvent) @@ -94,6 +109,18 @@ public SdmxWebManager toSdmxWebManager() { .build(); } + private void logConfig() { + Function properties = key -> PropertiesSupport.getProperty(emptyMap(), key); + if (log.isLoggable(Level.INFO)) { + for (Property p : new Property[]{RiRegistry.SOURCES_FILE_PROPERTY, RiNetworking.URL_BACKEND_PROPERTY}) { + log.log(Level.INFO, p.getKey() + ": " + p.get(properties)); + } + for (BooleanProperty p : new BooleanProperty[]{RiCaching.NO_CACHE_PROPERTY, RiNetworking.AUTO_PROXY_PROPERTY, RiNetworking.NO_DEFAULT_SSL_PROPERTY, RiNetworking.NO_SYSTEM_SSL_PROPERTY}) { + log.log(Level.INFO, p.getKey() + ": " + p.get(properties)); + } + } + } + public Languages toLanguages() { return Parser.of(Languages::parse) .parseValue(languages)