From 1fe0c957e5241bc7671e56e7493355967850a30c Mon Sep 17 00:00:00 2001 From: ndr_brt Date: Fri, 8 Mar 2024 11:49:37 +0100 Subject: [PATCH] feat(dsp): transform dspace DataAddress (#3975) --- DEPENDENCIES | 4 +- core/common/transform-dspace/build.gradle.kts | 30 +++++++++++++++ .../DspaceDataAddressSerialization.java | 2 +- .../JsonObjectFromDataAddressTransformer.java | 37 ++++++++----------- .../JsonObjectToDataAddressTransformer.java | 20 +++++----- .../core/transform/dspace/TestFunctions.java | 34 +++++++++++++++++ ...nObjectFromDataAddressTransformerTest.java | 32 ++++++++-------- ...sonObjectToDataAddressTransformerTest.java | 32 ++++++++-------- .../dsp-api-configuration/build.gradle.kts | 1 + .../DspApiConfigurationExtension.java | 27 +++++++------- .../DspApiConfigurationExtensionTest.java | 4 ++ .../dsp-catalog-api/build.gradle.kts | 3 +- .../DspCatalogTransformExtension.java | 13 ++++--- .../dsp/dsp-http-core/build.gradle.kts | 2 +- .../protocol/dsp/DspHttpCoreExtension.java | 4 +- .../dsp-negotiation-api/build.gradle.kts | 5 +-- ...DspNegotiationHttpDispatcherExtension.java | 2 +- .../DspNegotiationTransformExtension.java | 29 ++++++++------- .../dsp-transfer-process-api/build.gradle.kts | 4 +- ...DspTransferProcessDispatcherExtension.java | 2 +- .../DspTransferProcessTransformExtension.java | 23 ++++++------ ...ctToTransferRequestMessageTransformer.java | 22 +---------- ...TransferRequestMessageTransformerTest.java | 19 +++++----- .../ManagementApiConfigurationExtension.java | 27 +++++++++++++- .../policy/PolicyDefinitionApiExtension.java | 7 ++-- .../PolicyDefinitionApiExtensionTest.java | 5 +++ .../build.gradle.kts | 2 +- .../SignalingApiConfigurationExtension.java | 4 +- .../build.gradle.kts | 3 +- .../client/DataPlaneSignalingClientTest.java | 4 +- .../build.gradle.kts | 2 +- settings.gradle.kts | 1 + .../tests/build.gradle.kts | 1 + .../DataPlaneSignalingApiEndToEndTest.java | 4 +- .../test/e2e/AbstractEndToEndTransfer.java | 4 +- 35 files changed, 246 insertions(+), 169 deletions(-) create mode 100644 core/common/transform-dspace/build.gradle.kts rename {extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/src/main/java/org/eclipse/edc/connector/api/signaling/transform => core/common/transform-dspace/src/main/java/org/eclipse/edc/core/transform/dspace}/DspaceDataAddressSerialization.java (95%) rename {extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/src/main/java/org/eclipse/edc/connector/api/signaling/transform => core/common/transform-dspace/src/main/java/org/eclipse/edc/core/transform/dspace}/from/JsonObjectFromDataAddressTransformer.java (61%) rename {extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/src/main/java/org/eclipse/edc/connector/api/signaling/transform => core/common/transform-dspace/src/main/java/org/eclipse/edc/core/transform/dspace}/to/JsonObjectToDataAddressTransformer.java (79%) create mode 100644 core/common/transform-dspace/src/test/java/org/eclipse/edc/core/transform/dspace/TestFunctions.java rename {extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/src/test/java/org/eclipse/edc/connector/api/signaling/transform => core/common/transform-dspace/src/test/java/org/eclipse/edc/core/transform/dspace}/from/JsonObjectFromDataAddressTransformerTest.java (71%) rename {extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/src/test/java/org/eclipse/edc/connector/api/signaling/transform => core/common/transform-dspace/src/test/java/org/eclipse/edc/core/transform/dspace}/to/JsonObjectToDataAddressTransformerTest.java (73%) diff --git a/DEPENDENCIES b/DEPENDENCIES index 315a36a6936..207705ee0de 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -81,7 +81,7 @@ maven/mavencentral/com.lmax/disruptor/3.4.4, Apache-2.0, approved, clearlydefine maven/mavencentral/com.networknt/json-schema-validator/1.0.76, Apache-2.0, approved, CQ22638 maven/mavencentral/com.nimbusds/nimbus-jose-jwt/9.28, Apache-2.0, approved, clearlydefined maven/mavencentral/com.nimbusds/nimbus-jose-jwt/9.37.3, Apache-2.0, approved, #11701 -maven/mavencentral/com.puppycrawl.tools/checkstyle/10.14.0, , restricted, clearlydefined +maven/mavencentral/com.puppycrawl.tools/checkstyle/10.14.0, LGPL-2.1-or-later AND (Apache-2.0 AND LGPL-2.1-or-later) AND Apache-2.0, approved, #13562 maven/mavencentral/com.samskivert/jmustache/1.15, BSD-2-Clause, approved, clearlydefined maven/mavencentral/com.squareup.okhttp3/okhttp-dnsoverhttps/4.12.0, Apache-2.0, approved, #11159 maven/mavencentral/com.squareup.okhttp3/okhttp/4.12.0, Apache-2.0, approved, #11156 @@ -214,7 +214,7 @@ maven/mavencentral/org.apache.httpcomponents/httpclient/4.5.13, Apache-2.0 AND L maven/mavencentral/org.apache.httpcomponents/httpcore/4.4.13, Apache-2.0, approved, CQ23528 maven/mavencentral/org.apache.httpcomponents/httpcore/4.4.14, Apache-2.0, approved, CQ23528 maven/mavencentral/org.apache.httpcomponents/httpmime/4.5.13, Apache-2.0, approved, CQ11718 -maven/mavencentral/org.apache.kafka/kafka-clients/3.7.0, , restricted, clearlydefined +maven/mavencentral/org.apache.kafka/kafka-clients/3.7.0, Apache-2.0 AND (Apache-2.0 AND MIT) AND (Apache-2.0 AND BSD-3-Clause), approved, #13623 maven/mavencentral/org.apache.maven.doxia/doxia-core/1.12.0, Apache-2.0, approved, clearlydefined maven/mavencentral/org.apache.maven.doxia/doxia-logging-api/1.12.0, Apache-2.0, approved, clearlydefined maven/mavencentral/org.apache.maven.doxia/doxia-module-xdoc/1.12.0, Apache-2.0, approved, clearlydefined diff --git a/core/common/transform-dspace/build.gradle.kts b/core/common/transform-dspace/build.gradle.kts new file mode 100644 index 00000000000..fe51776e819 --- /dev/null +++ b/core/common/transform-dspace/build.gradle.kts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +plugins { + `java-library` + `maven-publish` +} + +dependencies { + api(project(":spi:common:catalog-spi")) + api(project(":spi:common:core-spi")) + api(project(":spi:common:json-ld-spi")) + api(project(":spi:common:transform-spi")) + + api(libs.jakartaJson) + + testImplementation(project(":core:common:junit")) + testImplementation(project(":extensions:common:json-ld")) +} diff --git a/extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/src/main/java/org/eclipse/edc/connector/api/signaling/transform/DspaceDataAddressSerialization.java b/core/common/transform-dspace/src/main/java/org/eclipse/edc/core/transform/dspace/DspaceDataAddressSerialization.java similarity index 95% rename from extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/src/main/java/org/eclipse/edc/connector/api/signaling/transform/DspaceDataAddressSerialization.java rename to core/common/transform-dspace/src/main/java/org/eclipse/edc/core/transform/dspace/DspaceDataAddressSerialization.java index 85b2da2401f..41129a8d40d 100644 --- a/extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/src/main/java/org/eclipse/edc/connector/api/signaling/transform/DspaceDataAddressSerialization.java +++ b/core/common/transform-dspace/src/main/java/org/eclipse/edc/core/transform/dspace/DspaceDataAddressSerialization.java @@ -12,7 +12,7 @@ * */ -package org.eclipse.edc.connector.api.signaling.transform; +package org.eclipse.edc.core.transform.dspace; import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; diff --git a/extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/src/main/java/org/eclipse/edc/connector/api/signaling/transform/from/JsonObjectFromDataAddressTransformer.java b/core/common/transform-dspace/src/main/java/org/eclipse/edc/core/transform/dspace/from/JsonObjectFromDataAddressTransformer.java similarity index 61% rename from extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/src/main/java/org/eclipse/edc/connector/api/signaling/transform/from/JsonObjectFromDataAddressTransformer.java rename to core/common/transform-dspace/src/main/java/org/eclipse/edc/core/transform/dspace/from/JsonObjectFromDataAddressTransformer.java index f87e95e40b6..5c825e9db24 100644 --- a/extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/src/main/java/org/eclipse/edc/connector/api/signaling/transform/from/JsonObjectFromDataAddressTransformer.java +++ b/core/common/transform-dspace/src/main/java/org/eclipse/edc/core/transform/dspace/from/JsonObjectFromDataAddressTransformer.java @@ -12,11 +12,12 @@ * */ -package org.eclipse.edc.connector.api.signaling.transform.from; +package org.eclipse.edc.core.transform.dspace.from; import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.json.JsonBuilderFactory; import jakarta.json.JsonObject; +import jakarta.json.stream.JsonCollectors; import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; import org.eclipse.edc.spi.types.domain.DataAddress; import org.eclipse.edc.transform.spi.TransformerContext; @@ -25,18 +26,18 @@ import java.util.Set; -import static org.eclipse.edc.connector.api.signaling.transform.DspaceDataAddressSerialization.DSPACE_DATAADDRESS_TYPE; -import static org.eclipse.edc.connector.api.signaling.transform.DspaceDataAddressSerialization.ENDPOINT_PROPERTIES_PROPERTY; -import static org.eclipse.edc.connector.api.signaling.transform.DspaceDataAddressSerialization.ENDPOINT_PROPERTY; -import static org.eclipse.edc.connector.api.signaling.transform.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_NAME_PROPERTY; -import static org.eclipse.edc.connector.api.signaling.transform.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_PROPERTY_TYPE; -import static org.eclipse.edc.connector.api.signaling.transform.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_VALUE_PROPERTY; -import static org.eclipse.edc.connector.api.signaling.transform.DspaceDataAddressSerialization.ENDPOINT_TYPE_PROPERTY; +import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.DSPACE_DATAADDRESS_TYPE; +import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTIES_PROPERTY; +import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_NAME_PROPERTY; +import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_PROPERTY_TYPE; +import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_VALUE_PROPERTY; +import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_TYPE_PROPERTY; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; import static org.eclipse.edc.spi.types.domain.DataAddress.EDC_DATA_ADDRESS_TYPE_PROPERTY; public class JsonObjectFromDataAddressTransformer extends AbstractJsonLdTransformer { - private static final Set EXCLUDED_PROPERTIES = Set.of(EDC_DATA_ADDRESS_TYPE_PROPERTY, "endpoint"); + + private static final Set EXCLUDED_PROPERTIES = Set.of(EDC_DATA_ADDRESS_TYPE_PROPERTY); private final JsonBuilderFactory jsonFactory; private final ObjectMapper mapper; @@ -48,22 +49,16 @@ public JsonObjectFromDataAddressTransformer(JsonBuilderFactory jsonFactory, Obje @Override public @Nullable JsonObject transform(@NotNull DataAddress dataAddress, @NotNull TransformerContext context) { - - var propsBuilder = jsonFactory.createArrayBuilder(); - - dataAddress.getProperties().entrySet().stream() + var endpointProperties = dataAddress.getProperties().entrySet().stream() .filter(e -> !EXCLUDED_PROPERTIES.contains(e.getKey())) - .forEach(e -> propsBuilder.add(endpointProperty(e.getKey(), e.getValue()))); + .map(it -> endpointProperty(it.getKey(), it.getValue())) + .collect(JsonCollectors.toJsonArray()); - var objectBuilder = jsonFactory.createObjectBuilder() + return jsonFactory.createObjectBuilder() .add(TYPE, DSPACE_DATAADDRESS_TYPE) .add(ENDPOINT_TYPE_PROPERTY, dataAddress.getType()) - .add(ENDPOINT_PROPERTY, dataAddress.getProperties().getOrDefault("endpoint", "https://example.com").toString()); - - - objectBuilder.add(ENDPOINT_PROPERTIES_PROPERTY, propsBuilder.build()); - - return objectBuilder.build(); + .add(ENDPOINT_PROPERTIES_PROPERTY, endpointProperties) + .build(); } private JsonObject endpointProperty(String key, Object value) { diff --git a/extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/src/main/java/org/eclipse/edc/connector/api/signaling/transform/to/JsonObjectToDataAddressTransformer.java b/core/common/transform-dspace/src/main/java/org/eclipse/edc/core/transform/dspace/to/JsonObjectToDataAddressTransformer.java similarity index 79% rename from extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/src/main/java/org/eclipse/edc/connector/api/signaling/transform/to/JsonObjectToDataAddressTransformer.java rename to core/common/transform-dspace/src/main/java/org/eclipse/edc/core/transform/dspace/to/JsonObjectToDataAddressTransformer.java index 965d375a8bd..6f4cc6d35ce 100644 --- a/extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/src/main/java/org/eclipse/edc/connector/api/signaling/transform/to/JsonObjectToDataAddressTransformer.java +++ b/core/common/transform-dspace/src/main/java/org/eclipse/edc/core/transform/dspace/to/JsonObjectToDataAddressTransformer.java @@ -12,12 +12,11 @@ * */ -package org.eclipse.edc.connector.api.signaling.transform.to; +package org.eclipse.edc.core.transform.dspace.to; import jakarta.json.JsonArray; import jakarta.json.JsonObject; import jakarta.json.JsonValue; -import org.eclipse.edc.connector.api.signaling.transform.DspaceDataAddressSerialization; import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; import org.eclipse.edc.spi.types.domain.DataAddress; import org.eclipse.edc.transform.spi.TransformerContext; @@ -27,8 +26,11 @@ import java.util.function.Consumer; import java.util.function.Function; -import static org.eclipse.edc.connector.api.signaling.transform.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_NAME_PROPERTY; -import static org.eclipse.edc.connector.api.signaling.transform.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_VALUE_PROPERTY; +import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTIES_PROPERTY; +import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTY; +import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_NAME_PROPERTY; +import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_VALUE_PROPERTY; +import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_TYPE_PROPERTY; /** * Transforms a {@link JsonObject} into a DataAddress using the DSPACE-serialization format. @@ -47,13 +49,9 @@ public JsonObjectToDataAddressTransformer() { private void transformProperties(String key, JsonValue jsonValue, DataAddress.Builder builder, TransformerContext context) { switch (key) { - case DspaceDataAddressSerialization.ENDPOINT_PROPERTY -> - transformString(jsonValue, endpoint -> builder.property("endpoint", endpoint), context); - case DspaceDataAddressSerialization.ENDPOINT_TYPE_PROPERTY -> { - var endpointType = transformString(jsonValue, context); - builder.type(endpointType); - } - case DspaceDataAddressSerialization.ENDPOINT_PROPERTIES_PROPERTY -> + case ENDPOINT_PROPERTY -> { } + case ENDPOINT_TYPE_PROPERTY -> builder.type(transformString(jsonValue, context)); + case ENDPOINT_PROPERTIES_PROPERTY -> transformEndpointProperties(jsonValue, ep -> builder.property(ep.name(), ep.value()), context); default -> throw new IllegalArgumentException("Unexpected value: " + key); } diff --git a/core/common/transform-dspace/src/test/java/org/eclipse/edc/core/transform/dspace/TestFunctions.java b/core/common/transform-dspace/src/test/java/org/eclipse/edc/core/transform/dspace/TestFunctions.java new file mode 100644 index 00000000000..479a1c3d0f0 --- /dev/null +++ b/core/common/transform-dspace/src/test/java/org/eclipse/edc/core/transform/dspace/TestFunctions.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +package org.eclipse.edc.core.transform.dspace; + +import com.apicatalog.jsonld.document.JsonDocument; +import jakarta.json.JsonObject; + +import static com.apicatalog.jsonld.JsonLd.expand; + +public class TestFunctions { + + /** + * Expands test input as Json-ld is required to be in this form + */ + public static JsonObject getExpanded(JsonObject message) { + try { + return expand(JsonDocument.of(message)).get().asJsonArray().getJsonObject(0); + } catch (Exception e) { + throw new AssertionError(e); + } + } +} diff --git a/extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/src/test/java/org/eclipse/edc/connector/api/signaling/transform/from/JsonObjectFromDataAddressTransformerTest.java b/core/common/transform-dspace/src/test/java/org/eclipse/edc/core/transform/dspace/from/JsonObjectFromDataAddressTransformerTest.java similarity index 71% rename from extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/src/test/java/org/eclipse/edc/connector/api/signaling/transform/from/JsonObjectFromDataAddressTransformerTest.java rename to core/common/transform-dspace/src/test/java/org/eclipse/edc/core/transform/dspace/from/JsonObjectFromDataAddressTransformerTest.java index 566ecf33e5e..fff7e3ec1c9 100644 --- a/extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/src/test/java/org/eclipse/edc/connector/api/signaling/transform/from/JsonObjectFromDataAddressTransformerTest.java +++ b/core/common/transform-dspace/src/test/java/org/eclipse/edc/core/transform/dspace/from/JsonObjectFromDataAddressTransformerTest.java @@ -12,7 +12,7 @@ * */ -package org.eclipse.edc.connector.api.signaling.transform.from; +package org.eclipse.edc.core.transform.dspace.from; import jakarta.json.Json; import org.eclipse.edc.jsonld.util.JacksonJsonLd; @@ -23,16 +23,17 @@ import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.edc.connector.api.signaling.transform.DspaceDataAddressSerialization.ENDPOINT_PROPERTIES_PROPERTY; -import static org.eclipse.edc.connector.api.signaling.transform.DspaceDataAddressSerialization.ENDPOINT_PROPERTY; -import static org.eclipse.edc.connector.api.signaling.transform.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_NAME_PROPERTY; -import static org.eclipse.edc.connector.api.signaling.transform.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_VALUE_PROPERTY; -import static org.eclipse.edc.connector.api.signaling.transform.DspaceDataAddressSerialization.ENDPOINT_TYPE_PROPERTY; +import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTIES_PROPERTY; +import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTY; +import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_NAME_PROPERTY; +import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_VALUE_PROPERTY; +import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_TYPE_PROPERTY; import static org.mockito.Mockito.mock; class JsonObjectFromDataAddressTransformerTest { - private final JsonObjectFromDataAddressTransformer transformer = new JsonObjectFromDataAddressTransformer(Json.createBuilderFactory(Map.of()), JacksonJsonLd.createObjectMapper()); + private final JsonObjectFromDataAddressTransformer transformer = new JsonObjectFromDataAddressTransformer( + Json.createBuilderFactory(Map.of()), JacksonJsonLd.createObjectMapper()); private final TransformerContext context = mock(); @Test @@ -48,14 +49,18 @@ void transform() { assertThat(jsonObject).isNotNull(); assertThat(jsonObject.getString(ENDPOINT_TYPE_PROPERTY)).isEqualTo("https://w3id.org/idsa/v4.1/HTTP"); - assertThat(jsonObject.getString(ENDPOINT_PROPERTY)).isEqualTo("https://example.com"); - assertThat(jsonObject.getJsonArray(ENDPOINT_PROPERTIES_PROPERTY)).hasSize(2) + assertThat(jsonObject.get(ENDPOINT_PROPERTY)).isEqualTo(null); + assertThat(jsonObject.getJsonArray(ENDPOINT_PROPERTIES_PROPERTY)).hasSize(3) .anySatisfy(jv -> { assertThat(jv.asJsonObject().getString(ENDPOINT_PROPERTY_NAME_PROPERTY)).isEqualTo("authorization"); assertThat(jv.asJsonObject().getString(ENDPOINT_PROPERTY_VALUE_PROPERTY)).isEqualTo("secret-token"); }).anySatisfy(jv -> { assertThat(jv.asJsonObject().getString(ENDPOINT_PROPERTY_NAME_PROPERTY)).isEqualTo("foo"); assertThat(jv.asJsonObject().getString(ENDPOINT_PROPERTY_VALUE_PROPERTY)).isEqualTo("bar"); + }) + .anySatisfy(jv -> { + assertThat(jv.asJsonObject().getString(ENDPOINT_PROPERTY_NAME_PROPERTY)).isEqualTo("endpoint"); + assertThat(jv.asJsonObject().getString(ENDPOINT_PROPERTY_VALUE_PROPERTY)).isEqualTo("https://example.com"); }); } @@ -71,16 +76,11 @@ void transform_withComplexProperty() { var jsonObject = transformer.transform(dataAddress, context); assertThat(jsonObject).isNotNull(); - assertThat(jsonObject.getString(ENDPOINT_TYPE_PROPERTY)).isEqualTo("https://w3id.org/idsa/v4.1/HTTP"); - assertThat(jsonObject.getString(ENDPOINT_PROPERTY)).isEqualTo("https://example.com"); - assertThat(jsonObject.getJsonArray(ENDPOINT_PROPERTIES_PROPERTY)).hasSize(2) + assertThat(jsonObject.getJsonArray(ENDPOINT_PROPERTIES_PROPERTY)) .anySatisfy(jv -> { - assertThat(jv.asJsonObject().getString(ENDPOINT_PROPERTY_NAME_PROPERTY)).isEqualTo("authorization"); - assertThat(jv.asJsonObject().getString(ENDPOINT_PROPERTY_VALUE_PROPERTY)).isEqualTo("secret-token"); - }).anySatisfy(jv -> { assertThat(jv.asJsonObject().getString(ENDPOINT_PROPERTY_NAME_PROPERTY)).isEqualTo("foo"); assertThat(jv.asJsonObject().getJsonObject(ENDPOINT_PROPERTY_VALUE_PROPERTY)) .containsKey("complexObj"); }); } -} \ No newline at end of file +} diff --git a/extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/src/test/java/org/eclipse/edc/connector/api/signaling/transform/to/JsonObjectToDataAddressTransformerTest.java b/core/common/transform-dspace/src/test/java/org/eclipse/edc/core/transform/dspace/to/JsonObjectToDataAddressTransformerTest.java similarity index 73% rename from extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/src/test/java/org/eclipse/edc/connector/api/signaling/transform/to/JsonObjectToDataAddressTransformerTest.java rename to core/common/transform-dspace/src/test/java/org/eclipse/edc/core/transform/dspace/to/JsonObjectToDataAddressTransformerTest.java index 7caa7caa5c7..0f8e1e10a28 100644 --- a/extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/src/test/java/org/eclipse/edc/connector/api/signaling/transform/to/JsonObjectToDataAddressTransformerTest.java +++ b/core/common/transform-dspace/src/test/java/org/eclipse/edc/core/transform/dspace/to/JsonObjectToDataAddressTransformerTest.java @@ -12,12 +12,13 @@ * */ -package org.eclipse.edc.connector.api.signaling.transform.to; +package org.eclipse.edc.core.transform.dspace.to; import jakarta.json.Json; import jakarta.json.JsonArrayBuilder; import jakarta.json.JsonBuilderFactory; import jakarta.json.JsonObjectBuilder; +import org.eclipse.edc.core.transform.dspace.TestFunctions; import org.eclipse.edc.transform.spi.TransformerContext; import org.junit.jupiter.api.Test; @@ -25,9 +26,11 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.eclipse.edc.connector.api.signaling.transform.DspaceDataAddressSerialization.DSPACE_DATAADDRESS_TYPE; -import static org.eclipse.edc.connector.api.signaling.transform.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_PROPERTY_TYPE; -import static org.eclipse.edc.connector.api.signaling.transform.TestFunctions.getExpanded; +import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.DSPACE_DATAADDRESS_TYPE; +import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTIES_PROPERTY; +import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTY; +import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_PROPERTY_PROPERTY_TYPE; +import static org.eclipse.edc.core.transform.dspace.DspaceDataAddressSerialization.ENDPOINT_TYPE_PROPERTY; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.CONTEXT; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.VOCAB; @@ -45,9 +48,9 @@ void transform() { var jsonObj = jsonFactory.createObjectBuilder() .add(CONTEXT, createContextBuilder().build()) .add(TYPE, DSPACE_DATAADDRESS_TYPE) - .add("endpointType", "https://w3id.org/idsa/v4.1/HTTP") - .add("endpoint", "http://example.com") - .add("endpointProperties", jsonFactory.createArrayBuilder() + .add(ENDPOINT_TYPE_PROPERTY, "https://w3id.org/idsa/v4.1/HTTP") + .add(ENDPOINT_PROPERTY, "http://example.com") + .add(ENDPOINT_PROPERTIES_PROPERTY, jsonFactory.createArrayBuilder() .add(property("authorization", "some-token")) .add(property("authType", "bearer")) .add(property("foo", "bar")) @@ -55,7 +58,7 @@ void transform() { ) .build(); - var expanded = getExpanded(jsonObj); + var expanded = TestFunctions.getExpanded(jsonObj); var dataAddress = transformer.transform(expanded, context); assertThat(dataAddress).isNotNull(); @@ -63,8 +66,7 @@ void transform() { assertThat(dataAddress.getProperties()) .containsEntry("authorization", "some-token") .containsEntry("authType", "bearer") - .containsEntry("fizz", "buzz") - .containsEntry("endpoint", "http://example.com"); + .containsEntry("fizz", "buzz"); } @Test @@ -72,15 +74,15 @@ void transform_withIllegalProperty() { var jsonObj = jsonFactory.createObjectBuilder() .add(CONTEXT, createContextBuilder().build()) .add(TYPE, DSPACE_DATAADDRESS_TYPE) - .add("endpointType", "https://w3id.org/idsa/v4.1/HTTP") - .add("endpoint", "http://example.com") - .add("endpointProperties", jsonFactory.createArrayBuilder() + .add(ENDPOINT_TYPE_PROPERTY, "https://w3id.org/idsa/v4.1/HTTP") + .add(ENDPOINT_PROPERTY, "http://example.com") + .add(ENDPOINT_PROPERTIES_PROPERTY, jsonFactory.createArrayBuilder() .add(property("fizz", "buzz")) ) .add("rogueProperty", 42L) .build(); - var expanded = getExpanded(jsonObj); + var expanded = TestFunctions.getExpanded(jsonObj); assertThatThrownBy(() -> transformer.transform(expanded, context)) .isInstanceOf(IllegalArgumentException.class) @@ -100,4 +102,4 @@ private JsonArrayBuilder createContextBuilder() { .add(jsonFactory.createObjectBuilder().add(DSPACE_PREFIX, DSPACE_SCHEMA)); } -} \ No newline at end of file +} diff --git a/data-protocols/dsp/dsp-api-configuration/build.gradle.kts b/data-protocols/dsp/dsp-api-configuration/build.gradle.kts index 14df4fb70d9..ac1924cc9c4 100644 --- a/data-protocols/dsp/dsp-api-configuration/build.gradle.kts +++ b/data-protocols/dsp/dsp-api-configuration/build.gradle.kts @@ -23,6 +23,7 @@ dependencies { api(project(":data-protocols:dsp:dsp-http-spi")) implementation(project(":core:common:jersey-providers")) implementation(project(":core:common:transform-core")) + implementation(project(":core:common:transform-dspace")) testImplementation(project(":core:common:junit")) } diff --git a/data-protocols/dsp/dsp-api-configuration/src/main/java/org/eclipse/edc/protocol/dsp/api/configuration/DspApiConfigurationExtension.java b/data-protocols/dsp/dsp-api-configuration/src/main/java/org/eclipse/edc/protocol/dsp/api/configuration/DspApiConfigurationExtension.java index 30671fb1ba2..d93815e055e 100644 --- a/data-protocols/dsp/dsp-api-configuration/src/main/java/org/eclipse/edc/protocol/dsp/api/configuration/DspApiConfigurationExtension.java +++ b/data-protocols/dsp/dsp-api-configuration/src/main/java/org/eclipse/edc/protocol/dsp/api/configuration/DspApiConfigurationExtension.java @@ -15,15 +15,15 @@ package org.eclipse.edc.protocol.dsp.api.configuration; import jakarta.json.Json; +import org.eclipse.edc.core.transform.dspace.from.JsonObjectFromDataAddressTransformer; +import org.eclipse.edc.core.transform.dspace.to.JsonObjectToDataAddressTransformer; import org.eclipse.edc.core.transform.transformer.OdrlTransformersFactory; import org.eclipse.edc.core.transform.transformer.from.JsonObjectFromAssetTransformer; import org.eclipse.edc.core.transform.transformer.from.JsonObjectFromCriterionTransformer; -import org.eclipse.edc.core.transform.transformer.from.JsonObjectFromDataAddressTransformer; import org.eclipse.edc.core.transform.transformer.from.JsonObjectFromPolicyTransformer; import org.eclipse.edc.core.transform.transformer.from.JsonObjectFromQuerySpecTransformer; import org.eclipse.edc.core.transform.transformer.to.JsonObjectToAssetTransformer; import org.eclipse.edc.core.transform.transformer.to.JsonObjectToCriterionTransformer; -import org.eclipse.edc.core.transform.transformer.to.JsonObjectToDataAddressTransformer; import org.eclipse.edc.core.transform.transformer.to.JsonObjectToQuerySpecTransformer; import org.eclipse.edc.core.transform.transformer.to.JsonValueToGenericTypeTransformer; import org.eclipse.edc.jsonld.spi.JsonLd; @@ -135,21 +135,22 @@ private void registerTransformers() { var jsonBuilderFactory = Json.createBuilderFactory(Map.of()); // EDC model to JSON-LD transformers - transformerRegistry.register(new JsonObjectFromPolicyTransformer(jsonBuilderFactory, participantIdMapper)); - transformerRegistry.register(new JsonObjectFromAssetTransformer(jsonBuilderFactory, mapper)); - transformerRegistry.register(new JsonObjectFromDataAddressTransformer(jsonBuilderFactory)); - transformerRegistry.register(new JsonObjectFromQuerySpecTransformer(jsonBuilderFactory)); - transformerRegistry.register(new JsonObjectFromCriterionTransformer(jsonBuilderFactory, mapper)); + var dspApiTransformerRegistry = transformerRegistry.forContext("dsp-api"); + dspApiTransformerRegistry.register(new JsonObjectFromPolicyTransformer(jsonBuilderFactory, participantIdMapper)); + dspApiTransformerRegistry.register(new JsonObjectFromAssetTransformer(jsonBuilderFactory, mapper)); + dspApiTransformerRegistry.register(new JsonObjectFromDataAddressTransformer(jsonBuilderFactory, mapper)); + dspApiTransformerRegistry.register(new JsonObjectFromQuerySpecTransformer(jsonBuilderFactory)); + dspApiTransformerRegistry.register(new JsonObjectFromCriterionTransformer(jsonBuilderFactory, mapper)); // JSON-LD to EDC model transformers // ODRL Transformers - OdrlTransformersFactory.jsonObjectToOdrlTransformers(participantIdMapper).forEach(transformerRegistry::register); + OdrlTransformersFactory.jsonObjectToOdrlTransformers(participantIdMapper).forEach(dspApiTransformerRegistry::register); - transformerRegistry.register(new JsonValueToGenericTypeTransformer(mapper)); - transformerRegistry.register(new JsonObjectToAssetTransformer()); - transformerRegistry.register(new JsonObjectToQuerySpecTransformer()); - transformerRegistry.register(new JsonObjectToCriterionTransformer()); - transformerRegistry.register(new JsonObjectToDataAddressTransformer()); + dspApiTransformerRegistry.register(new JsonValueToGenericTypeTransformer(mapper)); + dspApiTransformerRegistry.register(new JsonObjectToAssetTransformer()); + dspApiTransformerRegistry.register(new JsonObjectToQuerySpecTransformer()); + dspApiTransformerRegistry.register(new JsonObjectToCriterionTransformer()); + dspApiTransformerRegistry.register(new JsonObjectToDataAddressTransformer()); } } diff --git a/data-protocols/dsp/dsp-api-configuration/src/test/java/org/eclipse/edc/protocol/dsp/api/configuration/DspApiConfigurationExtensionTest.java b/data-protocols/dsp/dsp-api-configuration/src/test/java/org/eclipse/edc/protocol/dsp/api/configuration/DspApiConfigurationExtensionTest.java index 0837541e997..601ba9409aa 100644 --- a/data-protocols/dsp/dsp-api-configuration/src/test/java/org/eclipse/edc/protocol/dsp/api/configuration/DspApiConfigurationExtensionTest.java +++ b/data-protocols/dsp/dsp-api-configuration/src/test/java/org/eclipse/edc/protocol/dsp/api/configuration/DspApiConfigurationExtensionTest.java @@ -19,6 +19,7 @@ import org.eclipse.edc.spi.system.ServiceExtensionContext; import org.eclipse.edc.spi.system.configuration.ConfigFactory; import org.eclipse.edc.spi.types.TypeManager; +import org.eclipse.edc.transform.spi.TypeTransformerRegistry; import org.eclipse.edc.web.jersey.jsonld.JerseyJsonLdInterceptor; import org.eclipse.edc.web.jersey.jsonld.ObjectMapperProvider; import org.eclipse.edc.web.spi.WebServer; @@ -57,6 +58,9 @@ void setUp(ServiceExtensionContext context) { context.registerService(WebService.class, webService); context.registerService(WebServiceConfigurer.class, configurer); context.registerService(TypeManager.class, typeManager); + TypeTransformerRegistry typeTransformerRegistry = mock(); + when(typeTransformerRegistry.forContext(any())).thenReturn(mock()); + context.registerService(TypeTransformerRegistry.class, typeTransformerRegistry); var webServiceConfiguration = WebServiceConfiguration.Builder.newInstance() .contextAlias(CONTEXT_ALIAS) diff --git a/data-protocols/dsp/dsp-catalog/dsp-catalog-api/build.gradle.kts b/data-protocols/dsp/dsp-catalog/dsp-catalog-api/build.gradle.kts index 8707603ffc3..bf7a7d972d6 100644 --- a/data-protocols/dsp/dsp-catalog/dsp-catalog-api/build.gradle.kts +++ b/data-protocols/dsp/dsp-catalog/dsp-catalog-api/build.gradle.kts @@ -20,10 +20,9 @@ plugins { dependencies { api(project(":data-protocols:dsp:dsp-spi")) api(project(":data-protocols:dsp:dsp-http-spi")) - api(project(":spi:common:core-spi")) + api(project(":spi:common:web-spi")) api(project(":spi:control-plane:control-plane-spi")) - api(project(":extensions:common:http")) implementation(project(":core:common:validator-core")) diff --git a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/DspCatalogTransformExtension.java b/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/DspCatalogTransformExtension.java index 62c7ef75d4f..0228241569a 100644 --- a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/DspCatalogTransformExtension.java +++ b/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/DspCatalogTransformExtension.java @@ -60,12 +60,13 @@ public void initialize(ServiceExtensionContext context) { var jsonFactory = Json.createBuilderFactory(Map.of()); var mapper = typeManager.getMapper(JSON_LD); - registry.register(new JsonObjectFromCatalogRequestMessageTransformer(jsonFactory)); - registry.register(new JsonObjectToCatalogRequestMessageTransformer()); + var dspApiTransformerRegistry = registry.forContext("dsp-api"); + dspApiTransformerRegistry.register(new JsonObjectFromCatalogRequestMessageTransformer(jsonFactory)); + dspApiTransformerRegistry.register(new JsonObjectToCatalogRequestMessageTransformer()); - registry.register(new JsonObjectFromCatalogTransformer(jsonFactory, mapper, participantIdMapper)); - registry.register(new JsonObjectFromDatasetTransformer(jsonFactory, mapper)); - registry.register(new JsonObjectFromDistributionTransformer(jsonFactory)); - registry.register(new JsonObjectFromDataServiceTransformer(jsonFactory)); + dspApiTransformerRegistry.register(new JsonObjectFromCatalogTransformer(jsonFactory, mapper, participantIdMapper)); + dspApiTransformerRegistry.register(new JsonObjectFromDatasetTransformer(jsonFactory, mapper)); + dspApiTransformerRegistry.register(new JsonObjectFromDistributionTransformer(jsonFactory)); + dspApiTransformerRegistry.register(new JsonObjectFromDataServiceTransformer(jsonFactory)); } } diff --git a/data-protocols/dsp/dsp-http-core/build.gradle.kts b/data-protocols/dsp/dsp-http-core/build.gradle.kts index 63d80bde158..8f2381dec2a 100644 --- a/data-protocols/dsp/dsp-http-core/build.gradle.kts +++ b/data-protocols/dsp/dsp-http-core/build.gradle.kts @@ -27,6 +27,6 @@ dependencies { api(project(":data-protocols:dsp:dsp-spi")) api(project(":data-protocols:dsp:dsp-http-spi")) - testImplementation(project(":extensions:common:http")) testImplementation(project(":core:common:junit")) + testImplementation(project(":extensions:common:http:jersey-core")) } diff --git a/data-protocols/dsp/dsp-http-core/src/main/java/org/eclipse/edc/protocol/dsp/DspHttpCoreExtension.java b/data-protocols/dsp/dsp-http-core/src/main/java/org/eclipse/edc/protocol/dsp/DspHttpCoreExtension.java index 28194fc3a1d..c6a5c3c31c9 100644 --- a/data-protocols/dsp/dsp-http-core/src/main/java/org/eclipse/edc/protocol/dsp/DspHttpCoreExtension.java +++ b/data-protocols/dsp/dsp-http-core/src/main/java/org/eclipse/edc/protocol/dsp/DspHttpCoreExtension.java @@ -132,12 +132,12 @@ public DspHttpRemoteMessageDispatcher dspHttpRemoteMessageDispatcher(ServiceExte @Provider public DspRequestHandler dspRequestHandler() { - return new DspRequestHandlerImpl(monitor, validatorRegistry, transformerRegistry); + return new DspRequestHandlerImpl(monitor, validatorRegistry, transformerRegistry.forContext("dsp-api")); } @Provider public JsonLdRemoteMessageSerializer jsonLdRemoteMessageSerializer() { - return new JsonLdRemoteMessageSerializerImpl(transformerRegistry, typeManager.getMapper(JSON_LD), jsonLdService, DSP_SCOPE); + return new JsonLdRemoteMessageSerializerImpl(transformerRegistry.forContext("dsp-api"), typeManager.getMapper(JSON_LD), jsonLdService, DSP_SCOPE); } private void registerNegotiationPolicyScopes(DspHttpRemoteMessageDispatcher dispatcher) { diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-api/build.gradle.kts b/data-protocols/dsp/dsp-negotiation/dsp-negotiation-api/build.gradle.kts index 46c325275cf..857b27d02e4 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-api/build.gradle.kts +++ b/data-protocols/dsp/dsp-negotiation/dsp-negotiation-api/build.gradle.kts @@ -20,10 +20,9 @@ plugins { dependencies { api(project(":data-protocols:dsp:dsp-spi")) api(project(":data-protocols:dsp:dsp-http-spi")) - api(project(":spi:common:core-spi")) + api(project(":spi:common:web-spi")) api(project(":spi:control-plane:control-plane-spi")) - api(project(":extensions:common:http")) api(project(":extensions:common:json-ld")) implementation(project(":core:common:validator-core")) @@ -39,4 +38,4 @@ edcBuild { swagger { apiGroup.set("dsp-api") } -} \ No newline at end of file +} diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-http-dispatcher/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/dispatcher/DspNegotiationHttpDispatcherExtension.java b/data-protocols/dsp/dsp-negotiation/dsp-negotiation-http-dispatcher/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/dispatcher/DspNegotiationHttpDispatcherExtension.java index 921a1655a75..c4d503679ff 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-http-dispatcher/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/dispatcher/DspNegotiationHttpDispatcherExtension.java +++ b/data-protocols/dsp/dsp-negotiation/dsp-negotiation-http-dispatcher/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/dispatcher/DspNegotiationHttpDispatcherExtension.java @@ -72,7 +72,7 @@ public String name() { @Override public void initialize(ServiceExtensionContext context) { var contractNegotiationAckDeserializer = new JsonLdResponseBodyDeserializer<>( - ContractNegotiationAck.class, typeManager.getMapper(JSON_LD), jsonLd, transformerRegistry); + ContractNegotiationAck.class, typeManager.getMapper(JSON_LD), jsonLd, transformerRegistry.forContext("dsp-api")); messageDispatcher.registerMessage( ContractAgreementMessage.class, diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/DspNegotiationTransformExtension.java b/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/DspNegotiationTransformExtension.java index 5fcc976cdab..b6d15b7d811 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/DspNegotiationTransformExtension.java +++ b/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/DspNegotiationTransformExtension.java @@ -57,20 +57,21 @@ public String name() { public void initialize(ServiceExtensionContext context) { var builderFactory = Json.createBuilderFactory(Map.of()); - registry.register(new JsonObjectFromContractAgreementMessageTransformer(builderFactory)); - registry.register(new JsonObjectFromContractAgreementVerificationMessageTransformer(builderFactory)); - registry.register(new JsonObjectFromContractNegotiationEventMessageTransformer(builderFactory)); - registry.register(new JsonObjectFromContractNegotiationTerminationMessageTransformer(builderFactory)); - registry.register(new JsonObjectFromContractNegotiationTransformer(builderFactory)); - registry.register(new JsonObjectFromContractRequestMessageTransformer(builderFactory)); - registry.register(new JsonObjectFromContractOfferMessageTransformer(builderFactory)); + var dspApiTransformerRegistry = registry.forContext("dsp-api"); + dspApiTransformerRegistry.register(new JsonObjectFromContractAgreementMessageTransformer(builderFactory)); + dspApiTransformerRegistry.register(new JsonObjectFromContractAgreementVerificationMessageTransformer(builderFactory)); + dspApiTransformerRegistry.register(new JsonObjectFromContractNegotiationEventMessageTransformer(builderFactory)); + dspApiTransformerRegistry.register(new JsonObjectFromContractNegotiationTerminationMessageTransformer(builderFactory)); + dspApiTransformerRegistry.register(new JsonObjectFromContractNegotiationTransformer(builderFactory)); + dspApiTransformerRegistry.register(new JsonObjectFromContractRequestMessageTransformer(builderFactory)); + dspApiTransformerRegistry.register(new JsonObjectFromContractOfferMessageTransformer(builderFactory)); - registry.register(new JsonObjectToContractAgreementMessageTransformer()); - registry.register(new JsonObjectToContractAgreementVerificationMessageTransformer()); - registry.register(new JsonObjectToContractNegotiationEventMessageTransformer()); - registry.register(new JsonObjectToContractRequestMessageTransformer()); - registry.register(new JsonObjectToContractNegotiationTerminationMessageTransformer()); - registry.register(new JsonObjectToContractOfferMessageTransformer()); - registry.register(new JsonObjectToContractNegotiationAckTransformer()); + dspApiTransformerRegistry.register(new JsonObjectToContractAgreementMessageTransformer()); + dspApiTransformerRegistry.register(new JsonObjectToContractAgreementVerificationMessageTransformer()); + dspApiTransformerRegistry.register(new JsonObjectToContractNegotiationEventMessageTransformer()); + dspApiTransformerRegistry.register(new JsonObjectToContractRequestMessageTransformer()); + dspApiTransformerRegistry.register(new JsonObjectToContractNegotiationTerminationMessageTransformer()); + dspApiTransformerRegistry.register(new JsonObjectToContractOfferMessageTransformer()); + dspApiTransformerRegistry.register(new JsonObjectToContractNegotiationAckTransformer()); } } diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-api/build.gradle.kts b/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-api/build.gradle.kts index a83634b0a53..9b79b715b9f 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-api/build.gradle.kts +++ b/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-api/build.gradle.kts @@ -18,9 +18,9 @@ plugins { } dependencies { + api(project(":spi:common:web-spi")) api(project(":spi:control-plane:transfer-spi")) api(project(":spi:control-plane:control-plane-spi")) - api(project(":extensions:common:http")) api(project(":data-protocols:dsp:dsp-spi")) api(project(":data-protocols:dsp:dsp-http-spi")) @@ -39,4 +39,4 @@ edcBuild { swagger { apiGroup.set("dsp-api") } -} \ No newline at end of file +} diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-http-dispatcher/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/dispatcher/DspTransferProcessDispatcherExtension.java b/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-http-dispatcher/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/dispatcher/DspTransferProcessDispatcherExtension.java index c4d30ccd5c8..48501ec1c41 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-http-dispatcher/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/dispatcher/DspTransferProcessDispatcherExtension.java +++ b/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-http-dispatcher/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/dispatcher/DspTransferProcessDispatcherExtension.java @@ -74,7 +74,7 @@ public void initialize(ServiceExtensionContext context) { messageDispatcher.registerMessage( TransferRequestMessage.class, new PostDspHttpRequestFactory<>(remoteMessageSerializer, m -> BASE_PATH + TRANSFER_INITIAL_REQUEST), - new JsonLdResponseBodyDeserializer<>(TransferProcessAck.class, typeManager.getMapper(JSON_LD), jsonLd, transformerRegistry) + new JsonLdResponseBodyDeserializer<>(TransferProcessAck.class, typeManager.getMapper(JSON_LD), jsonLd, transformerRegistry.forContext("dsp-api")) ); messageDispatcher.registerMessage( TransferCompletionMessage.class, diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transformer/DspTransferProcessTransformExtension.java b/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transformer/DspTransferProcessTransformExtension.java index d44e9b264fd..a0145700ac9 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transformer/DspTransferProcessTransformExtension.java +++ b/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transformer/DspTransferProcessTransformExtension.java @@ -54,17 +54,18 @@ public String name() { public void initialize(ServiceExtensionContext context) { var builderFactory = Json.createBuilderFactory(Map.of()); - registry.register(new JsonObjectFromTransferProcessTransformer(builderFactory)); - registry.register(new JsonObjectFromTransferStartMessageTransformer(builderFactory)); - registry.register(new JsonObjectFromTransferCompletionMessageTransformer(builderFactory)); - registry.register(new JsonObjectFromTransferTerminationMessageTransformer(builderFactory)); - registry.register(new JsonObjectFromTransferRequestMessageTransformer(builderFactory)); - registry.register(new JsonObjectFromDataAddressTransformer(builderFactory)); + var dspApiTransformerRegistry = registry.forContext("dsp-api"); + dspApiTransformerRegistry.register(new JsonObjectFromTransferProcessTransformer(builderFactory)); + dspApiTransformerRegistry.register(new JsonObjectFromTransferStartMessageTransformer(builderFactory)); + dspApiTransformerRegistry.register(new JsonObjectFromTransferCompletionMessageTransformer(builderFactory)); + dspApiTransformerRegistry.register(new JsonObjectFromTransferTerminationMessageTransformer(builderFactory)); + dspApiTransformerRegistry.register(new JsonObjectFromTransferRequestMessageTransformer(builderFactory)); + dspApiTransformerRegistry.register(new JsonObjectFromDataAddressTransformer(builderFactory)); - registry.register(new JsonObjectToTransferRequestMessageTransformer()); - registry.register(new JsonObjectToTransferCompletionMessageTransformer()); - registry.register(new JsonObjectToTransferStartMessageTransformer()); - registry.register(new JsonObjectToTransferTerminationMessageTransformer()); - registry.register(new JsonObjectToTransferProcessAckTransformer()); + dspApiTransformerRegistry.register(new JsonObjectToTransferRequestMessageTransformer()); + dspApiTransformerRegistry.register(new JsonObjectToTransferCompletionMessageTransformer()); + dspApiTransformerRegistry.register(new JsonObjectToTransferStartMessageTransformer()); + dspApiTransformerRegistry.register(new JsonObjectToTransferTerminationMessageTransformer()); + dspApiTransformerRegistry.register(new JsonObjectToTransferProcessAckTransformer()); } } diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transformer/type/to/JsonObjectToTransferRequestMessageTransformer.java b/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transformer/type/to/JsonObjectToTransferRequestMessageTransformer.java index 730293db406..31bcc56fd57 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transformer/type/to/JsonObjectToTransferRequestMessageTransformer.java +++ b/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transformer/type/to/JsonObjectToTransferRequestMessageTransformer.java @@ -55,32 +55,12 @@ public JsonObjectToTransferRequestMessageTransformer() { visitProperties(messageObject, k -> switch (k) { case DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID -> v -> builder.contractId(transformString(v, context)); case DSPACE_PROPERTY_CALLBACK_ADDRESS -> v -> builder.callbackAddress(transformString(v, context)); + case DSPACE_PROPERTY_DATA_ADDRESS -> v -> builder.dataDestination(transformObject(v, DataAddress.class, context)); case DCT_FORMAT_ATTRIBUTE, DEPRECATED_DCT_FORMAT_ATTRIBUTE -> v -> builder.transferType(transformString(v, context)); default -> doNothing(); }); - builder.dataDestination(createDataAddress(messageObject, context)); - return builder.build(); } - // TODO replace with JsonObjectToDataAddressTransformer - private DataAddress createDataAddress(@NotNull JsonObject requestObject, @NotNull TransformerContext context) { - var dataAddressBuilder = DataAddress.Builder.newInstance(); - - var format = requestObject.get(DCT_FORMAT_ATTRIBUTE); - if (format != null) { - transformString(format, dataAddressBuilder::type, context); - } else { - transformString(requestObject.get(DEPRECATED_DCT_FORMAT_ATTRIBUTE), dataAddressBuilder::type, context); - } - - var dataAddressObject = returnJsonObject(requestObject.get(DSPACE_PROPERTY_DATA_ADDRESS), context, DSPACE_PROPERTY_DATA_ADDRESS, false); - if (dataAddressObject != null) { - dataAddressObject.forEach((key, value) -> transformString(value, v -> dataAddressBuilder.property(key, v), context)); - } - - return dataAddressBuilder.build(); - } - } diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transformer/to/JsonObjectToTransferRequestMessageTransformerTest.java b/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transformer/to/JsonObjectToTransferRequestMessageTransformerTest.java index 5f160751687..cfe1081a1c4 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transformer/to/JsonObjectToTransferRequestMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transformer/to/JsonObjectToTransferRequestMessageTransformerTest.java @@ -17,6 +17,7 @@ import jakarta.json.Json; import jakarta.json.JsonObject; import org.eclipse.edc.protocol.dsp.transferprocess.transformer.type.to.JsonObjectToTransferRequestMessageTransformer; +import org.eclipse.edc.spi.types.domain.DataAddress; import org.eclipse.edc.transform.spi.ProblemBuilder; import org.eclipse.edc.transform.spi.TransformerContext; import org.junit.jupiter.api.Test; @@ -33,7 +34,9 @@ import static org.eclipse.edc.protocol.dsp.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_DATA_ADDRESS; import static org.eclipse.edc.protocol.dsp.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE; import static org.eclipse.edc.spi.CoreConstants.EDC_NAMESPACE; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; @@ -56,7 +59,6 @@ void jsonObjectToTransferRequestWithoutDataAddress() { .add(TYPE, DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE) .add(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID, contractId) .add(DCT_FORMAT_ATTRIBUTE, destinationType) - .add(DSPACE_PROPERTY_DATA_ADDRESS, Json.createObjectBuilder().build()) .add(DSPACE_PROPERTY_CALLBACK_ADDRESS, callbackAddress) .add(DSPACE_PROPERTY_CONSUMER_PID, "processId") .build(); @@ -66,7 +68,7 @@ void jsonObjectToTransferRequestWithoutDataAddress() { assertThat(result).isNotNull(); assertThat(result.getContractId()).isEqualTo(contractId); assertThat(result.getTransferType()).isEqualTo(destinationType); - assertThat(result.getDataDestination().getType()).isEqualTo(destinationType); + assertThat(result.getDataDestination()).isNull(); assertThat(result.getCallbackAddress()).isEqualTo(callbackAddress); assertThat(result.getConsumerPid()).isEqualTo("processId"); @@ -75,6 +77,8 @@ void jsonObjectToTransferRequestWithoutDataAddress() { @Test void jsonObjectToTransferRequestWithDataAddress() { + var dataDestination = DataAddress.Builder.newInstance().type("any").build(); + when(context.transform(any(), eq(DataAddress.class))).thenReturn(dataDestination); var json = Json.createObjectBuilder() .add(TYPE, DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE) .add(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID, contractId) @@ -89,17 +93,17 @@ void jsonObjectToTransferRequestWithDataAddress() { assertThat(result).isNotNull(); assertThat(result.getContractId()).isEqualTo(contractId); assertThat(result.getTransferType()).isEqualTo(destinationType); - assertThat(result.getDataDestination().getType()).isEqualTo(destinationType); assertThat(result.getCallbackAddress()).isEqualTo(callbackAddress); - assertThat(result.getDataDestination().getStringProperty("accessKeyId")).isEqualTo("TESTID"); - assertThat(result.getDataDestination().getStringProperty("region")).isEqualTo("eu-central-1"); - + assertThat(result.getDataDestination()).isSameAs(dataDestination); + verify(context).transform(any(), eq(DataAddress.class)); verify(context, never()).reportProblem(anyString()); } @Deprecated(since = "0.5.1") @Test void jsonObjectToTransferRequestWithDataAddress_withDeprecatedDctNamespace() { + var dataDestination = DataAddress.Builder.newInstance().type("any").build(); + when(context.transform(any(), eq(DataAddress.class))).thenReturn(dataDestination); var json = Json.createObjectBuilder() .add(TYPE, DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE) .add(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID, contractId) @@ -113,7 +117,6 @@ void jsonObjectToTransferRequestWithDataAddress_withDeprecatedDctNamespace() { assertThat(result).isNotNull(); assertThat(result.getTransferType()).isEqualTo(destinationType); - assertThat(result.getDataDestination().getType()).isEqualTo(destinationType); verify(context, never()).reportProblem(anyString()); } @@ -141,7 +144,6 @@ void shouldGetConsumerPidFromProcessId_whenFormerIsNotSet() { .add(TYPE, DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE) .add(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID, contractId) .add(DCT_FORMAT_ATTRIBUTE, destinationType) - .add(DSPACE_PROPERTY_DATA_ADDRESS, Json.createObjectBuilder().build()) .add(DSPACE_PROPERTY_CALLBACK_ADDRESS, callbackAddress) .add(DSPACE_PROPERTY_PROCESS_ID, "processId") .build(); @@ -150,7 +152,6 @@ void shouldGetConsumerPidFromProcessId_whenFormerIsNotSet() { assertThat(result).isNotNull(); assertThat(result.getContractId()).isEqualTo(contractId); - assertThat(result.getDataDestination().getType()).isEqualTo(destinationType); assertThat(result.getCallbackAddress()).isEqualTo(callbackAddress); assertThat(result.getConsumerPid()).isEqualTo("processId"); diff --git a/extensions/common/api/management-api-configuration/src/main/java/org/eclipse/edc/connector/api/management/configuration/ManagementApiConfigurationExtension.java b/extensions/common/api/management-api-configuration/src/main/java/org/eclipse/edc/connector/api/management/configuration/ManagementApiConfigurationExtension.java index fbc0fea19c5..07be1f9a8d0 100644 --- a/extensions/common/api/management-api-configuration/src/main/java/org/eclipse/edc/connector/api/management/configuration/ManagementApiConfigurationExtension.java +++ b/extensions/common/api/management-api-configuration/src/main/java/org/eclipse/edc/connector/api/management/configuration/ManagementApiConfigurationExtension.java @@ -18,12 +18,22 @@ import org.eclipse.edc.api.auth.spi.AuthenticationRequestFilter; import org.eclipse.edc.api.auth.spi.AuthenticationService; import org.eclipse.edc.connector.api.management.configuration.transform.JsonObjectFromContractAgreementTransformer; +import org.eclipse.edc.core.transform.transformer.OdrlTransformersFactory; +import org.eclipse.edc.core.transform.transformer.from.JsonObjectFromAssetTransformer; +import org.eclipse.edc.core.transform.transformer.from.JsonObjectFromCriterionTransformer; +import org.eclipse.edc.core.transform.transformer.from.JsonObjectFromDataAddressTransformer; +import org.eclipse.edc.core.transform.transformer.from.JsonObjectFromPolicyTransformer; +import org.eclipse.edc.core.transform.transformer.from.JsonObjectFromQuerySpecTransformer; +import org.eclipse.edc.core.transform.transformer.to.JsonObjectToAssetTransformer; +import org.eclipse.edc.core.transform.transformer.to.JsonObjectToCriterionTransformer; import org.eclipse.edc.core.transform.transformer.to.JsonObjectToDataAddressTransformer; +import org.eclipse.edc.core.transform.transformer.to.JsonObjectToQuerySpecTransformer; import org.eclipse.edc.core.transform.transformer.to.JsonValueToGenericTypeTransformer; import org.eclipse.edc.jsonld.spi.JsonLd; import org.eclipse.edc.runtime.metamodel.annotation.Extension; import org.eclipse.edc.runtime.metamodel.annotation.Inject; import org.eclipse.edc.runtime.metamodel.annotation.Provides; +import org.eclipse.edc.spi.agent.ParticipantIdMapper; import org.eclipse.edc.spi.system.ServiceExtension; import org.eclipse.edc.spi.system.ServiceExtensionContext; import org.eclipse.edc.spi.types.TypeManager; @@ -76,6 +86,8 @@ public class ManagementApiConfigurationExtension implements ServiceExtension { private JsonLd jsonLd; @Inject private TypeTransformerRegistry transformerRegistry; + @Inject + private ParticipantIdMapper participantIdMapper; @Override public String name() { @@ -94,10 +106,21 @@ public void initialize(ServiceExtensionContext context) { webService.registerResource(webServiceConfiguration.getContextAlias(), new ObjectMapperProvider(jsonLdMapper)); webService.registerResource(webServiceConfiguration.getContextAlias(), new JerseyJsonLdInterceptor(jsonLd, jsonLdMapper, MANAGEMENT_SCOPE)); - var factory = Json.createBuilderFactory(Map.of()); var managementApiTransformerRegistry = transformerRegistry.forContext("management-api"); + + var factory = Json.createBuilderFactory(Map.of()); managementApiTransformerRegistry.register(new JsonObjectFromContractAgreementTransformer(factory)); + managementApiTransformerRegistry.register(new JsonObjectFromDataAddressTransformer(factory)); + managementApiTransformerRegistry.register(new JsonObjectFromAssetTransformer(factory, jsonLdMapper)); + managementApiTransformerRegistry.register(new JsonObjectFromPolicyTransformer(factory, participantIdMapper)); + managementApiTransformerRegistry.register(new JsonObjectFromQuerySpecTransformer(factory)); + managementApiTransformerRegistry.register(new JsonObjectFromCriterionTransformer(factory, jsonLdMapper)); + + OdrlTransformersFactory.jsonObjectToOdrlTransformers(participantIdMapper).forEach(managementApiTransformerRegistry::register); managementApiTransformerRegistry.register(new JsonObjectToDataAddressTransformer()); - managementApiTransformerRegistry.register(new JsonValueToGenericTypeTransformer(typeManager.getMapper(JSON_LD))); + managementApiTransformerRegistry.register(new JsonObjectToQuerySpecTransformer()); + managementApiTransformerRegistry.register(new JsonObjectToCriterionTransformer()); + managementApiTransformerRegistry.register(new JsonObjectToAssetTransformer()); + managementApiTransformerRegistry.register(new JsonValueToGenericTypeTransformer(jsonLdMapper)); } } diff --git a/extensions/control-plane/api/management-api/policy-definition-api/src/main/java/org/eclipse/edc/connector/api/management/policy/PolicyDefinitionApiExtension.java b/extensions/control-plane/api/management-api/policy-definition-api/src/main/java/org/eclipse/edc/connector/api/management/policy/PolicyDefinitionApiExtension.java index 3bc4295a441..b0744df472b 100644 --- a/extensions/control-plane/api/management-api/policy-definition-api/src/main/java/org/eclipse/edc/connector/api/management/policy/PolicyDefinitionApiExtension.java +++ b/extensions/control-plane/api/management-api/policy-definition-api/src/main/java/org/eclipse/edc/connector/api/management/policy/PolicyDefinitionApiExtension.java @@ -66,13 +66,14 @@ public String name() { @Override public void initialize(ServiceExtensionContext context) { var jsonBuilderFactory = Json.createBuilderFactory(Map.of()); - transformerRegistry.register(new JsonObjectToPolicyDefinitionTransformer()); + var managementApiTransformerRegistry = transformerRegistry.forContext("management-api"); var mapper = typeManager.getMapper(JSON_LD); - transformerRegistry.register(new JsonObjectFromPolicyDefinitionTransformer(jsonBuilderFactory, mapper)); + managementApiTransformerRegistry.register(new JsonObjectToPolicyDefinitionTransformer()); + managementApiTransformerRegistry.register(new JsonObjectFromPolicyDefinitionTransformer(jsonBuilderFactory, mapper)); validatorRegistry.register(EDC_POLICY_DEFINITION_TYPE, PolicyDefinitionValidator.instance()); var monitor = context.getMonitor(); - webService.registerResource(configuration.getContextAlias(), new PolicyDefinitionApiController(monitor, transformerRegistry, service, validatorRegistry)); + webService.registerResource(configuration.getContextAlias(), new PolicyDefinitionApiController(monitor, managementApiTransformerRegistry, service, validatorRegistry)); } } diff --git a/extensions/control-plane/api/management-api/policy-definition-api/src/test/java/org/eclipse/edc/connector/api/management/policy/PolicyDefinitionApiExtensionTest.java b/extensions/control-plane/api/management-api/policy-definition-api/src/test/java/org/eclipse/edc/connector/api/management/policy/PolicyDefinitionApiExtensionTest.java index 838e6356cce..2dc8169e2b4 100644 --- a/extensions/control-plane/api/management-api/policy-definition-api/src/test/java/org/eclipse/edc/connector/api/management/policy/PolicyDefinitionApiExtensionTest.java +++ b/extensions/control-plane/api/management-api/policy-definition-api/src/test/java/org/eclipse/edc/connector/api/management/policy/PolicyDefinitionApiExtensionTest.java @@ -17,6 +17,7 @@ import org.eclipse.edc.junit.extensions.DependencyInjectionExtension; import org.eclipse.edc.spi.system.ServiceExtensionContext; import org.eclipse.edc.spi.system.injection.ObjectFactory; +import org.eclipse.edc.transform.spi.TypeTransformerRegistry; import org.eclipse.edc.validator.spi.JsonObjectValidatorRegistry; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -27,6 +28,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; @ExtendWith(DependencyInjectionExtension.class) class PolicyDefinitionApiExtensionTest { @@ -36,6 +38,9 @@ class PolicyDefinitionApiExtensionTest { @BeforeEach void setUp(ServiceExtensionContext context, ObjectFactory factory) { + TypeTransformerRegistry typeTransformerRegistry = mock(); + when(typeTransformerRegistry.forContext(any())).thenReturn(mock()); + context.registerService(TypeTransformerRegistry.class, typeTransformerRegistry); context.registerService(JsonObjectValidatorRegistry.class, validatorRegistry); extension = factory.constructInstance(PolicyDefinitionApiExtension.class); } diff --git a/extensions/data-plane/data-plane-signaling/data-plane-signaling-api-configuration/build.gradle.kts b/extensions/data-plane/data-plane-signaling/data-plane-signaling-api-configuration/build.gradle.kts index 5bd1c7bbb67..4fca7eb58ff 100644 --- a/extensions/data-plane/data-plane-signaling/data-plane-signaling-api-configuration/build.gradle.kts +++ b/extensions/data-plane/data-plane-signaling/data-plane-signaling-api-configuration/build.gradle.kts @@ -22,7 +22,7 @@ dependencies { api(project(":spi:common:web-spi")) api(project(":spi:data-plane:data-plane-spi")) - implementation(project(":core:common:transform-core")) // for the transformer registry impl + implementation(project(":core:common:transform-dspace")) implementation(project(":core:common:jersey-providers")) implementation(project(":extensions:data-plane:data-plane-signaling:data-plane-signaling-transform")) implementation(libs.jakarta.rsApi) diff --git a/extensions/data-plane/data-plane-signaling/data-plane-signaling-api-configuration/src/main/java/org/eclipse/edc/connector/api/signaling/configuration/SignalingApiConfigurationExtension.java b/extensions/data-plane/data-plane-signaling/data-plane-signaling-api-configuration/src/main/java/org/eclipse/edc/connector/api/signaling/configuration/SignalingApiConfigurationExtension.java index 88f34319f83..89addb691b7 100644 --- a/extensions/data-plane/data-plane-signaling/data-plane-signaling-api-configuration/src/main/java/org/eclipse/edc/connector/api/signaling/configuration/SignalingApiConfigurationExtension.java +++ b/extensions/data-plane/data-plane-signaling/data-plane-signaling-api-configuration/src/main/java/org/eclipse/edc/connector/api/signaling/configuration/SignalingApiConfigurationExtension.java @@ -16,12 +16,12 @@ import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.json.Json; -import org.eclipse.edc.connector.api.signaling.transform.from.JsonObjectFromDataAddressTransformer; import org.eclipse.edc.connector.api.signaling.transform.from.JsonObjectFromDataFlowResponseMessageTransformer; -import org.eclipse.edc.connector.api.signaling.transform.to.JsonObjectToDataAddressTransformer; import org.eclipse.edc.connector.api.signaling.transform.to.JsonObjectToDataFlowStartMessageTransformer; import org.eclipse.edc.connector.api.signaling.transform.to.JsonObjectToDataFlowSuspendMessageTransformer; import org.eclipse.edc.connector.api.signaling.transform.to.JsonObjectToDataFlowTerminateMessageTransformer; +import org.eclipse.edc.core.transform.dspace.from.JsonObjectFromDataAddressTransformer; +import org.eclipse.edc.core.transform.dspace.to.JsonObjectToDataAddressTransformer; import org.eclipse.edc.jsonld.spi.JsonLd; import org.eclipse.edc.runtime.metamodel.annotation.Extension; import org.eclipse.edc.runtime.metamodel.annotation.Inject; diff --git a/extensions/data-plane/data-plane-signaling/data-plane-signaling-client/build.gradle.kts b/extensions/data-plane/data-plane-signaling/data-plane-signaling-client/build.gradle.kts index de721a0221d..5e86a683363 100644 --- a/extensions/data-plane/data-plane-signaling/data-plane-signaling-client/build.gradle.kts +++ b/extensions/data-plane/data-plane-signaling/data-plane-signaling-client/build.gradle.kts @@ -21,13 +21,14 @@ dependencies { api(project(":spi:common:http-spi")) api(project(":spi:common:core-spi")) api(project(":spi:data-plane-selector:data-plane-selector-spi")) - implementation(project(":core:common:transform-core")) // for the transformer registry impl implementation(project(":core:common:util")) implementation(project(":extensions:data-plane:data-plane-signaling:data-plane-signaling-transform")) implementation(libs.opentelemetry.instrumentation.annotations) testImplementation(project(":core:common:junit")) + testImplementation(project(":core:common:transform-core")) + testImplementation(project(":core:common:transform-dspace")) testImplementation(project(":extensions:common:json-ld")) testImplementation(libs.restAssured) testImplementation(libs.mockserver.netty) diff --git a/extensions/data-plane/data-plane-signaling/data-plane-signaling-client/src/test/java/org/eclipse/edc/connector/dataplane/client/DataPlaneSignalingClientTest.java b/extensions/data-plane/data-plane-signaling/data-plane-signaling-client/src/test/java/org/eclipse/edc/connector/dataplane/client/DataPlaneSignalingClientTest.java index eefca3dc3f3..183d20d232e 100644 --- a/extensions/data-plane/data-plane-signaling/data-plane-signaling-client/src/test/java/org/eclipse/edc/connector/dataplane/client/DataPlaneSignalingClientTest.java +++ b/extensions/data-plane/data-plane-signaling/data-plane-signaling-client/src/test/java/org/eclipse/edc/connector/dataplane/client/DataPlaneSignalingClientTest.java @@ -18,17 +18,17 @@ import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.json.Json; import jakarta.json.JsonObject; -import org.eclipse.edc.connector.api.signaling.transform.from.JsonObjectFromDataAddressTransformer; import org.eclipse.edc.connector.api.signaling.transform.from.JsonObjectFromDataFlowResponseMessageTransformer; import org.eclipse.edc.connector.api.signaling.transform.from.JsonObjectFromDataFlowStartMessageTransformer; import org.eclipse.edc.connector.api.signaling.transform.from.JsonObjectFromDataFlowSuspendMessageTransformer; import org.eclipse.edc.connector.api.signaling.transform.from.JsonObjectFromDataFlowTerminateMessageTransformer; -import org.eclipse.edc.connector.api.signaling.transform.to.JsonObjectToDataAddressTransformer; import org.eclipse.edc.connector.api.signaling.transform.to.JsonObjectToDataFlowResponseMessageTransformer; import org.eclipse.edc.connector.dataplane.selector.spi.client.DataPlaneClient; import org.eclipse.edc.connector.dataplane.selector.spi.instance.DataPlaneInstance; import org.eclipse.edc.connector.dataplane.spi.response.TransferErrorResponse; import org.eclipse.edc.core.transform.TypeTransformerRegistryImpl; +import org.eclipse.edc.core.transform.dspace.from.JsonObjectFromDataAddressTransformer; +import org.eclipse.edc.core.transform.dspace.to.JsonObjectToDataAddressTransformer; import org.eclipse.edc.jsonld.TitaniumJsonLd; import org.eclipse.edc.junit.annotations.ComponentTest; import org.eclipse.edc.spi.EdcException; diff --git a/extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/build.gradle.kts b/extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/build.gradle.kts index deb33a88eb3..b53de687153 100644 --- a/extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/build.gradle.kts +++ b/extensions/data-plane/data-plane-signaling/data-plane-signaling-transform/build.gradle.kts @@ -22,7 +22,7 @@ dependencies { api(project(":spi:common:web-spi")) api(project(":spi:data-plane:data-plane-spi")) - implementation(project(":core:common:transform-core")) // for the transformer registry impl + implementation(project(":core:common:transform-dspace")) implementation(project(":core:common:jersey-providers")) implementation(libs.jakarta.rsApi) diff --git a/settings.gradle.kts b/settings.gradle.kts index b12dea2c7df..cae918dec5d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -50,6 +50,7 @@ include(":core:common:policy-engine") include(":core:common:policy-evaluator") include(":core:common:state-machine") include(":core:common:transform-core") +include(":core:common:transform-dspace") include(":core:common:validator-core") include(":core:common:util") diff --git a/system-tests/e2e-dataplane-tests/tests/build.gradle.kts b/system-tests/e2e-dataplane-tests/tests/build.gradle.kts index 6f6d290c63e..9f7951f2eb5 100644 --- a/system-tests/e2e-dataplane-tests/tests/build.gradle.kts +++ b/system-tests/e2e-dataplane-tests/tests/build.gradle.kts @@ -35,6 +35,7 @@ dependencies { testImplementation(libs.mockserver.netty) testImplementation(libs.mockserver.client) testImplementation(project(":core:common:transform-core")) // for the transformer registry impl + testImplementation(project(":core:common:transform-dspace")) testImplementation(project(":extensions:common:crypto:crypto-common")) testCompileOnly(project(":system-tests:e2e-dataplane-tests:runtimes:data-plane")) diff --git a/system-tests/e2e-dataplane-tests/tests/src/test/java/org/eclipse/edc/test/e2e/DataPlaneSignalingApiEndToEndTest.java b/system-tests/e2e-dataplane-tests/tests/src/test/java/org/eclipse/edc/test/e2e/DataPlaneSignalingApiEndToEndTest.java index f019634fe5b..a4ad058a0f2 100644 --- a/system-tests/e2e-dataplane-tests/tests/src/test/java/org/eclipse/edc/test/e2e/DataPlaneSignalingApiEndToEndTest.java +++ b/system-tests/e2e-dataplane-tests/tests/src/test/java/org/eclipse/edc/test/e2e/DataPlaneSignalingApiEndToEndTest.java @@ -19,15 +19,15 @@ import io.restassured.http.ContentType; import jakarta.json.Json; import jakarta.json.JsonObject; -import org.eclipse.edc.connector.api.signaling.transform.from.JsonObjectFromDataAddressTransformer; import org.eclipse.edc.connector.api.signaling.transform.from.JsonObjectFromDataFlowStartMessageTransformer; -import org.eclipse.edc.connector.api.signaling.transform.to.JsonObjectToDataAddressTransformer; import org.eclipse.edc.connector.dataplane.spi.DataFlow; import org.eclipse.edc.connector.dataplane.spi.DataFlowStates; import org.eclipse.edc.connector.dataplane.spi.Endpoint; import org.eclipse.edc.connector.dataplane.spi.iam.PublicEndpointGeneratorService; import org.eclipse.edc.connector.dataplane.spi.store.DataPlaneStore; import org.eclipse.edc.core.transform.TypeTransformerRegistryImpl; +import org.eclipse.edc.core.transform.dspace.from.JsonObjectFromDataAddressTransformer; +import org.eclipse.edc.core.transform.dspace.to.JsonObjectToDataAddressTransformer; import org.eclipse.edc.jsonld.util.JacksonJsonLd; import org.eclipse.edc.junit.annotations.EndToEndTest; import org.eclipse.edc.spi.result.Failure; diff --git a/system-tests/e2e-transfer-test/runner/src/test/java/org/eclipse/edc/test/e2e/AbstractEndToEndTransfer.java b/system-tests/e2e-transfer-test/runner/src/test/java/org/eclipse/edc/test/e2e/AbstractEndToEndTransfer.java index 8c14776f4e5..09db627435d 100644 --- a/system-tests/e2e-transfer-test/runner/src/test/java/org/eclipse/edc/test/e2e/AbstractEndToEndTransfer.java +++ b/system-tests/e2e-transfer-test/runner/src/test/java/org/eclipse/edc/test/e2e/AbstractEndToEndTransfer.java @@ -235,9 +235,7 @@ private JsonObject httpDataAddress(String baseUrl) { return createObjectBuilder() .add(TYPE, EDC_NAMESPACE + "DataAddress") .add(EDC_NAMESPACE + "type", "HttpData") - .add(EDC_NAMESPACE + "properties", createObjectBuilder() - .add(EDC_NAMESPACE + "baseUrl", baseUrl) - .build()) + .add(EDC_NAMESPACE + "baseUrl", baseUrl) .build(); }