diff --git a/CHANGELOG.md b/CHANGELOG.md index e8122d691..d76b82877 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - ![API] Rename field `Dimension#label` as `Dimension#name` - ![API] Rename field `Attribute#label` as `Attribute#name` - ![API] Rename field `DataStructure#label` as `DataStructure#name` +- ![API] Rename field `SdmxWebSource#name` as `SdmxWebSource#id` - ![API] Set field `Dataflow#description` as optional - ![FORMAT] Improve parsing of time formats - ![FORMAT] Rename module `sdmx-dl-format-util ` as `smdx-dl-format-base` diff --git a/sdmx-dl-api/src/main/java/sdmxdl/web/SdmxWebManager.java b/sdmx-dl-api/src/main/java/sdmxdl/web/SdmxWebManager.java index 022558302..3faeb5d61 100644 --- a/sdmx-dl-api/src/main/java/sdmxdl/web/SdmxWebManager.java +++ b/sdmx-dl-api/src/main/java/sdmxdl/web/SdmxWebManager.java @@ -199,14 +199,14 @@ private static List initDefaultSources(List drivers) { return drivers .stream() .flatMap(driver -> driver.getDefaultSources().stream()) - .filter(distinctByKey(SdmxWebSource::getName)) + .filter(distinctByKey(SdmxWebSource::getId)) .collect(Collectors.toList()); } private static SortedMap initSourceMap(List customSources, List defaultSources) { return Stream.concat(customSources.stream(), defaultSources.stream()) .flatMap(SdmxWebManager::expandAliases) - .collect(Collectors.groupingBy(SdmxWebSource::getName, TreeMap::new, reducingByFirst())); + .collect(Collectors.groupingBy(SdmxWebSource::getId, TreeMap::new, reducingByFirst())); } private static Stream expandAliases(SdmxWebSource source) { diff --git a/sdmx-dl-api/src/main/java/sdmxdl/web/SdmxWebSource.java b/sdmx-dl-api/src/main/java/sdmxdl/web/SdmxWebSource.java index 36e1346d5..b6cdac5a4 100644 --- a/sdmx-dl-api/src/main/java/sdmxdl/web/SdmxWebSource.java +++ b/sdmx-dl-api/src/main/java/sdmxdl/web/SdmxWebSource.java @@ -37,7 +37,7 @@ public class SdmxWebSource extends SdmxSource { @lombok.NonNull - String name; + String id; @lombok.Singular Map descriptions; @@ -68,19 +68,15 @@ public class SdmxWebSource extends SdmxSource { URL monitorWebsite = null; @NonNull - public SdmxWebSource alias(@NonNull String name) throws IllegalArgumentException { - if (!aliases.contains(name)) { - throw new IllegalArgumentException(name); + public SdmxWebSource alias(@NonNull String id) throws IllegalArgumentException { + if (!aliases.contains(id)) { + throw new IllegalArgumentException(id); } - return toBuilder().name(name).build(); + return toBuilder().id(id).build(); } public boolean isAlias() { - return aliases.contains(name); - } - - public @NonNull String getId() { - return getDriver() + ":" + getName(); + return aliases.contains(id); } public @Nullable String getDescription(@NonNull LanguagePriorityList langs) { diff --git a/sdmx-dl-api/src/test/java/_test/sdmxdl/TestDriver.java b/sdmx-dl-api/src/test/java/_test/sdmxdl/TestDriver.java index 4a12a9527..c17ea2ee8 100644 --- a/sdmx-dl-api/src/test/java/_test/sdmxdl/TestDriver.java +++ b/sdmx-dl-api/src/test/java/_test/sdmxdl/TestDriver.java @@ -138,5 +138,5 @@ public boolean isAvailable() { } }; - public static final SdmxWebSource SOURCE = SdmxWebSource.builder().name("123").driver("456").dialect(SDMX21_DIALECT).endpointOf("http://localhost").build(); + public static final SdmxWebSource SOURCE = SdmxWebSource.builder().id("123").driver("456").dialect(SDMX21_DIALECT).endpointOf("http://localhost").build(); } diff --git a/sdmx-dl-api/src/test/java/sdmxdl/web/SdmxWebManagerTest.java b/sdmx-dl-api/src/test/java/sdmxdl/web/SdmxWebManagerTest.java index 8d8081b9a..0de515de8 100644 --- a/sdmx-dl-api/src/test/java/sdmxdl/web/SdmxWebManagerTest.java +++ b/sdmx-dl-api/src/test/java/sdmxdl/web/SdmxWebManagerTest.java @@ -97,9 +97,9 @@ public void testFactories() { @Test public void testGetSources() { - SdmxWebSource nbb = SdmxWebSource.builder().name("nbb").alias("bnb").driver("sdmx21").endpointOf("http://nbb").build(); - SdmxWebSource ecb = SdmxWebSource.builder().name("ecb").driver("sdmx21").endpointOf("http://ecb").build(); - SdmxWebSource abs = SdmxWebSource.builder().name("abs").driver("sdmx21").endpointOf("http://abs").build(); + SdmxWebSource nbb = SdmxWebSource.builder().id("nbb").alias("bnb").driver("sdmx21").endpointOf("http://nbb").build(); + SdmxWebSource ecb = SdmxWebSource.builder().id("ecb").driver("sdmx21").endpointOf("http://ecb").build(); + SdmxWebSource abs = SdmxWebSource.builder().id("abs").driver("sdmx21").endpointOf("http://abs").build(); SdmxWebSource nbbAlias = nbb.alias("bnb"); SdmxWebSource nbbDialect = nbb.toBuilder().dialect("custom").clearAliases().build(); @@ -172,12 +172,12 @@ public void testGetSources() { @Test public void testGetDefaultSources() { - SdmxWebSource source1a = SdmxWebSource.builder().name("s1").driver("dX").endpointOf("http://abc").build(); - SdmxWebSource source2 = SdmxWebSource.builder().name("s2").driver("dX").endpointOf("http://abc").build(); + SdmxWebSource source1a = SdmxWebSource.builder().id("s1").driver("dX").endpointOf("http://abc").build(); + SdmxWebSource source2 = SdmxWebSource.builder().id("s2").driver("dX").endpointOf("http://abc").build(); WebDriver driverX = MockedDriver.builder().name("dX").rank(WRAPPED_RANK).available(true).customSource(source1a).customSource(source2).build(); - SdmxWebSource source1b = SdmxWebSource.builder().name("s1").driver("dY").endpointOf("http://xyz").build(); - SdmxWebSource source3 = SdmxWebSource.builder().name("s3").driver("dY").endpointOf("http://xyz").build(); + SdmxWebSource source1b = SdmxWebSource.builder().id("s1").driver("dY").endpointOf("http://xyz").build(); + SdmxWebSource source3 = SdmxWebSource.builder().id("s3").driver("dY").endpointOf("http://xyz").build(); WebDriver driverY = MockedDriver.builder().name("dY").rank(NATIVE_RANK).available(true).customSource(source1b).customSource(source3).build(); assertThat(SdmxWebManager.builder().driver(driverX).driver(driverY).build().getDefaultSources()) @@ -198,7 +198,7 @@ public void testGetConnection() throws IOException { .isThrownBy(() -> manager.getConnection("ko")) .as("Invalid source name"); - assertThatCode(() -> manager.getConnection(sampleSource.getName()).close()).doesNotThrowAnyException(); + assertThatCode(() -> manager.getConnection(sampleSource.getId()).close()).doesNotThrowAnyException(); WebDriver driver1 = MockedDriver .builder() @@ -206,7 +206,7 @@ public void testGetConnection() throws IOException { .rank(WRAPPED_RANK) .available(true) .repo(sample, EnumSet.allOf(Feature.class)) - .customSource(SdmxWebSource.builder().name("source").driver("d1").dialect("azerty").endpointOf(sample.getName()).build()) + .customSource(SdmxWebSource.builder().id("source").driver("d1").dialect("azerty").endpointOf(sample.getName()).build()) .build(); WebDriver driver2 = MockedDriver @@ -215,7 +215,7 @@ public void testGetConnection() throws IOException { .rank(NATIVE_RANK) .available(true) .repo(sample, EnumSet.allOf(Feature.class)) - .customSource(SdmxWebSource.builder().name("source").driver("d2").dialect("azerty").endpointOf(sample.getName()).build()) + .customSource(SdmxWebSource.builder().id("source").driver("d2").dialect("azerty").endpointOf(sample.getName()).build()) .build(); try (Connection c = SdmxWebManager.builder().driver(driver2).driver(driver1).build().getConnection("source")) { @@ -240,7 +240,7 @@ public void testGetConnectionOfSource() { .as("Invalid source driver"); assertThatCode(() -> manager.getConnection(sampleSource).close()).doesNotThrowAnyException(); - assertThatCode(() -> manager.getConnection(sampleSource.toBuilder().name("other").build()).close()).doesNotThrowAnyException(); + assertThatCode(() -> manager.getConnection(sampleSource.toBuilder().id("other").build()).close()).doesNotThrowAnyException(); } @SuppressWarnings("EmptyTryBlock") @@ -251,31 +251,31 @@ public void testInvalidSourceProperties() throws IOException { SdmxWebManager manager = SdmxWebManager .builder() .driver(sampleDriver) - .eventListener((source, event) -> events.add(source.getName() + ":" + event)) + .eventListener((source, event) -> events.add(source.getId() + ":" + event)) .build(); - SdmxWebSource noProp = sampleSource.toBuilder().name("noProp").clearProperties().build(); + SdmxWebSource noProp = sampleSource.toBuilder().id("noProp").clearProperties().build(); try (Connection ignored = manager.getConnection(noProp)) { } assertThat(events).isEmpty(); - SdmxWebSource validProp = sampleSource.toBuilder().name("validProp").build(); + SdmxWebSource validProp = sampleSource.toBuilder().id("validProp").build(); try (Connection ignored = manager.getConnection(validProp)) { } assertThat(events).isEmpty(); - SdmxWebSource invalidProp = sampleSource.toBuilder().name("invalidProp").property("boom", "123").build(); + SdmxWebSource invalidProp = sampleSource.toBuilder().id("invalidProp").property("boom", "123").build(); try (Connection ignored = manager.getConnection(invalidProp)) { } assertThat(events).singleElement(as(STRING)) - .contains(invalidProp.getName()) + .contains(invalidProp.getId()) .contains("boom"); } private final DataRepository sample = DataRepository.builder().name("repo").build(); private final SdmxWebSource sampleSource = SdmxWebSource .builder() - .name("repoSource") + .id("repoSource") .driver("repoDriver") .dialect("azerty") .endpointOf(sample.getName()) diff --git a/sdmx-dl-api/src/test/java/sdmxdl/web/SdmxWebSourceTest.java b/sdmx-dl-api/src/test/java/sdmxdl/web/SdmxWebSourceTest.java index 0ba7c5969..b3c0e3839 100644 --- a/sdmx-dl-api/src/test/java/sdmxdl/web/SdmxWebSourceTest.java +++ b/sdmx-dl-api/src/test/java/sdmxdl/web/SdmxWebSourceTest.java @@ -37,13 +37,13 @@ public void testBuilderEndpointOf() throws MalformedURLException { assertThatIllegalArgumentException() .isThrownBy(() -> SdmxWebSource.builder().endpointOf("h ttp://localhost")); - assertThat(SdmxWebSource.builder().endpointOf("http://localhost").name("").driver("").build().getEndpoint()) + assertThat(SdmxWebSource.builder().endpointOf("http://localhost").id("").driver("").build().getEndpoint()) .isEqualTo(URI.create("http://localhost")); } @Test public void testBuilderDescription() { - SdmxWebSource base = SdmxWebSource.builder().endpointOf("http://localhost").name("").driver("").build(); + SdmxWebSource base = SdmxWebSource.builder().endpointOf("http://localhost").id("").driver("").build(); assertThat( base @@ -77,16 +77,16 @@ public void testBuilderPropertyOf() { assertThatNullPointerException() .isThrownBy(() -> SdmxWebSource.builder().propertyOf("", null)); - assertThat(SdmxWebSource.builder().propertyOf("hello", "world").endpointOf("http://localhost").name("").driver("").build().getProperties()) + assertThat(SdmxWebSource.builder().propertyOf("hello", "world").endpointOf("http://localhost").id("").driver("").build().getProperties()) .containsEntry("hello", "world"); } @Test public void testAlias() { - SdmxWebSource estat = SdmxWebSource.builder().name("ESTAT").alias("EUROSTAT").driver("").endpointOf("http://localhost").build(); + SdmxWebSource estat = SdmxWebSource.builder().id("ESTAT").alias("EUROSTAT").driver("").endpointOf("http://localhost").build(); assertThat(estat.alias("EUROSTAT")) - .isEqualTo(estat.toBuilder().name("EUROSTAT").build()); + .isEqualTo(estat.toBuilder().id("EUROSTAT").build()); assertThatNullPointerException() .isThrownBy(() -> estat.alias(null)); @@ -97,15 +97,15 @@ public void testAlias() { @Test public void testIsAlias() { - SdmxWebSource base = SdmxWebSource.builder().name("ESTAT").driver("").endpointOf("http://localhost").build(); + SdmxWebSource base = SdmxWebSource.builder().id("ESTAT").driver("").endpointOf("http://localhost").build(); assertThat(base.isAlias()).isFalse(); assertThat(base.toBuilder().alias("EUROSTAT").build().isAlias()).isFalse(); - assertThat(base.toBuilder().name("EUROSTAT").alias("EUROSTAT").build().isAlias()).isTrue(); + assertThat(base.toBuilder().id("EUROSTAT").alias("EUROSTAT").build().isAlias()).isTrue(); } @Test public void testWebsite() { - SdmxWebSource base = SdmxWebSource.builder().name("ESTAT").driver("").endpointOf("http://localhost").build(); + SdmxWebSource base = SdmxWebSource.builder().id("ESTAT").driver("").endpointOf("http://localhost").build(); assertThat(base.getWebsite()).isNull(); assertThat(base.toBuilder().websiteOf("http://somewhere").build().getWebsite()) .asString() diff --git a/sdmx-dl-api/src/test/java/tests/sdmxdl/web/MockedDriver.java b/sdmx-dl-api/src/test/java/tests/sdmxdl/web/MockedDriver.java index df9a4bc1f..593f89b3f 100644 --- a/sdmx-dl-api/src/test/java/tests/sdmxdl/web/MockedDriver.java +++ b/sdmx-dl-api/src/test/java/tests/sdmxdl/web/MockedDriver.java @@ -78,7 +78,7 @@ private Stream generateSources() { public static SdmxWebSource sourceOf(String name, String driverName, DataRepository repo) { return SdmxWebSource .builder() - .name(name) + .id(name) .driver(driverName) .endpointOf(repo.getName()) .build(); diff --git a/sdmx-dl-api/src/test/java/tests/sdmxdl/web/WebDriverAssert.java b/sdmx-dl-api/src/test/java/tests/sdmxdl/web/WebDriverAssert.java index 5a5869f8a..1aa3a8ee9 100644 --- a/sdmx-dl-api/src/test/java/tests/sdmxdl/web/WebDriverAssert.java +++ b/sdmx-dl-api/src/test/java/tests/sdmxdl/web/WebDriverAssert.java @@ -17,7 +17,7 @@ public WebContext noOpWebContext() { public void assertCompliance(WebDriver d) { SdmxWebSource validSource = SdmxWebSource .builder() - .name("valid") + .id("valid") .driver(d.getName()) .dialect("azerty") .endpointOf("http://localhost") @@ -40,7 +40,7 @@ public void assertCompliance(WebDriver d) { } private void checkSource(SdmxWebSource o, WebDriver d) { - assertThat(o.getName()).isNotBlank(); + assertThat(o.getId()).isNotBlank(); assertThat(o.getProperties()).isNotNull(); assertThat(o.getDriver()).isEqualTo(d.getName()); assertThat(o.getProperties().keySet()).isSubsetOf(d.getSupportedProperties()); diff --git a/sdmx-dl-cli/src/main/java/internal/sdmxdl/cli/ConsoleAuthenticator.java b/sdmx-dl-cli/src/main/java/internal/sdmxdl/cli/ConsoleAuthenticator.java index 7217c65a1..e26d35c0a 100644 --- a/sdmx-dl-cli/src/main/java/internal/sdmxdl/cli/ConsoleAuthenticator.java +++ b/sdmx-dl-cli/src/main/java/internal/sdmxdl/cli/ConsoleAuthenticator.java @@ -45,7 +45,7 @@ public void invalidate(SdmxWebSource source) { } private PasswordAuthentication readPasswordAuthentication(SdmxWebSource source) throws IOError { - console.format("Enter your credentials for %s\n", source.getName()); + console.format("Enter your credentials for %s\n", source.getId()); String username = console.readLine("Enter username: "); char[] password = console.readPassword("Enter password: "); return new PasswordAuthentication(username, password); diff --git a/sdmx-dl-cli/src/main/java/internal/sdmxdl/cli/WebOptions.java b/sdmx-dl-cli/src/main/java/internal/sdmxdl/cli/WebOptions.java index dddbb8817..59745528e 100644 --- a/sdmx-dl-cli/src/main/java/internal/sdmxdl/cli/WebOptions.java +++ b/sdmx-dl-cli/src/main/java/internal/sdmxdl/cli/WebOptions.java @@ -157,7 +157,7 @@ public void onSourceEvent(SdmxWebSource source, String message) { main.accept(source, message); } if (verboseOptions.isVerbose()) { - verboseOptions.reportToErrorStream("WEB", source.getName() + ": " + message); + verboseOptions.reportToErrorStream("WEB", source.getId() + ": " + message); } } } diff --git a/sdmx-dl-cli/src/main/java/sdmxdl/cli/ListSourcesCommand.java b/sdmx-dl-cli/src/main/java/sdmxdl/cli/ListSourcesCommand.java index 9c593e6b8..798dd897b 100644 --- a/sdmx-dl-cli/src/main/java/sdmxdl/cli/ListSourcesCommand.java +++ b/sdmx-dl-cli/src/main/java/sdmxdl/cli/ListSourcesCommand.java @@ -51,7 +51,7 @@ public Void call() throws Exception { private CsvTable getTable() { return CsvTable .builderOf(SdmxWebSource.class) - .columnOf("Name", SdmxWebSource::getName, Formatter.onString()) + .columnOf("Name", SdmxWebSource::getId, Formatter.onString()) .columnOf("Description", this::getDescription, Formatter.onString()) .columnOf("Aliases", SdmxWebSource::getAliases, CsvUtil.fromIterable(Formatter.onString(), ',')) .columnOf("Driver", SdmxWebSource::getDriver, Formatter.onString()) diff --git a/sdmx-dl-cli/src/test/java/_test/FileSample.java b/sdmx-dl-cli/src/test/java/_test/FileSample.java index 6a7b2c19a..e464e6c21 100644 --- a/sdmx-dl-cli/src/test/java/_test/FileSample.java +++ b/sdmx-dl-cli/src/test/java/_test/FileSample.java @@ -36,7 +36,7 @@ public static File create(Path temp) throws IOException { private static SdmxWebSource sourceOf(String name, File data, File struct) throws MalformedURLException { return SdmxWebSource .builder() - .name(name) + .id(name) .driver("ri:file") .endpoint(data.toURI()) .property("structureURL", struct.toURI().toURL().toString()) diff --git a/sdmx-dl-cli/src/test/java/internal/sdmxdl/cli/WebOptionsTest.java b/sdmx-dl-cli/src/test/java/internal/sdmxdl/cli/WebOptionsTest.java index 0680508c1..787e5ed2b 100644 --- a/sdmx-dl-cli/src/test/java/internal/sdmxdl/cli/WebOptionsTest.java +++ b/sdmx-dl-cli/src/test/java/internal/sdmxdl/cli/WebOptionsTest.java @@ -58,7 +58,7 @@ private File newInvalidFile(Path temp) throws IOException { private File newValidFile(Path temp) throws IOException { File result = Files.createFile(temp.resolve("validFile")).toFile(); - SdmxWebSource source = SdmxWebSource.builder().name("xyz").driver("dummy").endpointOf("http://localhost").build(); + SdmxWebSource source = SdmxWebSource.builder().id("xyz").driver("dummy").endpointOf("http://localhost").build(); XmlWebSource.getFormatter().formatFile(singletonList(source), result); return result; } diff --git a/sdmx-dl-desktop/src/main/java/internal/sdmxdl/desktop/SdmxAutoCompletion.java b/sdmx-dl-desktop/src/main/java/internal/sdmxdl/desktop/SdmxAutoCompletion.java index 2fc13f9e0..505952dba 100644 --- a/sdmx-dl-desktop/src/main/java/internal/sdmxdl/desktop/SdmxAutoCompletion.java +++ b/sdmx-dl-desktop/src/main/java/internal/sdmxdl/desktop/SdmxAutoCompletion.java @@ -135,7 +135,7 @@ public AutoCompletionSource getSource() { .builder(this::load) .behavior(SYNC) .postProcessor(this::filterAndSort) - .valueToString(SdmxWebSource::getName) + .valueToString(SdmxWebSource::getId) .build(); } @@ -144,7 +144,7 @@ public ListCellRenderer getRenderer() { return new CustomListCellRenderer() { @Override protected String getValueAsString(SdmxWebSource value) { - return value.getName() + ": " + manager.getLanguages().select(value.getDescriptions()); + return value.getId() + ": " + manager.getLanguages().select(value.getDescriptions()); } @Override @@ -171,7 +171,7 @@ private Predicate getFilter(String term) { Predicate filter = ExtAutoCompletionSource.basicFilter(term); LanguagePriorityList langs = manager.getLanguages(); return value -> filter.test(langs.select(value.getDescriptions())) - || filter.test(value.getName()) + || filter.test(value.getId()) || value.getAliases().stream().anyMatch(filter); } } diff --git a/sdmx-dl-desktop/src/main/java/sdmxdl/desktop/MainComponent.java b/sdmx-dl-desktop/src/main/java/sdmxdl/desktop/MainComponent.java index 50f0642ff..43d06e3fd 100644 --- a/sdmx-dl-desktop/src/main/java/sdmxdl/desktop/MainComponent.java +++ b/sdmx-dl-desktop/src/main/java/sdmxdl/desktop/MainComponent.java @@ -188,8 +188,8 @@ public void actionPerformed(ActionEvent e) { main.putClientProperty(FlatClientProperties.TABBED_PANE_TAB_TYPE, FlatClientProperties.TABBED_PANE_TAB_TYPE_CARD); sourcesList.setCellRenderer(JLists.cellRendererOf((label, value) -> { - label.setText(nameDescription(value.getName(), value.getDescription(LanguagePriorityList.ANY)).render()); - label.setIcon(getDataSourceIcon(value.getName(), 24, sourcesList::repaint)); + label.setText(nameDescription(value.getId(), value.getDescription(LanguagePriorityList.ANY)).render()); + label.setIcon(getDataSourceIcon(value.getId(), 24, sourcesList::repaint)); label.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); })); diff --git a/sdmx-dl-format-xml/src/main/java/sdmxdl/format/xml/XmlWebSource.java b/sdmx-dl-format-xml/src/main/java/sdmxdl/format/xml/XmlWebSource.java index c6daac5b8..ec49931a5 100644 --- a/sdmx-dl-format-xml/src/main/java/sdmxdl/format/xml/XmlWebSource.java +++ b/sdmx-dl-format-xml/src/main/java/sdmxdl/format/xml/XmlWebSource.java @@ -73,7 +73,7 @@ private static List parseXml(XMLStreamReader reader) throws XMLSt item = SdmxWebSource.builder(); break; case NAME_TAG: - item.name(reader.getElementText()); + item.id(reader.getElementText()); break; case DESCRIPTION_TAG: String lang = reader.getAttributeValue(null, LANG_ATTR); @@ -122,7 +122,7 @@ private static void formatXml(List list, XMLStreamWriter writer, writer.writeStartElement(SOURCES_TAG); for (SdmxWebSource source : list) { writer.writeStartElement(SOURCE_TAG); - writeTextElement(writer, NAME_TAG, source.getName()); + writeTextElement(writer, NAME_TAG, source.getId()); for (Map.Entry description : source.getDescriptions().entrySet()) { writeDescription(writer, description); } diff --git a/sdmx-dl-format-xml/src/test/java/sdmxdl/format/xml/XmlWebSourceTest.java b/sdmx-dl-format-xml/src/test/java/sdmxdl/format/xml/XmlWebSourceTest.java index e1a9e6808..7b0710f33 100644 --- a/sdmx-dl-format-xml/src/test/java/sdmxdl/format/xml/XmlWebSourceTest.java +++ b/sdmx-dl-format-xml/src/test/java/sdmxdl/format/xml/XmlWebSourceTest.java @@ -35,7 +35,7 @@ public class XmlWebSourceTest { private final List sample = Arrays.asList( SdmxWebSource .builder() - .name("ECB") + .id("ECB") .description("en", "European Central Bank") .driver("ri:sdmx21") .dialect(SDMX21_DIALECT) @@ -48,7 +48,7 @@ public class XmlWebSourceTest { .build(), SdmxWebSource .builder() - .name("other") + .id("other") .descriptionOf("some description") .driver("dummy") .endpointOf("http://localhost") diff --git a/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/CommonSdmxExceptions.java b/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/CommonSdmxExceptions.java index f030a7ccf..10af0f786 100644 --- a/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/CommonSdmxExceptions.java +++ b/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/CommonSdmxExceptions.java @@ -28,23 +28,23 @@ */ public final class CommonSdmxExceptions { - public static @NonNull IOException connectionClosed(@NonNull HasSourceName source) { - return new IOException(String.format("Connection closed from '%s'", source.getName())); + public static @NonNull IOException connectionClosed(@NonNull HasMarker source) { + return new IOException(String.format("Connection closed from '%s'", source.getMarker())); } - public static @NonNull IOException missingFlow(@NonNull HasSourceName source, @NonNull DataflowRef ref) { - return new IOException(String.format("Missing flow '%s' from '%s'", ref, source.getName())); + public static @NonNull IOException missingFlow(@NonNull HasMarker source, @NonNull DataflowRef ref) { + return new IOException(String.format("Missing flow '%s' from '%s'", ref, source.getMarker())); } - public static @NonNull IOException missingStructure(@NonNull HasSourceName source, @NonNull DataStructureRef ref) { - return new IOException(String.format("Missing structure '%s' from '%s'", ref, source.getName())); + public static @NonNull IOException missingStructure(@NonNull HasMarker source, @NonNull DataStructureRef ref) { + return new IOException(String.format("Missing structure '%s' from '%s'", ref, source.getMarker())); } - public static @NonNull IOException missingData(@NonNull HasSourceName source, @NonNull DataflowRef ref) { - return new IOException(String.format("Missing data '%s' from '%s'", ref, source.getName())); + public static @NonNull IOException missingData(@NonNull HasMarker source, @NonNull DataflowRef ref) { + return new IOException(String.format("Missing data '%s' from '%s'", ref, source.getMarker())); } - public static @NonNull IOException missingCodelist(@NonNull HasSourceName source, @NonNull CodelistRef ref) { - return new IOException(String.format("Missing codelist '%s' from '%s'", ref, source.getName())); + public static @NonNull IOException missingCodelist(@NonNull HasMarker source, @NonNull CodelistRef ref) { + return new IOException(String.format("Missing codelist '%s' from '%s'", ref, source.getMarker())); } } diff --git a/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/ConnectionSupport.java b/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/ConnectionSupport.java index d77cd2b5a..aea6ab9ef 100644 --- a/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/ConnectionSupport.java +++ b/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/ConnectionSupport.java @@ -9,7 +9,7 @@ @lombok.experimental.UtilityClass public class ConnectionSupport { - public static @NonNull Dataflow getFlowFromFlows(@NonNull DataflowRef flowRef, @NonNull Connection connection, @NonNull HasSourceName source) throws IOException, IllegalArgumentException { + public static @NonNull Dataflow getFlowFromFlows(@NonNull DataflowRef flowRef, @NonNull Connection connection, @NonNull HasMarker source) throws IOException, IllegalArgumentException { return connection .getFlows() .stream() diff --git a/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/HasMarker.java b/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/HasMarker.java new file mode 100644 index 000000000..30ad1374a --- /dev/null +++ b/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/HasMarker.java @@ -0,0 +1,8 @@ +package sdmxdl.provider; + +import lombok.NonNull; + +public interface HasMarker { + + @NonNull Marker getMarker(); +} diff --git a/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/HasSourceName.java b/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/HasSourceName.java deleted file mode 100644 index 2444580f7..000000000 --- a/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/HasSourceName.java +++ /dev/null @@ -1,8 +0,0 @@ -package sdmxdl.provider; - -import lombok.NonNull; - -public interface HasSourceName { - - @NonNull String getName(); -} diff --git a/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/Marker.java b/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/Marker.java new file mode 100644 index 000000000..754c19c57 --- /dev/null +++ b/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/Marker.java @@ -0,0 +1,25 @@ +package sdmxdl.provider; + +import lombok.NonNull; +import sdmxdl.DataRepository; +import sdmxdl.file.SdmxFileSource; +import sdmxdl.web.SdmxWebSource; + +@lombok.Value(staticConstructor = "of") +public class Marker implements CharSequence { + + @lombok.experimental.Delegate(types = CharSequence.class) + @NonNull String content; + + public static @NonNull Marker of(@NonNull SdmxWebSource s) { + return new Marker(s.getDriver() + ":" + s.getId()); + } + + public static @NonNull Marker of(@NonNull SdmxFileSource s) { + return new Marker(s.getData().getPath()); + } + + public static @NonNull Marker of(@NonNull DataRepository repository) { + return new Marker(repository.getName()); + } +} diff --git a/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/file/CachedFileClient.java b/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/file/CachedFileClient.java index 4fbd32bd5..81c0350ee 100644 --- a/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/file/CachedFileClient.java +++ b/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/file/CachedFileClient.java @@ -22,6 +22,7 @@ import sdmxdl.ext.Cache; import sdmxdl.file.SdmxFileSource; import sdmxdl.provider.DataRef; +import sdmxdl.provider.Marker; import sdmxdl.provider.TypedId; import java.io.IOException; @@ -79,6 +80,11 @@ private static TypedId initIdOfLoadData(URI base) { ).with("loadData"); } + @Override + public @NonNull Marker getMarker() { + return delegate.getMarker(); + } + @Override public void testClient() throws IOException { delegate.testClient(); diff --git a/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/file/FileClient.java b/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/file/FileClient.java index c019798db..9b06f9f82 100644 --- a/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/file/FileClient.java +++ b/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/file/FileClient.java @@ -3,17 +3,12 @@ import lombok.NonNull; import sdmxdl.Series; import sdmxdl.provider.DataRef; -import sdmxdl.provider.HasSourceName; +import sdmxdl.provider.HasMarker; import java.io.IOException; import java.util.stream.Stream; -public interface FileClient extends HasSourceName { - - @Override - default @NonNull String getName() { - return "fixme"; - } +public interface FileClient extends HasMarker { void testClient() throws IOException; diff --git a/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/web/CachedRestClient.java b/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/web/CachedRestClient.java index 2cb2ac05d..b2a08aa46 100644 --- a/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/web/CachedRestClient.java +++ b/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/web/CachedRestClient.java @@ -20,6 +20,7 @@ import sdmxdl.*; import sdmxdl.ext.Cache; import sdmxdl.provider.DataRef; +import sdmxdl.provider.Marker; import sdmxdl.provider.TypedId; import sdmxdl.web.SdmxWebSource; @@ -110,8 +111,8 @@ private static TypedId initIdOfNoData(URI base) { } @Override - public @NonNull String getName() { - return delegate.getName(); + public @NonNull Marker getMarker() { + return delegate.getMarker(); } @Override diff --git a/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/web/RestClient.java b/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/web/RestClient.java index 610ed9afe..0cf96a26f 100644 --- a/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/web/RestClient.java +++ b/sdmx-dl-provider-base/src/main/java/sdmxdl/provider/web/RestClient.java @@ -19,7 +19,7 @@ import lombok.NonNull; import sdmxdl.*; import sdmxdl.provider.DataRef; -import sdmxdl.provider.HasSourceName; +import sdmxdl.provider.HasMarker; import java.io.IOException; import java.util.List; @@ -28,7 +28,7 @@ /** * @author Philippe Charles */ -public interface RestClient extends HasSourceName { +public interface RestClient extends HasMarker { @NonNull List getFlows() throws IOException; diff --git a/sdmx-dl-provider-base/src/test/java/_test/sdmxdl/util/XCountingFileClient.java b/sdmx-dl-provider-base/src/test/java/_test/sdmxdl/util/XCountingFileClient.java index 02e7335fb..e46ce1911 100644 --- a/sdmx-dl-provider-base/src/test/java/_test/sdmxdl/util/XCountingFileClient.java +++ b/sdmx-dl-provider-base/src/test/java/_test/sdmxdl/util/XCountingFileClient.java @@ -3,6 +3,7 @@ import lombok.NonNull; import sdmxdl.Series; import sdmxdl.provider.DataRef; +import sdmxdl.provider.Marker; import sdmxdl.provider.file.FileClient; import sdmxdl.provider.file.FileInfo; @@ -19,6 +20,11 @@ public final class XCountingFileClient implements FileClient { @lombok.NonNull private final AtomicInteger count; + @Override + public @NonNull Marker getMarker() { + return delegate.getMarker(); + } + @Override public void testClient() throws IOException { delegate.testClient(); diff --git a/sdmx-dl-provider-base/src/test/java/_test/sdmxdl/util/XCountingRestClient.java b/sdmx-dl-provider-base/src/test/java/_test/sdmxdl/util/XCountingRestClient.java index ced9f96e7..af355afbb 100644 --- a/sdmx-dl-provider-base/src/test/java/_test/sdmxdl/util/XCountingRestClient.java +++ b/sdmx-dl-provider-base/src/test/java/_test/sdmxdl/util/XCountingRestClient.java @@ -19,6 +19,7 @@ import lombok.NonNull; import sdmxdl.*; import sdmxdl.provider.DataRef; +import sdmxdl.provider.Marker; import sdmxdl.provider.web.RestClient; import java.io.IOException; @@ -39,8 +40,8 @@ public final class XCountingRestClient implements RestClient { private final AtomicInteger count; @Override - public @NonNull String getName() { - return delegate.getName(); + public @NonNull Marker getMarker() { + return delegate.getMarker(); } @Override diff --git a/sdmx-dl-provider-base/src/test/java/_test/sdmxdl/util/XFailingRestClient.java b/sdmx-dl-provider-base/src/test/java/_test/sdmxdl/util/XFailingRestClient.java index 1a954266b..cf5f0ac5d 100644 --- a/sdmx-dl-provider-base/src/test/java/_test/sdmxdl/util/XFailingRestClient.java +++ b/sdmx-dl-provider-base/src/test/java/_test/sdmxdl/util/XFailingRestClient.java @@ -19,6 +19,7 @@ import lombok.NonNull; import sdmxdl.*; import sdmxdl.provider.DataRef; +import sdmxdl.provider.Marker; import sdmxdl.provider.web.RestClient; import java.io.IOException; @@ -32,8 +33,8 @@ public enum XFailingRestClient implements RestClient { TEST_EXPECTED { @Override - public @NonNull String getName() { - return ""; + public @NonNull Marker getMarker() { + return Marker.of(""); } @Override @@ -73,7 +74,7 @@ public void testClient() throws IOException { }, TEST_UNEXPECTED { @Override - public @NonNull String getName() { + public @NonNull Marker getMarker() { throw new CustomRuntimeException(); } @@ -114,7 +115,7 @@ public void testClient() { }, TEST_NULL { @Override - public @NonNull String getName() { + public @NonNull Marker getMarker() { return null; } diff --git a/sdmx-dl-provider-base/src/test/java/_test/sdmxdl/util/XRepoFileClient.java b/sdmx-dl-provider-base/src/test/java/_test/sdmxdl/util/XRepoFileClient.java index df479529c..89a312b99 100644 --- a/sdmx-dl-provider-base/src/test/java/_test/sdmxdl/util/XRepoFileClient.java +++ b/sdmx-dl-provider-base/src/test/java/_test/sdmxdl/util/XRepoFileClient.java @@ -5,6 +5,7 @@ import sdmxdl.DataRepository; import sdmxdl.Series; import sdmxdl.provider.DataRef; +import sdmxdl.provider.Marker; import sdmxdl.provider.file.FileClient; import sdmxdl.provider.file.FileInfo; @@ -17,6 +18,11 @@ public final class XRepoFileClient implements FileClient { @lombok.NonNull private final DataRepository repository; + @Override + public @NonNull Marker getMarker() { + return Marker.of(repository); + } + @Override public void testClient() { } diff --git a/sdmx-dl-provider-base/src/test/java/_test/sdmxdl/util/XRepoRestClient.java b/sdmx-dl-provider-base/src/test/java/_test/sdmxdl/util/XRepoRestClient.java index 78554da68..cd1481199 100644 --- a/sdmx-dl-provider-base/src/test/java/_test/sdmxdl/util/XRepoRestClient.java +++ b/sdmx-dl-provider-base/src/test/java/_test/sdmxdl/util/XRepoRestClient.java @@ -20,6 +20,7 @@ import sdmxdl.*; import sdmxdl.provider.CommonSdmxExceptions; import sdmxdl.provider.DataRef; +import sdmxdl.provider.Marker; import sdmxdl.provider.web.RestClient; import java.io.IOException; @@ -36,8 +37,8 @@ public final class XRepoRestClient implements RestClient { private final DataRepository repository; @Override - public @NonNull String getName() { - return repository.getName(); + public @NonNull Marker getMarker() { + return Marker.of(repository); } @Override diff --git a/sdmx-dl-provider-base/src/test/java/sdmxdl/provider/CommonSdmxExceptionsTest.java b/sdmx-dl-provider-base/src/test/java/sdmxdl/provider/CommonSdmxExceptionsTest.java index 0ed3db11f..7b78a3bfb 100644 --- a/sdmx-dl-provider-base/src/test/java/sdmxdl/provider/CommonSdmxExceptionsTest.java +++ b/sdmx-dl-provider-base/src/test/java/sdmxdl/provider/CommonSdmxExceptionsTest.java @@ -12,7 +12,7 @@ @SuppressWarnings({"ConstantConditions", "ThrowableNotThrown"}) public class CommonSdmxExceptionsTest { - private static final String SOURCE = "abc"; + private static final Marker SOURCE = Marker.of("abc"); private static final DataflowRef DATAFLOW_REF = DataflowRef.parse("df"); private static final DataStructureRef DATA_STRUCTURE_REF = DataStructureRef.parse("ds"); private static final CodelistRef CODELIST_REF = CodelistRef.parse("cl"); @@ -24,7 +24,7 @@ public void testConnectionClosed() { assertThat(connectionClosed(() -> SOURCE)) .hasNoCause() - .hasMessageContaining(SOURCE); + .hasMessageContainingAll(SOURCE); } @Test @@ -37,7 +37,7 @@ public void testMissingFlow() { assertThat(missingFlow(() -> SOURCE, DATAFLOW_REF)) .hasNoCause() - .hasMessageContaining(SOURCE) + .hasMessageContainingAll(SOURCE) .hasMessageContaining(DATAFLOW_REF.getId()); } @@ -51,7 +51,7 @@ public void testMissingStructure() { assertThat(missingStructure(() -> SOURCE, DATA_STRUCTURE_REF)) .hasNoCause() - .hasMessageContaining(SOURCE) + .hasMessageContainingAll(SOURCE) .hasMessageContaining(DATA_STRUCTURE_REF.getId()); } @@ -65,7 +65,7 @@ public void testMissingData() { assertThat(missingData(() -> SOURCE, DATAFLOW_REF)) .hasNoCause() - .hasMessageContaining(SOURCE) + .hasMessageContainingAll(SOURCE) .hasMessageContaining(DATAFLOW_REF.getId()); } @@ -79,7 +79,7 @@ public void testMissingCodelist() { assertThat(missingCodelist(() -> SOURCE, CODELIST_REF)) .hasNoCause() - .hasMessageContaining(SOURCE) + .hasMessageContainingAll(SOURCE) .hasMessageContaining(CODELIST_REF.getId()); } } diff --git a/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/ConnectorsRestClient.java b/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/ConnectorsRestClient.java index e22012789..a54020b96 100644 --- a/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/ConnectorsRestClient.java +++ b/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/ConnectorsRestClient.java @@ -29,6 +29,7 @@ import sdmxdl.*; import sdmxdl.format.ObsParser; import sdmxdl.provider.DataRef; +import sdmxdl.provider.Marker; import sdmxdl.provider.web.RestClient; import sdmxdl.provider.web.RestClientSupplier; import sdmxdl.provider.web.WebEvents; @@ -77,7 +78,7 @@ public interface GenericSupplier { RestSdmxClient client = supplier.get(); client.setEndpoint(source.getEndpoint()); configure(client, source, context); - return new ConnectorsRestClient(source.getName(), client, obsFactory); + return new ConnectorsRestClient(Marker.of(source), client, obsFactory); } catch (URISyntaxException ex) { throw new RuntimeException(ex); } @@ -92,12 +93,12 @@ public interface GenericSupplier { return (source, context) -> { RestSdmxClient client = supplier.get(source.getEndpoint(), source.getProperties()); configure(client, source, context); - return new ConnectorsRestClient(source.getName(), client, obsFactory); + return new ConnectorsRestClient(Marker.of(source), client, obsFactory); }; } @lombok.NonNull - private final String name; + private final Marker marker; @lombok.NonNull private final RestSdmxClient connector; @@ -106,8 +107,8 @@ public interface GenericSupplier { private final Supplier dataFactory; @Override - public @NonNull String getName() { - return name; + public @NonNull Marker getMarker() { + return marker; } @Override @@ -120,7 +121,7 @@ public interface GenericSupplier { .map(Connectors::toFlow) .collect(Collectors.toList()); } catch (SdmxException ex) { - throw wrap(ex, "Failed to get dataflows from '%s'", name); + throw wrap(ex, "Failed to get dataflows from '%s'", marker); } } @@ -129,7 +130,7 @@ public interface GenericSupplier { try { return Connectors.toFlow(connector.getDataflow(ref.getId(), ref.getAgency(), ref.getVersion())); } catch (SdmxException ex) { - throw wrap(ex, "Failed to get dataflow '%s' from '%s'", ref, name); + throw wrap(ex, "Failed to get dataflow '%s' from '%s'", ref, marker); } } @@ -138,7 +139,7 @@ public interface GenericSupplier { try { return Connectors.toStructure(connector.getDataFlowStructure(Connectors.fromStructureRef(ref), true)); } catch (SdmxException ex) { - throw wrap(ex, "Failed to get datastructure '%s' from '%s'", ref, name); + throw wrap(ex, "Failed to get datastructure '%s' from '%s'", ref, marker); } } @@ -151,7 +152,7 @@ public interface GenericSupplier { if (Connectors.isNoResultMatchingQuery(ex)) { return Stream.empty(); } - throw wrap(ex, "Failed to get data '%s' from '%s'", ref, name); + throw wrap(ex, "Failed to get data '%s' from '%s'", ref, marker); } } @@ -164,7 +165,7 @@ public interface GenericSupplier { .codes(connector.getCodes(ref.getId(), ref.getAgency(), ref.getVersion())) .build(); } catch (SdmxException ex) { - throw wrap(ex, "Failed to get codelist '%s' from '%s'", ref, name); + throw wrap(ex, "Failed to get codelist '%s' from '%s'", ref, marker); } } @@ -179,7 +180,7 @@ public void testClient() throws IOException { try { connector.getDataflows(); } catch (SdmxException ex) { - throw wrap(ex, "Failed to ping '%s' : '%s'", name, ex.getMessage()); + throw wrap(ex, "Failed to ping '%s' : '%s'", marker, ex.getMessage()); } } diff --git a/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/EurostatDriver.java b/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/EurostatDriver.java index 30bef9360..a65d811be 100644 --- a/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/EurostatDriver.java +++ b/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/EurostatDriver.java @@ -45,7 +45,7 @@ public final class EurostatDriver implements WebDriver { .defaultDialect(SDMX21_DIALECT) .source(SdmxWebSource .builder() - .name("ESTAT") + .id("ESTAT") .alias("EUROSTAT") .descriptionOf("Eurostat") .description("en", "Eurostat") diff --git a/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/ImfDriver.java b/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/ImfDriver.java index a1161ea7a..ef0b8f586 100644 --- a/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/ImfDriver.java +++ b/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/ImfDriver.java @@ -45,7 +45,7 @@ public final class ImfDriver implements WebDriver { .defaultDialect(Dialect.SDMX20_DIALECT) .source(SdmxWebSource .builder() - .name("IMF") + .id("IMF") .descriptionOf("International Monetary Fund") .description("en", "International Monetary Fund") .driver(CONNECTORS_IMF) diff --git a/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/InseeDriver.java b/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/InseeDriver.java index ed632f854..664df3cb2 100644 --- a/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/InseeDriver.java +++ b/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/InseeDriver.java @@ -63,7 +63,7 @@ public final class InseeDriver implements WebDriver { .defaultDialect(INSEE_2017) .source(SdmxWebSource .builder() - .name("INSEE") + .id("INSEE") .descriptionOf("Institut national de la statistique et des études économiques") .driver(CONNECTORS_INSEE) .endpointOf("https://bdm.insee.fr/series/sdmx") diff --git a/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/NbbDriver.java b/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/NbbDriver.java index 2d2d47a09..45fcec079 100644 --- a/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/NbbDriver.java +++ b/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/NbbDriver.java @@ -45,7 +45,7 @@ public final class NbbDriver implements WebDriver { .defaultDialect(Dialect.SDMX20_DIALECT) .source(SdmxWebSource .builder() - .name("NBB") + .id("NBB") .descriptionOf("National Bank of Belgium") .driver(CONNECTORS_NBB) .endpointOf("https://stat.nbb.be/restsdmx/sdmx.ashx") diff --git a/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/OecdDriver.java b/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/OecdDriver.java index c034b7b34..c94c436ef 100644 --- a/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/OecdDriver.java +++ b/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/OecdDriver.java @@ -45,7 +45,7 @@ public final class OecdDriver implements WebDriver { .defaultDialect(Dialect.SDMX20_DIALECT) .source(SdmxWebSource .builder() - .name("OECD") + .id("OECD") .descriptionOf("The Organisation for Economic Co-operation and Development") .driver(CONNECTORS_OECD) .endpointOf("https://stats.oecd.org/restsdmx/sdmx.ashx") diff --git a/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/Sdmx21Driver.java b/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/Sdmx21Driver.java index afa4a0c8f..bfc94d3b6 100644 --- a/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/Sdmx21Driver.java +++ b/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/Sdmx21Driver.java @@ -55,7 +55,7 @@ public final class Sdmx21Driver implements WebDriver { .defaultDialect(SDMX21_DIALECT) .source(SdmxWebSource .builder() - .name("ABS") + .id("ABS") .descriptionOf("Australian Bureau of Statistics") .description("en", "Australian Bureau of Statistics") .driver(CONNECTORS_SDMX_21) @@ -67,7 +67,7 @@ public final class Sdmx21Driver implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("BIS") + .id("BIS") .descriptionOf("Bank for International Settlements") .description("en", "Bank for International Settlements") .driver(CONNECTORS_SDMX_21) @@ -79,7 +79,7 @@ public final class Sdmx21Driver implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("CAMSTAT") + .id("CAMSTAT") .descriptionOf("National Institute of Statistics of Cambodia") .description("en", "National Institute of Statistics of Cambodia") .description("km", " វិទ្យាស្ថានជាតិស្ថិតិ") @@ -91,7 +91,7 @@ public final class Sdmx21Driver implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("ECB") + .id("ECB") .descriptionOf("European Central Bank") .driver(CONNECTORS_SDMX_21) .dialect("ECB2020") @@ -104,7 +104,7 @@ public final class Sdmx21Driver implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("ESCAP") + .id("ESCAP") .descriptionOf("Economic and Social Commission for Asia and the Pacific") .description("en", "Economic and Social Commission for Asia and the Pacific") .driver(CONNECTORS_SDMX_21) @@ -115,7 +115,7 @@ public final class Sdmx21Driver implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("ILO") + .id("ILO") .descriptionOf("International Labour Organization") .driver(CONNECTORS_SDMX_21) .endpointOf("https://www.ilo.org/sdmx/rest") @@ -126,7 +126,7 @@ public final class Sdmx21Driver implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("IMF_SDMX_CENTRAL") + .id("IMF_SDMX_CENTRAL") .descriptionOf("International Monetary Fund (SDMX Central)") .driver(CONNECTORS_SDMX_21) .endpointOf("https://sdmxcentral.imf.org/ws/public/sdmxapi/rest") @@ -138,7 +138,7 @@ public final class Sdmx21Driver implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("INEGI") + .id("INEGI") .descriptionOf("Instituto Nacional de Estadistica y Geografia") .driver(CONNECTORS_SDMX_21) .endpointOf("https://sdmx.snieg.mx/service/Rest") @@ -148,7 +148,7 @@ public final class Sdmx21Driver implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("ISTAT") + .id("ISTAT") .descriptionOf("Istituto Nazionale di Statistica") .driver(CONNECTORS_SDMX_21) .endpointOf("https://esploradati.istat.it/SDMXWS/rest") @@ -160,7 +160,7 @@ public final class Sdmx21Driver implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("NB") + .id("NB") .descriptionOf("Norges Bank") .description("en", "Norges Bank") .description("no", "Norges Bank") @@ -173,7 +173,7 @@ public final class Sdmx21Driver implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("SGR") + .id("SGR") .descriptionOf("SDMX Global Registry") .description("en", "SDMX Global Registry") .driver(CONNECTORS_SDMX_21) @@ -185,7 +185,7 @@ public final class Sdmx21Driver implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("SIMEL") + .id("SIMEL") .descriptionOf("El Salvador Labour Market Information System") .driver(CONNECTORS_SDMX_21) .endpointOf("https://disseminatesimel.mtps.gob.sv/rest") @@ -196,7 +196,7 @@ public final class Sdmx21Driver implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("SPC") + .id("SPC") .descriptionOf("Pacific Data Hub") .description("en", "Pacific Data Hub") .description("fr", "Pacific Data Hub") @@ -209,7 +209,7 @@ public final class Sdmx21Driver implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("STATEC") + .id("STATEC") .descriptionOf("National Institute of statistics and economic studies of the Grand Duchy of Luxembourg") .description("en", "National Institute of statistics and economic studies of the Grand Duchy of Luxembourg") .description("fr", "Institut national de la statistique et des études économiques du Grand-Duché de Luxembourg") @@ -222,7 +222,7 @@ public final class Sdmx21Driver implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("UNDATA") + .id("UNDATA") .descriptionOf("Data access system to UN databases") .description("en", "Data access system to UN databases") .driver(CONNECTORS_SDMX_21) @@ -234,7 +234,7 @@ public final class Sdmx21Driver implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("WB") + .id("WB") .descriptionOf("World Bank") .driver(CONNECTORS_SDMX_21) .endpointOf("https://api.worldbank.org/v2/sdmx/rest") @@ -245,7 +245,7 @@ public final class Sdmx21Driver implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("WITS") + .id("WITS") .descriptionOf("World Integrated Trade Solutions") .driver(CONNECTORS_SDMX_21) .endpointOf("http://wits.worldbank.org/API/V1/SDMX/V21/rest") diff --git a/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/SeDriver.java b/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/SeDriver.java index ffd5ea644..bd64562ac 100644 --- a/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/SeDriver.java +++ b/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/SeDriver.java @@ -48,7 +48,7 @@ public final class SeDriver implements WebDriver { .defaultDialect(SDMX20_DIALECT) .source(SdmxWebSource .builder() - .name("SE") + .id("SE") .descriptionOf("Statistics Estonia") .driver(CONNECTORS_SE) .endpointOf("http://andmebaas.stat.ee/restsdmx/sdmx.ashx") diff --git a/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/UisDriver.java b/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/UisDriver.java index 6cffabef5..03e44f774 100644 --- a/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/UisDriver.java +++ b/sdmx-dl-provider-connectors/src/main/java/internal/sdmxdl/provider/connectors/drivers/UisDriver.java @@ -50,7 +50,7 @@ public final class UisDriver implements WebDriver { .defaultDialect(SDMX20_DIALECT) .source(SdmxWebSource .builder() - .name("UIS") + .id("UIS") .descriptionOf("Unesco Institute for Statistics") .driver(CONNECTORS_UIS) .endpointOf(FALLBACK_ENDPOINT) diff --git a/sdmx-dl-provider-connectors/src/test/java/internal/sdmxld/connectors/drivers/Sdmx20DriverTest.java b/sdmx-dl-provider-connectors/src/test/java/internal/sdmxld/connectors/drivers/Sdmx20DriverTest.java index f2e4341f4..28af438fe 100644 --- a/sdmx-dl-provider-connectors/src/test/java/internal/sdmxld/connectors/drivers/Sdmx20DriverTest.java +++ b/sdmx-dl-provider-connectors/src/test/java/internal/sdmxld/connectors/drivers/Sdmx20DriverTest.java @@ -36,7 +36,7 @@ public void testCompliance() { @Test public void testConnect() { - SdmxWebSource x = SdmxWebSource.builder().name("localhost").driver("connectors:sdmx20").dialect(SDMX20_DIALECT).endpointOf("http://localhost").build(); + SdmxWebSource x = SdmxWebSource.builder().id("localhost").driver("connectors:sdmx20").dialect(SDMX20_DIALECT).endpointOf("http://localhost").build(); assertThatCode(() -> new Sdmx20Driver().connect(x, WebDriverAssert.noOpWebContext()).close()).doesNotThrowAnyException(); } diff --git a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/file/XmlFileClient.java b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/file/XmlFileClient.java index 1c04d3e25..c52592aec 100644 --- a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/file/XmlFileClient.java +++ b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/file/XmlFileClient.java @@ -27,9 +27,10 @@ import sdmxdl.file.SdmxFileSource; import sdmxdl.format.DataCursor; import sdmxdl.format.ObsParser; -import sdmxdl.format.xml.XmlMediaTypes; import sdmxdl.format.xml.SdmxXmlStreams; +import sdmxdl.format.xml.XmlMediaTypes; import sdmxdl.provider.DataRef; +import sdmxdl.provider.Marker; import sdmxdl.provider.file.FileClient; import sdmxdl.provider.file.FileInfo; @@ -60,6 +61,11 @@ public class XmlFileClient implements FileClient { @lombok.NonNull BiConsumer eventListener; + @Override + public @NonNull Marker getMarker() { + return Marker.of(source); + } + @Override public void testClient() throws IOException { if (!source.getData().exists()) { diff --git a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/RiRestClient.java b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/RiRestClient.java index 8a9db12bf..1e8605de1 100644 --- a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/RiRestClient.java +++ b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/RiRestClient.java @@ -26,6 +26,7 @@ import sdmxdl.format.ObsParser; import sdmxdl.provider.CommonSdmxExceptions; import sdmxdl.provider.DataRef; +import sdmxdl.provider.Marker; import sdmxdl.provider.web.RestClient; import sdmxdl.web.SdmxWebSource; import sdmxdl.web.spi.WebContext; @@ -46,7 +47,7 @@ public class RiRestClient implements RestClient { public static @NonNull RiRestClient of(@NonNull SdmxWebSource s, @NonNull WebContext c, @NonNull RiRestQueries queries, @NonNull RiRestParsers parsers, boolean detailSupported) throws IOException { return new RiRestClient( - s.getId(), + Marker.of(s), s.getEndpoint().toURL(), c.getLanguages(), ObsParser::newDefault, @@ -57,7 +58,7 @@ public class RiRestClient implements RestClient { } @lombok.Getter - protected final String name; + protected final Marker marker; protected final URL endpoint; protected final LanguagePriorityList langs; protected final Supplier obsFactory; diff --git a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/authenticators/WinPasswordVaultAuthenticator.java b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/authenticators/WinPasswordVaultAuthenticator.java index 78fbc1f73..d814742ed 100644 --- a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/authenticators/WinPasswordVaultAuthenticator.java +++ b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/authenticators/WinPasswordVaultAuthenticator.java @@ -20,7 +20,7 @@ public boolean isAvailable() { @Override public PasswordAuthentication getPasswordAuthentication(SdmxWebSource source) throws IOException { try (WinPasswordVault vault = WinPasswordVault.open()) { - String message = "Enter your credentials for " + source.getName(); + String message = "Enter your credentials for " + source.getId(); return toPasswordAuthentication(vault.getOrPrompt(getResource(source), message, false)); } } diff --git a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/BbkDriver.java b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/BbkDriver.java index ac1aac3bb..aba06fdca 100644 --- a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/BbkDriver.java +++ b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/BbkDriver.java @@ -27,6 +27,7 @@ import sdmxdl.*; import sdmxdl.format.ObsParser; import sdmxdl.provider.DataRef; +import sdmxdl.provider.Marker; import sdmxdl.provider.SdmxFix; import sdmxdl.provider.web.RestConnector; import sdmxdl.provider.web.WebDriverSupport; @@ -60,7 +61,7 @@ public final class BbkDriver implements WebDriver { .defaultDialect(DIALECT) .source(SdmxWebSource .builder() - .name("BBK") + .id("BBK") .descriptionOf("Deutsche Bundesbank") .description("en", "Deutsche Bundesbank") .description("de", "Deutsche Bundesbank") @@ -77,7 +78,7 @@ static final class BbkRestClient extends RiRestClient { BbkRestClient(SdmxWebSource s, WebContext c) throws IOException { super( - s.getId(), + Marker.of(s), s.getEndpoint().toURL(), c.getLanguages(), ObsParser::newDefault, diff --git a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/DotStatDriver2.java b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/DotStatDriver2.java index 6b35c6e5b..ed6bf5013 100644 --- a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/DotStatDriver2.java +++ b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/DotStatDriver2.java @@ -16,7 +16,6 @@ */ package internal.sdmxdl.provider.ri.web.drivers; -import internal.sdmxdl.provider.ri.web.RiHttpUtils; import internal.sdmxdl.provider.ri.web.DotStatRestParsers; import internal.sdmxdl.provider.ri.web.DotStatRestQueries; import internal.sdmxdl.provider.ri.web.RiRestClient; @@ -53,7 +52,7 @@ public final class DotStatDriver2 implements WebDriver { .defaultDialect(SDMX20_DIALECT) .source(SdmxWebSource .builder() - .name("OECD") + .id("OECD") .descriptionOf("The Organisation for Economic Co-operation and Development") .description("en", "The Organisation for Economic Co-operation and Development") .description("es", "Organización para la Cooperación y el Desarrollo Económicos") @@ -67,7 +66,7 @@ public final class DotStatDriver2 implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("SE") + .id("SE") .descriptionOf("Statistics Estonia") .description("en", "Statistics Estonia") .description("et", "Statistikaameti") @@ -79,7 +78,7 @@ public final class DotStatDriver2 implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("UIS") + .id("UIS") .descriptionOf("Unesco Institute for Statistics") .description("en", "Unesco Institute for Statistics") .description("fr", "Unesco Institut de statistique") @@ -91,7 +90,7 @@ public final class DotStatDriver2 implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("UKDS") + .id("UKDS") .descriptionOf("UK Data Service") .description("en", "UK Data Service") .driver(RI_DOTSTAT) diff --git a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/EurostatDriver2.java b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/EurostatDriver2.java index 24d474bb9..0658de6bf 100644 --- a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/EurostatDriver2.java +++ b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/EurostatDriver2.java @@ -34,9 +34,10 @@ import sdmxdl.format.ObsParser; import sdmxdl.format.xml.SdmxXmlStreams; import sdmxdl.format.xml.XmlMediaTypes; +import sdmxdl.provider.Marker; import sdmxdl.provider.SdmxFix; -import sdmxdl.provider.web.RestConnector; import sdmxdl.provider.web.RestClient; +import sdmxdl.provider.web.RestConnector; import sdmxdl.provider.web.WebDriverSupport; import sdmxdl.web.SdmxWebSource; import sdmxdl.web.spi.WebContext; @@ -84,7 +85,7 @@ public final class EurostatDriver2 implements WebDriver { .defaultDialect(SDMX21_DIALECT) .source(SdmxWebSource .builder() - .name("ESTAT") + .id("ESTAT") .alias("EUROSTAT") .descriptionOf("Eurostat") .description("en", "Eurostat") @@ -100,7 +101,7 @@ public final class EurostatDriver2 implements WebDriver { private static RestClient newClient(SdmxWebSource s, WebContext c) throws IOException { return new RiRestClient( - s.getId(), + Marker.of(s), s.getEndpoint().toURL(), c.getLanguages(), ObsParser::newDefault, diff --git a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/ImfDriver2.java b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/ImfDriver2.java index 35b5b2c3c..e2cbf01f8 100644 --- a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/ImfDriver2.java +++ b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/ImfDriver2.java @@ -65,7 +65,7 @@ public final class ImfDriver2 implements WebDriver { .defaultDialect(SDMX20_DIALECT) .source(SdmxWebSource .builder() - .name("IMF") + .id("IMF") .descriptionOf("International Monetary Fund") .description("en", "International Monetary Fund") .driver(RI_IMF) diff --git a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/InseeDriver2.java b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/InseeDriver2.java index a2f4b5d3a..390078678 100644 --- a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/InseeDriver2.java +++ b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/InseeDriver2.java @@ -34,6 +34,7 @@ import sdmxdl.format.time.StandardReportingFormat; import sdmxdl.format.time.TimeFormats; import sdmxdl.format.xml.XmlMediaTypes; +import sdmxdl.provider.Marker; import sdmxdl.provider.SdmxFix; import sdmxdl.provider.web.RestConnector; import sdmxdl.provider.web.WebDriverSupport; @@ -67,7 +68,7 @@ public final class InseeDriver2 implements WebDriver { .defaultDialect(DIALECT) .source(SdmxWebSource .builder() - .name("INSEE") + .id("INSEE") .descriptionOf("National Institute of Statistics and Economic Studies") .description("en", "National Institute of Statistics and Economic Studies") .description("fr", "Institut national de la statistique et des études économiques") @@ -105,7 +106,7 @@ private final static class InseeRestClient extends RiRestClient { InseeRestClient(SdmxWebSource s, WebContext c) throws IOException { super( - s.getId(), + Marker.of(s), s.getEndpoint().toURL(), c.getLanguages(), OBS_FACTORY, diff --git a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/NbbDriver2.java b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/NbbDriver2.java index 785fced8f..25ccec391 100644 --- a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/NbbDriver2.java +++ b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/NbbDriver2.java @@ -33,6 +33,7 @@ import sdmxdl.LanguagePriorityList; import sdmxdl.format.ObsParser; import sdmxdl.provider.DataRef; +import sdmxdl.provider.Marker; import sdmxdl.provider.SdmxFix; import sdmxdl.provider.web.RestConnector; import sdmxdl.provider.web.WebDriverSupport; @@ -67,7 +68,7 @@ public final class NbbDriver2 implements WebDriver { .defaultDialect(SDMX20_DIALECT) .source(SdmxWebSource .builder() - .name("NBB") + .id("NBB") .descriptionOf("National Bank of Belgium") .description("en", "National Bank of Belgium") .description("de", "Belgische National Bank") @@ -83,7 +84,7 @@ public final class NbbDriver2 implements WebDriver { private static RiRestClient newClient(SdmxWebSource s, WebContext c) throws IOException { return newClient( - s.getId(), + Marker.of(s), s.getEndpoint().toURL(), c.getLanguages(), RiHttpUtils.newClient(s, c) @@ -91,8 +92,8 @@ private static RiRestClient newClient(SdmxWebSource s, WebContext c) throws IOEx } @VisibleForTesting - static @NonNull RiRestClient newClient(@NonNull String name, @NonNull URL endpoint, @NonNull LanguagePriorityList langs, @NonNull HttpClient executor) { - return new RiRestClient(name, endpoint, langs, ObsParser::newDefault, + static @NonNull RiRestClient newClient(@NonNull Marker marker, @NonNull URL endpoint, @NonNull LanguagePriorityList langs, @NonNull HttpClient executor) { + return new RiRestClient(marker, endpoint, langs, ObsParser::newDefault, new InterceptingClient(executor, (client, request, response) -> checkInternalErrorRedirect(response)), new NbbQueries(), new DotStatRestParsers(), diff --git a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/PxWebDriver.java b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/PxWebDriver.java index 940a362a2..8dceffffb 100644 --- a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/PxWebDriver.java +++ b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/PxWebDriver.java @@ -25,7 +25,8 @@ import sdmxdl.format.time.ObservationalTimePeriod; import sdmxdl.format.xml.SdmxXmlStreams; import sdmxdl.provider.ConnectionSupport; -import sdmxdl.provider.HasSourceName; +import sdmxdl.provider.HasMarker; +import sdmxdl.provider.Marker; import sdmxdl.provider.TypedId; import sdmxdl.provider.web.WebDriverSupport; import sdmxdl.web.SdmxWebSource; @@ -68,7 +69,7 @@ public final class PxWebDriver implements WebDriver { .supportedPropertyOf(CACHE_TTL_PROPERTY) .source(SdmxWebSource .builder() - .name("STATFIN") + .id("STATFIN") .descriptionOf("Statistics Finland") .description("en", "Statistics Finland") .description("sv", "Statistikcentralen") @@ -81,8 +82,8 @@ public final class PxWebDriver implements WebDriver { private static @NonNull Connection newConnection(@NonNull SdmxWebSource source, @NonNull WebContext context) throws IOException { PxWebClient client = new DefaultPxWebClient( - source.getName(), - source.getName().toLowerCase(Locale.ROOT), + Marker.of(source), + source.getId().toLowerCase(Locale.ROOT), source.getEndpoint().toURL(), RiHttpUtils.newClient(source, context) ); @@ -146,7 +147,7 @@ public void close() { } } - private interface PxWebClient extends HasSourceName { + private interface PxWebClient extends HasMarker { @NonNull Config getConfig() throws IOException; @@ -162,7 +163,7 @@ private static final class DefaultPxWebClient implements PxWebClient { @lombok.Getter @lombok.NonNull - private final String name; + private final Marker marker; @lombok.NonNull private final String dbId; @@ -291,8 +292,8 @@ private static TypedId initIdOfMeta(URI base) { } @Override - public @NonNull String getName() { - return delegate.getName(); + public @NonNull Marker getMarker() { + return delegate.getMarker(); } @Override diff --git a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/RngDriver.java b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/RngDriver.java index e07898617..3abc59a8c 100644 --- a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/RngDriver.java +++ b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/RngDriver.java @@ -8,7 +8,8 @@ import nbbrd.service.ServiceProvider; import sdmxdl.*; import sdmxdl.provider.ConnectionSupport; -import sdmxdl.provider.HasSourceName; +import sdmxdl.provider.HasMarker; +import sdmxdl.provider.Marker; import sdmxdl.provider.web.WebDriverSupport; import sdmxdl.web.SdmxWebSource; import sdmxdl.web.spi.WebContext; @@ -49,7 +50,7 @@ public final class RngDriver implements WebDriver { .connector(RngDriver::newConnection) .source(SdmxWebSource .builder() - .name("RNG") + .id("RNG") .descriptionOf("Random number generator") .description("en", "Random number generator") .driver(RI_RNG) @@ -60,7 +61,7 @@ public final class RngDriver implements WebDriver { private static @NonNull Connection newConnection(@NonNull SdmxWebSource source, @NonNull WebContext context) { RngDriverId config = RngDriverId.parse(source.getEndpoint()); - return new RngConnection(source.getId(), config); + return new RngConnection(Marker.of(source), config); } @RepresentableAs(URI.class) @@ -98,13 +99,13 @@ public static RngDriverId parse(URI endpoint) throws IllegalArgumentException { } @lombok.AllArgsConstructor - private static final class RngConnection implements Connection, HasSourceName { + private static final class RngConnection implements Connection, HasMarker { private static final String FREQ = "FREQ"; private static final String INDEX = "INDEX"; @lombok.Getter - private final String name; + private final Marker marker; private final RngDriverId config; @Override diff --git a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/Sdmx21Driver2.java b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/Sdmx21Driver2.java index da75bf97f..fab52f6e4 100644 --- a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/Sdmx21Driver2.java +++ b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/Sdmx21Driver2.java @@ -54,7 +54,7 @@ public final class Sdmx21Driver2 implements WebDriver { .defaultDialect(SDMX21_DIALECT) .source(SdmxWebSource .builder() - .name("ABS") + .id("ABS") .descriptionOf("Australian Bureau of Statistics") .description("en", "Australian Bureau of Statistics") .driver(RI_SDMX_21) @@ -66,7 +66,7 @@ public final class Sdmx21Driver2 implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("BIS") + .id("BIS") .descriptionOf("Bank for International Settlements") .description("en", "Bank for International Settlements") .driver(RI_SDMX_21) @@ -78,7 +78,7 @@ public final class Sdmx21Driver2 implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("CAMSTAT") + .id("CAMSTAT") .descriptionOf("National Institute of Statistics of Cambodia") .description("en", "National Institute of Statistics of Cambodia") .description("km", " វិទ្យាស្ថានជាតិស្ថិតិ") @@ -90,7 +90,7 @@ public final class Sdmx21Driver2 implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("ECB") + .id("ECB") .descriptionOf("European Central Bank") .description("en", "European Central Bank") .driver(RI_SDMX_21) @@ -103,7 +103,7 @@ public final class Sdmx21Driver2 implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("ESCAP") + .id("ESCAP") .descriptionOf("Economic and Social Commission for Asia and the Pacific") .description("en", "Economic and Social Commission for Asia and the Pacific") .driver(RI_SDMX_21) @@ -114,7 +114,7 @@ public final class Sdmx21Driver2 implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("ILO") + .id("ILO") .descriptionOf("International Labour Organization") .description("en", "International Labour Organization") .description("es", "Organzación Internacional de Trabajo") @@ -128,7 +128,7 @@ public final class Sdmx21Driver2 implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("IMF_SDMX_CENTRAL") + .id("IMF_SDMX_CENTRAL") .descriptionOf("International Monetary Fund (SDMX Central)") .description("en", "International Monetary Fund (SDMX Central)") .description("fr", "Fonds monétaire international (SDMX Central)") @@ -141,7 +141,7 @@ public final class Sdmx21Driver2 implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("INEGI") + .id("INEGI") .descriptionOf("National Institute of Statistics, Geography and Informatics") .description("en", "National Institute of Statistics, Geography and Informatics") .description("es", "Instituto Nacional de Estadística, Geografía e Informática") @@ -155,7 +155,7 @@ public final class Sdmx21Driver2 implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("ISTAT") + .id("ISTAT") .descriptionOf("Italian National Institute of Statistics") .description("en", "Italian National Institute of Statistics") .description("it", "Istituto Nazionale di Statistica") @@ -168,7 +168,7 @@ public final class Sdmx21Driver2 implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("NB") + .id("NB") .descriptionOf("Norges Bank") .description("en", "Norges Bank") .description("no", "Norges Bank") @@ -181,7 +181,7 @@ public final class Sdmx21Driver2 implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("SGR") + .id("SGR") .descriptionOf("SDMX Global Registry") .description("en", "SDMX Global Registry") .driver(RI_SDMX_21) @@ -193,7 +193,7 @@ public final class Sdmx21Driver2 implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("SIMEL") + .id("SIMEL") .descriptionOf("El Salvador Labor Market Information System") .description("en", "El Salvador Labor Market Information System") .description("es", "Sistema de Información del Mercado Laboral") @@ -206,7 +206,7 @@ public final class Sdmx21Driver2 implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("SPC") + .id("SPC") .descriptionOf("Pacific Data Hub") .description("en", "Pacific Data Hub") .description("fr", "Pacific Data Hub") @@ -219,7 +219,7 @@ public final class Sdmx21Driver2 implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("STATEC") + .id("STATEC") .descriptionOf("National Institute of statistics and economic studies of the Grand Duchy of Luxembourg") .description("en", "National Institute of statistics and economic studies of the Grand Duchy of Luxembourg") .description("fr", "Institut national de la statistique et des études économiques du Grand-Duché de Luxembourg") @@ -232,7 +232,7 @@ public final class Sdmx21Driver2 implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("TNSO") + .id("TNSO") .descriptionOf("National Statistical Office of Thailand") .description("en", "National Statistical Office of Thailand") .description("th", "สำนักงานสถิติแห่งชาติ") @@ -245,7 +245,7 @@ public final class Sdmx21Driver2 implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("UNDATA") + .id("UNDATA") .descriptionOf("Data access system to UN databases") .description("en", "Data access system to UN databases") .driver(RI_SDMX_21) @@ -257,7 +257,7 @@ public final class Sdmx21Driver2 implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("UNICEF") + .id("UNICEF") .descriptionOf("UN International Children's Emergency Fund") .description("en", "UN International Children's Emergency Fund") .driver(RI_SDMX_21) @@ -269,7 +269,7 @@ public final class Sdmx21Driver2 implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("WB") + .id("WB") .descriptionOf("World Bank") .description("en", "World Bank") .description("es", "Banco Mundial") @@ -284,7 +284,7 @@ public final class Sdmx21Driver2 implements WebDriver { .build()) .source(SdmxWebSource .builder() - .name("WITS") + .id("WITS") .descriptionOf("World Integrated Trade Solutions") .description("en", "World Integrated Trade Solution") .description("es", "Solución Comercial Integrada Mundial") diff --git a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/StatCanDriver.java b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/StatCanDriver.java index 62707f756..07aac46e4 100644 --- a/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/StatCanDriver.java +++ b/sdmx-dl-provider-ri/src/main/java/internal/sdmxdl/provider/ri/web/drivers/StatCanDriver.java @@ -65,7 +65,7 @@ public final class StatCanDriver implements WebDriver { .supportedPropertyOf(CACHE_TTL_PROPERTY) .source(SdmxWebSource .builder() - .name("STATCAN") + .id("STATCAN") .descriptionOf("Statistics Canada") .description("en", "Statistics Canada") .description("fr", "Statistique Canada") @@ -80,7 +80,7 @@ public final class StatCanDriver implements WebDriver { private static @NonNull Connection newConnection(@NonNull SdmxWebSource source, @NonNull WebContext context) throws IOException { StatCanClient client = new DefaultStatCanClient( - source.getName(), + Marker.of(source), source.getEndpoint().toURL(), context.getLanguages(), newClient(source, context) @@ -156,7 +156,7 @@ public void close() { } @VisibleForTesting - interface StatCanClient extends HasSourceName { + interface StatCanClient extends HasMarker { @NonNull List getFlows() throws IOException; @@ -170,7 +170,7 @@ interface StatCanClient extends HasSourceName { static class DefaultStatCanClient implements StatCanClient { @lombok.Getter - private final String name; + private final Marker marker; private final URL endpoint; private final LanguagePriorityList langs; private final HttpClient client; @@ -298,8 +298,8 @@ private static TypedId initIdOfRepo(URI base) { } @Override - public @NonNull String getName() { - return delegate.getName(); + public @NonNull Marker getMarker() { + return delegate.getMarker(); } @Override diff --git a/sdmx-dl-provider-ri/src/test/java/internal/sdmxdl/provider/ri/web/RiHttpUtilsTest.java b/sdmx-dl-provider-ri/src/test/java/internal/sdmxdl/provider/ri/web/RiHttpUtilsTest.java index d31708578..9f00a1ea1 100644 --- a/sdmx-dl-provider-ri/src/test/java/internal/sdmxdl/provider/ri/web/RiHttpUtilsTest.java +++ b/sdmx-dl-provider-ri/src/test/java/internal/sdmxdl/provider/ri/web/RiHttpUtilsTest.java @@ -29,7 +29,7 @@ public void testFactory() { SdmxWebSource source = SdmxWebSource .builder() - .name("abc") + .id("abc") .driver("xyz") .endpointOf("http://localhost") .build(); diff --git a/sdmx-dl-provider-ri/src/test/java/internal/sdmxdl/provider/ri/web/RiRestClientTest.java b/sdmx-dl-provider-ri/src/test/java/internal/sdmxdl/provider/ri/web/RiRestClientTest.java index e4bab2193..f0acd9473 100644 --- a/sdmx-dl-provider-ri/src/test/java/internal/sdmxdl/provider/ri/web/RiRestClientTest.java +++ b/sdmx-dl-provider-ri/src/test/java/internal/sdmxdl/provider/ri/web/RiRestClientTest.java @@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test; import sdmxdl.*; import sdmxdl.format.ObsParser; +import sdmxdl.provider.Marker; import tests.sdmxdl.api.ByteSource; import tests.sdmxdl.format.xml.SdmxXmlSources; @@ -83,7 +84,7 @@ public void testGetCodelist() throws IOException { private static RiRestClient of(HttpClient executor) throws MalformedURLException { return new RiRestClient( - "abc", + Marker.of("abc"), new URL("http://localhost"), LanguagePriorityList.ANY, ObsParser::newDefault, diff --git a/sdmx-dl-provider-ri/src/test/java/internal/sdmxdl/provider/ri/web/drivers/NbbDriver2Test.java b/sdmx-dl-provider-ri/src/test/java/internal/sdmxdl/provider/ri/web/drivers/NbbDriver2Test.java index 04e251520..84fe8b0ba 100644 --- a/sdmx-dl-provider-ri/src/test/java/internal/sdmxdl/provider/ri/web/drivers/NbbDriver2Test.java +++ b/sdmx-dl-provider-ri/src/test/java/internal/sdmxdl/provider/ri/web/drivers/NbbDriver2Test.java @@ -20,9 +20,10 @@ import internal.sdmxdl.provider.ri.web.RiRestClient; import internal.util.http.HttpResponseException; import nbbrd.io.net.MediaType; -import sdmxdl.*; import org.junit.jupiter.api.Test; +import sdmxdl.*; import sdmxdl.provider.DataRef; +import sdmxdl.provider.Marker; import tests.sdmxdl.web.WebDriverAssert; import javax.net.ssl.HttpsURLConnection; @@ -103,7 +104,7 @@ public void testCheckInternalErrorRedirect() { private RiRestClient newClient(RestClientResponseMock response) throws MalformedURLException { return NbbDriver2.newClient( - "NBBFIX2", + Marker.of("NBBFIX2"), new URL("https://stat.nbb.be/restsdmx/sdmx.ashx"), LanguagePriorityList.ANY, (httpRequest) -> response);