diff --git a/docs/_ldio/ldio-core/ldio-http-requester.md b/docs/_ldio/ldio-core/ldio-http-requester.md index 64e9d9012..97acb7ebf 100644 --- a/docs/_ldio/ldio-core/ldio-http-requester.md +++ b/docs/_ldio/ldio-core/ldio-http-requester.md @@ -38,3 +38,8 @@ This requester supports the below config: enabled: true max-requests-per-minute: 500 ``` + +## Retry +When retries are enabled, the following statuses are always retried, regardless of the configured statuses-to-retry: +- 5xx (500 and above) +- 429 \ No newline at end of file diff --git a/docs/_ldio/ldio-inputs/art/ldes-client-connector.svg b/docs/_ldio/ldio-inputs/art/ldes-client-connector.svg new file mode 100644 index 000000000..f1c1d5e92 --- /dev/null +++ b/docs/_ldio/ldio-inputs/art/ldes-client-connector.svg @@ -0,0 +1,4 @@ + + + +
Actor
Actor
Consumer connector
Consumer connector
Provider connector
Provider connector
LDES Server
LDES Server
LDES Client
LDES Client
transfer endpoint
transfer...
token endpoint
token en...
Authorization token
Authorizat...
Text is not SVG - cannot display
\ No newline at end of file diff --git a/docs/_ldio/ldio-inputs/ldio-ldes-client-connector.md b/docs/_ldio/ldio-inputs/ldio-ldes-client-connector.md new file mode 100644 index 000000000..b86dfbcbd --- /dev/null +++ b/docs/_ldio/ldio-inputs/ldio-ldes-client-connector.md @@ -0,0 +1,49 @@ +--- + layout: default + parent: LDIO Inputs + title: LDES Client +--- + +# LDIO Ldes Client Connector + +***be.vlaanderen.informatievlaanderen.ldes.ldio.LdioLdesClientConnector*** + +An EDC (Eclipse dataspace Connector) LDIO wrapper component for the [LDI LDES Client building block](../../core/ldi-inputs/ldes-client) + +This component adds EDC support to [the ldio ldes client](./ldio-ldes-client.md). If you'd like to know how to configure the LDES Client, +we refer to [the ldio ldes client](./ldio-ldes-client.md). +The additional functionality provided by this component makes it possible to use the Ldes Client to consume an LDES through an EDC connector. +This component exposes two endpoints: + +1. http://://transfer + The Ldio component will start the data transfer with the connector. You have to send the transfer request to + the LdioLdesClientConnector instead of the EDC consumer connector. The LDIO Ldes Client Connector will start the transfer + with the connector and also keep the transfer alive while consuming the LDES (e.g. request a new token when it expires). +3. http://://token + This endpoint should never be called directly. This is the callback to be provided in the transfer request. + The EDC connector will use this callback endpoint to provide the LDES Client with a token. + +![img](./art/ldes-client-connector.svg) + +## Config + +| Property | Description | Required | Default | Example | Supported values | +|:-----------------------|:----------------------------------------------------------------------------------------------------------------|:---------|:-------------|:----------------------------------------------------------------|:--------------------| +| connector-transfer-url | The transfer url of the EDC connector which has to be called to start a transfer | Yes | N/A | http://consumer-connector:29193/management/v2/transferprocesses | HTTP and HTTPS urls | +| proxy-url-to-replace | Makes it possible to proxy a part of the url of the LDES**. Indicates which part of the url should be replaced. | No | empty string | http://ldes-behind-connectors.dev | string | +| proxy-url-replacement | Makes it possible to proxy a part of the url of the LDES**. Indicates the replacement url part. | No | memory | http://consumer-connector:29193 | string | +** The url mentioned here are the actual url's used by the LDES Server (hostname). These are included in the results bodies to indicate relations, etc. This is a temporary solution until the client and server support relative urls. + + +## Examples + +```yaml +input: + name: be.vlaanderen.informatievlaanderen.ldes.ldio.LdioLdesClientConnector + config: + url: http://consumer-connector:29291/public + connector-transfer-url: http://consumer-connector:29193/management/v2/transferprocesses + proxy-url-to-replace: http://localhost:8081/devices + proxy-url-replacement: http://consumer-connector:29291/public + source-format: application/n-quads +``` diff --git a/docs/assets/images/vlaanderen_header.png b/docs/assets/images/vlaanderen_header.png deleted file mode 100644 index 54aa995a4..000000000 Binary files a/docs/assets/images/vlaanderen_header.png and /dev/null differ diff --git a/ldi-api/pom.xml b/ldi-api/pom.xml index 121f2c7ab..c26e5381d 100644 --- a/ldi-api/pom.xml +++ b/ldi-api/pom.xml @@ -3,7 +3,7 @@ be.vlaanderen.informatievlaanderen.ldes linked-data-interactions - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 diff --git a/ldi-api/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/types/LdiOneToManyTransformer.java b/ldi-api/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/types/LdiOneToManyTransformer.java new file mode 100644 index 000000000..abbc04c32 --- /dev/null +++ b/ldi-api/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/types/LdiOneToManyTransformer.java @@ -0,0 +1,9 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldi.types; + +import org.apache.jena.rdf.model.Model; + +import java.util.List; + +public interface LdiOneToManyTransformer extends LdiComponent { + List transform(Model model); +} diff --git a/ldi-api/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/types/LdiTransformer.java b/ldi-api/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/types/LdiOneToOneTransformer.java similarity index 69% rename from ldi-api/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/types/LdiTransformer.java rename to ldi-api/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/types/LdiOneToOneTransformer.java index 460fdcbc6..5d8f5cb8e 100644 --- a/ldi-api/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/types/LdiTransformer.java +++ b/ldi-api/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/types/LdiOneToOneTransformer.java @@ -2,14 +2,12 @@ import org.apache.jena.rdf.model.Model; -import java.util.Collection; -import java.util.function.Function; - /** * The LDI Transformer provides a user to take a linked data model (RDF) from * the pipeline and perform transformations * onto it. Afterwards, this model will be put back onto the pipeline towards a * next transformer or an LDI Output. */ -public interface LdiTransformer extends LdiComponent, Function> { +public interface LdiOneToOneTransformer extends LdiComponent { + Model transform(Model model); } diff --git a/ldi-core/file-archiving/pom.xml b/ldi-core/file-archiving/pom.xml index 21d612043..5a5dcb8ee 100644 --- a/ldi-core/file-archiving/pom.xml +++ b/ldi-core/file-archiving/pom.xml @@ -6,7 +6,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldi ldi-core - 1.9.0 + 1.10.0-SNAPSHOT file-archiving diff --git a/ldi-core/file-archiving/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/TimestampFromCurrentTimeExtractorTest.java b/ldi-core/file-archiving/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/TimestampFromCurrentTimeExtractorTest.java index 8cf14c63c..7edafec00 100644 --- a/ldi-core/file-archiving/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/TimestampFromCurrentTimeExtractorTest.java +++ b/ldi-core/file-archiving/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/TimestampFromCurrentTimeExtractorTest.java @@ -23,4 +23,4 @@ void extractTimestamp() { assertTrue(result.isAfter(LocalDateTime.now().minusMinutes(5))); } -} \ No newline at end of file +} diff --git a/ldi-core/geojson-to-wkt/pom.xml b/ldi-core/geojson-to-wkt/pom.xml index c8e2d9268..a2fbca61a 100644 --- a/ldi-core/geojson-to-wkt/pom.xml +++ b/ldi-core/geojson-to-wkt/pom.xml @@ -6,7 +6,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldi ldi-core - 1.9.0 + 1.10.0-SNAPSHOT geojson-to-wkt diff --git a/ldi-core/geojson-to-wkt/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/GeoJsonToWktTransformer.java b/ldi-core/geojson-to-wkt/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/GeoJsonToWktTransformer.java index 1b5bf63ed..90c27b9c2 100644 --- a/ldi-core/geojson-to-wkt/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/GeoJsonToWktTransformer.java +++ b/ldi-core/geojson-to-wkt/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/GeoJsonToWktTransformer.java @@ -1,6 +1,6 @@ package be.vlaanderen.informatievlaanderen.ldes.ldi; -import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiTransformer; +import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiOneToOneTransformer; import org.apache.jena.datatypes.RDFDatatype; import org.apache.jena.datatypes.TypeMapper; import org.apache.jena.rdf.model.*; @@ -11,7 +11,7 @@ import static be.vlaanderen.informatievlaanderen.ldes.ldi.WktConverter.GEOJSON_GEOMETRY; -public class GeoJsonToWktTransformer implements LdiTransformer { +public class GeoJsonToWktTransformer implements LdiOneToOneTransformer { private final WktConverter wktConverter = new WktConverter(); @@ -20,7 +20,7 @@ public class GeoJsonToWktTransformer implements LdiTransformer { * containing geosparql#wktLiteral */ @Override - public List apply(Model model) { + public Model transform(Model model) { final List geometryStatements = model.listStatements(null, GEOJSON_GEOMETRY, (RDFNode) null) .toList(); geometryStatements.forEach(oldGeometryStatement -> { @@ -29,7 +29,7 @@ public List apply(Model model) { model.remove(createModelWithChildStatements(model, oldGeometryStatement)); model.add(newGeometryStatement); }); - return List.of(model); + return model; } private Statement createNewGeometryStatement(Statement oldStatement, Model geometryModel) { @@ -60,5 +60,4 @@ private void addChildStatements(Model model, Resource subject, Set st statements.add(statement); }); } - } diff --git a/ldi-core/geojson-to-wkt/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/GeoJsonToWktTransformerTest.java b/ldi-core/geojson-to-wkt/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/GeoJsonToWktTransformerTest.java index b31a68401..eb7185363 100644 --- a/ldi-core/geojson-to-wkt/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/GeoJsonToWktTransformerTest.java +++ b/ldi-core/geojson-to-wkt/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/GeoJsonToWktTransformerTest.java @@ -1,6 +1,8 @@ package be.vlaanderen.informatievlaanderen.ldes.ldi; -import org.apache.jena.rdf.model.*; +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.Property; +import org.apache.jena.rdf.model.Resource; import org.apache.jena.riot.Lang; import org.apache.jena.riot.RDFParser; import org.apache.jena.vocabulary.RDF; @@ -8,9 +10,7 @@ import static org.apache.jena.rdf.model.ResourceFactory.createProperty; import static org.apache.jena.rdf.model.ResourceFactory.createStatement; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; class GeoJsonToWktTransformerTest { @@ -18,8 +18,8 @@ class GeoJsonToWktTransformerTest { @Test void testApply() { - Model result = transformer.apply( - RDFParser.source("geojson-all-types.json").lang(Lang.JSONLD).build().toModel()).get(0); + Model result = transformer.transform( + RDFParser.source("geojson-all-types.json").lang(Lang.JSONLD).build().toModel()); Model expectedResult = RDFParser.source("result-all-types.json").lang(Lang.JSONLD).build().toModel(); @@ -34,7 +34,7 @@ void shouldThrowException_whenGeometryContainsMultipleTypes() { Property lineStringProperty = createProperty("https://purl.org/geojson/vocab#LineString"); model.add(createStatement(subject, RDF.type, lineStringProperty)); - var exception = assertThrows(IllegalArgumentException.class, () -> transformer.apply(model)); + var exception = assertThrows(IllegalArgumentException.class, () -> transformer.transform(model)); assertEquals("Could not determine http://www.w3.org/1999/02/22-rdf-syntax-ns#type of " + "https://purl.org/geojson/vocab#geometry", exception.getMessage()); diff --git a/ldi-core/json-to-ld-adapter/pom.xml b/ldi-core/json-to-ld-adapter/pom.xml index 56e3d7b17..bf7babb86 100644 --- a/ldi-core/json-to-ld-adapter/pom.xml +++ b/ldi-core/json-to-ld-adapter/pom.xml @@ -6,7 +6,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldi ldi-core - 1.9.0 + 1.10.0-SNAPSHOT json-to-ld-adapter diff --git a/ldi-core/ldes-client/pom.xml b/ldi-core/ldes-client/pom.xml index 1e136c42f..7af35d8bc 100644 --- a/ldi-core/ldes-client/pom.xml +++ b/ldi-core/ldes-client/pom.xml @@ -5,7 +5,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldi ldi-core - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 diff --git a/ldi-core/ldes-client/starting-node/pom.xml b/ldi-core/ldes-client/starting-node/pom.xml index 0fc9d713b..acd7113cb 100644 --- a/ldi-core/ldes-client/starting-node/pom.xml +++ b/ldi-core/ldes-client/starting-node/pom.xml @@ -5,7 +5,7 @@ ldes-client be.vlaanderen.informatievlaanderen.ldes.client - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 starting-node diff --git a/ldi-core/ldes-client/tree-node-fetcher/pom.xml b/ldi-core/ldes-client/tree-node-fetcher/pom.xml index 30b0ba24e..72e800f13 100644 --- a/ldi-core/ldes-client/tree-node-fetcher/pom.xml +++ b/ldi-core/ldes-client/tree-node-fetcher/pom.xml @@ -5,7 +5,7 @@ ldes-client be.vlaanderen.informatievlaanderen.ldes.client - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 tree-node-fetcher diff --git a/ldi-core/ldes-client/tree-node-fetcher/src/main/java/ldes/client/treenodefetcher/domain/valueobjects/TreeNodeRequest.java b/ldi-core/ldes-client/tree-node-fetcher/src/main/java/ldes/client/treenodefetcher/domain/valueobjects/TreeNodeRequest.java index d5c390d3c..bf2765ebe 100644 --- a/ldi-core/ldes-client/tree-node-fetcher/src/main/java/ldes/client/treenodefetcher/domain/valueobjects/TreeNodeRequest.java +++ b/ldi-core/ldes-client/tree-node-fetcher/src/main/java/ldes/client/treenodefetcher/domain/valueobjects/TreeNodeRequest.java @@ -25,7 +25,7 @@ public Request createRequest() { RequestHeaders requestHeaders = new RequestHeaders( List.of(new RequestHeader(HttpHeaders.ACCEPT, lang.getHeaderString()))); if (etag != null) { - requestHeaders = requestHeaders.addRequestHeader(new RequestHeader(HttpHeaders.IF_NONE_MATCH, etag)); + requestHeaders = requestHeaders.withRequestHeader(new RequestHeader(HttpHeaders.IF_NONE_MATCH, etag)); } return new GetRequest(treeNodeUrl, requestHeaders); } diff --git a/ldi-core/ldes-client/tree-node-supplier/pom.xml b/ldi-core/ldes-client/tree-node-supplier/pom.xml index 94f292bd4..377c2a376 100644 --- a/ldi-core/ldes-client/tree-node-supplier/pom.xml +++ b/ldi-core/ldes-client/tree-node-supplier/pom.xml @@ -5,7 +5,7 @@ ldes-client be.vlaanderen.informatievlaanderen.ldes.client - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 tree-node-supplier diff --git a/ldi-core/ldi-common/pom.xml b/ldi-core/ldi-common/pom.xml index 185acd92b..b457f83ce 100644 --- a/ldi-core/ldi-common/pom.xml +++ b/ldi-core/ldi-common/pom.xml @@ -6,7 +6,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldi ldi-core - 1.9.0 + 1.10.0-SNAPSHOT ldi-common diff --git a/ldi-core/ldi-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/rdf/formatter/JsonLdWriter.java b/ldi-core/ldi-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/rdf/formatter/JsonLdFrameWriter.java similarity index 91% rename from ldi-core/ldi-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/rdf/formatter/JsonLdWriter.java rename to ldi-core/ldi-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/rdf/formatter/JsonLdFrameWriter.java index 45049648e..2f9e23ff7 100644 --- a/ldi-core/ldi-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/rdf/formatter/JsonLdWriter.java +++ b/ldi-core/ldi-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/rdf/formatter/JsonLdFrameWriter.java @@ -13,10 +13,10 @@ import static be.vlaanderen.informatievlaanderen.ldes.ldi.rdf.formatter.PrefixAdder.addPrefixesToModel; -public class JsonLdWriter implements LdiRdfWriter { +public class JsonLdFrameWriter implements LdiRdfWriter { private final String frame; - public JsonLdWriter(LdiRdfWriterProperties properties) { + public JsonLdFrameWriter(LdiRdfWriterProperties properties) { this.frame = properties.getJsonLdFrame(); } diff --git a/ldi-core/ldi-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/rdf/formatter/JsonLdPrettyWriter.java b/ldi-core/ldi-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/rdf/formatter/JsonLdPrettyWriter.java new file mode 100644 index 000000000..d4673a156 --- /dev/null +++ b/ldi-core/ldi-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/rdf/formatter/JsonLdPrettyWriter.java @@ -0,0 +1,18 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldi.rdf.formatter; + +import org.apache.jena.rdf.model.Model; +import org.apache.jena.riot.RDFFormat; +import org.apache.jena.riot.RDFWriter; + +import static be.vlaanderen.informatievlaanderen.ldes.ldi.rdf.formatter.PrefixAdder.addPrefixesToModel; + +public class JsonLdPrettyWriter implements LdiRdfWriter { + + @Override + public String write(Model model) { + return RDFWriter.source(addPrefixesToModel(model)) + .format(RDFFormat.JSONLD10_PRETTY) + .asString(); + } + +} diff --git a/ldi-core/ldi-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/rdf/formatter/LdiRdfWriter.java b/ldi-core/ldi-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/rdf/formatter/LdiRdfWriter.java index 12d730125..9ddc78f6a 100644 --- a/ldi-core/ldi-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/rdf/formatter/LdiRdfWriter.java +++ b/ldi-core/ldi-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/rdf/formatter/LdiRdfWriter.java @@ -3,12 +3,16 @@ import org.apache.jena.rdf.model.Model; import org.apache.jena.riot.Lang; +import static org.apache.commons.lang3.StringUtils.isBlank; + public interface LdiRdfWriter { String write(Model model); static LdiRdfWriter getRdfWriter(LdiRdfWriterProperties properties) { if (Lang.JSONLD.equals(properties.getLang())) { - return new JsonLdWriter(properties); + return isBlank(properties.getJsonLdFrame()) + ? new JsonLdPrettyWriter() + : new JsonLdFrameWriter(properties); } else { return new GenericRdfWriter(properties); } diff --git a/ldi-core/ldi-common/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/rdf/formatter/LdiRdfWriterTest.java b/ldi-core/ldi-common/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/rdf/formatter/LdiRdfWriterTest.java index 1b131b227..0ceeeef6e 100644 --- a/ldi-core/ldi-common/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/rdf/formatter/LdiRdfWriterTest.java +++ b/ldi-core/ldi-common/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/rdf/formatter/LdiRdfWriterTest.java @@ -22,6 +22,7 @@ import static org.junit.jupiter.api.Assertions.*; public class LdiRdfWriterTest { + @Test void formatModel_jsonLD() throws IOException, URISyntaxException { String input = getFileContentString("rdf/formatter/product.jsonld"); @@ -31,16 +32,35 @@ void formatModel_jsonLD() throws IOException, URISyntaxException { .toModel(); String frame = getFileContentString("rdf/formatter/product.frame.jsonld"); - JsonObject expected = JSON.parse(getFileContentString("rdf/formatter/expected/product.jsonld")); + Model expected = RDFParser.fromString(getFileContentString("rdf/formatter/expected/product.jsonld")) + .lang(Lang.JSONLD).toModel(); LdiRdfWriterProperties writerProperties = new LdiRdfWriterProperties(Map.of(FRAME, frame)); String output = LdiRdfWriter.getRdfWriter(writerProperties.withLang(Lang.JSONLD)).write(model); JsonObject outputJson = JSON.parse(output); + Model outputModel = RDFParser.fromString(output).lang(Lang.JSONLD).toModel(); assertFalse(outputJson.hasKey("@graph")); - assertEquals(expected, outputJson); + assertTrue(outputModel.isIsomorphicWith(expected)); + } + + @Test + void formatModel_jsonLD_withoutFrame() throws IOException, URISyntaxException { + String input = getFileContentString("rdf/formatter/product.jsonld"); + + Model model = RDFParser.fromString(input) + .lang(Lang.JSONLD) + .toModel(); + + LdiRdfWriterProperties writerProperties = new LdiRdfWriterProperties(); + + String output = LdiRdfWriter.getRdfWriter(writerProperties.withLang(Lang.JSONLD)).write(model); + + JsonObject outputJson = JSON.parse(output); + + assertNotNull(outputJson); } @Test @@ -86,7 +106,7 @@ void getFramedContext() { } """; - JsonLDWriteContext context = (JsonLDWriteContext) JsonLdWriter.getFramedContext(frame); + JsonLDWriteContext context = (JsonLDWriteContext) JsonLdFrameWriter.getFramedContext(frame); JsonObject frameObject = JSON.parse((String) context.get(JsonLD10Writer.JSONLD_FRAME)); assertTrue(frameObject.hasKey("@type")); diff --git a/ldi-core/model-splitter/pom.xml b/ldi-core/model-splitter/pom.xml index 74dcc2c27..564491979 100644 --- a/ldi-core/model-splitter/pom.xml +++ b/ldi-core/model-splitter/pom.xml @@ -6,7 +6,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldi ldi-core - 1.9.0 + 1.10.0-SNAPSHOT be.vlaanderen.informatievlaanderen.ldes.ldi diff --git a/ldi-core/model-splitter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/ModelSplitTransformer.java b/ldi-core/model-splitter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/ModelSplitTransformer.java index d60dfd4c2..8c4b455fc 100644 --- a/ldi-core/model-splitter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/ModelSplitTransformer.java +++ b/ldi-core/model-splitter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/ModelSplitTransformer.java @@ -1,23 +1,22 @@ package be.vlaanderen.informatievlaanderen.ldes.ldi; -import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiTransformer; +import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiOneToManyTransformer; import org.apache.jena.rdf.model.Model; -import java.util.Collection; +import java.util.List; -public class ModelSplitTransformer implements LdiTransformer { +public class ModelSplitTransformer implements LdiOneToManyTransformer { private final String subjectType; private final ModelSplitter modelSplitter; - public ModelSplitTransformer(String subjectType, ModelSplitter modelSplitter) { + public ModelSplitTransformer(String subjectType) { this.subjectType = subjectType; - this.modelSplitter = modelSplitter; + this.modelSplitter = new ModelSplitter(); } @Override - public Collection apply(Model model) { + public List transform(Model model) { return modelSplitter.split(model, subjectType); } - } diff --git a/ldi-core/model-splitter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/ModelSplitter.java b/ldi-core/model-splitter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/ModelSplitter.java index 96bcd3421..81a140690 100644 --- a/ldi-core/model-splitter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/ModelSplitter.java +++ b/ldi-core/model-splitter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/ModelSplitter.java @@ -8,18 +8,18 @@ import java.util.ArrayDeque; import java.util.Deque; -import java.util.Set; +import java.util.List; import static org.apache.commons.lang3.ObjectUtils.isNotEmpty; import static org.apache.jena.rdf.model.ResourceFactory.createProperty; public class ModelSplitter { - public Set split(Model inputModel, String subjectType) { + public List split(Model inputModel, String subjectType) { return inputModel .listSubjectsWithProperty(RDF.type, createProperty(subjectType)) .mapWith(subject -> extractModelForSubject(inputModel, subject)) - .toSet(); + .toList(); } private Model extractModelForSubject(Model inputModel, Resource subject) { diff --git a/ldi-core/model-splitter/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/ModelSplitTransformerTest.java b/ldi-core/model-splitter/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/ModelSplitTransformerTest.java index 18dd47a51..d52c532c7 100644 --- a/ldi-core/model-splitter/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/ModelSplitTransformerTest.java +++ b/ldi-core/model-splitter/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/ModelSplitTransformerTest.java @@ -1,39 +1,28 @@ package be.vlaanderen.informatievlaanderen.ldes.ldi; import org.apache.jena.rdf.model.Model; -import org.apache.jena.rdf.model.ModelFactory; +import org.apache.jena.riot.RDFParser; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import java.util.List; -import java.util.Set; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.when; +import static org.junit.jupiter.api.Assertions.assertEquals; @ExtendWith(MockitoExtension.class) class ModelSplitTransformerTest { - @Mock - private ModelSplitter modelSplitter; - @Test void testApply() { - String subjectType = "subjectType"; - ModelSplitTransformer modelSplitTransformer = new ModelSplitTransformer(subjectType, modelSplitter); - Model modelA = ModelFactory.createDefaultModel(); - Model modelB = ModelFactory.createDefaultModel(); - Model modelC = ModelFactory.createDefaultModel(); - when(modelSplitter.split(modelA, subjectType)).thenReturn(Set.of(modelB, modelC)); + String subjectType = "http://schema.org/Movie"; + ModelSplitTransformer modelSplitTransformer = new ModelSplitTransformer(subjectType); + + Model inputModel = RDFParser.source("generic/input.ttl").toModel(); - List result = modelSplitTransformer.apply(modelA).stream().toList(); + List result = modelSplitTransformer.transform(inputModel).stream().toList(); assertEquals(2, result.size()); - assertFalse(result.contains(modelA)); - assertTrue(result.contains(modelB)); - assertTrue(result.contains(modelC)); } } diff --git a/ldi-core/model-splitter/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/ModelSplitterTest.java b/ldi-core/model-splitter/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/ModelSplitterTest.java index 4d5840d79..1db7591a4 100644 --- a/ldi-core/model-splitter/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/ModelSplitterTest.java +++ b/ldi-core/model-splitter/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/ModelSplitterTest.java @@ -17,7 +17,7 @@ class ModelSplitterTest { @Test void test_generic() { Model inputModel = RDFParser.source("generic/input.ttl").toModel(); - Set result = new ModelSplitter().split(inputModel, "http://schema.org/Movie"); + List result = new ModelSplitter().split(inputModel, "http://schema.org/Movie"); assertEquals(2, result.size()); assertModels(List.of("generic/member1.ttl", "generic/member2.ttl"), result); @@ -26,7 +26,7 @@ void test_generic() { @Test void test_crowdscan() { Model inputModel = RDFParser.source("crowdscan/input.ttl").toModel(); - Set result = new ModelSplitter().split(inputModel, + List result = new ModelSplitter().split(inputModel, "http://def.isotc211.org/iso19156/2011/Observation#OM_Observation"); assertEquals(3, result.size()); @@ -37,7 +37,7 @@ void test_crowdscan() { @Test void test_traffic() { Model inputModel = RDFParser.source("traffic/input.ttl").toModel(); - Set result = new ModelSplitter().split(inputModel, + List result = new ModelSplitter().split(inputModel, "https://data.vlaanderen.be/ns/verkeersmetingen#Verkeersmeting"); assertEquals(10, result.size()); @@ -54,7 +54,7 @@ void test_traffic() { "traffic/measure10.ttl"), result); } - private void assertModels(List expectedModelPaths, Set result) { + private void assertModels(List expectedModelPaths, List result) { Set expectedModels = expectedModelPaths .stream() .map(RDFParser::source) diff --git a/ldi-core/ngsiv2-to-ld-adapter/pom.xml b/ldi-core/ngsiv2-to-ld-adapter/pom.xml index 93284e458..8f6917d16 100644 --- a/ldi-core/ngsiv2-to-ld-adapter/pom.xml +++ b/ldi-core/ngsiv2-to-ld-adapter/pom.xml @@ -6,7 +6,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldi ldi-core - 1.9.0 + 1.10.0-SNAPSHOT ngsiv2-to-ld-adapter diff --git a/ldi-core/pom.xml b/ldi-core/pom.xml index 0b4f2e94c..0dbcfa6dc 100644 --- a/ldi-core/pom.xml +++ b/ldi-core/pom.xml @@ -3,7 +3,7 @@ linked-data-interactions be.vlaanderen.informatievlaanderen.ldes - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 diff --git a/ldi-core/rdf-adapter/pom.xml b/ldi-core/rdf-adapter/pom.xml index ade730b4d..2048bb884 100644 --- a/ldi-core/rdf-adapter/pom.xml +++ b/ldi-core/rdf-adapter/pom.xml @@ -5,7 +5,7 @@ ldi-core be.vlaanderen.informatievlaanderen.ldes.ldi - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 diff --git a/ldi-core/repository-materialiser/pom.xml b/ldi-core/repository-materialiser/pom.xml index 26b5e807c..66f811df5 100644 --- a/ldi-core/repository-materialiser/pom.xml +++ b/ldi-core/repository-materialiser/pom.xml @@ -6,7 +6,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldi ldi-core - 1.9.0 + 1.10.0-SNAPSHOT @@ -14,8 +14,6 @@ UTF-8 4.3.6 - - ../.. repository-materialiser diff --git a/ldi-core/request-executor/pom.xml b/ldi-core/request-executor/pom.xml index c70e1e0c0..bb63faa04 100644 --- a/ldi-core/request-executor/pom.xml +++ b/ldi-core/request-executor/pom.xml @@ -5,7 +5,7 @@ ldi-core be.vlaanderen.informatievlaanderen.ldes.ldi - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 request-executor diff --git a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/EdcRequestExecutor.java b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/EdcRequestExecutor.java new file mode 100644 index 000000000..ca8ca7587 --- /dev/null +++ b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/EdcRequestExecutor.java @@ -0,0 +1,41 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc; + +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.RequestExecutor; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.services.TokenService; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.valueobjects.EdcUrlProxy; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects.*; + +import java.util.List; + +public class EdcRequestExecutor implements RequestExecutor { + + private final RequestExecutor requestExecutor; + private final TokenService tokenService; + private final EdcUrlProxy urlProxy; + + public EdcRequestExecutor(RequestExecutor requestExecutor, TokenService tokenService, EdcUrlProxy urlProxy) { + this.requestExecutor = requestExecutor; + this.tokenService = tokenService; + this.urlProxy = urlProxy; + } + + @Override + public Response execute(Request request) { + final Request edcRequest = createEdcRequest(request); + var response = requestExecutor.execute(edcRequest); + if (response.isFobidden()) { + tokenService.invalidateToken(); + return execute(request); + } else { + return response; + } + } + + private Request createEdcRequest(Request request) { + final var tokenHeader = tokenService.waitForTokenHeader(); + final var requestHeaders = new RequestHeaders(List.of(tokenHeader)); + final var url = urlProxy.proxy(request.getUrl()); + return request.with(url).with(requestHeaders); + } + +} diff --git a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/README.md b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/README.md new file mode 100644 index 000000000..e5bd40cce --- /dev/null +++ b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/README.md @@ -0,0 +1,3 @@ +# Eclipse Dataspace Components (EDC) Request executor + +This implementation of the requestExecutor makes it possible to use the LDES Client within [edc](https://github.com/eclipse-edc). \ No newline at end of file diff --git a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/services/MemoryTokenService.java b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/services/MemoryTokenService.java new file mode 100644 index 000000000..bdf52ad22 --- /dev/null +++ b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/services/MemoryTokenService.java @@ -0,0 +1,48 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.services; + +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.valueobjects.EdcToken; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects.RequestHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.time.Duration; + +import static org.apache.commons.lang3.ThreadUtils.sleep; + +public class MemoryTokenService implements TokenService { + + private final TransferService transferService; + private final Logger log = LoggerFactory.getLogger(MemoryTokenService.class); + + private EdcToken token; + + public MemoryTokenService(TransferService transferService) { + this.transferService = transferService; + } + + public RequestHeader waitForTokenHeader() { + if (token != null) { + return token.getTokenHeader(); + } + + try { + log.info("waiting for token.."); + sleep(Duration.ofSeconds(5)); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + + return waitForTokenHeader(); + } + + public void invalidateToken() { + token = null; + transferService.refreshTransfer(); + } + + @Override + public void updateToken(String token) { + this.token = EdcToken.fromJsonString(token); + } + +} diff --git a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/services/MemoryTransferService.java b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/services/MemoryTransferService.java new file mode 100644 index 000000000..e0018b35f --- /dev/null +++ b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/services/MemoryTransferService.java @@ -0,0 +1,46 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.services; + +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.RequestExecutor; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects.PostRequest; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects.RequestHeader; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects.RequestHeaders; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects.Response; +import org.apache.http.HttpHeaders; +import org.apache.http.entity.ContentType; + +import java.util.List; + +public class MemoryTransferService implements TransferService { + + private final RequestExecutor requestExecutor; + private final String consumerConnectorUrl; + private String transfer; + + public MemoryTransferService(RequestExecutor requestExecutor, String consumerConnectorUrl) { + this.requestExecutor = requestExecutor; + this.consumerConnectorUrl = consumerConnectorUrl; + } + + @Override + public Response startTransfer(String transfer) { + this.transfer = transfer; + return sendTransferRequest(); + } + + @Override + public void refreshTransfer() { + if (transfer == null) { + throw new IllegalStateException("A transfer needs to be started before it can be refreshed!"); + } + + sendTransferRequest(); + } + + private Response sendTransferRequest() { + var contentType = new RequestHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType()); + var requestHeaders = new RequestHeaders(List.of(contentType)); + var request = new PostRequest(consumerConnectorUrl, requestHeaders, transfer); + return requestExecutor.execute(request); + } + +} diff --git a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/services/TokenService.java b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/services/TokenService.java new file mode 100644 index 000000000..58db9d9b7 --- /dev/null +++ b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/services/TokenService.java @@ -0,0 +1,13 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.services; + +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects.RequestHeader; + +public interface TokenService { + + RequestHeader waitForTokenHeader(); + + void invalidateToken(); + + void updateToken(String token); + +} diff --git a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/services/TransferService.java b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/services/TransferService.java new file mode 100644 index 000000000..af6e4984b --- /dev/null +++ b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/services/TransferService.java @@ -0,0 +1,11 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.services; + +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects.Response; + +public interface TransferService { + + Response startTransfer(String transfer); + + void refreshTransfer(); + +} diff --git a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/valueobjects/EdcToken.java b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/valueobjects/EdcToken.java new file mode 100644 index 000000000..8ab4ab1d1 --- /dev/null +++ b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/valueobjects/EdcToken.java @@ -0,0 +1,31 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.valueobjects; + +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects.RequestHeader; +import org.apache.jena.atlas.json.JSON; +import org.apache.jena.atlas.json.JsonObject; + +public class EdcToken { + + private final JsonObject token; + + private EdcToken(JsonObject token) { + this.token = token; + } + + public static EdcToken fromJsonString(String token) { + return new EdcToken(JSON.parse(token)); + } + + public RequestHeader getTokenHeader() { + final var authKey = token.get("authKey"); + if (authKey == null) { + throw new IllegalArgumentException("Invalid token: authKey not found"); + } + final var authCode = token.get("authCode"); + if (authCode == null) { + throw new IllegalArgumentException("Invalid token: authCode not found"); + } + return new RequestHeader(authKey.getAsString().value(), authCode.getAsString().value()); + } + +} diff --git a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/valueobjects/EdcUrlProxy.java b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/valueobjects/EdcUrlProxy.java new file mode 100644 index 000000000..cbfe75b68 --- /dev/null +++ b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/valueobjects/EdcUrlProxy.java @@ -0,0 +1,35 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.valueobjects; + +/** + *

