Skip to content

Commit

Permalink
Fix sources file property in configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
charphi committed Oct 4, 2024
1 parent 9642232 commit 4b2d63b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -81,19 +88,39 @@ 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)
.onError(this::reportError)
.build();
}

private void logConfig() {
Function<? super String, ? extends CharSequence> 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)
Expand Down

0 comments on commit 4b2d63b

Please sign in to comment.