+ * Makes it possible to proxy a part of the url. + * For example when you are following an LDES at "www.example.com" + * through a consumer connector "www.my-fictional-connector.com". + *

+ *

+ * When the original LDES has a relation to follow to + * "www.example.com/by-location", this proxy will translate this to + * "www.my-fictional-connector.com/by-location". + *

+ *

+ * In this case "urlToReplace" is "www.example.com" and "replacementUrl" is + * "www.my-fictional-connector.com". + * This component is required until the LDES Server and Client support relative + * urls. + *

+ */ +public class EdcUrlProxy { + + private final String urlToReplace; + private final String replacementUrl; + + public EdcUrlProxy(String urlToReplace, String replacementUrl) { + this.urlToReplace = urlToReplace; + this.replacementUrl = replacementUrl; + } + + public String proxy(String url) { + return url.replace(urlToReplace, replacementUrl); + } + +} diff --git a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/services/RequestExecutorFactory.java b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/services/RequestExecutorFactory.java index e00607d97..967b76e96 100644 --- a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/services/RequestExecutorFactory.java +++ b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/services/RequestExecutorFactory.java @@ -2,6 +2,9 @@ import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.RequestExecutor; import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.clientcredentials.ClientCredentialsConfig; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.EdcRequestExecutor; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.services.TokenService; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.valueobjects.EdcUrlProxy; import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.noauth.ApiKeyConfig; import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.noauth.DefaultConfig; @@ -21,4 +24,10 @@ public RequestExecutor createClientCredentialsExecutor(String clientId, return new ClientCredentialsConfig(clientId, secret, tokenEndpoint).createRequestExecutor(); } + public RequestExecutor createEdcExecutor(RequestExecutor requestExecutor, + TokenService tokenService, + EdcUrlProxy edcUrlProxy) { + return new EdcRequestExecutor(requestExecutor, tokenService, edcUrlProxy); + } + } diff --git a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/GetRequest.java b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/GetRequest.java index 5ab5386e4..31f1e8d7a 100644 --- a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/GetRequest.java +++ b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/GetRequest.java @@ -8,8 +8,19 @@ public GetRequest(String url, RequestHeaders requestHeaders) { super(url, requestHeaders); } + @Override public String getMethod() { return METHOD_NAME; } + @Override + public Request with(String url) { + return new GetRequest(url, requestHeaders); + } + + @Override + public Request with(RequestHeaders requestHeaders) { + return new GetRequest(url, requestHeaders); + } + } diff --git a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/PostRequest.java b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/PostRequest.java index 1fe15028d..c0f428603 100644 --- a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/PostRequest.java +++ b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/PostRequest.java @@ -3,6 +3,8 @@ import org.apache.http.HttpHeaders; import org.apache.http.entity.ContentType; +import java.util.Objects; + public class PostRequest extends Request { public static final String METHOD_NAME = "POST"; @@ -17,6 +19,16 @@ public String getMethod() { return METHOD_NAME; } + @Override + public Request with(String url) { + return new PostRequest(url, requestHeaders, body); + } + + @Override + public Request with(RequestHeaders requestHeaders) { + return new PostRequest(url, requestHeaders, body); + } + public String getBody() { return body; } @@ -28,4 +40,21 @@ public String getContentType() { .orElse(ContentType.TEXT_PLAIN.getMimeType()); } + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + if (!super.equals(o)) + return false; + PostRequest that = (PostRequest) o; + return Objects.equals(body, that.body); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), body); + } + } diff --git a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/Request.java b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/Request.java index faa1acbee..6398cd987 100644 --- a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/Request.java +++ b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/Request.java @@ -1,5 +1,7 @@ package be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects; +import java.util.Objects; + import static org.apache.commons.lang3.Validate.notNull; /** @@ -7,8 +9,8 @@ */ public abstract class Request { - private final String url; - private final RequestHeaders requestHeaders; + final String url; + final RequestHeaders requestHeaders; protected Request(String url, RequestHeaders requestHeaders) { this.url = url; @@ -25,4 +27,23 @@ public RequestHeaders getRequestHeaders() { public abstract String getMethod(); + public abstract Request with(String url); + + public abstract Request with(RequestHeaders requestHeaders); + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + Request request = (Request) o; + return Objects.equals(url, request.url) && Objects.equals(requestHeaders, request.requestHeaders); + } + + @Override + public int hashCode() { + return Objects.hash(url, requestHeaders); + } + } diff --git a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/RequestHeader.java b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/RequestHeader.java index 0e3ef5aeb..92fe9a6e7 100644 --- a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/RequestHeader.java +++ b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/RequestHeader.java @@ -1,5 +1,7 @@ package be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects; +import java.util.Objects; + import static org.apache.commons.lang3.Validate.notNull; public class RequestHeader { @@ -26,4 +28,20 @@ public String getKey() { public String getValue() { return value; } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + RequestHeader that = (RequestHeader) o; + return Objects.equals(key, that.key) && Objects.equals(value, that.value); + } + + @Override + public int hashCode() { + return Objects.hash(key, value); + } + } diff --git a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/RequestHeaders.java b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/RequestHeaders.java index a73d8d263..53a643b23 100644 --- a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/RequestHeaders.java +++ b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/RequestHeaders.java @@ -12,7 +12,7 @@ public RequestHeaders(List requestHeaders) { this.headers = requestHeaders; } - public RequestHeaders addRequestHeader(RequestHeader requestHeader) { + public RequestHeaders withRequestHeader(RequestHeader requestHeader) { ArrayList updatedRequestHeaders = new ArrayList<>(headers); updatedRequestHeaders.add(requestHeader); return new RequestHeaders(updatedRequestHeaders); @@ -32,4 +32,21 @@ public Optional getFirst(String key) { .filter(header -> Objects.equals(lowerCase(header.getKey()), lowerCase(key))) .findFirst(); } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + RequestHeaders that = (RequestHeaders) o; + return new HashSet<>(headers).containsAll(that.headers) + && new HashSet<>(that.headers).containsAll(headers); + } + + @Override + public int hashCode() { + return Objects.hash(headers); + } + } diff --git a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/Response.java b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/Response.java index 74de9c0c6..fd66c47d8 100644 --- a/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/Response.java +++ b/ldi-core/request-executor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/Response.java @@ -41,6 +41,10 @@ public boolean isOk() { return hasStatus(List.of(HttpStatus.SC_OK)); } + public boolean isFobidden() { + return hasStatus(List.of(HttpStatus.SC_FORBIDDEN)); + } + public boolean isRedirect() { final int permanentRedirect = 308; // not yet included in apache library return hasStatus(List.of( diff --git a/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/EdcRequestExecutorTest.java b/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/EdcRequestExecutorTest.java new file mode 100644 index 000000000..c0a18a74f --- /dev/null +++ b/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/EdcRequestExecutorTest.java @@ -0,0 +1,59 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc; + +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.RequestExecutor; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.services.TokenService; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.valueobjects.EdcUrlProxy; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects.GetRequest; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects.RequestHeader; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects.RequestHeaders; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects.Response; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +class EdcRequestExecutorTest { + + @InjectMocks + private EdcRequestExecutor edcRequestExecutor; + + @Mock + private EdcUrlProxy urlProxy; + + @Mock + private RequestExecutor requestExecutor; + + @Mock + private TokenService tokenService; + + @Test + void test_execute() { + final var url = "http://example.org"; + when(urlProxy.proxy(url)).thenReturn(url); + final var requestHeader = new RequestHeader("Authorization", "1234"); + when(tokenService.waitForTokenHeader()).thenReturn(requestHeader); + + final var request = new GetRequest(url, RequestHeaders.empty()); + final var edcRequest = new GetRequest(url, new RequestHeaders(List.of(requestHeader))); + when(requestExecutor.execute(edcRequest)) + .thenReturn(new Response(request, List.of(), 403, null)) + .thenReturn(new Response(request, List.of(), 200, "body")); + + Response response = edcRequestExecutor.execute(request); + + verify(tokenService).invalidateToken(); + assertEquals(200, response.getHttpStatus()); + assertTrue(response.getBody().isPresent()); + assertEquals("body", response.getBody().get()); + } + +} \ No newline at end of file diff --git a/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/services/MemoryTokenServiceTest.java b/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/services/MemoryTokenServiceTest.java new file mode 100644 index 000000000..e2f192e9a --- /dev/null +++ b/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/services/MemoryTokenServiceTest.java @@ -0,0 +1,42 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.services; + +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects.RequestHeader; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.time.Duration; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +@ExtendWith(MockitoExtension.class) +class MemoryTokenServiceTest { + + @Mock + private TransferService transferService; + + @InjectMocks + private MemoryTokenService memoryTokenService; + + @Test + void test_memoryTokenService() { + memoryTokenService.updateToken("{'authKey': 'auth-key', 'authCode': 'auth-code'}"); + // token is found after update + RequestHeader requestHeader = memoryTokenService.waitForTokenHeader(); + assertNotNull(requestHeader); + + verify(transferService, times(0)).refreshTransfer(); + memoryTokenService.invalidateToken(); + + // no token is found after invalidation + final var duration = Duration.ofSeconds(1); + assertThrows(Error.class, + () -> assertTimeoutPreemptively(duration, () -> memoryTokenService.waitForTokenHeader())); + verify(transferService, times(1)).refreshTransfer(); + } + +} \ No newline at end of file diff --git a/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/services/MemoryTransferServiceTest.java b/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/services/MemoryTransferServiceTest.java new file mode 100644 index 000000000..2df0206c5 --- /dev/null +++ b/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/services/MemoryTransferServiceTest.java @@ -0,0 +1,55 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.services; + +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.RequestExecutor; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects.PostRequest; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects.RequestHeader; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects.RequestHeaders; +import org.apache.commons.lang3.reflect.FieldUtils; +import org.apache.http.HttpHeaders; +import org.apache.http.entity.ContentType; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +@ExtendWith(MockitoExtension.class) +class MemoryTransferServiceTest { + + @InjectMocks + private MemoryTransferService memoryTransferService; + + @Mock + private RequestExecutor requestExecutor; + + private final String consumerConnectorUrl = "http://example.org"; + + @BeforeEach + public void setUp() throws IllegalAccessException { + FieldUtils.writeField(memoryTransferService, "consumerConnectorUrl", consumerConnectorUrl, true); + } + + @Test + void refreshTransfer_ShouldThrowException_WhenNoTransferStarted() { + assertThrows(IllegalStateException.class, memoryTransferService::refreshTransfer); + } + + @Test + void startTransfer_AndrefreshTransfer_ShouldSendTransfer_WhenTransferIsAvailable() { + var transfer = "my-transfer"; + memoryTransferService.startTransfer(transfer); + memoryTransferService.refreshTransfer(); + + var contentType = new RequestHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType()); + var requestHeaders = new RequestHeaders(List.of(contentType)); + var request = new PostRequest(consumerConnectorUrl, requestHeaders, transfer); + verify(requestExecutor, times(2)).execute(request); + } +} \ No newline at end of file diff --git a/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/valueobjects/EdcTokenTest.java b/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/valueobjects/EdcTokenTest.java new file mode 100644 index 000000000..73aef59b3 --- /dev/null +++ b/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/valueobjects/EdcTokenTest.java @@ -0,0 +1,41 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.valueobjects; + +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects.RequestHeader; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class EdcTokenTest { + + @Nested + class GetTokenHeader { + + @Test + void shouldThrowException_WhenAuthKeyIsMissing() { + EdcToken edcToken = EdcToken.fromJsonString("{'authCode': 'auth-code'}"); + + var illegalArgumentException = assertThrows(IllegalArgumentException.class, edcToken::getTokenHeader); + assertTrue(illegalArgumentException.getMessage().contains("authKey not found")); + } + + @Test + void shouldThrowException_WhenAuthCodeIsMissing() { + EdcToken edcToken = EdcToken.fromJsonString("{'authKey': 'auth-key'}"); + + var illegalArgumentException = assertThrows(IllegalArgumentException.class, edcToken::getTokenHeader); + assertTrue(illegalArgumentException.getMessage().contains("authCode not found")); + } + + @Test + void shouldReturnToken_WhenPresent() { + EdcToken edcToken = EdcToken.fromJsonString("{'authKey': 'auth-key', 'authCode': 'auth-code'}"); + + RequestHeader tokenHeader = edcToken.getTokenHeader(); + + assertEquals("auth-key", tokenHeader.getKey()); + assertEquals("auth-code", tokenHeader.getValue()); + } + } + +} \ No newline at end of file diff --git a/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/valueobjects/EdcUrlProxyTest.java b/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/valueobjects/EdcUrlProxyTest.java new file mode 100644 index 000000000..923f1b4cb --- /dev/null +++ b/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/executor/edc/valueobjects/EdcUrlProxyTest.java @@ -0,0 +1,18 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.valueobjects; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class EdcUrlProxyTest { + + @Test + void proxy() { + EdcUrlProxy urlProxy = new EdcUrlProxy("www.to-replace.com", "www.replacement.com"); + + String result = urlProxy.proxy("www.to-replace.com/by-page?pageNumber=22"); + + assertEquals("www.replacement.com/by-page?pageNumber=22", result); + } + +} \ No newline at end of file diff --git a/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/GetRequestTest.java b/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/GetRequestTest.java new file mode 100644 index 000000000..5cef2a70c --- /dev/null +++ b/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/GetRequestTest.java @@ -0,0 +1,32 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects; + +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; + +class GetRequestTest { + + @Test + void test_WithUrl() { + var initialRequest = new GetRequest("url", new RequestHeaders(List.of(new RequestHeader("key", "val")))); + + var requestWithOtherUrl = initialRequest.with("other-url"); + assertEquals(initialRequest.getRequestHeaders(), requestWithOtherUrl.getRequestHeaders()); + assertEquals(initialRequest.getMethod(), requestWithOtherUrl.getMethod()); + assertNotEquals(initialRequest.getUrl(), requestWithOtherUrl.getUrl()); + } + + @Test + void test_WithRequestHeaders() { + var initialRequest = new GetRequest("url", new RequestHeaders(List.of(new RequestHeader("key", "val")))); + + var requestWithOtherUrl = initialRequest + .with(new RequestHeaders(List.of(new RequestHeader("other-key", "val")))); + assertNotEquals(initialRequest.getRequestHeaders(), requestWithOtherUrl.getRequestHeaders()); + assertEquals(initialRequest.getMethod(), requestWithOtherUrl.getMethod()); + assertEquals(initialRequest.getUrl(), requestWithOtherUrl.getUrl()); + } + +} \ No newline at end of file diff --git a/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/PostRequestTest.java b/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/PostRequestTest.java index d0874aa09..a7e2bcdcd 100644 --- a/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/PostRequestTest.java +++ b/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/PostRequestTest.java @@ -1,8 +1,16 @@ package be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.ArgumentsProvider; +import org.junit.jupiter.params.provider.ArgumentsSource; import java.util.List; +import java.util.function.BiConsumer; +import java.util.stream.Stream; import static org.junit.jupiter.api.Assertions.*; @@ -28,4 +36,79 @@ void getContentType() { assertEquals(contentType, new PostRequest(URL, new RequestHeaders(requestHeaders), BODY).getContentType()); } + @ParameterizedTest + @ArgumentsSource(EqualityTestProvider.class) + void testEqualsAndHashCode(BiConsumer assertion, PostRequest a, PostRequest b) { + assertNotNull(assertion); + assertion.accept(a, b); + if (a != null && b != null) { + assertion.accept(a.hashCode(), b.hashCode()); + } + } + + static class EqualityTestProvider implements ArgumentsProvider { + + private static final PostRequest requestA = new PostRequest("url", + new RequestHeaders(List.of(new RequestHeader("key", "val"))), "body"); + + @Override + public Stream provideArguments(ExtensionContext context) { + return Stream.of( + Arguments.of(equals(), requestA, requestA), + Arguments.of(equals(), + new PostRequest("url", new RequestHeaders(List.of(new RequestHeader("key", "val"))), + "body"), + requestA), + Arguments.of(notEquals(), + new PostRequest("other-url", new RequestHeaders(List.of(new RequestHeader("key", "val"))), + "body"), + requestA), + Arguments.of(notEquals(), + new PostRequest("url", new RequestHeaders(List.of(new RequestHeader("other-key", "val"))), + "body"), + requestA), + Arguments.of(notEquals(), + new PostRequest("url", new RequestHeaders(List.of(new RequestHeader("key", "other-val"))), + "body"), + requestA), + Arguments.of(notEquals(), + new PostRequest("url", new RequestHeaders(List.of(new RequestHeader("key", "val"))), + "other-body"), + requestA), + Arguments.of(notEquals(), new PostRequest(null, RequestHeaders.empty(), null), requestA)); + } + + private static BiConsumer equals() { + return Assertions::assertEquals; + } + + private static BiConsumer notEquals() { + return Assertions::assertNotEquals; + } + + } + + @Test + void test_WithUrl() { + var initialRequest = new PostRequest("url", new RequestHeaders(List.of(new RequestHeader("key", "val"))), + "body"); + + var requestWithOtherUrl = initialRequest.with("other-url"); + assertEquals(initialRequest.getRequestHeaders(), requestWithOtherUrl.getRequestHeaders()); + assertEquals(initialRequest.getMethod(), requestWithOtherUrl.getMethod()); + assertNotEquals(initialRequest.getUrl(), requestWithOtherUrl.getUrl()); + } + + @Test + void test_WithRequestHeaders() { + var initialRequest = new PostRequest("url", new RequestHeaders(List.of(new RequestHeader("key", "val"))), + "body"); + + var requestWithOtherUrl = initialRequest + .with(new RequestHeaders(List.of(new RequestHeader("other-key", "val")))); + assertNotEquals(initialRequest.getRequestHeaders(), requestWithOtherUrl.getRequestHeaders()); + assertEquals(initialRequest.getMethod(), requestWithOtherUrl.getMethod()); + assertEquals(initialRequest.getUrl(), requestWithOtherUrl.getUrl()); + } + } \ No newline at end of file diff --git a/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/ResponseTest.java b/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/ResponseTest.java index 54160d134..98f709f73 100644 --- a/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/ResponseTest.java +++ b/ldi-core/request-executor/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/requestexecutor/valueobjects/ResponseTest.java @@ -18,4 +18,12 @@ void test_isSuccess() { assertFalse(new Response(null, List.of(), 500, null).isSuccess()); } + @Test + void isFobidden() { + assertFalse(new Response(null, List.of(), 200, null).isFobidden()); + assertFalse(new Response(null, List.of(), 400, null).isFobidden()); + assertTrue(new Response(null, List.of(), 403, null).isFobidden()); + assertFalse(new Response(null, List.of(), 500, null).isFobidden()); + } + } \ No newline at end of file diff --git a/ldi-core/rml-adapter/pom.xml b/ldi-core/rml-adapter/pom.xml index 1b42fa9c9..5583005e7 100644 --- a/ldi-core/rml-adapter/pom.xml +++ b/ldi-core/rml-adapter/pom.xml @@ -5,7 +5,7 @@ ldi-core be.vlaanderen.informatievlaanderen.ldes.ldi - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 diff --git a/ldi-core/sparql-construct/pom.xml b/ldi-core/sparql-construct/pom.xml index 5848c5566..b7d3e36e7 100644 --- a/ldi-core/sparql-construct/pom.xml +++ b/ldi-core/sparql-construct/pom.xml @@ -3,7 +3,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldi ldi-core - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 diff --git a/ldi-core/sparql-construct/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/SparqlConstructTransformer.java b/ldi-core/sparql-construct/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/SparqlConstructTransformer.java index 7a20bc9b1..ae25b944b 100644 --- a/ldi-core/sparql-construct/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/SparqlConstructTransformer.java +++ b/ldi-core/sparql-construct/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/SparqlConstructTransformer.java @@ -1,7 +1,7 @@ package be.vlaanderen.informatievlaanderen.ldes.ldi; import be.vlaanderen.informatievlaanderen.ldes.ldi.sparqlfunctions.*; -import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiTransformer; +import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiOneToManyTransformer; import org.apache.jena.query.*; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Resource; @@ -11,7 +11,7 @@ import java.util.Iterator; import java.util.List; -public class SparqlConstructTransformer implements LdiTransformer { +public class SparqlConstructTransformer implements LdiOneToManyTransformer { private final Query query; private final boolean includeOriginal; @@ -23,7 +23,7 @@ public SparqlConstructTransformer(Query query, boolean includeOriginal) { } @Override - public List apply(Model linkedDataModel) { + public List transform(Model linkedDataModel) { final Dataset dataset = queryDataset(linkedDataModel); final List result = extractModelsFromDataset(dataset); handleIncludeOriginal(result, linkedDataModel); diff --git a/ldi-core/sparql-construct/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/SparqlConstructTransformerTest.java b/ldi-core/sparql-construct/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/SparqlConstructTransformerTest.java index 4fb117ea3..862500a15 100644 --- a/ldi-core/sparql-construct/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/SparqlConstructTransformerTest.java +++ b/ldi-core/sparql-construct/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/SparqlConstructTransformerTest.java @@ -64,7 +64,7 @@ void when_executeTransform_ExpectTransformedModel() { Model model = ModelFactory.createDefaultModel().add(originalData); - List models = sparqlConstructTransformer.apply(model); + List models = sparqlConstructTransformer.transform(model); assertTrue(models.get(0).contains(transformedData)); assertFalse(models.get(0).contains(originalData)); @@ -78,7 +78,7 @@ void when_executeTransform_includeOriginal_ExpectTransformedModelWithOriginal() Model model = ModelFactory.createDefaultModel().add(originalData); - List models = sparqlConstructTransformer.apply(model); + List models = sparqlConstructTransformer.transform(model); assertTrue(models.get(0).contains(transformedData)); assertTrue(models.get(0).contains(originalData)); @@ -91,7 +91,7 @@ void shouldSplitModels_whenQueryContainsGraph_AndHasNoDefaultModelStatements() t SparqlConstructTransformer sparqlConstructTransformer = new SparqlConstructTransformer( QueryFactory.create(constructQuery), false); - List result = sparqlConstructTransformer.apply(inputModel); + List result = sparqlConstructTransformer.transform(inputModel); assertEquals(3, result.size()); assertModels( @@ -106,7 +106,7 @@ void shouldNotSplitModels_whenQueryContainsNoGraph_AndHasOnlyDefaultModelStateme SparqlConstructTransformer sparqlConstructTransformer = new SparqlConstructTransformer( QueryFactory.create(constructQuery), false); - List result = sparqlConstructTransformer.apply(inputModel); + List result = sparqlConstructTransformer.transform(inputModel); assertEquals(1, result.size()); Model expectedResult = RDFParser.source("crowdscan/no-graph-observations.ttl").toModel(); @@ -120,7 +120,7 @@ void shouldSplitModels_whenQueryContainsGraph_AndHasDefaultModelStatements() thr SparqlConstructTransformer sparqlConstructTransformer = new SparqlConstructTransformer( QueryFactory.create(constructQuery), false); - List result = sparqlConstructTransformer.apply(inputModel); + List result = sparqlConstructTransformer.transform(inputModel); assertEquals(10, result.size()); assertModels(List.of( diff --git a/ldi-core/sparql-construct/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/sparqlfunctions/SparqlConstructFunctionsTest.java b/ldi-core/sparql-construct/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/sparqlfunctions/SparqlConstructFunctionsTest.java index 83e67ec34..15887adca 100644 --- a/ldi-core/sparql-construct/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/sparqlfunctions/SparqlConstructFunctionsTest.java +++ b/ldi-core/sparql-construct/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/sparqlfunctions/SparqlConstructFunctionsTest.java @@ -143,7 +143,7 @@ void geoFunctions_firstCoordinate(String id, String midpoint, String line, Strin SparqlConstructTransformer sparqlConstructTransformer = new SparqlConstructTransformer( QueryFactory.create(geoConstructFirstCoordinateQuery), false); - List result = sparqlConstructTransformer.apply(createGeoModel(line)); + List result = sparqlConstructTransformer.transform(createGeoModel(line)); Statement expected = createStatement(INIT_MODEL.createResource(DATA_FROM_SOURCE), INIT_MODEL.createProperty(GEOSPARQL_AS_WKT), @@ -158,7 +158,7 @@ void geoFunctions_lastCoordinate(String id, String midpoint, String line, String SparqlConstructTransformer sparqlConstructTransformer = new SparqlConstructTransformer( QueryFactory.create(geoConstructLastCoordinateQuery), false); - List result = sparqlConstructTransformer.apply(createGeoModel(line)); + List result = sparqlConstructTransformer.transform(createGeoModel(line)); Statement expected = createStatement(INIT_MODEL.createResource(DATA_FROM_SOURCE), INIT_MODEL.createProperty(GEOSPARQL_AS_WKT), @@ -173,7 +173,7 @@ void geoFunctions_lineLength(String id, String midpoint, String line, String sta SparqlConstructTransformer sparqlConstructTransformer = new SparqlConstructTransformer( QueryFactory.create(geoConstructLineLengthQuery), false); - List result = sparqlConstructTransformer.apply(createGeoModel(line)); + List result = sparqlConstructTransformer.transform(createGeoModel(line)); double expected = (double) Math.round((Double.parseDouble(offset) * 2) * 100) / 100; @@ -190,7 +190,7 @@ void geoFunctions_midPoint(String id, String midpoint, String line) { SparqlConstructTransformer sparqlConstructTransformer = new SparqlConstructTransformer( QueryFactory.create(geoConstructMidPointQuery), false); - List result = sparqlConstructTransformer.apply(createGeoModel(line)); + List result = sparqlConstructTransformer.transform(createGeoModel(line)); Coordinate expected = SparqlFunctionsUtils.getCoordinatesFromPointAsString(midpoint); @@ -208,7 +208,7 @@ void geoFunctions_pointAtFromStart(String id, String midpoint, String line, Stri SparqlConstructTransformer sparqlConstructTransformer = new SparqlConstructTransformer( QueryFactory.create(geoConstructPointAtFromStartQuery), false); - List result = sparqlConstructTransformer.apply(createGeoModel(line, offset)); + List result = sparqlConstructTransformer.transform(createGeoModel(line, offset)); Coordinate expected = SparqlFunctionsUtils.getCoordinatesFromPointAsString(midpoint); @@ -227,7 +227,7 @@ void geoFunctions_distanceFromStart(String id, String midpoint, String line, Str SparqlConstructTransformer sparqlConstructTransformer = new SparqlConstructTransformer( QueryFactory.create(geoConstructDistanceFromStartQuery), false); - List result = sparqlConstructTransformer.apply(createGeoModelTwoLiterals(line, midpoint)); + List result = sparqlConstructTransformer.transform(createGeoModelTwoLiterals(line, midpoint)); double expected = Double.parseDouble(offset); double distanceFromStart = result.get(0).listStatements().nextStatement().getDouble(); @@ -242,7 +242,7 @@ void geoFunctions_getLineAtIndex() { String multiLineString = "MULTILINESTRING ((10 10, 20 20, 10 40), (40 40, 30 30, 40 20, 30 10))"; int index = 0; - List result = sparqlConstructTransformer.apply(createGeoModel(multiLineString, index)); + List result = sparqlConstructTransformer.transform(createGeoModel(multiLineString, index)); String lineString = "LINESTRING(10 10, 20 20, 10 40)"; Statement expected = createStatement(INIT_MODEL.createResource(DATA_FROM_SOURCE), diff --git a/ldi-core/version-materialiser/pom.xml b/ldi-core/version-materialiser/pom.xml index 29f02535d..51c0a4c36 100644 --- a/ldi-core/version-materialiser/pom.xml +++ b/ldi-core/version-materialiser/pom.xml @@ -3,7 +3,7 @@ ldi-core be.vlaanderen.informatievlaanderen.ldes.ldi - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 diff --git a/ldi-core/version-materialiser/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/VersionMaterialiser.java b/ldi-core/version-materialiser/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/VersionMaterialiser.java index 5f737cff5..6b53785ca 100644 --- a/ldi-core/version-materialiser/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/VersionMaterialiser.java +++ b/ldi-core/version-materialiser/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/VersionMaterialiser.java @@ -1,7 +1,7 @@ package be.vlaanderen.informatievlaanderen.ldes.ldi; import be.vlaanderen.informatievlaanderen.ldes.ldi.exceptions.ObjectIdentifierException; -import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiTransformer; +import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiOneToOneTransformer; import org.apache.jena.rdf.model.*; import org.apache.jena.rdf.model.impl.StatementImpl; @@ -9,7 +9,7 @@ import static org.apache.jena.rdf.model.ResourceFactory.createProperty; -public class VersionMaterialiser implements LdiTransformer { +public class VersionMaterialiser implements LdiOneToOneTransformer { private final Property versionPredicate; private final boolean restrictToMembers; @@ -19,7 +19,7 @@ public VersionMaterialiser(Property versionPredicate, boolean restrictToMembers) } @Override - public List apply(Model linkedDataModel) { + public Model transform(Model linkedDataModel) { final Model versionMaterialisedModel = ModelFactory.createDefaultModel(); Map versionIDEntityIDMap = getVersionIDEntityIDMap(linkedDataModel, versionPredicate); @@ -33,9 +33,9 @@ public List apply(Model linkedDataModel) { versionMaterialisedModel.add(deversionedStatements); if (restrictToMembers) { - return List.of(reduceToLDESMemberOnlyModel(versionMaterialisedModel)); + return reduceToLDESMemberOnlyModel(versionMaterialisedModel); } - return List.of(versionMaterialisedModel); + return versionMaterialisedModel; } private Statement deversionStatement(Map versionIdEntityIdMap, Statement statement) { diff --git a/ldi-core/version-materialiser/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/VersionMaterialiserTest.java b/ldi-core/version-materialiser/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/VersionMaterialiserTest.java index 363df46ee..d1d68061c 100644 --- a/ldi-core/version-materialiser/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/VersionMaterialiserTest.java +++ b/ldi-core/version-materialiser/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/VersionMaterialiserTest.java @@ -43,7 +43,7 @@ void testVersionMaterialiseMemberOnly() throws IOException { Model versionedMember = turtleFileToQuadString("src/test/resources/ldes-member-versioned.ttl"); - Model output = versionMaterialiser.apply(versionedMember).get(0); + Model output = versionMaterialiser.transform(versionedMember); InputStream comparisonFile = new FileInputStream("src/test/resources/ldes-member-unversioned.ttl"); Model comparisonModel = RDFParser.create() @@ -63,7 +63,7 @@ void testVersionMaterialiseWithContext() throws IOException { Model versionedMember = turtleFileToQuadString("src/test/resources/ldes-member-versioned.ttl"); - Model output = versionMaterialiser.apply(versionedMember).get(0); + Model output = versionMaterialiser.transform(versionedMember); InputStream comparisonFile = new FileInputStream( "src/test/resources/ldes-member-unversioned-context-included.ttl"); diff --git a/ldi-core/version-object-creator/pom.xml b/ldi-core/version-object-creator/pom.xml index 1d5984979..46c882857 100644 --- a/ldi-core/version-object-creator/pom.xml +++ b/ldi-core/version-object-creator/pom.xml @@ -3,7 +3,7 @@ ldi-core be.vlaanderen.informatievlaanderen.ldes.ldi - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 diff --git a/ldi-core/version-object-creator/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/VersionObjectCreator.java b/ldi-core/version-object-creator/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/VersionObjectCreator.java index 1b76ae1f4..de31fa9c4 100644 --- a/ldi-core/version-object-creator/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/VersionObjectCreator.java +++ b/ldi-core/version-object-creator/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/VersionObjectCreator.java @@ -1,7 +1,7 @@ package be.vlaanderen.informatievlaanderen.ldes.ldi; import be.vlaanderen.informatievlaanderen.ldes.ldi.extractor.PropertyExtractor; -import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiTransformer; +import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiOneToOneTransformer; import be.vlaanderen.informatievlaanderen.ldes.ldi.valueobjects.MemberInfo; import org.apache.jena.datatypes.TypeMapper; import org.apache.jena.graph.Node; @@ -16,7 +16,7 @@ import static org.apache.jena.rdf.model.ResourceFactory.*; -public class VersionObjectCreator implements LdiTransformer { +public class VersionObjectCreator implements LdiOneToOneTransformer { private static final Logger LOGGER = LoggerFactory.getLogger(VersionObjectCreator.class); @@ -34,8 +34,8 @@ public class VersionObjectCreator implements LdiTransformer { private final Property versionOfProperty; public VersionObjectCreator(PropertyExtractor dateObservedPropertyExtractor, Resource memberTypeResource, - String delimiter, - Property generatedAtTimeProperty, Property versionOfProperty) { + String delimiter, + Property generatedAtTimeProperty, Property versionOfProperty) { this.dateObservedPropertyExtractor = dateObservedPropertyExtractor; this.memberTypeResource = memberTypeResource; this.delimiter = delimiter; @@ -44,15 +44,15 @@ public VersionObjectCreator(PropertyExtractor dateObservedPropertyExtractor, Res } @Override - public List apply(Model linkedDataModel) { + public Model transform(Model linkedDataModel) { final String dateObserved = getDateObserved(linkedDataModel); Optional memberInfo = extractMemberInfo(linkedDataModel); if (memberInfo.isPresent()) - return List.of(constructVersionObject(linkedDataModel, new MemberInfo(memberInfo.get(), dateObserved))); + return constructVersionObject(linkedDataModel, new MemberInfo(memberInfo.get(), dateObserved)); LOGGER.warn(DATE_OBSERVED_PROPERTY_COULD_NOT_BE_FOUND, dateObserved); - return List.of(linkedDataModel); + return linkedDataModel; } private Optional extractMemberInfo(Model linkedDataModel) { diff --git a/ldi-core/version-object-creator/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/VersionObjectCreatorTest.java b/ldi-core/version-object-creator/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/VersionObjectCreatorTest.java index 28cfab52b..705c3bb91 100644 --- a/ldi-core/version-object-creator/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/VersionObjectCreatorTest.java +++ b/ldi-core/version-object-creator/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldi/VersionObjectCreatorTest.java @@ -87,7 +87,7 @@ void when_dateObservedPropertyIsNoDatetime_expectCurrentDatetime() { VersionObjectCreator versionObjectCreator = new VersionObjectCreator(dateObservedPropertyExtractor, memberType, DEFAULT_DELIMITER, generatedAtTimeProperty, versionOfProperty); - Model versionObject = versionObjectCreator.apply(inputModel).get(0); + Model versionObject = versionObjectCreator.transform(inputModel); final LocalDateTime startTestTime = LocalDateTime.now(); @@ -124,8 +124,7 @@ void when_dateObservedPropertyIsNested_thenAPropertyPathCanBeProvided() { DEFAULT_DELIMITER, generatedAtTimeProperty, versionOfProperty); String result = versionObjectCreator - .apply(inputModel) - .get(0) + .transform(inputModel) .listSubjectsWithProperty(RDF.type, initModel.createResource("http://example.org/Something")) .mapWith(RDFNode::asResource) .mapWith(Resource::getURI) @@ -146,7 +145,7 @@ void shouldMatchCountOfObjects(String fileName, String expectedId, LocalDateTime model.createResource(memberType), DEFAULT_DELIMITER, null, null); - Model versionObject = versionObjectCreator.apply(model).get(0); + Model versionObject = versionObjectCreator.transform(model); final String minuteTheTestStarted = getPartOfLocalDateTime(startTestTime); final String minuteAfterTheTestStarted = getPartOfLocalDateTime(startTestTime.plusMinutes(1)); @@ -167,7 +166,7 @@ void when_memberInfoExtractionFails_warningMessageIsLogged() { VersionObjectCreator versionObjectCreator = new VersionObjectCreator(new EmptyPropertyExtractor(), null, DEFAULT_DELIMITER, null, null); - versionObjectCreator.apply(initModel); + versionObjectCreator.transform(initModel); List logsList = listAppender.list; assertTrue( diff --git a/ldi-nifi.Dockerfile b/ldi-nifi.Dockerfile index a98b78f73..0f70028b6 100644 --- a/ldi-nifi.Dockerfile +++ b/ldi-nifi.Dockerfile @@ -8,7 +8,7 @@ FROM maven:3.8.5-openjdk-18 AS builder # MAVEN: application FROM builder as app-stage COPY . . -RUN mvn clean net.revelc.code.formatter:formatter-maven-plugin:format install -DskipTests +RUN mvn clean install -DskipTests FROM ldes/nifi:${NIFI_DOCKER_IMAGE_VERSION} AS packaging-stage diff --git a/ldi-nifi/ldi-nifi-common/pom.xml b/ldi-nifi/ldi-nifi-common/pom.xml index 92e38fd90..a54159a30 100644 --- a/ldi-nifi/ldi-nifi-common/pom.xml +++ b/ldi-nifi/ldi-nifi-common/pom.xml @@ -3,16 +3,12 @@ be.vlaanderen.informatievlaanderen.ldes.ldi ldi-nifi - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 ldi-nifi-common - - ../.. - - org.apache.jena diff --git a/ldi-nifi/ldi-nifi-processors/archive-file-in/pom.xml b/ldi-nifi/ldi-nifi-processors/archive-file-in/pom.xml index 46bd5c2d1..8177a41cd 100644 --- a/ldi-nifi/ldi-nifi-processors/archive-file-in/pom.xml +++ b/ldi-nifi/ldi-nifi-processors/archive-file-in/pom.xml @@ -6,17 +6,13 @@ be.vlaanderen.informatievlaanderen.ldes.ldi.nifi ldi-nifi-processors - 1.9.0 + 1.10.0-SNAPSHOT archive-file-in nar - - ../../.. - - be.vlaanderen.informatievlaanderen.ldes.ldi diff --git a/ldi-nifi/ldi-nifi-processors/archive-file-out/pom.xml b/ldi-nifi/ldi-nifi-processors/archive-file-out/pom.xml index de0ac680f..05e570ec6 100644 --- a/ldi-nifi/ldi-nifi-processors/archive-file-out/pom.xml +++ b/ldi-nifi/ldi-nifi-processors/archive-file-out/pom.xml @@ -6,16 +6,12 @@ be.vlaanderen.informatievlaanderen.ldes.ldi.nifi ldi-nifi-processors - 1.9.0 + 1.10.0-SNAPSHOT archive-file-out nar - - ../../.. - - be.vlaanderen.informatievlaanderen.ldes.ldi diff --git a/ldi-nifi/ldi-nifi-processors/create-version-object-processor/pom.xml b/ldi-nifi/ldi-nifi-processors/create-version-object-processor/pom.xml index 8daa9ec35..7390688ce 100644 --- a/ldi-nifi/ldi-nifi-processors/create-version-object-processor/pom.xml +++ b/ldi-nifi/ldi-nifi-processors/create-version-object-processor/pom.xml @@ -3,17 +3,13 @@ be.vlaanderen.informatievlaanderen.ldes.ldi.nifi ldi-nifi-processors - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 create-version-object-processor nar - - ../../.. - - be.vlaanderen.informatievlaanderen.ldes.ldi diff --git a/ldi-nifi/ldi-nifi-processors/create-version-object-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/CreateVersionObjectProcessor.java b/ldi-nifi/ldi-nifi-processors/create-version-object-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/CreateVersionObjectProcessor.java index 9ce28530c..d8e734540 100644 --- a/ldi-nifi/ldi-nifi-processors/create-version-object-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/CreateVersionObjectProcessor.java +++ b/ldi-nifi/ldi-nifi-processors/create-version-object-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/CreateVersionObjectProcessor.java @@ -93,7 +93,7 @@ public void onTrigger(final ProcessContext context, final ProcessSession session String content = FlowManager.receiveData(session, flowFile); try { Model input = RDFParserBuilder.create().fromString(content).lang(lang).toModel(); - Model versionObject = versionObjectCreator.apply(input).get(0); + Model versionObject = versionObjectCreator.transform(input); if (versionObject.isIsomorphicWith(input)) { FlowManager.sendRDFToRelation(session, flowFile, versionObject, diff --git a/ldi-nifi/ldi-nifi-processors/geojson-to-wkt-processor/pom.xml b/ldi-nifi/ldi-nifi-processors/geojson-to-wkt-processor/pom.xml index b67c6009d..bac76ac31 100644 --- a/ldi-nifi/ldi-nifi-processors/geojson-to-wkt-processor/pom.xml +++ b/ldi-nifi/ldi-nifi-processors/geojson-to-wkt-processor/pom.xml @@ -6,16 +6,12 @@ be.vlaanderen.informatievlaanderen.ldes.ldi.nifi ldi-nifi-processors - 1.9.0 + 1.10.0-SNAPSHOT geojson-to-wkt-processor nar - - ../../.. - - be.vlaanderen.informatievlaanderen.ldes.ldi diff --git a/ldi-nifi/ldi-nifi-processors/geojson-to-wkt-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/GeoJsonToWktProcessor.java b/ldi-nifi/ldi-nifi-processors/geojson-to-wkt-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/GeoJsonToWktProcessor.java index caff81536..7615decd6 100644 --- a/ldi-nifi/ldi-nifi-processors/geojson-to-wkt-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/GeoJsonToWktProcessor.java +++ b/ldi-nifi/ldi-nifi-processors/geojson-to-wkt-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/GeoJsonToWktProcessor.java @@ -18,10 +18,7 @@ import java.util.Set; import static be.vlaanderen.informatievlaanderen.ldes.ldi.processors.config.GeoJsonToWktProcessorProperties.DATA_SOURCE_FORMAT; -import static be.vlaanderen.informatievlaanderen.ldes.ldi.processors.services.FlowManager.FAILURE; -import static be.vlaanderen.informatievlaanderen.ldes.ldi.processors.services.FlowManager.SUCCESS; -import static be.vlaanderen.informatievlaanderen.ldes.ldi.processors.services.FlowManager.receiveDataAsModel; -import static be.vlaanderen.informatievlaanderen.ldes.ldi.processors.services.FlowManager.sendRDFToRelation; +import static be.vlaanderen.informatievlaanderen.ldes.ldi.processors.services.FlowManager.*; @SuppressWarnings("java:S2160") // nifi handles equals/hashcode of processors @Tags({ "ldes, vsds, geojson, wkt" }) @@ -52,8 +49,8 @@ public void onTrigger(final ProcessContext context, final ProcessSession session try { Lang dataSourceFormat = GeoJsonToWktProcessorProperties.getDataSourceFormat(context); Model inputModel = receiveDataAsModel(session, flowFile, dataSourceFormat); - geoJsonToWktTransformer.apply(inputModel) - .forEach(result -> sendRDFToRelation(session, flowFile, result, SUCCESS, dataSourceFormat)); + Model result = geoJsonToWktTransformer.transform(inputModel); + sendRDFToRelation(session, flowFile, result, SUCCESS, dataSourceFormat); } catch (Exception e) { getLogger().error("Error transforming geojson to wkt: {}", e.getMessage()); sendRDFToRelation(session, flowFile, FAILURE); diff --git a/ldi-nifi/ldi-nifi-processors/json-to-ld-processor/pom.xml b/ldi-nifi/ldi-nifi-processors/json-to-ld-processor/pom.xml index 492bb7e68..9cfa2d9c9 100644 --- a/ldi-nifi/ldi-nifi-processors/json-to-ld-processor/pom.xml +++ b/ldi-nifi/ldi-nifi-processors/json-to-ld-processor/pom.xml @@ -6,16 +6,12 @@ be.vlaanderen.informatievlaanderen.ldes.ldi.nifi ldi-nifi-processors - 1.9.0 + 1.10.0-SNAPSHOT json-to-ld-processor nar - - ../../.. - - be.vlaanderen.informatievlaanderen.ldes.ldi diff --git a/ldi-nifi/ldi-nifi-processors/ldes-client-processor/pom.xml b/ldi-nifi/ldi-nifi-processors/ldes-client-processor/pom.xml index 194dfe4f8..55523048b 100644 --- a/ldi-nifi/ldi-nifi-processors/ldes-client-processor/pom.xml +++ b/ldi-nifi/ldi-nifi-processors/ldes-client-processor/pom.xml @@ -3,17 +3,13 @@ be.vlaanderen.informatievlaanderen.ldes.ldi.nifi ldi-nifi-processors - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 ldes-client-processor nar - - ../../.. - - diff --git a/ldi-nifi/ldi-nifi-processors/ldes-client-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/LdesClient.java b/ldi-nifi/ldi-nifi-processors/ldes-client-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/LdesClient.java index 094c165fc..48f1d7a39 100644 --- a/ldi-nifi/ldi-nifi-processors/ldes-client-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/LdesClient.java +++ b/ldi-nifi/ldi-nifi-processors/ldes-client-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/LdesClient.java @@ -75,8 +75,7 @@ public void onScheduled(final ProcessContext context) { final RequestExecutor requestExecutor = getRequestExecutorWithPossibleRetry(context); LdesMetaData ldesMetaData = new LdesMetaData(dataSourceUrl, dataSourceFormat); StatePersistence statePersistence = statePersistenceFactory.getStatePersistence(context); - TreeNodeProcessor treeNodeProcessor = new TreeNodeProcessor(ldesMetaData, - statePersistence, requestExecutor); + TreeNodeProcessor treeNodeProcessor = new TreeNodeProcessor(ldesMetaData, statePersistence, requestExecutor); boolean keepState = stateKept(context); memberSupplier = new MemberSupplier(treeNodeProcessor, keepState); diff --git a/ldi-nifi/ldi-nifi-processors/model-split-processor/pom.xml b/ldi-nifi/ldi-nifi-processors/model-split-processor/pom.xml index 6751149d0..93cc21502 100644 --- a/ldi-nifi/ldi-nifi-processors/model-split-processor/pom.xml +++ b/ldi-nifi/ldi-nifi-processors/model-split-processor/pom.xml @@ -6,7 +6,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldi.nifi ldi-nifi-processors - 1.9.0 + 1.10.0-SNAPSHOT be.vlaanderen.informatievlaanderen.ldes.ldio @@ -14,10 +14,6 @@ nar - - ../../.. - - be.vlaanderen.informatievlaanderen.ldes.ldi diff --git a/ldi-nifi/ldi-nifi-processors/model-split-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/ModelSplitProcessor.java b/ldi-nifi/ldi-nifi-processors/model-split-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/ModelSplitProcessor.java index aebd8fc9f..b12ba24c9 100644 --- a/ldi-nifi/ldi-nifi-processors/model-split-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/ModelSplitProcessor.java +++ b/ldi-nifi/ldi-nifi-processors/model-split-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/ModelSplitProcessor.java @@ -1,6 +1,6 @@ package be.vlaanderen.informatievlaanderen.ldes.ldi.processors; -import be.vlaanderen.informatievlaanderen.ldes.ldi.ModelSplitter; +import be.vlaanderen.informatievlaanderen.ldes.ldi.ModelSplitTransformer; import be.vlaanderen.informatievlaanderen.ldes.ldi.processors.config.ModelSplitProperties; import org.apache.jena.rdf.model.Model; import org.apache.jena.riot.Lang; @@ -27,7 +27,7 @@ @CapabilityDescription("Splits a single model into multiple models.") public class ModelSplitProcessor extends AbstractProcessor { - private ModelSplitter modelSplitter; + private ModelSplitTransformer modelSplitter; @Override public Set getRelationships() { @@ -41,7 +41,7 @@ public final List getSupportedPropertyDescriptors() { @OnScheduled public void onScheduled(final ProcessContext context) { - modelSplitter = new ModelSplitter(); + modelSplitter = new ModelSplitTransformer(ModelSplitProperties.getSubjectType(context)); } @Override @@ -51,8 +51,7 @@ public void onTrigger(final ProcessContext context, final ProcessSession session try { Lang dataSourceFormat = determineDataSourceFormat(flowFile, context); Model inputModel = receiveDataAsModel(session, flowFile, dataSourceFormat); - modelSplitter - .split(inputModel, ModelSplitProperties.getSubjectType(context)) + modelSplitter.transform(inputModel) .forEach(model -> sendRDFToRelation(session, session.create(), model, SUCCESS, dataSourceFormat)); sendRDFToRelation(session, flowFile, inputModel, PROCESSED_INPUT_FILE, dataSourceFormat); diff --git a/ldi-nifi/ldi-nifi-processors/ngsiv2-to-ld-processor/pom.xml b/ldi-nifi/ldi-nifi-processors/ngsiv2-to-ld-processor/pom.xml index 999183668..aa53da625 100644 --- a/ldi-nifi/ldi-nifi-processors/ngsiv2-to-ld-processor/pom.xml +++ b/ldi-nifi/ldi-nifi-processors/ngsiv2-to-ld-processor/pom.xml @@ -7,16 +7,12 @@ ldi-nifi-processors be.vlaanderen.informatievlaanderen.ldes.ldi.nifi - 1.9.0 + 1.10.0-SNAPSHOT ngsiv2-to-ld-processor nar - - ../../.. - - be.vlaanderen.informatievlaanderen.ldes.ldi diff --git a/ldi-nifi/ldi-nifi-processors/pom.xml b/ldi-nifi/ldi-nifi-processors/pom.xml index 42d754996..d439d300c 100644 --- a/ldi-nifi/ldi-nifi-processors/pom.xml +++ b/ldi-nifi/ldi-nifi-processors/pom.xml @@ -3,7 +3,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldi ldi-nifi - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 @@ -25,8 +25,4 @@ model-split-processor - - ../.. - - diff --git a/ldi-nifi/ldi-nifi-processors/rdf4j-repository-materialisation-processor/pom.xml b/ldi-nifi/ldi-nifi-processors/rdf4j-repository-materialisation-processor/pom.xml index ff997ca5c..f758f12b6 100644 --- a/ldi-nifi/ldi-nifi-processors/rdf4j-repository-materialisation-processor/pom.xml +++ b/ldi-nifi/ldi-nifi-processors/rdf4j-repository-materialisation-processor/pom.xml @@ -6,17 +6,12 @@ be.vlaanderen.informatievlaanderen.ldes.ldi.nifi ldi-nifi-processors - 1.9.0 + 1.10.0-SNAPSHOT rdf4j-repository-materialisation-processor nar - - - ../../.. - - diff --git a/ldi-nifi/ldi-nifi-processors/sparql-interactions-processor/pom.xml b/ldi-nifi/ldi-nifi-processors/sparql-interactions-processor/pom.xml index 3c57c765e..1182186a3 100644 --- a/ldi-nifi/ldi-nifi-processors/sparql-interactions-processor/pom.xml +++ b/ldi-nifi/ldi-nifi-processors/sparql-interactions-processor/pom.xml @@ -3,17 +3,13 @@ be.vlaanderen.informatievlaanderen.ldes.ldi.nifi ldi-nifi-processors - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 sparql-interactions-processor nar - - ../../.. - - be.vlaanderen.informatievlaanderen.ldes.ldi diff --git a/ldi-nifi/ldi-nifi-processors/sparql-interactions-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/SparqlConstructProcessor.java b/ldi-nifi/ldi-nifi-processors/sparql-interactions-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/SparqlConstructProcessor.java index f165d7a74..5b20cbf83 100644 --- a/ldi-nifi/ldi-nifi-processors/sparql-interactions-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/SparqlConstructProcessor.java +++ b/ldi-nifi/ldi-nifi-processors/sparql-interactions-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/SparqlConstructProcessor.java @@ -53,7 +53,7 @@ public void onTrigger(final ProcessContext context, final ProcessSession session final Model inputModel = receiveDataAsModel(session, flowFile, SparqlProcessorProperties.getDataSourceFormat(context)); - transformer.apply(inputModel) + transformer.transform(inputModel) .forEach(resultModel -> sendRDFToRelation(session, flowFile, resultModel, SUCCESS, SparqlProcessorProperties.getDataSourceFormat(context))); } catch (Exception e) { diff --git a/ldi-nifi/ldi-nifi-processors/version-materialisation-processor/pom.xml b/ldi-nifi/ldi-nifi-processors/version-materialisation-processor/pom.xml index a01c61904..ea0437d24 100644 --- a/ldi-nifi/ldi-nifi-processors/version-materialisation-processor/pom.xml +++ b/ldi-nifi/ldi-nifi-processors/version-materialisation-processor/pom.xml @@ -3,17 +3,13 @@ be.vlaanderen.informatievlaanderen.ldes.ldi.nifi ldi-nifi-processors - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 version-materialisation-processor nar - - ../../.. - - be.vlaanderen.informatievlaanderen.ldes.ldi diff --git a/ldi-nifi/ldi-nifi-processors/version-materialisation-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/VersionMaterialiseProcessor.java b/ldi-nifi/ldi-nifi-processors/version-materialisation-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/VersionMaterialiseProcessor.java index 126d227d3..d0c166f91 100644 --- a/ldi-nifi/ldi-nifi-processors/version-materialisation-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/VersionMaterialiseProcessor.java +++ b/ldi-nifi/ldi-nifi-processors/version-materialisation-processor/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldi/processors/VersionMaterialiseProcessor.java @@ -56,10 +56,9 @@ public void onTrigger(final ProcessContext context, final ProcessSession session final Model inputModel = receiveDataAsModel(session, flowFile, RDFLanguages.contentTypeToLang(flowFile.getAttribute("mime.type"))); - versionMaterialiser.apply(inputModel) - .forEach(versionMaterialisedModel -> sendRDFToRelation(session, flowFile, - versionMaterialisedModel, SUCCESS, - RDFLanguages.contentTypeToLang(flowFile.getAttribute("mime.type")))); + Model result = versionMaterialiser.transform(inputModel); + sendRDFToRelation(session, flowFile, result, SUCCESS, + RDFLanguages.contentTypeToLang(flowFile.getAttribute("mime.type"))); } catch (Exception e) { getLogger().error("Error executing version materialisation: {}", e.getMessage()); diff --git a/ldi-nifi/pom.xml b/ldi-nifi/pom.xml index 53061c05f..e66f1b4d2 100644 --- a/ldi-nifi/pom.xml +++ b/ldi-nifi/pom.xml @@ -3,7 +3,7 @@ linked-data-interactions be.vlaanderen.informatievlaanderen.ldes - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 pom @@ -18,7 +18,6 @@ 1.23.2 - .. @@ -46,11 +45,6 @@ junit-jupiter - - org.junit.jupiter - junit-jupiter-api - - org.junit.jupiter junit-jupiter-api diff --git a/ldi-orchestrator/ldio-application/pom.xml b/ldi-orchestrator/ldio-application/pom.xml index 1eb96d727..b639a8174 100644 --- a/ldi-orchestrator/ldio-application/pom.xml +++ b/ldi-orchestrator/ldio-application/pom.xml @@ -3,7 +3,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldi ldi-orchestrator - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 @@ -116,6 +116,16 @@ + + ldio-ldes-client-connector + + + be.vlaanderen.informatievlaanderen.ldes.ldio + ldio-ldes-client-connector + ${project.version} + + + ldio-archive-file-in diff --git a/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/FlowAutoConfiguration.java b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/FlowAutoConfiguration.java index fad8b2bd9..7f86bf830 100644 --- a/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/FlowAutoConfiguration.java +++ b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/FlowAutoConfiguration.java @@ -4,11 +4,13 @@ import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiAdapter; import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiComponent; import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiOutput; -import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiTransformer; import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioConfigurator; import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioInputConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioTransformerConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.events.PipelineCreatedEvent; import be.vlaanderen.informatievlaanderen.ldes.ldio.services.ComponentExecutorImpl; import be.vlaanderen.informatievlaanderen.ldes.ldio.services.LdiSender; +import be.vlaanderen.informatievlaanderen.ldes.ldio.types.LdioTransformer; import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.ComponentDefinition; import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.ComponentProperties; import jakarta.annotation.PostConstruct; @@ -19,11 +21,9 @@ import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; import static be.vlaanderen.informatievlaanderen.ldes.ldio.config.OrchestratorConfig.DEBUG; import static be.vlaanderen.informatievlaanderen.ldes.ldio.config.OrchestratorConfig.ORCHESTRATOR_NAME; @@ -31,6 +31,7 @@ @Configuration @ComponentScan("be.vlaanderen.informatievlaanderen") +@Component public class FlowAutoConfiguration { private static final Logger LOGGER = LoggerFactory.getLogger(FlowAutoConfiguration.class); private final OrchestratorConfig orchestratorConfig; @@ -50,19 +51,31 @@ public void registerInputBeans() { } public ComponentExecutor componentExecutor(final PipelineConfig pipelineConfig) { - List ldiTransformers = pipelineConfig.getTransformers() + List ldioTransformers = pipelineConfig.getTransformers() .stream() .map(this::getLdioTransformer) .toList(); + List ldiOutputs = pipelineConfig.getOutputs() .stream() .map(this::getLdioOutput) .toList(); LdiSender ldiSender = new LdiSender(eventPublisher, ldiOutputs); + + List processorChain = new ArrayList<>(ldioTransformers.subList(0, ldioTransformers.size())); + + processorChain.add(ldiSender); + + LdioTransformer ldioTransformerPipeline = processorChain.get(0); + + if (processorChain.size() > 1) { + ldioTransformerPipeline = LdioTransformer.link(processorChain.get(0), processorChain); + } + registerBean(pipelineConfig.getName() + "-ldiSender", ldiSender); - return new ComponentExecutorImpl(ldiTransformers, ldiSender); + return new ComponentExecutorImpl(ldioTransformerPipeline); } public void initialiseLdiInput(PipelineConfig config) { @@ -89,6 +102,7 @@ public void initialiseLdiInput(PipelineConfig config) { Object ldiInput = configurator.configure(adapter, executor, new ComponentProperties(inputConfig)); registerBean(pipeLineName, ldiInput); + eventPublisher.publishEvent(new PipelineCreatedEvent(this, config)); } private LdiAdapter getLdioAdapter(ComponentDefinition componentDefinition) { @@ -100,13 +114,14 @@ private LdiAdapter getLdioAdapter(ComponentDefinition componentDefinition) { return debug ? new AdapterDebugger(adapter) : adapter; } - private LdiTransformer getLdioTransformer(ComponentDefinition componentDefinition) { + private LdioTransformer getLdioTransformer(ComponentDefinition componentDefinition) { boolean debug = componentDefinition.getConfig().getOptionalBoolean(DEBUG).orElse(false); - LdiTransformer ldiTransformer = (LdiTransformer) getLdiComponent(componentDefinition.getName(), - componentDefinition.getConfig()); + LdioTransformer ldiTransformer = ((LdioTransformerConfigurator) configContext + .getBean(componentDefinition.getName())) + .configure(componentDefinition.getConfig()); - return debug ? new TransformDebugger(ldiTransformer) : ldiTransformer; + return debug ? new TransformerDebugger(ldiTransformer) : ldiTransformer; } private LdiOutput getLdioOutput(ComponentDefinition componentDefinition) { @@ -119,8 +134,7 @@ private LdiOutput getLdioOutput(ComponentDefinition componentDefinition) { } private LdiComponent getLdiComponent(String beanName, ComponentProperties config) { - LdioConfigurator ldioConfigurator = (LdioConfigurator) configContext.getBean(beanName); - return ldioConfigurator.configure(config); + return ((LdioConfigurator) configContext.getBean(beanName)).configure(config); } private void registerBean(String pipelineName, Object bean) { diff --git a/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/TransformDebugger.java b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/TransformDebugger.java deleted file mode 100644 index fc8490ac6..000000000 --- a/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/TransformDebugger.java +++ /dev/null @@ -1,26 +0,0 @@ -package be.vlaanderen.informatievlaanderen.ldes.ldio.config; - -import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiTransformer; -import org.apache.jena.rdf.model.Model; -import org.apache.jena.riot.Lang; -import org.apache.jena.riot.RDFWriter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Collection; - -public class TransformDebugger implements LdiTransformer { - private final Logger log; - private final LdiTransformer ldiTransformer; - - public TransformDebugger(LdiTransformer ldiTransformer) { - this.ldiTransformer = ldiTransformer; - log = LoggerFactory.getLogger(ldiTransformer.getClass()); - } - - @Override - public Collection apply(Model model) { - log.debug("Starting model: \n" + RDFWriter.source(model).lang(Lang.TTL).asString()); - return ldiTransformer.apply(model); - } -} diff --git a/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/TransformerDebugger.java b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/TransformerDebugger.java new file mode 100644 index 000000000..faa68d6f4 --- /dev/null +++ b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/TransformerDebugger.java @@ -0,0 +1,22 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldio.config; + +import be.vlaanderen.informatievlaanderen.ldes.ldio.types.LdioTransformer; +import org.apache.jena.rdf.model.Model; +import org.apache.jena.riot.Lang; +import org.apache.jena.riot.RDFWriter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TransformerDebugger extends LdioTransformer { + private final Logger log; + + public TransformerDebugger(LdioTransformer ldiTransformer) { + log = LoggerFactory.getLogger(ldiTransformer.getClass()); + } + + @Override + public void apply(Model model) { + log.debug("Starting model: \n {}", RDFWriter.source(model).lang(Lang.TTL).asString()); + this.next(model); + } +} diff --git a/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/events/PipelineCreatedEvent.java b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/events/PipelineCreatedEvent.java new file mode 100644 index 000000000..3d188f6d2 --- /dev/null +++ b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/events/PipelineCreatedEvent.java @@ -0,0 +1,18 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldio.events; + +import be.vlaanderen.informatievlaanderen.ldes.ldio.config.PipelineConfig; +import org.springframework.context.ApplicationEvent; + +public final class PipelineCreatedEvent extends ApplicationEvent { + private final PipelineConfig pipelineConfig; + + public PipelineCreatedEvent(Object source, PipelineConfig pipelineConfig) { + super(source); + this.pipelineConfig = pipelineConfig; + } + + public PipelineConfig pipelineConfig() { + return pipelineConfig; + } + +} diff --git a/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/events/PipelineStatusEvent.java b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/events/PipelineStatusEvent.java index 5044fb5ef..44086ffcf 100644 --- a/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/events/PipelineStatusEvent.java +++ b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/events/PipelineStatusEvent.java @@ -2,14 +2,5 @@ import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.PipelineStatus; -public class PipelineStatusEvent { - private final PipelineStatus status; - - public PipelineStatusEvent(PipelineStatus status) { - this.status = status; - } - - public PipelineStatus getStatus() { - return status; - } +public record PipelineStatusEvent(PipelineStatus status) { } diff --git a/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/CatalogController.java b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/CatalogController.java new file mode 100644 index 000000000..4cd075956 --- /dev/null +++ b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/CatalogController.java @@ -0,0 +1,56 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldio.services; + +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioAdapterConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioInputConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioOutputConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioTransformerConfigurator; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.http.HttpEntity; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@RestController +@RequestMapping(path = "/admin/api/v1/catalog") +public class CatalogController { + private final ConfigurableApplicationContext context; + + public CatalogController(ConfigurableApplicationContext context) { + this.context = context; + } + + @GetMapping + public ResponseEntity> catalog() { + return ResponseEntity.ok(Stream.of(inputs(), adapters(), transformers(), outputs()) + .map(HttpEntity::getBody) + .filter(Objects::nonNull) + .flatMap(Set::stream) + .collect(Collectors.toSet())); + } + + @GetMapping(path = "/inputs") + public ResponseEntity> inputs() { + return ResponseEntity.ok(context.getBeansOfType(LdioInputConfigurator.class).keySet()); + } + + @GetMapping(path = "/adapters") + public ResponseEntity> adapters() { + return ResponseEntity.ok(context.getBeansOfType(LdioAdapterConfigurator.class).keySet()); + } + + @GetMapping(path = "/transformers") + public ResponseEntity> transformers() { + return ResponseEntity.ok(context.getBeansOfType(LdioTransformerConfigurator.class).keySet()); + } + + @GetMapping(path = "/outputs") + public ResponseEntity> outputs() { + return ResponseEntity.ok(context.getBeansOfType(LdioOutputConfigurator.class).keySet()); + } +} diff --git a/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/ComponentExecutorImpl.java b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/ComponentExecutorImpl.java index 9c29c5e50..7104c1e7e 100644 --- a/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/ComponentExecutorImpl.java +++ b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/ComponentExecutorImpl.java @@ -1,43 +1,19 @@ package be.vlaanderen.informatievlaanderen.ldes.ldio.services; import be.vlaanderen.informatievlaanderen.ldes.ldi.services.ComponentExecutor; -import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiTransformer; +import be.vlaanderen.informatievlaanderen.ldes.ldio.types.LdioTransformer; import org.apache.jena.rdf.model.Model; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - public class ComponentExecutorImpl implements ComponentExecutor { - private final ExecutorService executorService; - private final List ldiTransformers; - private final LdiSender ldiSender; + private final LdioTransformer ldiTransformerPipeline; - public ComponentExecutorImpl(List ldiTransformers, LdiSender ldiSender) { - this.executorService = Executors.newSingleThreadExecutor(); - this.ldiTransformers = ldiTransformers; - this.ldiSender = ldiSender; + public ComponentExecutorImpl(LdioTransformer ldiTransformerPipeline) { + this.ldiTransformerPipeline = ldiTransformerPipeline; } @Override public void transformLinkedData(final Model linkedDataModel) { - executorService.execute(() -> { - List transformedLinkedDataModels = List.of(linkedDataModel); - for (LdiTransformer component : ldiTransformers) { - transformedLinkedDataModels = transformedLinkedDataModels.stream() - .flatMap(model -> component.apply(model).stream()).toList(); - } - - transformedLinkedDataModels.forEach(ldiSender); - }); - } - - public List getLdiTransformers() { - return ldiTransformers; - } - - public LdiSender getLdiSender() { - return ldiSender; + ldiTransformerPipeline.apply(linkedDataModel); } } diff --git a/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/LdiSender.java b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/LdiSender.java index aa1185e41..ad8d68082 100644 --- a/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/LdiSender.java +++ b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/LdiSender.java @@ -2,6 +2,7 @@ import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiOutput; import be.vlaanderen.informatievlaanderen.ldes.ldio.events.PipelineStatusEvent; +import be.vlaanderen.informatievlaanderen.ldes.ldio.types.LdioTransformer; import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.PipelineStatus; import org.apache.jena.rdf.model.Model; import org.springframework.context.ApplicationEventPublisher; @@ -10,12 +11,11 @@ import java.util.ArrayDeque; import java.util.List; import java.util.Queue; -import java.util.function.Consumer; import static be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.PipelineStatus.HALTED; import static be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.PipelineStatus.RUNNING; -public class LdiSender implements Consumer { +public class LdiSender extends LdioTransformer { private final ApplicationEventPublisher applicationEventPublisher; private PipelineStatus pipelineStatus; private final List ldiOutputs; @@ -28,19 +28,10 @@ public LdiSender(ApplicationEventPublisher applicationEventPublisher, this.pipelineStatus = RUNNING; } - @Override - public void accept(Model model) { - if (pipelineStatus == RUNNING) { - ldiOutputs.parallelStream().forEach(ldiOutput -> ldiOutput.accept(model)); - } else { - queue.add(model); - } - } - @SuppressWarnings({ "java:S131", "java:S1301" }) @EventListener public void handlePipelineStatus(PipelineStatusEvent statusEvent) { - switch (statusEvent.getStatus()) { + switch (statusEvent.status()) { case RESUMING -> { while (!queue.isEmpty()) { ldiOutputs.parallelStream().forEach(ldiOutput -> ldiOutput.accept(queue.poll())); @@ -51,4 +42,13 @@ public void handlePipelineStatus(PipelineStatusEvent statusEvent) { case HALTED -> this.pipelineStatus = HALTED; } } + + @Override + public void apply(Model model) { + if (pipelineStatus == RUNNING) { + ldiOutputs.parallelStream().forEach(ldiOutput -> ldiOutput.accept(model)); + } else { + queue.add(model); + } + } } diff --git a/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/PipelineController.java b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/PipelineController.java index 52f377cae..52e57b041 100644 --- a/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/PipelineController.java +++ b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/PipelineController.java @@ -1,8 +1,8 @@ package be.vlaanderen.informatievlaanderen.ldes.ldio.services; +import be.vlaanderen.informatievlaanderen.ldes.ldio.config.PipelineConfig; import be.vlaanderen.informatievlaanderen.ldes.ldio.events.PipelineStatusEvent; import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.PipelineStatus; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.event.EventListener; import org.springframework.http.ResponseEntity; @@ -11,17 +11,25 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + import static be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.PipelineStatus.*; @RestController @RequestMapping(path = "/admin/api/v1/pipeline") +// TODO redefine pipelinestatus feature public class PipelineController { - @Autowired - private ApplicationEventPublisher applicationEventPublisher; + private final ApplicationEventPublisher applicationEventPublisher; + private final PipelineService pipelineService; private PipelineStatus pipelineStatus = PipelineStatus.RUNNING; + public PipelineController(ApplicationEventPublisher applicationEventPublisher, PipelineService pipelineService) { + this.applicationEventPublisher = applicationEventPublisher; + this.pipelineService = pipelineService; + } + @GetMapping(path = "/status") public ResponseEntity getPipelineStatus() { return ResponseEntity.ok(pipelineStatus); @@ -44,9 +52,14 @@ public ResponseEntity resumePipeline() { }; } + @GetMapping(path = "/overview") + public ResponseEntity> overview() { + return ResponseEntity.ok(pipelineService.getPipelines()); + } + @EventListener public void handlePipelineStatusResponse(PipelineStatusEvent statusEvent) { - this.pipelineStatus = statusEvent.getStatus(); + this.pipelineStatus = statusEvent.status(); } private ResponseEntity resumeHaltedPipeline() { @@ -58,5 +71,4 @@ private ResponseEntity haltRunningPipeline() { applicationEventPublisher.publishEvent(new PipelineStatusEvent(HALTED)); return ResponseEntity.ok(HALTED); } - } diff --git a/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/PipelineCreatedEventListener.java b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/PipelineCreatedEventListener.java new file mode 100644 index 000000000..96ecb6e4c --- /dev/null +++ b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/PipelineCreatedEventListener.java @@ -0,0 +1,20 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldio.services; + +import be.vlaanderen.informatievlaanderen.ldes.ldio.events.PipelineCreatedEvent; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; + +@Component +public class PipelineCreatedEventListener implements ApplicationListener { + private final PipelineService pipelineService; + + public PipelineCreatedEventListener(PipelineService pipelineService) { + this.pipelineService = pipelineService; + } + + @Override + public void onApplicationEvent(PipelineCreatedEvent event) { + pipelineService.addPipeline(event.pipelineConfig()); + } +} diff --git a/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/PipelineService.java b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/PipelineService.java new file mode 100644 index 000000000..f61e94583 --- /dev/null +++ b/ldi-orchestrator/ldio-application/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/PipelineService.java @@ -0,0 +1,20 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldio.services; + +import be.vlaanderen.informatievlaanderen.ldes.ldio.config.PipelineConfig; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class PipelineService { + private final List pipelines = new ArrayList<>(); + + public void addPipeline(PipelineConfig pipeline) { + pipelines.add(pipeline); + } + + public List getPipelines() { + return pipelines; + } +} diff --git a/ldi-orchestrator/ldio-application/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/MockFlowConfiguration.java b/ldi-orchestrator/ldio-application/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/MockFlowConfiguration.java index 9639cb281..b0f32ae88 100644 --- a/ldi-orchestrator/ldio-application/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/MockFlowConfiguration.java +++ b/ldi-orchestrator/ldio-application/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/MockFlowConfiguration.java @@ -2,11 +2,13 @@ import be.vlaanderen.informatievlaanderen.ldes.ldi.services.ComponentExecutor; import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiAdapter; -import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiComponent; import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiInput; +import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiOutput; import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioConfigurator; import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioInputConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioTransformerConfigurator; import be.vlaanderen.informatievlaanderen.ldes.ldio.modules.*; +import be.vlaanderen.informatievlaanderen.ldes.ldio.types.LdioTransformer; import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.ComponentProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -29,14 +31,14 @@ public LdioConfigurator dummyAdapt() { @Bean @Qualifier("dummyTransform") - public LdioConfigurator dummyTransform() { - return new DummyTransformConfigurator(); + public LdioTransformerConfigurator dummyTransform() { + return new DummyTransformTransformerConfigurator(); } @Bean @Qualifier("dummyOut") public LdioConfigurator dummyOut() { - return new DummyOutConfigurator(); + return new DummyOutProcessorConfigurator(); } static class DummyInConfigurator implements LdioInputConfigurator { @@ -51,25 +53,27 @@ public LdiInput configure(LdiAdapter adapter, static class DummyAdaptConfigurator implements LdioConfigurator { @Override - public LdiComponent configure(ComponentProperties properties) { + public LdiAdapter configure(ComponentProperties properties) { return new DummyAdapt(); } } - static class DummyTransformConfigurator implements LdioConfigurator { + static class DummyTransformTransformerConfigurator implements LdioTransformerConfigurator { + @Override - public LdiComponent configure(ComponentProperties properties) { + public LdioTransformer configure(ComponentProperties properties) { return new DummyTransform(); } } - static class DummyOutConfigurator implements LdioConfigurator { + static class DummyOutProcessorConfigurator implements LdioConfigurator { @Autowired MockVault mockVault; @Override - public LdiComponent configure(ComponentProperties properties) { + public LdiOutput configure(ComponentProperties properties) { return new DummyOut(mockVault); } } + } diff --git a/ldi-orchestrator/ldio-application/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/modules/DummyOut.java b/ldi-orchestrator/ldio-application/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/modules/DummyOut.java index 880eedb52..35a617910 100644 --- a/ldi-orchestrator/ldio-application/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/modules/DummyOut.java +++ b/ldi-orchestrator/ldio-application/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/modules/DummyOut.java @@ -3,12 +3,7 @@ import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiOutput; import org.apache.jena.rdf.model.Model; -import java.util.ArrayList; -import java.util.List; - public class DummyOut implements LdiOutput { - public List output = new ArrayList<>(); - private final MockVault mockVault; public DummyOut(MockVault mockVault) { diff --git a/ldi-orchestrator/ldio-application/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/modules/DummyTransform.java b/ldi-orchestrator/ldio-application/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/modules/DummyTransform.java index fff7aee59..fcb7e3b9b 100644 --- a/ldi-orchestrator/ldio-application/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/modules/DummyTransform.java +++ b/ldi-orchestrator/ldio-application/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/modules/DummyTransform.java @@ -1,17 +1,20 @@ package be.vlaanderen.informatievlaanderen.ldes.ldio.modules; -import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiTransformer; +import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiOneToOneTransformer; +import be.vlaanderen.informatievlaanderen.ldes.ldio.types.LdioTransformer; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Resource; -import java.util.List; - -public class DummyTransform implements LdiTransformer { - @Override - public List apply(Model model) { +public class DummyTransform extends LdioTransformer { + LdiOneToOneTransformer ldiTransformer = model -> { Resource subject = model.listSubjects().toList().get(0); model.add(model.createLiteralStatement(subject, model.createProperty("http://schema.org/description"), "Transformed")); - return List.of(model); + return model; + }; + + @Override + public void apply(Model model) { + this.next(ldiTransformer.transform(model)); } } diff --git a/ldi-orchestrator/ldio-application/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/PipelineControllerTest.java b/ldi-orchestrator/ldio-application/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/PipelineControllerTest.java deleted file mode 100644 index 09780f7d8..000000000 --- a/ldi-orchestrator/ldio-application/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/services/PipelineControllerTest.java +++ /dev/null @@ -1,82 +0,0 @@ -package be.vlaanderen.informatievlaanderen.ldes.ldio.services; - -import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.PipelineStatus; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; -import org.springframework.test.web.reactive.server.WebTestClient; - -import static be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.PipelineStatus.*; - -@WebFluxTest -class PipelineControllerTest { - @Autowired - WebTestClient client; - private final String base_url = "/admin/api/v1/pipeline/"; - private final String resume_url = base_url + "resume"; - private final String halt_url = base_url + "halt"; - - @Test - void when_PipeLineIsHalted_EventIsSent() { - client.post() - .uri(halt_url) - .exchange() - .expectStatus() - .isOk() - .expectBody(PipelineStatus.class) - .isEqualTo(HALTED); - - client.post() - .uri(halt_url) - .exchange() - .expectStatus() - .isOk() - .expectBody(PipelineStatus.class) - .isEqualTo(HALTED); - - String status_url = base_url + "status"; - client.get() - .uri(status_url) - .exchange() - .expectStatus() - .isOk() - .expectBody(PipelineStatus.class) - .isEqualTo(HALTED); - } - - @Test - void when_PipelineIsResumedWhenHalted_ReturnsResuming() { - client.post() - .uri(halt_url) - .exchange() - .expectStatus() - .isOk() - .expectBody(PipelineStatus.class) - .isEqualTo(HALTED); - - client.post().uri(resume_url) - .exchange() - .expectStatus() - .isOk() - .expectBody(PipelineStatus.class) - .isEqualTo(RESUMING); - - client.post().uri(resume_url) - .exchange() - .expectStatus() - .isOk() - .expectBody(PipelineStatus.class) - .isEqualTo(RESUMING); - } - - @Test - void when_PipelineIsResumedWhenRunning_EventIsNotSent() { - client.post().uri(resume_url) - .exchange() - .expectStatus() - .isOk() - .expectBody(PipelineStatus.class) - .isEqualTo(RUNNING); - } - -} diff --git a/ldi-orchestrator/ldio-common/pom.xml b/ldi-orchestrator/ldio-common/pom.xml index e0a44e123..2ebd3ee68 100644 --- a/ldi-orchestrator/ldio-common/pom.xml +++ b/ldi-orchestrator/ldio-common/pom.xml @@ -5,7 +5,7 @@ ldi-orchestrator be.vlaanderen.informatievlaanderen.ldes.ldi - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 diff --git a/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/PipelineConfig.java b/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/PipelineConfig.java index 6b0aec480..9d9ea817a 100644 --- a/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/PipelineConfig.java +++ b/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/PipelineConfig.java @@ -3,10 +3,11 @@ import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.ComponentDefinition; import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.InputComponentDefinition; +import java.io.Serializable; import java.util.LinkedList; import java.util.List; -public class PipelineConfig { +public class PipelineConfig implements Serializable { public static final String PIPELINE_NAME = "pipeline.name"; private String name; private String description; diff --git a/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/configurator/LdioAdapterConfigurator.java b/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/configurator/LdioAdapterConfigurator.java new file mode 100644 index 000000000..e3030e9dc --- /dev/null +++ b/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/configurator/LdioAdapterConfigurator.java @@ -0,0 +1,4 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldio.configurator; + +public interface LdioAdapterConfigurator extends LdioConfigurator { +} diff --git a/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/configurator/LdioOutputConfigurator.java b/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/configurator/LdioOutputConfigurator.java new file mode 100644 index 000000000..f750cebf2 --- /dev/null +++ b/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/configurator/LdioOutputConfigurator.java @@ -0,0 +1,4 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldio.configurator; + +public interface LdioOutputConfigurator extends LdioConfigurator { +} diff --git a/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/configurator/LdioTransformerConfigurator.java b/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/configurator/LdioTransformerConfigurator.java new file mode 100644 index 000000000..591346b53 --- /dev/null +++ b/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/configurator/LdioTransformerConfigurator.java @@ -0,0 +1,8 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldio.configurator; + +import be.vlaanderen.informatievlaanderen.ldes.ldio.types.LdioTransformer; +import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.ComponentProperties; + +public interface LdioTransformerConfigurator { + LdioTransformer configure(ComponentProperties properties); +} diff --git a/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/types/LdioTransformer.java b/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/types/LdioTransformer.java new file mode 100644 index 000000000..bd841fbe8 --- /dev/null +++ b/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/types/LdioTransformer.java @@ -0,0 +1,28 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldio.types; + +import org.apache.jena.rdf.model.Model; + +import java.util.List; + +public abstract class LdioTransformer { + + private LdioTransformer nextProcessor; + + public abstract void apply(Model model); + + protected void next(Model model) { + if (nextProcessor != null) { + nextProcessor.apply(model); + } + } + + public static LdioTransformer link(LdioTransformer first, List chain) { + LdioTransformer head = first; + for (LdioTransformer nextInChain : chain) { + head.nextProcessor = nextInChain; + head = nextInChain; + } + return first; + } + +} diff --git a/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/types/LdioVaultTransformer.java b/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/types/LdioVaultTransformer.java new file mode 100644 index 000000000..790e913ec --- /dev/null +++ b/ldi-orchestrator/ldio-common/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/types/LdioVaultTransformer.java @@ -0,0 +1,26 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldio.types; + +import org.apache.jena.rdf.model.Model; + +import java.util.ArrayList; +import java.util.List; + +/** + * This LdioTransformer can be used for test purposes. + */ +public class LdioVaultTransformer extends LdioTransformer { + private final List models; + + public LdioVaultTransformer() { + this.models = new ArrayList<>(); + } + + @Override + public void apply(Model model) { + models.add(model); + } + + public List getModels() { + return models; + } +} diff --git a/ldi-orchestrator/ldio-connectors/ldio-archive-file-in/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-archive-file-in/pom.xml index 548f0daea..eb897019b 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-archive-file-in/pom.xml +++ b/ldi-orchestrator/ldio-connectors/ldio-archive-file-in/pom.xml @@ -6,7 +6,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldio ldio-connectors - 1.9.0 + 1.10.0-SNAPSHOT ldio-archive-file-in diff --git a/ldi-orchestrator/ldio-connectors/ldio-azure-blob-out/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-azure-blob-out/pom.xml index e24ee9014..1c8b11e6a 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-azure-blob-out/pom.xml +++ b/ldi-orchestrator/ldio-connectors/ldio-azure-blob-out/pom.xml @@ -6,7 +6,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldio ldio-connectors - 1.9.0 + 1.10.0-SNAPSHOT diff --git a/ldi-orchestrator/ldio-connectors/ldio-azure-blob-out/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioAzureBlobOutAutoConfig.java b/ldi-orchestrator/ldio-connectors/ldio-azure-blob-out/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioAzureBlobOutAutoConfig.java index c29c3b441..fc4341d7f 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-azure-blob-out/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioAzureBlobOutAutoConfig.java +++ b/ldi-orchestrator/ldio-connectors/ldio-azure-blob-out/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioAzureBlobOutAutoConfig.java @@ -1,8 +1,8 @@ package be.vlaanderen.informatievlaanderen.ldes.ldio.config; -import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiComponent; +import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiOutput; import be.vlaanderen.informatievlaanderen.ldes.ldio.LdiAzureBlobOut; -import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioOutputConfigurator; import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.ComponentProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -10,11 +10,11 @@ @Configuration public class LdioAzureBlobOutAutoConfig { @Bean("be.vlaanderen.informatievlaanderen.ldes.ldio.LdiAzureBlobOut") - public LdioConfigurator ldioConfigurator() { + public LdioOutputConfigurator ldioConfigurator() { return new LdioAzureBlobOutConfigurator(); } - public static class LdioAzureBlobOutConfigurator implements LdioConfigurator { + public static class LdioAzureBlobOutConfigurator implements LdioOutputConfigurator { public static final String PROPERTY_LANG = "lang"; public static final String PROPERTY_STORAGE_ACCOUNT_NAME = "storage-account-name"; public static final String PROPERTY_CONNECTION_STRING = "connection-string"; @@ -24,7 +24,7 @@ public static class LdioAzureBlobOutConfigurator implements LdioConfigurator { public static final String DEFAULT_JSON_CONTEXT_URI = ""; @Override - public LdiComponent configure(ComponentProperties properties) { + public LdiOutput configure(ComponentProperties properties) { String outputLanguage = properties.getOptionalProperty(PROPERTY_LANG) .orElse(DEFAULT_OUTPUT_LANG); String storageAccountName = properties.getProperty(PROPERTY_STORAGE_ACCOUNT_NAME); diff --git a/ldi-orchestrator/ldio-connectors/ldio-console-out/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-console-out/pom.xml index 6eab585d0..6cfc89065 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-console-out/pom.xml +++ b/ldi-orchestrator/ldio-connectors/ldio-console-out/pom.xml @@ -3,7 +3,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldio ldio-connectors - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 diff --git a/ldi-orchestrator/ldio-connectors/ldio-console-out/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioConsoleOutAutoConfig.java b/ldi-orchestrator/ldio-connectors/ldio-console-out/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioConsoleOutAutoConfig.java index e3fb2bdf0..211417077 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-console-out/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioConsoleOutAutoConfig.java +++ b/ldi-orchestrator/ldio-connectors/ldio-console-out/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioConsoleOutAutoConfig.java @@ -3,7 +3,7 @@ import be.vlaanderen.informatievlaanderen.ldes.ldi.rdf.formatter.LdiRdfWriterProperties; import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiComponent; import be.vlaanderen.informatievlaanderen.ldes.ldio.LdiConsoleOut; -import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioOutputConfigurator; import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.ComponentProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -13,11 +13,11 @@ @Configuration public class LdioConsoleOutAutoConfig { @Bean("be.vlaanderen.informatievlaanderen.ldes.ldio.LdioConsoleOut") - public LdioConfigurator ldioConfigurator() { + public LdioOutputConfigurator ldioConfigurator() { return new LdioConsoleOutConfigurator(); } - public static class LdioConsoleOutConfigurator implements LdioConfigurator { + public static class LdioConsoleOutConfigurator implements LdioOutputConfigurator { @Override public LdiComponent configure(ComponentProperties config) { diff --git a/ldi-orchestrator/ldio-connectors/ldio-file-out/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-file-out/pom.xml index b547abc1f..e86d5c830 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-file-out/pom.xml +++ b/ldi-orchestrator/ldio-connectors/ldio-file-out/pom.xml @@ -6,7 +6,7 @@ ldio-connectors be.vlaanderen.informatievlaanderen.ldes.ldio - 1.9.0 + 1.10.0-SNAPSHOT ldio-file-out diff --git a/ldi-orchestrator/ldio-connectors/ldio-file-out/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioFileOutAutoConfig.java b/ldi-orchestrator/ldio-connectors/ldio-file-out/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioFileOutAutoConfig.java index 449a308d7..600ec2dad 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-file-out/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioFileOutAutoConfig.java +++ b/ldi-orchestrator/ldio-connectors/ldio-file-out/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioFileOutAutoConfig.java @@ -5,7 +5,7 @@ import be.vlaanderen.informatievlaanderen.ldes.ldio.TimestampExtractor; import be.vlaanderen.informatievlaanderen.ldes.ldio.TimestampFromCurrentTimeExtractor; import be.vlaanderen.informatievlaanderen.ldes.ldio.TimestampFromPathExtractor; -import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioOutputConfigurator; import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.ComponentProperties; import org.apache.jena.rdf.model.ResourceFactory; import org.springframework.context.annotation.Bean; @@ -20,8 +20,8 @@ public class LdioFileOutAutoConfig { public static final String TIMESTAMP_PATH_PROP = "timestamp-path"; @Bean("be.vlaanderen.informatievlaanderen.ldes.ldio.LdioFileOut") - public LdioConfigurator ldiFileOutConfigurator() { - return new LdioConfigurator() { + public LdioOutputConfigurator ldiFileOutConfigurator() { + return new LdioOutputConfigurator() { @Override public LdiComponent configure(ComponentProperties properties) { final String archiveDirectory = properties.getProperty(ARCHIVE_ROOT_DIR_PROP); diff --git a/ldi-orchestrator/ldio-connectors/ldio-geojson-to-wkt/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-geojson-to-wkt/pom.xml index 9960d26e0..26b9a83c4 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-geojson-to-wkt/pom.xml +++ b/ldi-orchestrator/ldio-connectors/ldio-geojson-to-wkt/pom.xml @@ -6,7 +6,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldio ldio-connectors - 1.9.0 + 1.10.0-SNAPSHOT ldio-geojson-to-wkt diff --git a/ldi-orchestrator/ldio-connectors/ldio-geojson-to-wkt/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioGeoJsonToWkt.java b/ldi-orchestrator/ldio-connectors/ldio-geojson-to-wkt/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioGeoJsonToWkt.java new file mode 100644 index 000000000..70bb686d2 --- /dev/null +++ b/ldi-orchestrator/ldio-connectors/ldio-geojson-to-wkt/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioGeoJsonToWkt.java @@ -0,0 +1,18 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldio.config; + +import be.vlaanderen.informatievlaanderen.ldes.ldi.GeoJsonToWktTransformer; +import be.vlaanderen.informatievlaanderen.ldes.ldio.types.LdioTransformer; +import org.apache.jena.rdf.model.Model; + +public class LdioGeoJsonToWkt extends LdioTransformer { + private final GeoJsonToWktTransformer transformer; + + public LdioGeoJsonToWkt() { + this.transformer = new GeoJsonToWktTransformer(); + } + + @Override + public void apply(Model model) { + this.next(transformer.transform(model)); + } +} diff --git a/ldi-orchestrator/ldio-connectors/ldio-geojson-to-wkt/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioGeoJsonToWktAutoConfig.java b/ldi-orchestrator/ldio-connectors/ldio-geojson-to-wkt/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioGeoJsonToWktAutoConfig.java index 7db2d589b..c19266fef 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-geojson-to-wkt/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioGeoJsonToWktAutoConfig.java +++ b/ldi-orchestrator/ldio-connectors/ldio-geojson-to-wkt/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioGeoJsonToWktAutoConfig.java @@ -1,7 +1,6 @@ package be.vlaanderen.informatievlaanderen.ldes.ldio.config; -import be.vlaanderen.informatievlaanderen.ldes.ldi.GeoJsonToWktTransformer; -import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioTransformerConfigurator; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -9,8 +8,8 @@ public class LdioGeoJsonToWktAutoConfig { @Bean("be.vlaanderen.informatievlaanderen.ldes.ldi.GeoJsonToWktTransformer") - public LdioConfigurator geoJsonToWktConfigurator() { - return properties -> new GeoJsonToWktTransformer(); + public LdioTransformerConfigurator geoJsonToWktConfigurator() { + return properties -> new LdioGeoJsonToWkt(); } } diff --git a/ldi-orchestrator/ldio-connectors/ldio-http-enricher/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-http-enricher/pom.xml index 9f45fdb81..2e1da55ac 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-http-enricher/pom.xml +++ b/ldi-orchestrator/ldio-connectors/ldio-http-enricher/pom.xml @@ -5,7 +5,7 @@ ldio-connectors be.vlaanderen.informatievlaanderen.ldes.ldio - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 diff --git a/ldi-orchestrator/ldio-connectors/ldio-http-enricher/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioHttpEnricher.java b/ldi-orchestrator/ldio-connectors/ldio-http-enricher/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioHttpEnricher.java index d976a3a26..6bb085096 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-http-enricher/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioHttpEnricher.java +++ b/ldi-orchestrator/ldio-connectors/ldio-http-enricher/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioHttpEnricher.java @@ -3,7 +3,7 @@ import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.RequestExecutor; import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects.*; import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiAdapter; -import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiTransformer; +import be.vlaanderen.informatievlaanderen.ldes.ldio.types.LdioTransformer; import org.apache.commons.text.StringEscapeUtils; import org.apache.http.HttpHeaders; import org.apache.http.entity.ContentType; @@ -12,10 +12,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Collection; import java.util.List; -public class LdioHttpEnricher implements LdiTransformer { +public class LdioHttpEnricher extends LdioTransformer { private static final Logger LOGGER = LoggerFactory.getLogger(LdioHttpEnricher.class); @@ -31,14 +30,14 @@ public LdioHttpEnricher(LdiAdapter adapter, RequestExecutor requestExecutor, } @Override - public Collection apply(Model model) { + public void apply(Model model) { final Request request = createRequest(model); final Response response = requestExecutor.execute(request); LOGGER.info(request.getMethod() + " " + request.getUrl() + " " + response.getHttpStatus()); addResponseToModel(model, response); - return List.of(model); + this.next(model); } private Request createRequest(Model model) { diff --git a/ldi-orchestrator/ldio-connectors/ldio-http-enricher/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioHttpEnricherAutoConfig.java b/ldi-orchestrator/ldio-connectors/ldio-http-enricher/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioHttpEnricherAutoConfig.java index 69fea52ad..d12d547b4 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-http-enricher/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioHttpEnricherAutoConfig.java +++ b/ldi-orchestrator/ldio-connectors/ldio-http-enricher/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioHttpEnricherAutoConfig.java @@ -4,7 +4,8 @@ import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiAdapter; import be.vlaanderen.informatievlaanderen.ldes.ldio.LdioHttpEnricher; import be.vlaanderen.informatievlaanderen.ldes.ldio.RequestPropertyPathExtractors; -import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioAdapterConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioTransformerConfigurator; import be.vlaanderen.informatievlaanderen.ldes.ldio.requestexecutor.LdioRequestExecutorSupplier; import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.ComponentProperties; import org.springframework.context.ConfigurableApplicationContext; @@ -18,7 +19,7 @@ public class LdioHttpEnricherAutoConfig { @Bean("be.vlaanderen.informatievlaanderen.ldes.ldio.LdioHttpEnricher") - public LdioConfigurator ldioConfigurator(ConfigurableApplicationContext configContext) { + public LdioTransformerConfigurator ldioConfigurator(ConfigurableApplicationContext configContext) { return config -> { final LdiAdapter adapter = createAdapter(configContext, config); final RequestPropertyPathExtractors requestPropertyPaths = new PropertyPathExtractorConverter(config) @@ -30,7 +31,8 @@ public LdioConfigurator ldioConfigurator(ConfigurableApplicationContext configCo private LdiAdapter createAdapter(ConfigurableApplicationContext configContext, ComponentProperties config) { final String adapterBeanName = config.getProperty(ADAPTER_NAME); - final LdioConfigurator ldioConfigurator = (LdioConfigurator) configContext.getBean(adapterBeanName); + final LdioAdapterConfigurator ldioConfigurator = (LdioAdapterConfigurator) configContext + .getBean(adapterBeanName); return (LdiAdapter) ldioConfigurator.configure(config.extractNestedProperties(ADAPTER_CONFIG)); } diff --git a/ldi-orchestrator/ldio-connectors/ldio-http-enricher/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/HttpEnricherSteps.java b/ldi-orchestrator/ldio-connectors/ldio-http-enricher/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/HttpEnricherSteps.java index 8fac14cf0..6cc81db3c 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-http-enricher/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/HttpEnricherSteps.java +++ b/ldi-orchestrator/ldio-connectors/ldio-http-enricher/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/HttpEnricherSteps.java @@ -6,6 +6,8 @@ import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.RequestExecutor; import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.services.RequestExecutorFactory; import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiAdapter; +import be.vlaanderen.informatievlaanderen.ldes.ldio.types.LdioTransformer; +import be.vlaanderen.informatievlaanderen.ldes.ldio.types.LdioVaultTransformer; import io.cucumber.java.en.And; import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; @@ -15,10 +17,10 @@ import org.apache.jena.riot.RDFParser; import org.apache.jena.riot.RDFParserBuilder; -import java.util.ArrayList; import java.util.List; import java.util.stream.Stream; +import static be.vlaanderen.informatievlaanderen.ldes.ldio.types.LdioTransformer.link; import static org.apache.jena.rdf.model.ResourceFactory.createProperty; import static org.apache.jena.rdf.model.ResourceFactory.createResource; import static org.apache.jena.riot.RDFLanguages.nameToLang; @@ -26,9 +28,9 @@ public class HttpEnricherSteps { - private List resultModels; private Model inputModel; - private LdioHttpEnricher ldioHttpEnricher; + private LdioTransformer ldioHttpEnricher; + private LdioVaultTransformer vault; private LdiAdapter ldiAdapter; private String urlPropertyPath; private String bodyPropertyPath; @@ -73,7 +75,9 @@ public void iCreateAnLdioHttpEnricherWithTheConfiguredProperties() { getPropertyPathExtractor(bodyPropertyPath), getPropertyPathExtractor(headerPropertyPath), getPropertyPathExtractor(httpMethodPropertyPath)); - ldioHttpEnricher = new LdioHttpEnricher(ldiAdapter, requestExecutor, propertyPathExtractors); + vault = new LdioVaultTransformer(); + ldioHttpEnricher = link(new LdioHttpEnricher(ldiAdapter, requestExecutor, propertyPathExtractors), + List.of(vault)); } private PropertyExtractor getPropertyPathExtractor(String propertyPath) { @@ -97,17 +101,17 @@ public void iHaveAModelWithAnInvalidHttpMethod() { @When("I send the model to the enricher") public void iSendTheModelToTheEnricher() { - resultModels = new ArrayList<>(ldioHttpEnricher.apply(inputModel)); + ldioHttpEnricher.apply(inputModel); } @Then("The result contains {int} model") public void theResultContainsModel(int resultCount) { - assertEquals(resultCount, resultModels.size()); + assertEquals(resultCount, vault.getModels().size()); } @Then("The result contains a model with both the input and the http response") public void theResultContainsAModelWithBothTheInputAndTheHttpResponse() { - Model resultModel = this.resultModels.get(0); + Model resultModel = this.vault.getModels().get(0); final Model expectedModel = ModelFactory.createDefaultModel(); expectedModel.add(inputModel); diff --git a/ldi-orchestrator/ldio-connectors/ldio-http-in-poller/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-http-in-poller/pom.xml index 6ecbd08fd..b6d09142e 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-http-in-poller/pom.xml +++ b/ldi-orchestrator/ldio-connectors/ldio-http-in-poller/pom.xml @@ -6,7 +6,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldio ldio-connectors - 1.9.0 + 1.10.0-SNAPSHOT ldio-http-in-poller diff --git a/ldi-orchestrator/ldio-connectors/ldio-http-in-poller/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/HttpInputPollerTest.java b/ldi-orchestrator/ldio-connectors/ldio-http-in-poller/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/HttpInputPollerTest.java index 19bc4c5c7..9fe1a6602 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-http-in-poller/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/HttpInputPollerTest.java +++ b/ldi-orchestrator/ldio-connectors/ldio-http-in-poller/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/HttpInputPollerTest.java @@ -32,7 +32,7 @@ class HttpInputPollerTest { private static final String CONTENT = "_:b0 \"Jane Doe\" ."; private static final String CONTENT_TYPE = "application/n-quads"; private HttpInputPoller httpInputPoller; - private static RequestExecutor noAuthExecutor = new RequestExecutorFactory().createNoAuthExecutor(); + private static final RequestExecutor noAuthExecutor = new RequestExecutorFactory().createNoAuthExecutor(); @BeforeEach void setUp() { diff --git a/ldi-orchestrator/ldio-connectors/ldio-http-in/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-http-in/pom.xml index 38fae0181..d2d48d728 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-http-in/pom.xml +++ b/ldi-orchestrator/ldio-connectors/ldio-http-in/pom.xml @@ -3,16 +3,12 @@ be.vlaanderen.informatievlaanderen.ldes.ldio ldio-connectors - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 ldio-http-in - - ../../.. - - org.springframework.boot diff --git a/ldi-orchestrator/ldio-connectors/ldio-http-in/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioHttpIn.java b/ldi-orchestrator/ldio-connectors/ldio-http-in/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioHttpIn.java index 0b46f9298..0aa1d6370 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-http-in/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioHttpIn.java +++ b/ldi-orchestrator/ldio-connectors/ldio-http-in/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioHttpIn.java @@ -11,8 +11,6 @@ import org.springframework.web.reactive.function.server.ServerResponse; import java.util.NoSuchElementException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import static org.springframework.web.reactive.function.server.RequestPredicates.POST; import static org.springframework.web.reactive.function.server.RouterFunctions.route; @@ -21,7 +19,6 @@ public class LdioHttpIn extends LdiInput { private static final Logger LOGGER = LoggerFactory.getLogger(LdioHttpIn.class); private final String endpoint; - private final ExecutorService executorService = Executors.newSingleThreadExecutor(); public LdioHttpIn(ComponentExecutor executor, LdiAdapter adapter, String endpoint) { super(executor, adapter); @@ -40,9 +37,8 @@ public RouterFunction mapping() { + req.headers().contentLength().orElse(0L)); return req.bodyToMono(String.class) - .doOnNext(content -> executorService - .execute(() -> getAdapter().apply(Content.of(content, contentType)) - .forEach(getExecutor()::transformLinkedData))) + .doOnNext(content -> getAdapter().apply(Content.of(content, contentType)) + .forEach(getExecutor()::transformLinkedData)) .flatMap(body -> ServerResponse.accepted().build()); }); } diff --git a/ldi-orchestrator/ldio-connectors/ldio-http-out/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-http-out/pom.xml index 993b3ab4e..2e28ee53c 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-http-out/pom.xml +++ b/ldi-orchestrator/ldio-connectors/ldio-http-out/pom.xml @@ -3,7 +3,7 @@ ldio-connectors be.vlaanderen.informatievlaanderen.ldes.ldio - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 diff --git a/ldi-orchestrator/ldio-connectors/ldio-http-out/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioHttpOutAutoConfig.java b/ldi-orchestrator/ldio-connectors/ldio-http-out/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioHttpOutAutoConfig.java index cb1fa7030..63c1f0dea 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-http-out/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioHttpOutAutoConfig.java +++ b/ldi-orchestrator/ldio-connectors/ldio-http-out/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioHttpOutAutoConfig.java @@ -4,7 +4,7 @@ import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.RequestExecutor; import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiComponent; import be.vlaanderen.informatievlaanderen.ldes.ldio.LdioHttpOut; -import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioOutputConfigurator; import be.vlaanderen.informatievlaanderen.ldes.ldio.requestexecutor.LdioRequestExecutorSupplier; import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.ComponentProperties; import org.springframework.context.annotation.Bean; @@ -16,11 +16,11 @@ public class LdioHttpOutAutoConfig { @Bean("be.vlaanderen.informatievlaanderen.ldes.ldio.LdioHttpOut") - public LdioHttpOutConfigurator ldiHttpOutConfigurator() { + public LdioOutputConfigurator ldiHttpOutConfigurator() { return new LdioHttpOutConfigurator(); } - public static class LdioHttpOutConfigurator implements LdioConfigurator { + public static class LdioHttpOutConfigurator implements LdioOutputConfigurator { @Override public LdiComponent configure(ComponentProperties config) { diff --git a/ldi-orchestrator/ldio-connectors/ldio-json-to-ld-adapter/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-json-to-ld-adapter/pom.xml index 03806fe30..1eb2d23ed 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-json-to-ld-adapter/pom.xml +++ b/ldi-orchestrator/ldio-connectors/ldio-json-to-ld-adapter/pom.xml @@ -5,7 +5,7 @@ ldio-connectors be.vlaanderen.informatievlaanderen.ldes.ldio - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 diff --git a/ldi-orchestrator/ldio-connectors/ldio-json-to-ld-adapter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioJsonToLdAdapterAutoConfig.java b/ldi-orchestrator/ldio-connectors/ldio-json-to-ld-adapter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioJsonToLdAdapterAutoConfig.java index 99a3f01ed..b2b4f92cf 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-json-to-ld-adapter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioJsonToLdAdapterAutoConfig.java +++ b/ldi-orchestrator/ldio-connectors/ldio-json-to-ld-adapter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioJsonToLdAdapterAutoConfig.java @@ -2,7 +2,7 @@ import be.vlaanderen.informatievlaanderen.ldes.ldi.JsonToLdAdapter; import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiComponent; -import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioAdapterConfigurator; import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.ComponentProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -11,11 +11,11 @@ public class LdioJsonToLdAdapterAutoConfig { @Bean("be.vlaanderen.informatievlaanderen.ldes.ldi.JsonToLdAdapter") - public LdioConfigurator ldioJsonToLdAdapterConfigurator() { - return new LdioJsonToLdAdapterConfigurator(); + public LdioAdapterConfigurator ldioJsonToLdAdapterConfigurator() { + return new LdioJsonToLdConfigurator(); } - public static class LdioJsonToLdAdapterConfigurator implements LdioConfigurator { + public static class LdioJsonToLdConfigurator implements LdioAdapterConfigurator { @Override public LdiComponent configure(ComponentProperties config) { String coreContext = config.getProperty("core-context"); diff --git a/ldi-orchestrator/ldio-connectors/ldio-json-to-ld-adapter/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/JsonToLdIntegrationSteps.java b/ldi-orchestrator/ldio-connectors/ldio-json-to-ld-adapter/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/JsonToLdIntegrationSteps.java index ca8c3fc01..ff1188cab 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-json-to-ld-adapter/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/JsonToLdIntegrationSteps.java +++ b/ldi-orchestrator/ldio-connectors/ldio-json-to-ld-adapter/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/JsonToLdIntegrationSteps.java @@ -35,7 +35,7 @@ public void setConfig() { @And("I create the adapter") public void iCreateAdapter() { ComponentProperties properties = new ComponentProperties(config); - adapter = new LdioJsonToLdAdapterAutoConfig.LdioJsonToLdAdapterConfigurator().configure(properties); + adapter = new LdioJsonToLdAdapterAutoConfig.LdioJsonToLdConfigurator().configure(properties); } @When("I send a json object") diff --git a/ldi-orchestrator/ldio-connectors/ldio-kafka/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-kafka/pom.xml index c0136b017..39e8c89d5 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-kafka/pom.xml +++ b/ldi-orchestrator/ldio-connectors/ldio-kafka/pom.xml @@ -5,16 +5,12 @@ ldio-connectors be.vlaanderen.informatievlaanderen.ldes.ldio - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 ldio-kafka - - ../../.. - - be.vlaanderen.informatievlaanderen.ldes.ldi diff --git a/ldi-orchestrator/ldio-connectors/ldio-kafka/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioKafkaOutAutoConfig.java b/ldi-orchestrator/ldio-connectors/ldio-kafka/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioKafkaOutAutoConfig.java index c832b82f5..349075788 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-kafka/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioKafkaOutAutoConfig.java +++ b/ldi-orchestrator/ldio-connectors/ldio-kafka/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioKafkaOutAutoConfig.java @@ -1,6 +1,6 @@ package be.vlaanderen.informatievlaanderen.ldes.ldio.config; -import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioOutputConfigurator; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -8,8 +8,8 @@ public class LdioKafkaOutAutoConfig { @Bean("be.vlaanderen.informatievlaanderen.ldes.ldio.LdioKafkaOut") - public LdioConfigurator ldiKafkaOutConfigurator() { - return new LdioKafkaOutConfigurator(); + public LdioOutputConfigurator ldiKafkaOutConfigurator() { + return new LdioKafkaOutProcessorConfigurator(); } } diff --git a/ldi-orchestrator/ldio-connectors/ldio-kafka/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioKafkaOutConfigurator.java b/ldi-orchestrator/ldio-connectors/ldio-kafka/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioKafkaOutProcessorConfigurator.java similarity index 97% rename from ldi-orchestrator/ldio-connectors/ldio-kafka/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioKafkaOutConfigurator.java rename to ldi-orchestrator/ldio-connectors/ldio-kafka/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioKafkaOutProcessorConfigurator.java index 97ca23189..c0383837d 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-kafka/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioKafkaOutConfigurator.java +++ b/ldi-orchestrator/ldio-connectors/ldio-kafka/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioKafkaOutProcessorConfigurator.java @@ -6,7 +6,7 @@ import be.vlaanderen.informatievlaanderen.ldes.ldio.LdioKafkaOut; import be.vlaanderen.informatievlaanderen.ldes.ldio.auth.KafkaAuthStrategy; import be.vlaanderen.informatievlaanderen.ldes.ldio.auth.SaslSslPlainConfigProvider; -import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioOutputConfigurator; import be.vlaanderen.informatievlaanderen.ldes.ldio.exceptions.SecurityProtocolNotSupportedException; import be.vlaanderen.informatievlaanderen.ldes.ldio.keyextractor.KafkaKeyExtractor; import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.ComponentProperties; @@ -23,7 +23,7 @@ import static be.vlaanderen.informatievlaanderen.ldes.ldio.auth.KafkaAuthStrategy.SASL_SSL_PLAIN; import static be.vlaanderen.informatievlaanderen.ldes.ldio.config.KafkaOutConfigKeys.*; -public class LdioKafkaOutConfigurator implements LdioConfigurator { +public class LdioKafkaOutProcessorConfigurator implements LdioOutputConfigurator { @Override public LdiComponent configure(ComponentProperties config) { diff --git a/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/pom.xml new file mode 100644 index 000000000..ea3c7cf7b --- /dev/null +++ b/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/pom.xml @@ -0,0 +1,59 @@ + + + + be.vlaanderen.informatievlaanderen.ldes.ldio + ldio-connectors + 1.10.0-SNAPSHOT + + 4.0.0 + + ldio-ldes-client-connector + + + + + org.springframework.boot + spring-boot-starter-webflux + + + ch.qos.logback + logback-classic + + + + + + be.vlaanderen.informatievlaanderen.ldes.ldio + ldio-request-executor + ${project.version} + compile + + + be.vlaanderen.informatievlaanderen.ldes.ldio + ldio-ldes-client + + + net.bytebuddy + byte-buddy-dep + + + org.mockito + mockito-core + + + ${project.version} + compile + + + + + org.springframework + spring-test + test + + + + + \ No newline at end of file diff --git a/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioLdesClientConnectorApi.java b/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioLdesClientConnectorApi.java new file mode 100644 index 000000000..a9540cccb --- /dev/null +++ b/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioLdesClientConnectorApi.java @@ -0,0 +1,54 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldio; + +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.services.TokenService; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.services.TransferService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; +import reactor.core.publisher.Mono; + +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; + +public class LdioLdesClientConnectorApi { + + private static final Logger log = LoggerFactory.getLogger(LdioLdesClientConnectorApi.class); + private final String pipelineName; + private final TransferService transferService; + private final TokenService tokenService; + + public LdioLdesClientConnectorApi(String pipelineName, TransferService transferService, TokenService tokenService) { + this.pipelineName = pipelineName; + this.transferService = transferService; + this.tokenService = tokenService; + } + + public RouterFunction endpoints() { + return route(POST("/%s/token".formatted(pipelineName)), + request -> { + logIncomingRequest(request); + return request.bodyToMono(String.class) + .doOnNext(tokenService::updateToken) + .flatMap(body -> ServerResponse.accepted().build()); + }).andRoute(POST("/%s/transfer".formatted(pipelineName)), + request -> { + logIncomingRequest(request); + return request.bodyToMono(String.class) + .flatMap(requestString -> { + var response = transferService.startTransfer(requestString).getBody() + .orElse(""); + return ServerResponse.accepted().body(Mono.just(response), String.class); + }); + }); + } + + private void logIncomingRequest(ServerRequest request) { + var type = request.headers().contentType().map(MediaType::toString).orElse("(unknown)"); + long contentLength = request.headers().contentLength().orElse(0L); + log.atDebug().log("POST /%s type: %s length: %s".formatted(pipelineName, type, contentLength)); + } + +} diff --git a/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioLdesClientConnectorAutoConfig.java b/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioLdesClientConnectorAutoConfig.java new file mode 100644 index 000000000..c53770c2a --- /dev/null +++ b/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioLdesClientConnectorAutoConfig.java @@ -0,0 +1,74 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldio.config; + +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.RequestExecutor; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.services.MemoryTokenService; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.services.MemoryTransferService; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.valueobjects.EdcUrlProxy; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.noauth.DefaultConfig; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.services.RequestExecutorFactory; +import be.vlaanderen.informatievlaanderen.ldes.ldi.services.ComponentExecutor; +import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiAdapter; +import be.vlaanderen.informatievlaanderen.ldes.ldio.LdesClientRunner; +import be.vlaanderen.informatievlaanderen.ldes.ldio.LdioLdesClient; +import be.vlaanderen.informatievlaanderen.ldes.ldio.LdioLdesClientConnectorApi; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioInputConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.ComponentProperties; +import ldes.client.treenodesupplier.domain.valueobject.StatePersistence; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import static be.vlaanderen.informatievlaanderen.ldes.ldio.config.PipelineConfig.PIPELINE_NAME; + +@SuppressWarnings("java:S6830") +@Configuration +public class LdioLdesClientConnectorAutoConfig { + + public static final String NAME = "be.vlaanderen.informatievlaanderen.ldes.ldio.LdioLdesClientConnector"; + + @Bean(NAME) + public LdioHttpInConfigurator ldioConfigurator() { + return new LdioHttpInConfigurator(); + } + + public static class LdioHttpInConfigurator implements LdioInputConfigurator { + + public static final String CONNECTOR_TRANSFER_URL = "connector-transfer-url"; + public static final String PROXY_URL_TO_REPLACE = "proxy-url-to-replace"; + public static final String PROXY_URL_REPLACEMENT = "proxy-url-replacement"; + + private final StatePersistenceFactory statePersistenceFactory = new StatePersistenceFactory(); + private final RequestExecutor baseRequestExecutor = new DefaultConfig().createRequestExecutor(); + private final RequestExecutorFactory requestExecutorFactory = new RequestExecutorFactory(); + + @Override + public Object configure(LdiAdapter adapter, ComponentExecutor executor, ComponentProperties properties) { + final var connectorTransferUrl = properties.getProperty(CONNECTOR_TRANSFER_URL); + final var transferService = new MemoryTransferService(baseRequestExecutor, connectorTransferUrl); + final var tokenService = new MemoryTokenService(transferService); + startLdesClient(executor, properties, tokenService); + + final var pipelineName = properties.getProperty(PIPELINE_NAME); + return new LdioLdesClientConnectorApi(pipelineName, transferService, tokenService).endpoints(); + } + + public void startLdesClient(ComponentExecutor componentExecutor, + ComponentProperties properties, + MemoryTokenService tokenService) { + final var urlProxy = getEdcUrlProxy(properties); + final var edcRequestExecutor = requestExecutorFactory.createEdcExecutor(baseRequestExecutor, tokenService, + urlProxy); + final StatePersistence statePersistence = statePersistenceFactory.getStatePersistence(properties); + final LdesClientRunner ldesClientRunner = new LdesClientRunner(edcRequestExecutor, properties, + componentExecutor, statePersistence); + + // starts the client + new LdioLdesClient(componentExecutor, ldesClientRunner); + } + + private static EdcUrlProxy getEdcUrlProxy(ComponentProperties properties) { + final var proxyUrlToReplace = properties.getOptionalProperty(PROXY_URL_TO_REPLACE).orElse(""); + final var proxyUrlReplacement = properties.getOptionalProperty(PROXY_URL_REPLACEMENT).orElse(""); + return new EdcUrlProxy(proxyUrlToReplace, proxyUrlReplacement); + } + } +} diff --git a/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioLdesClientConnectorApiTest.java b/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioLdesClientConnectorApiTest.java new file mode 100644 index 000000000..3f31eb762 --- /dev/null +++ b/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/test/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioLdesClientConnectorApiTest.java @@ -0,0 +1,71 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldio; + +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.services.TokenService; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.executor.edc.services.TransferService; +import be.vlaanderen.informatievlaanderen.ldes.ldi.requestexecutor.valueobjects.Response; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.test.web.reactive.server.WebTestClient; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; +import reactor.core.publisher.Mono; + +import java.util.List; + +import static org.mockito.Mockito.*; + +class LdioLdesClientConnectorApiTest { + + private WebTestClient client; + private final String endpoint = "endpoint"; + private TransferService transferService; + private TokenService tokenService; + + @BeforeEach + void setup() { + transferService = mock(TransferService.class); + tokenService = mock(TokenService.class); + + final RouterFunction routerFunction = new LdioLdesClientConnectorApi(endpoint, transferService, + tokenService).endpoints(); + + client = WebTestClient + .bindToRouterFunction(routerFunction) + .build(); + } + + @Test + void testTokenEndpoint() { + String content = "token"; + + client.post() + .uri("/%s/token".formatted(endpoint)) + .body(Mono.just(content), String.class) + .exchange() + .expectStatus() + .isAccepted(); + + verify(tokenService).updateToken(content); + verify(transferService, times(0)).startTransfer(any()); + } + + @Test + void testTransferEndpoint() { + String content = "transfer"; + String transferResult = "transfer-result"; + when(transferService.startTransfer(content)).thenReturn(new Response(null, List.of(), 200, "transfer-result")); + + client.post() + .uri("/%s/transfer".formatted(endpoint)) + .body(Mono.just(content), String.class) + .exchange() + .expectStatus() + .isAccepted() + .expectBody(String.class) + .isEqualTo(transferResult); + + verify(transferService).startTransfer(content); + verify(tokenService, times(0)).updateToken(any()); + } + +} \ No newline at end of file diff --git a/ldi-orchestrator/ldio-connectors/ldio-ldes-client/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-ldes-client/pom.xml index 6e130d6f4..cd47c89dc 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-ldes-client/pom.xml +++ b/ldi-orchestrator/ldio-connectors/ldio-ldes-client/pom.xml @@ -3,16 +3,12 @@ be.vlaanderen.informatievlaanderen.ldes.ldio ldio-connectors - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 ldio-ldes-client - - ../../.. - - diff --git a/ldi-orchestrator/ldio-connectors/ldio-ldes-client/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdesClientRunner.java b/ldi-orchestrator/ldio-connectors/ldio-ldes-client/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdesClientRunner.java index bbcaa45b8..985cdc1c7 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-ldes-client/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdesClientRunner.java +++ b/ldi-orchestrator/ldio-connectors/ldio-ldes-client/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdesClientRunner.java @@ -53,8 +53,7 @@ private MemberSupplier getMemberSupplier() { Lang sourceFormat = properties.getOptionalProperty(LdioLdesClientProperties.SOURCE_FORMAT) .map(RDFLanguages::nameToLang) .orElse(Lang.JSONLD); - LdesMetaData ldesMetaData = new LdesMetaData(targetUrl, - sourceFormat); + LdesMetaData ldesMetaData = new LdesMetaData(targetUrl, sourceFormat); TreeNodeProcessor treeNodeProcessor = getTreeNodeProcessor(statePersistence, requestExecutor, ldesMetaData); boolean keepState = properties.getOptionalBoolean(LdioLdesClientProperties.KEEP_STATE).orElse(false); diff --git a/ldi-orchestrator/ldio-connectors/ldio-model-split/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-model-split/pom.xml index e27d8a8f1..ce4041b4c 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-model-split/pom.xml +++ b/ldi-orchestrator/ldio-connectors/ldio-model-split/pom.xml @@ -6,7 +6,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldio ldio-connectors - 1.9.0 + 1.10.0-SNAPSHOT ldio-model-split diff --git a/ldi-orchestrator/ldio-connectors/ldio-model-split/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioModelSplitTransformerAutoConfig.java b/ldi-orchestrator/ldio-connectors/ldio-model-split/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioModelSplitTransformerAutoConfig.java index 3b5e66ee5..a187c61bc 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-model-split/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioModelSplitTransformerAutoConfig.java +++ b/ldi-orchestrator/ldio-connectors/ldio-model-split/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioModelSplitTransformerAutoConfig.java @@ -1,9 +1,7 @@ package be.vlaanderen.informatievlaanderen.ldes.ldio.config; -import be.vlaanderen.informatievlaanderen.ldes.ldi.ModelSplitTransformer; -import be.vlaanderen.informatievlaanderen.ldes.ldi.ModelSplitter; -import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiComponent; -import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioTransformerConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.types.LdioTransformer; import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.ComponentProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -12,18 +10,19 @@ public class LdioModelSplitTransformerAutoConfig { @Bean("be.vlaanderen.informatievlaanderen.ldes.ldi.ModelSplitTransformer") - public LdioConfigurator ldiModelSplitConfigurator() { - return new LdioModelSplitTransformerConfigurator(); + public LdioTransformerConfigurator ldiModelSplitConfigurator() { + return new LdioModelSplitTransformerTransformerConfigurator(); } - public static class LdioModelSplitTransformerConfigurator implements LdioConfigurator { + public static class LdioModelSplitTransformerTransformerConfigurator implements LdioTransformerConfigurator { public static final String SUBJECT_TYPE = "split-subject-type"; @Override - public LdiComponent configure(ComponentProperties config) { + public LdioTransformer configure(ComponentProperties config) { final String subjectType = config.getProperty(SUBJECT_TYPE); - return new ModelSplitTransformer(subjectType, new ModelSplitter()); + return new LdioModelSplitter(subjectType); } + } } diff --git a/ldi-orchestrator/ldio-connectors/ldio-model-split/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioModelSplitter.java b/ldi-orchestrator/ldio-connectors/ldio-model-split/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioModelSplitter.java new file mode 100644 index 000000000..971a179ec --- /dev/null +++ b/ldi-orchestrator/ldio-connectors/ldio-model-split/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioModelSplitter.java @@ -0,0 +1,18 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldio.config; + +import be.vlaanderen.informatievlaanderen.ldes.ldi.ModelSplitTransformer; +import be.vlaanderen.informatievlaanderen.ldes.ldio.types.LdioTransformer; +import org.apache.jena.rdf.model.Model; + +public class LdioModelSplitter extends LdioTransformer { + private final ModelSplitTransformer modelSplitter; + + protected LdioModelSplitter(String subjectType) { + this.modelSplitter = new ModelSplitTransformer(subjectType); + } + + @Override + public void apply(Model model) { + modelSplitter.transform(model).forEach(this::next); + } +} diff --git a/ldi-orchestrator/ldio-connectors/ldio-ngsiv2-to-ld-adapter/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-ngsiv2-to-ld-adapter/pom.xml index 87b23f3e5..ebcc048c7 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-ngsiv2-to-ld-adapter/pom.xml +++ b/ldi-orchestrator/ldio-connectors/ldio-ngsiv2-to-ld-adapter/pom.xml @@ -6,7 +6,7 @@ ldio-connectors be.vlaanderen.informatievlaanderen.ldes.ldio - 1.9.0 + 1.10.0-SNAPSHOT ldio-ngsiv2-to-ld-adapter @@ -15,7 +15,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldi ngsiv2-to-ld-adapter - 1.9.0 + 1.10.0-SNAPSHOT compile diff --git a/ldi-orchestrator/ldio-connectors/ldio-ngsiv2-to-ld-adapter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioNgsiv2ToLdAdapterAutoConfig.java b/ldi-orchestrator/ldio-connectors/ldio-ngsiv2-to-ld-adapter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioNgsiv2ToLdAdapterAutoConfig.java index c603c63af..0d5287599 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-ngsiv2-to-ld-adapter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioNgsiv2ToLdAdapterAutoConfig.java +++ b/ldi-orchestrator/ldio-connectors/ldio-ngsiv2-to-ld-adapter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioNgsiv2ToLdAdapterAutoConfig.java @@ -1,8 +1,8 @@ package be.vlaanderen.informatievlaanderen.ldes.ldio.config; import be.vlaanderen.informatievlaanderen.ldes.ldi.NgsiV2ToLdAdapter; -import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiComponent; -import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiAdapter; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioAdapterConfigurator; import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.ComponentProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -11,13 +11,13 @@ public class LdioNgsiv2ToLdAdapterAutoConfig { @Bean("be.vlaanderen.informatievlaanderen.ldes.ldi.NgsiV2ToLdAdapter") - public LdioConfigurator ldiHttpOutConfigurator() { - return new LdioSparqlConstructConfigurator(); + public LdioAdapterConfigurator ldiHttpOutConfigurator() { + return new LdioSparqlConstructProcessorConfigurator(); } - public static class LdioSparqlConstructConfigurator implements LdioConfigurator { + public static class LdioSparqlConstructProcessorConfigurator implements LdioAdapterConfigurator { @Override - public LdiComponent configure(ComponentProperties config) { + public LdiAdapter configure(ComponentProperties config) { String dataIdentifier = config.getProperty("data-identifier"); String coreContext = config.getProperty("core-context"); String ldContext = config.getOptionalProperty("ld-context").orElse(null); diff --git a/ldi-orchestrator/ldio-connectors/ldio-rdf-adapter/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-rdf-adapter/pom.xml index e3624e08d..b9c854fc5 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-rdf-adapter/pom.xml +++ b/ldi-orchestrator/ldio-connectors/ldio-rdf-adapter/pom.xml @@ -5,7 +5,7 @@ ldio-connectors be.vlaanderen.informatievlaanderen.ldes.ldio - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 diff --git a/ldi-orchestrator/ldio-connectors/ldio-rdf-adapter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioRdfAdapterAutoConfig.java b/ldi-orchestrator/ldio-connectors/ldio-rdf-adapter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioRdfAdapterAutoConfig.java index f6aa3adf9..a4e9d8017 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-rdf-adapter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioRdfAdapterAutoConfig.java +++ b/ldi-orchestrator/ldio-connectors/ldio-rdf-adapter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioRdfAdapterAutoConfig.java @@ -1,8 +1,8 @@ package be.vlaanderen.informatievlaanderen.ldes.ldio.config; import be.vlaanderen.informatievlaanderen.ldes.ldi.RdfAdapter; -import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiComponent; -import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiAdapter; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioAdapterConfigurator; import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.ComponentProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -11,13 +11,13 @@ public class LdioRdfAdapterAutoConfig { @Bean("be.vlaanderen.informatievlaanderen.ldes.ldi.RdfAdapter") - public LdioConfigurator ldiHttpOutConfigurator() { - return new LdioSparqlConstructConfigurator(); + public LdioAdapterConfigurator ldiHttpOutConfigurator() { + return new LdioRdfConfigurator(); } - public static class LdioSparqlConstructConfigurator implements LdioConfigurator { + public static class LdioRdfConfigurator implements LdioAdapterConfigurator { @Override - public LdiComponent configure(ComponentProperties config) { + public LdiAdapter configure(ComponentProperties config) { return new RdfAdapter(); } } diff --git a/ldi-orchestrator/ldio-connectors/ldio-repository-materialiser/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-repository-materialiser/pom.xml index e9130e888..f024262a1 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-repository-materialiser/pom.xml +++ b/ldi-orchestrator/ldio-connectors/ldio-repository-materialiser/pom.xml @@ -6,7 +6,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldio ldio-connectors - 1.9.0 + 1.10.0-SNAPSHOT ldio-repository-materialiser diff --git a/ldi-orchestrator/ldio-connectors/ldio-repository-materialiser/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LioRepositoryMaterialiserAutoConfig.java b/ldi-orchestrator/ldio-connectors/ldio-repository-materialiser/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LioRepositoryMaterialiserAutoConfig.java index 87b89ad1f..60570be65 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-repository-materialiser/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LioRepositoryMaterialiserAutoConfig.java +++ b/ldi-orchestrator/ldio-connectors/ldio-repository-materialiser/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LioRepositoryMaterialiserAutoConfig.java @@ -2,7 +2,7 @@ import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiComponent; import be.vlaanderen.informatievlaanderen.ldes.ldio.LdioRepositoryMaterialiser; -import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioOutputConfigurator; import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.ComponentProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -11,11 +11,11 @@ public class LioRepositoryMaterialiserAutoConfig { @Bean("be.vlaanderen.informatievlaanderen.ldes.ldi.RepositoryMaterialiser") - public LdioConfigurator ldiRepoMaterialiserConfigurator() { - return new LdiRepoMaterialiserConfigurator(); + public LdioOutputConfigurator ldiRepoMaterialiserConfigurator() { + return new LdiRepoMaterialiserProcessorConfigurator(); } - public static class LdiRepoMaterialiserConfigurator implements LdioConfigurator { + public static class LdiRepoMaterialiserProcessorConfigurator implements LdioOutputConfigurator { @Override public LdiComponent configure(ComponentProperties config) { return new LdioRepositoryMaterialiser(config); diff --git a/ldi-orchestrator/ldio-connectors/ldio-request-executor/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-request-executor/pom.xml index 495487711..90a417965 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-request-executor/pom.xml +++ b/ldi-orchestrator/ldio-connectors/ldio-request-executor/pom.xml @@ -6,7 +6,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldio ldio-connectors - 1.9.0 + 1.10.0-SNAPSHOT ldio-request-executor diff --git a/ldi-orchestrator/ldio-connectors/ldio-rml-adapter/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-rml-adapter/pom.xml index 77f5196f9..243380093 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-rml-adapter/pom.xml +++ b/ldi-orchestrator/ldio-connectors/ldio-rml-adapter/pom.xml @@ -5,7 +5,7 @@ ldio-connectors be.vlaanderen.informatievlaanderen.ldes.ldio - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 diff --git a/ldi-orchestrator/ldio-connectors/ldio-rml-adapter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioRmlAdapterAutoConfig.java b/ldi-orchestrator/ldio-connectors/ldio-rml-adapter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioRmlAdapterAutoConfig.java index 38ca1aefe..03e1348a8 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-rml-adapter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioRmlAdapterAutoConfig.java +++ b/ldi-orchestrator/ldio-connectors/ldio-rml-adapter/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioRmlAdapterAutoConfig.java @@ -1,8 +1,8 @@ package be.vlaanderen.informatievlaanderen.ldes.ldio.config; import be.vlaanderen.informatievlaanderen.ldes.ldi.RmlAdapter; -import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiComponent; -import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiAdapter; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioAdapterConfigurator; import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.ComponentProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -11,15 +11,15 @@ public class LdioRmlAdapterAutoConfig { @Bean("be.vlaanderen.informatievlaanderen.ldes.ldi.RmlAdapter") - public LdioConfigurator ldiHttpOutConfigurator() { - return new LdioRmlAdapterConfigurator(); + public LdioAdapterConfigurator ldiHttpOutConfigurator() { + return new LdioRmlAdapterProcessorConfigurator(); } - public static class LdioRmlAdapterConfigurator implements LdioConfigurator { + public static class LdioRmlAdapterProcessorConfigurator implements LdioAdapterConfigurator { public static final String MAPPING = "mapping"; @Override - public LdiComponent configure(ComponentProperties config) { + public LdiAdapter configure(ComponentProperties config) { String rmlMapping = config.getOptionalPropertyFromFile(MAPPING).orElse(config.getProperty(MAPPING)); return new RmlAdapter(rmlMapping); diff --git a/ldi-orchestrator/ldio-connectors/ldio-sparql-construct/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-sparql-construct/pom.xml index 434d50e69..7d12c1869 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-sparql-construct/pom.xml +++ b/ldi-orchestrator/ldio-connectors/ldio-sparql-construct/pom.xml @@ -3,7 +3,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldio ldio-connectors - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 diff --git a/ldi-orchestrator/ldio-connectors/ldio-sparql-construct/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioSparqlConstruct.java b/ldi-orchestrator/ldio-connectors/ldio-sparql-construct/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioSparqlConstruct.java new file mode 100644 index 000000000..776837690 --- /dev/null +++ b/ldi-orchestrator/ldio-connectors/ldio-sparql-construct/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioSparqlConstruct.java @@ -0,0 +1,19 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldio.config; + +import be.vlaanderen.informatievlaanderen.ldes.ldi.SparqlConstructTransformer; +import be.vlaanderen.informatievlaanderen.ldes.ldio.types.LdioTransformer; +import org.apache.jena.query.Query; +import org.apache.jena.rdf.model.Model; + +public class LdioSparqlConstruct extends LdioTransformer { + private final SparqlConstructTransformer transformer; + + public LdioSparqlConstruct(Query query, boolean inferMode) { + transformer = new SparqlConstructTransformer(query, inferMode); + } + + @Override + public void apply(Model model) { + transformer.transform(model).forEach(this::next); + } +} diff --git a/ldi-orchestrator/ldio-connectors/ldio-sparql-construct/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioSparqlConstructAutoConfig.java b/ldi-orchestrator/ldio-connectors/ldio-sparql-construct/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioSparqlConstructAutoConfig.java index c1f00da7e..21711c06a 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-sparql-construct/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioSparqlConstructAutoConfig.java +++ b/ldi-orchestrator/ldio-connectors/ldio-sparql-construct/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioSparqlConstructAutoConfig.java @@ -1,8 +1,7 @@ package be.vlaanderen.informatievlaanderen.ldes.ldio.config; -import be.vlaanderen.informatievlaanderen.ldes.ldi.SparqlConstructTransformer; -import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiComponent; -import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioTransformerConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.types.LdioTransformer; import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.ComponentProperties; import org.apache.jena.query.Query; import org.apache.jena.query.QueryFactory; @@ -13,20 +12,20 @@ public class LdioSparqlConstructAutoConfig { @Bean("be.vlaanderen.informatievlaanderen.ldes.ldi.SparqlConstructTransformer") - public LdioConfigurator ldioConfigurator() { - return new LdioSparqlConstructConfigurator(); + public LdioTransformerConfigurator ldioConfigurator() { + return new LdioSparqlConstructTransformerConfigurator(); } - public static class LdioSparqlConstructConfigurator implements LdioConfigurator { + public static class LdioSparqlConstructTransformerConfigurator implements LdioTransformerConfigurator { public static final String QUERY = "query"; public static final String INFER = "infer"; @Override - public LdiComponent configure(ComponentProperties config) { + public LdioTransformer configure(ComponentProperties config) { String queryContents = config.getOptionalPropertyFromFile(QUERY).orElse(config.getProperty(QUERY)); Query query = QueryFactory.create(queryContents); boolean inferMode = config.getOptionalBoolean(INFER).orElse(false); - return new SparqlConstructTransformer(query, inferMode); + return new LdioSparqlConstruct(query, inferMode); } } diff --git a/ldi-orchestrator/ldio-connectors/ldio-version-materialiser/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-version-materialiser/pom.xml index 43106283f..01dccd71c 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-version-materialiser/pom.xml +++ b/ldi-orchestrator/ldio-connectors/ldio-version-materialiser/pom.xml @@ -3,7 +3,7 @@ ldio-connectors be.vlaanderen.informatievlaanderen.ldes.ldio - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 diff --git a/ldi-orchestrator/ldio-connectors/ldio-version-materialiser/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioVersionMaterialiser.java b/ldi-orchestrator/ldio-connectors/ldio-version-materialiser/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioVersionMaterialiser.java new file mode 100644 index 000000000..46d293714 --- /dev/null +++ b/ldi-orchestrator/ldio-connectors/ldio-version-materialiser/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioVersionMaterialiser.java @@ -0,0 +1,19 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldio.config; + +import be.vlaanderen.informatievlaanderen.ldes.ldi.VersionMaterialiser; +import be.vlaanderen.informatievlaanderen.ldes.ldio.types.LdioTransformer; +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.Property; + +public class LdioVersionMaterialiser extends LdioTransformer { + private final VersionMaterialiser versionMaterialiser; + + public LdioVersionMaterialiser(Property versionOfProperty, boolean restrictToMembers) { + this.versionMaterialiser = new VersionMaterialiser(versionOfProperty, restrictToMembers); + } + + @Override + public void apply(Model model) { + this.next(versionMaterialiser.transform(model)); + } +} diff --git a/ldi-orchestrator/ldio-connectors/ldio-version-materialiser/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioVersionMaterialiserAutoConfig.java b/ldi-orchestrator/ldio-connectors/ldio-version-materialiser/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioVersionMaterialiserAutoConfig.java index 1987ce772..7730d2643 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-version-materialiser/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioVersionMaterialiserAutoConfig.java +++ b/ldi-orchestrator/ldio-connectors/ldio-version-materialiser/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioVersionMaterialiserAutoConfig.java @@ -1,8 +1,7 @@ package be.vlaanderen.informatievlaanderen.ldes.ldio.config; -import be.vlaanderen.informatievlaanderen.ldes.ldi.VersionMaterialiser; -import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiComponent; -import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioTransformerConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.types.LdioTransformer; import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.ComponentProperties; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; @@ -13,21 +12,22 @@ @Configuration public class LdioVersionMaterialiserAutoConfig { @Bean("be.vlaanderen.informatievlaanderen.ldes.ldi.VersionMaterialiser") - public LdioConfigurator ldioConfigurator() { - return new LdioVersionMaterialiserConfigurator(); + public LdioTransformerConfigurator ldioConfigurator() { + return new LdioVersionMaterialiserTransformerConfigurator(); } - public static class LdioVersionMaterialiserConfigurator implements LdioConfigurator { + public static class LdioVersionMaterialiserTransformerConfigurator implements LdioTransformerConfigurator { @Override - public LdiComponent configure(ComponentProperties config) { + public LdioTransformer configure(ComponentProperties config) { Model initModel = ModelFactory.createDefaultModel(); Property versionOfProperty = config.getOptionalProperty("versionOf-property") .map(initModel::createProperty) .orElse(initModel.createProperty("http://purl.org/dc/terms/isVersionOf")); boolean restrictToMembers = config.getOptionalBoolean("restrict-to-members").orElse(false); - return new VersionMaterialiser(versionOfProperty, restrictToMembers); + + return new LdioVersionMaterialiser(versionOfProperty, restrictToMembers); } } } diff --git a/ldi-orchestrator/ldio-connectors/ldio-version-object-creator/pom.xml b/ldi-orchestrator/ldio-connectors/ldio-version-object-creator/pom.xml index e89731b76..8ea021cbb 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-version-object-creator/pom.xml +++ b/ldi-orchestrator/ldio-connectors/ldio-version-object-creator/pom.xml @@ -3,7 +3,7 @@ ldio-connectors be.vlaanderen.informatievlaanderen.ldes.ldio - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 diff --git a/ldi-orchestrator/ldio-connectors/ldio-version-object-creator/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioVersionObjectCreator.java b/ldi-orchestrator/ldio-connectors/ldio-version-object-creator/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioVersionObjectCreator.java new file mode 100644 index 000000000..a77c724de --- /dev/null +++ b/ldi-orchestrator/ldio-connectors/ldio-version-object-creator/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioVersionObjectCreator.java @@ -0,0 +1,24 @@ +package be.vlaanderen.informatievlaanderen.ldes.ldio.config; + +import be.vlaanderen.informatievlaanderen.ldes.ldi.VersionObjectCreator; +import be.vlaanderen.informatievlaanderen.ldes.ldi.extractor.PropertyExtractor; +import be.vlaanderen.informatievlaanderen.ldes.ldio.types.LdioTransformer; +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.Property; +import org.apache.jena.rdf.model.Resource; + +public class LdioVersionObjectCreator extends LdioTransformer { + + private final VersionObjectCreator versionObjectCreator; + + public LdioVersionObjectCreator(PropertyExtractor dateObservedPropertyExtractor, Resource memberType, + String delimiter, Property generatedAtProperty, Property versionOfProperty) { + this.versionObjectCreator = new VersionObjectCreator(dateObservedPropertyExtractor, memberType, delimiter, + generatedAtProperty, versionOfProperty); + } + + @Override + public void apply(Model model) { + next(versionObjectCreator.transform(model)); + } +} diff --git a/ldi-orchestrator/ldio-connectors/ldio-version-object-creator/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioVersionObjectCreatorAutoConfig.java b/ldi-orchestrator/ldio-connectors/ldio-version-object-creator/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioVersionObjectCreatorAutoConfig.java index 367d1399f..e8a639d25 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-version-object-creator/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioVersionObjectCreatorAutoConfig.java +++ b/ldi-orchestrator/ldio-connectors/ldio-version-object-creator/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/config/LdioVersionObjectCreatorAutoConfig.java @@ -1,11 +1,10 @@ package be.vlaanderen.informatievlaanderen.ldes.ldio.config; -import be.vlaanderen.informatievlaanderen.ldes.ldi.VersionObjectCreator; import be.vlaanderen.informatievlaanderen.ldes.ldi.extractor.EmptyPropertyExtractor; import be.vlaanderen.informatievlaanderen.ldes.ldi.extractor.PropertyExtractor; import be.vlaanderen.informatievlaanderen.ldes.ldi.extractor.PropertyPathExtractor; -import be.vlaanderen.informatievlaanderen.ldes.ldi.types.LdiComponent; -import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.configurator.LdioTransformerConfigurator; +import be.vlaanderen.informatievlaanderen.ldes.ldio.types.LdioTransformer; import be.vlaanderen.informatievlaanderen.ldes.ldio.valueobjects.ComponentProperties; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; @@ -19,14 +18,14 @@ @Configuration public class LdioVersionObjectCreatorAutoConfig { @Bean("be.vlaanderen.informatievlaanderen.ldes.ldi.VersionObjectCreator") - public LdioConfigurator ldioConfigurator() { - return new LdioVersionObjectCreatorConfigurator(); + public LdioTransformerConfigurator ldioConfigurator() { + return new LdioVersionObjectCreatorTransformerConfigurator(); } - public static class LdioVersionObjectCreatorConfigurator implements LdioConfigurator { + public static class LdioVersionObjectCreatorTransformerConfigurator implements LdioTransformerConfigurator { @Override - public LdiComponent configure(ComponentProperties properties) { + public LdioTransformer configure(ComponentProperties properties) { Model initModel = ModelFactory.createDefaultModel(); PropertyExtractor dateObservedPropertyExtractor = properties.getOptionalProperty("date-observed-property") @@ -47,7 +46,8 @@ public LdiComponent configure(ComponentProperties properties) { .map(initModel::createProperty) .orElse(null); - return new VersionObjectCreator(dateObservedPropertyExtractor, memberType, delimiter, generatedAtProperty, + return new LdioVersionObjectCreator(dateObservedPropertyExtractor, memberType, delimiter, + generatedAtProperty, versionOfProperty); } } diff --git a/ldi-orchestrator/ldio-connectors/pom.xml b/ldi-orchestrator/ldio-connectors/pom.xml index 73b12ca2a..0a47988ff 100644 --- a/ldi-orchestrator/ldio-connectors/pom.xml +++ b/ldi-orchestrator/ldio-connectors/pom.xml @@ -3,7 +3,7 @@ be.vlaanderen.informatievlaanderen.ldes.ldi ldi-orchestrator - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 @@ -17,6 +17,7 @@ ldio-http-in ldio-http-in-poller ldio-ldes-client + ldio-ldes-client-connector ldio-archive-file-in ldio-rdf-adapter @@ -92,6 +93,18 @@ ${junit-platform-suite.version} test + + net.bytebuddy + byte-buddy + + + org.mockito + mockito-core + + + org.mockito + mockito-junit-jupiter + diff --git a/ldi-orchestrator/pom.xml b/ldi-orchestrator/pom.xml index 6829d0251..6bddc5dff 100644 --- a/ldi-orchestrator/pom.xml +++ b/ldi-orchestrator/pom.xml @@ -3,7 +3,7 @@ be.vlaanderen.informatievlaanderen.ldes linked-data-interactions - 1.9.0 + 1.10.0-SNAPSHOT 4.0.0 diff --git a/ldio.Dockerfile b/ldio.Dockerfile index 1d6a6f6f7..d2aef2ae5 100644 --- a/ldio.Dockerfile +++ b/ldio.Dockerfile @@ -25,6 +25,7 @@ COPY --from=app-stage ldi-orchestrator/ldio-application/target/ldio-application. COPY --from=app-stage ldi-orchestrator/ldio-connectors/ldio-http-in/target/ldio-http-in-jar-with-dependencies.jar ./lib/ COPY --from=app-stage ldi-orchestrator/ldio-connectors/ldio-http-in-poller/target/ldio-http-in-poller-jar-with-dependencies.jar ./lib/ COPY --from=app-stage ldi-orchestrator/ldio-connectors/ldio-ldes-client/target/ldio-ldes-client-jar-with-dependencies.jar ./lib/ +COPY --from=app-stage ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/target/ldio-ldes-client-connector-jar-with-dependencies.jar ./lib/ COPY --from=app-stage ldi-orchestrator/ldio-connectors/ldio-kafka/target/ldio-kafka-jar-with-dependencies.jar ./lib/ COPY --from=app-stage ldi-orchestrator/ldio-connectors/ldio-archive-file-in/target/ldio-archive-file-in-jar-with-dependencies.jar ./lib/ @@ -47,7 +48,6 @@ COPY --from=app-stage ldi-orchestrator/ldio-connectors/ldio-azure-blob-out/targe COPY --from=app-stage ldi-orchestrator/ldio-connectors/ldio-file-out/target/ldio-file-out-jar-with-dependencies.jar ./lib/ COPY --from=app-stage ldi-orchestrator/ldio-connectors/ldio-repository-materialiser/target/ldio-repository-materialiser-jar-with-dependencies.jar ./lib/ -RUN dir -s RUN mkdir "state" RUN chmod -R 777 ./state diff --git a/pom.xml b/pom.xml index 4d76ec993..59067c726 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ be.vlaanderen.informatievlaanderen.ldes linked-data-interactions pom - 1.9.0 + 1.10.0-SNAPSHOT ldi-api @@ -53,11 +53,6 @@ false false - - 2.23.0 - false - - ${maven.multiModuleProjectDirectory} 1.9.0 4.8.0 @@ -89,24 +84,6 @@ - - - net.revelc.code.formatter - formatter-maven-plugin - ${formatter-maven-plugin.version} - - - - validate - - - - - ${skipFormatCode} - UTF-8 - ${relative-formatter-path}/settings.xml - - org.apache.maven.plugins maven-gpg-plugin @@ -131,11 +108,6 @@ - - - net.revelc.code.formatter - formatter-maven-plugin - net.revelc.code impsort-maven-plugin