diff --git a/data-protocols/dsp/dsp-catalog/build.gradle.kts b/data-protocols/dsp/dsp-catalog/build.gradle.kts index bbac359bc3a..d02db7cb805 100644 --- a/data-protocols/dsp/dsp-catalog/build.gradle.kts +++ b/data-protocols/dsp/dsp-catalog/build.gradle.kts @@ -22,4 +22,5 @@ dependencies { api(project(":data-protocols:dsp:dsp-catalog:dsp-catalog-http-dispatcher")) api(project(":data-protocols:dsp:dsp-catalog:dsp-catalog-transform")) api(project(":data-protocols:dsp:dsp-catalog:lib:dsp-catalog-validation-lib")) + api(project(":data-protocols:dsp:dsp-catalog:lib:dsp-catalog-transform-lib")) } diff --git a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/build.gradle.kts b/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/build.gradle.kts index 3583e3a704a..a9a97299397 100644 --- a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/build.gradle.kts +++ b/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/build.gradle.kts @@ -17,11 +17,8 @@ plugins { } dependencies { - api(project(":spi:common:json-ld-spi")) - api(project(":spi:control-plane:catalog-spi")) - api(project(":extensions:common:json-ld")) - api(project(":data-protocols:dsp:dsp-spi")) - api(project(":data-protocols:dsp:dsp-http-spi")) - + api(project(":spi:common:core-spi")) + implementation(project(":core:common:lib:transform-lib")) + implementation(project(":data-protocols:dsp:dsp-catalog:lib:dsp-catalog-transform-lib")) } diff --git a/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/build.gradle.kts b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/build.gradle.kts new file mode 100644 index 00000000000..f33a2eb64d3 --- /dev/null +++ b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/build.gradle.kts @@ -0,0 +1,25 @@ +/* + * 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` +} + +dependencies { + api(project(":spi:common:json-ld-spi")) + api(project(":data-protocols:dsp:dsp-spi")) + implementation(project(":core:common:lib:transform-lib")) + + testImplementation(project(":core:common:junit")) +} \ No newline at end of file diff --git a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogErrorTransformer.java b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogErrorTransformer.java similarity index 65% rename from data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogErrorTransformer.java rename to data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogErrorTransformer.java index 619faa0095b..7ff0060d0c7 100644 --- a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogErrorTransformer.java +++ b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogErrorTransformer.java @@ -17,34 +17,39 @@ import jakarta.json.JsonBuilderFactory; import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.catalog.spi.CatalogError; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspCatalogPropertyAndTypeNames.DSPACE_TYPE_CATALOG_ERROR; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspCatalogPropertyAndTypeNames.DSPACE_TYPE_CATALOG_ERROR_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON_TERM; /** * Transforms a {@link CatalogError} to a {@link JsonObject} in JSON-LD expanded form. */ -public class JsonObjectFromCatalogErrorTransformer extends AbstractJsonLdTransformer { +public class JsonObjectFromCatalogErrorTransformer extends AbstractNamespaceAwareJsonLdTransformer { private final JsonBuilderFactory jsonFactory; public JsonObjectFromCatalogErrorTransformer(JsonBuilderFactory jsonFactory) { - super(CatalogError.class, JsonObject.class); + this(jsonFactory, DSPACE_SCHEMA); + } + + public JsonObjectFromCatalogErrorTransformer(JsonBuilderFactory jsonFactory, String schema) { + super(CatalogError.class, JsonObject.class, schema); this.jsonFactory = jsonFactory; } @Override public @Nullable JsonObject transform(@NotNull CatalogError error, @NotNull TransformerContext context) { return jsonFactory.createObjectBuilder() - .add(TYPE, DSPACE_TYPE_CATALOG_ERROR) - .add(DSPACE_PROPERTY_CODE, error.getCode()) - .add(DSPACE_PROPERTY_REASON, jsonFactory.createArrayBuilder(error.getMessages())) + .add(TYPE, forNamespace(DSPACE_TYPE_CATALOG_ERROR_TERM)) + .add(forNamespace(DSPACE_PROPERTY_CODE_TERM), error.getCode()) + .add(forNamespace(DSPACE_PROPERTY_REASON_TERM), jsonFactory.createArrayBuilder(error.getMessages())) .build(); } } diff --git a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogRequestMessageTransformer.java b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogRequestMessageTransformer.java similarity index 67% rename from data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogRequestMessageTransformer.java rename to data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogRequestMessageTransformer.java index 94435fb006d..774912126da 100644 --- a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogRequestMessageTransformer.java +++ b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogRequestMessageTransformer.java @@ -17,34 +17,39 @@ import jakarta.json.JsonBuilderFactory; import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.catalog.spi.CatalogRequestMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspCatalogPropertyAndTypeNames.DSPACE_PROPERTY_FILTER_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspCatalogPropertyAndTypeNames.DSPACE_TYPE_CATALOG_REQUEST_MESSAGE_IRI; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspCatalogPropertyAndTypeNames.DSPACE_PROPERTY_FILTER_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspCatalogPropertyAndTypeNames.DSPACE_TYPE_CATALOG_REQUEST_MESSAGE_TERM; /** * Transforms a {@link CatalogRequestMessage} to a {@link JsonObject} in JSON-LD expanded form. */ -public class JsonObjectFromCatalogRequestMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectFromCatalogRequestMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { private final JsonBuilderFactory jsonFactory; public JsonObjectFromCatalogRequestMessageTransformer(JsonBuilderFactory jsonFactory) { - super(CatalogRequestMessage.class, JsonObject.class); + this(jsonFactory, DSPACE_SCHEMA); + } + + public JsonObjectFromCatalogRequestMessageTransformer(JsonBuilderFactory jsonFactory, String schema) { + super(CatalogRequestMessage.class, JsonObject.class, schema); this.jsonFactory = jsonFactory; } @Override public @Nullable JsonObject transform(@NotNull CatalogRequestMessage message, @NotNull TransformerContext context) { var builder = jsonFactory.createObjectBuilder(); - builder.add(TYPE, DSPACE_TYPE_CATALOG_REQUEST_MESSAGE_IRI); + builder.add(TYPE, forNamespace(DSPACE_TYPE_CATALOG_REQUEST_MESSAGE_TERM)); if (message.getQuerySpec() != null) { - builder.add(DSPACE_PROPERTY_FILTER_IRI, context.transform(message.getQuerySpec(), JsonObject.class)); + builder.add(forNamespace(DSPACE_PROPERTY_FILTER_TERM), context.transform(message.getQuerySpec(), JsonObject.class)); } return builder.build(); diff --git a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogTransformer.java b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogTransformer.java similarity index 82% rename from data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogTransformer.java rename to data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogTransformer.java index 26bb581be3c..73820883975 100644 --- a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogTransformer.java +++ b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogTransformer.java @@ -18,7 +18,7 @@ import jakarta.json.JsonBuilderFactory; import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.catalog.spi.Catalog; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.spi.agent.ParticipantIdMapper; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; @@ -28,22 +28,27 @@ import static java.util.Optional.ofNullable; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCAT_CATALOG_TYPE; import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCAT_DATASET_ATTRIBUTE; import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCAT_DATA_SERVICE_ATTRIBUTE; import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCAT_DISTRIBUTION_ATTRIBUTE; -import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DSPACE_PROPERTY_PARTICIPANT_ID; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DSPACE_PROPERTY_PARTICIPANT_ID_TERM; /** * Converts from a {@link Catalog} to a DCAT catalog as a {@link JsonObject} in JSON-LD expanded form. */ -public class JsonObjectFromCatalogTransformer extends AbstractJsonLdTransformer { +public class JsonObjectFromCatalogTransformer extends AbstractNamespaceAwareJsonLdTransformer { private final JsonBuilderFactory jsonFactory; private final ObjectMapper mapper; private final ParticipantIdMapper participantIdMapper; public JsonObjectFromCatalogTransformer(JsonBuilderFactory jsonFactory, ObjectMapper mapper, ParticipantIdMapper participantIdMapper) { - super(Catalog.class, JsonObject.class); + this(jsonFactory, mapper, participantIdMapper, DSPACE_SCHEMA); + } + + public JsonObjectFromCatalogTransformer(JsonBuilderFactory jsonFactory, ObjectMapper mapper, ParticipantIdMapper participantIdMapper, String namespace) { + super(Catalog.class, JsonObject.class, namespace); this.jsonFactory = jsonFactory; this.mapper = mapper; this.participantIdMapper = participantIdMapper; @@ -70,7 +75,7 @@ public JsonObjectFromCatalogTransformer(JsonBuilderFactory jsonFactory, ObjectMa .add(DCAT_DISTRIBUTION_ATTRIBUTE, distributions) .add(DCAT_DATA_SERVICE_ATTRIBUTE, dataServices); - ofNullable(catalog.getParticipantId()).ifPresent(pid -> objectBuilder.add(DSPACE_PROPERTY_PARTICIPANT_ID, participantIdMapper.toIri(pid))); + ofNullable(catalog.getParticipantId()).ifPresent(pid -> objectBuilder.add(forNamespace(DSPACE_PROPERTY_PARTICIPANT_ID_TERM), participantIdMapper.toIri(pid))); transformProperties(catalog.getProperties(), objectBuilder, mapper, context); diff --git a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDataServiceTransformer.java b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDataServiceTransformer.java similarity index 100% rename from data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDataServiceTransformer.java rename to data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDataServiceTransformer.java diff --git a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDatasetTransformer.java b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDatasetTransformer.java similarity index 100% rename from data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDatasetTransformer.java rename to data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDatasetTransformer.java diff --git a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDistributionTransformer.java b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDistributionTransformer.java similarity index 100% rename from data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDistributionTransformer.java rename to data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDistributionTransformer.java diff --git a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/to/JsonObjectToCatalogRequestMessageTransformer.java b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/to/JsonObjectToCatalogRequestMessageTransformer.java similarity index 73% rename from data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/to/JsonObjectToCatalogRequestMessageTransformer.java rename to data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/to/JsonObjectToCatalogRequestMessageTransformer.java index 3346c27f99d..24b70333b9e 100644 --- a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/to/JsonObjectToCatalogRequestMessageTransformer.java +++ b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/catalog/transform/to/JsonObjectToCatalogRequestMessageTransformer.java @@ -16,7 +16,7 @@ import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.catalog.spi.CatalogRequestMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.spi.query.QuerySpec; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; @@ -24,15 +24,20 @@ import java.util.Optional; -import static org.eclipse.edc.protocol.dsp.spi.type.DspCatalogPropertyAndTypeNames.DSPACE_PROPERTY_FILTER_IRI; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspCatalogPropertyAndTypeNames.DSPACE_PROPERTY_FILTER_TERM; /** * Transforms a {@link JsonObject} in JSON-LD expanded form to a {@link CatalogRequestMessage}. */ -public class JsonObjectToCatalogRequestMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectToCatalogRequestMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { public JsonObjectToCatalogRequestMessageTransformer() { - super(JsonObject.class, CatalogRequestMessage.class); + this(DSPACE_SCHEMA); + } + + public JsonObjectToCatalogRequestMessageTransformer(String namespace) { + super(JsonObject.class, CatalogRequestMessage.class, namespace); } @Override @@ -40,7 +45,7 @@ public JsonObjectToCatalogRequestMessageTransformer() { var builder = CatalogRequestMessage.Builder.newInstance(); Optional.of(object) - .map(it -> it.get(DSPACE_PROPERTY_FILTER_IRI)) + .map(it -> it.get(forNamespace(DSPACE_PROPERTY_FILTER_TERM))) .map(it -> transformObject(it, QuerySpec.class, context)) .ifPresent(builder::querySpec); diff --git a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogErrorTransformerTest.java b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogErrorTransformerTest.java similarity index 84% rename from data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogErrorTransformerTest.java rename to data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogErrorTransformerTest.java index ed65ea78e56..64cf491f1e1 100644 --- a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogErrorTransformerTest.java +++ b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogErrorTransformerTest.java @@ -26,9 +26,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspCatalogPropertyAndTypeNames.DSPACE_TYPE_CATALOG_ERROR; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON; +import static org.eclipse.edc.protocol.dsp.spi.type.DspCatalogPropertyAndTypeNames.DSPACE_TYPE_CATALOG_ERROR_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON_IRI; import static org.mockito.Mockito.mock; class JsonObjectFromCatalogErrorTransformerTest { @@ -54,8 +54,8 @@ void transform_returnJsonObject() { var result = transformer.transform(error, context); assertThat(result).isNotNull(); - assertThat(result.getJsonString(TYPE).getString()).isEqualTo(DSPACE_TYPE_CATALOG_ERROR); - assertThat(result.getString(DSPACE_PROPERTY_CODE)).isEqualTo("code"); - assertThat(result.getJsonArray(DSPACE_PROPERTY_REASON)).contains(Json.createValue("message")); + assertThat(result.getJsonString(TYPE).getString()).isEqualTo(DSPACE_TYPE_CATALOG_ERROR_IRI); + assertThat(result.getString(DSPACE_PROPERTY_CODE_IRI)).isEqualTo("code"); + assertThat(result.getJsonArray(DSPACE_PROPERTY_REASON_IRI)).contains(Json.createValue("message")); } } diff --git a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogRequestMessageTransformerTest.java b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogRequestMessageTransformerTest.java similarity index 100% rename from data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogRequestMessageTransformerTest.java rename to data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogRequestMessageTransformerTest.java diff --git a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogTransformerTest.java b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogTransformerTest.java similarity index 98% rename from data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogTransformerTest.java rename to data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogTransformerTest.java index 2b9c7e84a1f..fc42ba4612e 100644 --- a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogTransformerTest.java +++ b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromCatalogTransformerTest.java @@ -39,7 +39,7 @@ import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCAT_CATALOG_TYPE; import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCAT_DATASET_ATTRIBUTE; import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCAT_DATA_SERVICE_ATTRIBUTE; -import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DSPACE_PROPERTY_PARTICIPANT_ID; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DSPACE_PROPERTY_PARTICIPANT_ID_IRI; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -97,7 +97,7 @@ void transform_returnJsonObject() { .isInstanceOf(JsonArray.class) .matches(v -> v.asJsonArray().size() == 1) .matches(v -> v.asJsonArray().get(0).equals(dataServiceJson)); - assertThat(result.getString(DSPACE_PROPERTY_PARTICIPANT_ID)).isEqualTo("urn:namespace:participantId"); + assertThat(result.getString(DSPACE_PROPERTY_PARTICIPANT_ID_IRI)).isEqualTo("urn:namespace:participantId"); assertThat(result.get(CATALOG_PROPERTY)).isNotNull(); verify(context, times(1)).transform(catalog.getDatasets().get(0), JsonObject.class); diff --git a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDataServiceTransformerTest.java b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDataServiceTransformerTest.java similarity index 100% rename from data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDataServiceTransformerTest.java rename to data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDataServiceTransformerTest.java diff --git a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDatasetTransformerTest.java b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDatasetTransformerTest.java similarity index 100% rename from data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDatasetTransformerTest.java rename to data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDatasetTransformerTest.java diff --git a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDistributionTransformerTest.java b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDistributionTransformerTest.java similarity index 100% rename from data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDistributionTransformerTest.java rename to data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/from/JsonObjectFromDistributionTransformerTest.java diff --git a/data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/to/JsonObjectToCatalogRequestMessageTransformerTest.java b/data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/to/JsonObjectToCatalogRequestMessageTransformerTest.java similarity index 100% rename from data-protocols/dsp/dsp-catalog/dsp-catalog-transform/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/to/JsonObjectToCatalogRequestMessageTransformerTest.java rename to data-protocols/dsp/dsp-catalog/lib/dsp-catalog-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/catalog/transform/to/JsonObjectToCatalogRequestMessageTransformerTest.java diff --git a/data-protocols/dsp/dsp-http-core/src/test/java/org/eclipse/edc/protocol/dsp/http/message/DspRequestHandlerImplTest.java b/data-protocols/dsp/dsp-http-core/src/test/java/org/eclipse/edc/protocol/dsp/http/message/DspRequestHandlerImplTest.java index a9d9a2e7f1a..843f2076a4c 100644 --- a/data-protocols/dsp/dsp-http-core/src/test/java/org/eclipse/edc/protocol/dsp/http/message/DspRequestHandlerImplTest.java +++ b/data-protocols/dsp/dsp-http-core/src/test/java/org/eclipse/edc/protocol/dsp/http/message/DspRequestHandlerImplTest.java @@ -42,9 +42,9 @@ import static org.assertj.core.api.InstanceOfAssertFactories.type; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; import static org.eclipse.edc.protocol.dsp.http.spi.types.HttpMessageProtocol.DATASPACE_PROTOCOL_HTTP; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROCESS_ID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON_IRI; import static org.eclipse.edc.validator.spi.Violation.violation; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; @@ -66,8 +66,8 @@ class DspRequestHandlerImplTest { private static JsonObject error(String code, String reason, String processId) { var json = Json.createObjectBuilder() .add(TYPE, "TestError") - .add(DSPACE_PROPERTY_CODE, code) - .add(DSPACE_PROPERTY_REASON, reason); + .add(DSPACE_PROPERTY_CODE_IRI, code) + .add(DSPACE_PROPERTY_REASON_IRI, reason); Optional.ofNullable(processId).ifPresent(id -> json.add(DSPACE_PROPERTY_PROCESS_ID, id)); @@ -158,8 +158,8 @@ void shouldReturnUnauthorized_whenTokenIsNull() { assertThat(result.getStatus()).isEqualTo(401); assertThat(result.getEntity()).asInstanceOf(type(JsonObject.class)).satisfies(error -> { assertThat(error.getString(TYPE)).isEqualTo("TestError"); - assertThat(error.getString(DSPACE_PROPERTY_CODE)).isEqualTo("401"); - assertThat(error.get(DSPACE_PROPERTY_REASON)).isNotNull(); + assertThat(error.getString(DSPACE_PROPERTY_CODE_IRI)).isEqualTo("401"); + assertThat(error.get(DSPACE_PROPERTY_REASON_IRI)).isNotNull(); }); } @@ -176,8 +176,8 @@ void shouldFail_whenTokenIsNotValid() { assertThat(result.getStatus()).isEqualTo(401); assertThat(result.getEntity()).asInstanceOf(type(JsonObject.class)).satisfies(error -> { assertThat(error.getString(TYPE)).isEqualTo("TestError"); - assertThat(error.getString(DSPACE_PROPERTY_CODE)).isEqualTo("401"); - assertThat(error.get(DSPACE_PROPERTY_REASON)).isNotNull(); + assertThat(error.getString(DSPACE_PROPERTY_CODE_IRI)).isEqualTo("401"); + assertThat(error.get(DSPACE_PROPERTY_REASON_IRI)).isNotNull(); }); } @@ -278,8 +278,8 @@ void shouldReturnUnauthorized_whenTokenIsNull() { assertThat(result.getStatus()).isEqualTo(401); assertThat(result.getEntity()).asInstanceOf(type(JsonObject.class)).satisfies(error -> { assertThat(error.getString(TYPE)).isEqualTo("TestError"); - assertThat(error.getString(DSPACE_PROPERTY_CODE)).isEqualTo("401"); - assertThat(error.get(DSPACE_PROPERTY_REASON)).isNotNull(); + assertThat(error.getString(DSPACE_PROPERTY_CODE_IRI)).isEqualTo("401"); + assertThat(error.get(DSPACE_PROPERTY_REASON_IRI)).isNotNull(); }); } @@ -300,8 +300,8 @@ void shouldFail_whenTokenIsNotValid() { assertThat(result.getStatus()).isEqualTo(401); assertThat(result.getEntity()).asInstanceOf(type(JsonObject.class)).satisfies(error -> { assertThat(error.getString(TYPE)).isEqualTo("TestError"); - assertThat(error.getString(DSPACE_PROPERTY_CODE)).isEqualTo("401"); - assertThat(error.get(DSPACE_PROPERTY_REASON)).isNotNull(); + assertThat(error.getString(DSPACE_PROPERTY_CODE_IRI)).isEqualTo("401"); + assertThat(error.get(DSPACE_PROPERTY_REASON_IRI)).isNotNull(); }); } @@ -467,9 +467,9 @@ void shouldFail_whenTokenIsNotValid() { assertThat(result.getStatus()).isEqualTo(401); assertThat(result.getEntity()).asInstanceOf(type(JsonObject.class)).satisfies(error -> { assertThat(error.getString(TYPE)).isEqualTo("TestError"); - assertThat(error.getString(DSPACE_PROPERTY_CODE)).isEqualTo("401"); + assertThat(error.getString(DSPACE_PROPERTY_CODE_IRI)).isEqualTo("401"); assertThat(error.getString(DSPACE_PROPERTY_PROCESS_ID)).isEqualTo("processId"); - assertThat(error.get(DSPACE_PROPERTY_REASON)).isNotNull(); + assertThat(error.get(DSPACE_PROPERTY_REASON_IRI)).isNotNull(); }); } @@ -492,9 +492,9 @@ void shouldReturnUnauthorized_whenTokenIsNull() { assertThat(result.getStatus()).isEqualTo(401); assertThat(result.getEntity()).asInstanceOf(type(JsonObject.class)).satisfies(error -> { assertThat(error.getString(TYPE)).isEqualTo("TestError"); - assertThat(error.getString(DSPACE_PROPERTY_CODE)).isEqualTo("401"); + assertThat(error.getString(DSPACE_PROPERTY_CODE_IRI)).isEqualTo("401"); assertThat(error.getString(DSPACE_PROPERTY_PROCESS_ID)).isEqualTo("processId"); - assertThat(error.get(DSPACE_PROPERTY_REASON)).isNotNull(); + assertThat(error.get(DSPACE_PROPERTY_REASON_IRI)).isNotNull(); }); } @@ -511,9 +511,9 @@ void shouldFail_whenValidationFails() { assertThat(result.getStatus()).isEqualTo(400); assertThat(result.getEntity()).asInstanceOf(type(JsonObject.class)).satisfies(error -> { assertThat(error.getString(TYPE)).isEqualTo("TestError"); - assertThat(error.getString(DSPACE_PROPERTY_CODE)).isEqualTo("400"); + assertThat(error.getString(DSPACE_PROPERTY_CODE_IRI)).isEqualTo("400"); assertThat(error.getString(DSPACE_PROPERTY_PROCESS_ID)).isEqualTo("processId"); - assertThat(error.get(DSPACE_PROPERTY_REASON)).isNotNull(); + assertThat(error.get(DSPACE_PROPERTY_REASON_IRI)).isNotNull(); }); } @@ -533,9 +533,9 @@ void shouldFail_whenTransformationFails() { assertThat(result.getStatus()).isEqualTo(400); assertThat(result.getEntity()).asInstanceOf(type(JsonObject.class)).satisfies(error -> { assertThat(error.getString(TYPE)).isEqualTo("TestError"); - assertThat(error.getString(DSPACE_PROPERTY_CODE)).isEqualTo("400"); + assertThat(error.getString(DSPACE_PROPERTY_CODE_IRI)).isEqualTo("400"); assertThat(error.getString(DSPACE_PROPERTY_PROCESS_ID)).isEqualTo("processId"); - assertThat(error.get(DSPACE_PROPERTY_REASON)).isNotNull(); + assertThat(error.get(DSPACE_PROPERTY_REASON_IRI)).isNotNull(); }); } @@ -570,9 +570,9 @@ void shouldFail_whenIdIsNotValid() { assertThat(result.getStatus()).isEqualTo(400); assertThat(result.getEntity()).asInstanceOf(type(JsonObject.class)).satisfies(error -> { assertThat(error.getString(TYPE)).isEqualTo("TestError"); - assertThat(error.getString(DSPACE_PROPERTY_CODE)).isEqualTo("400"); + assertThat(error.getString(DSPACE_PROPERTY_CODE_IRI)).isEqualTo("400"); assertThat(error.getString(DSPACE_PROPERTY_PROCESS_ID)).isEqualTo("anotherId"); - assertThat(error.get(DSPACE_PROPERTY_REASON)).isNotNull(); + assertThat(error.get(DSPACE_PROPERTY_REASON_IRI)).isNotNull(); }); } @@ -594,9 +594,9 @@ void shouldFail_whenServiceCallFails() { assertThat(result.getStatus()).isEqualTo(409); assertThat(result.getEntity()).asInstanceOf(type(JsonObject.class)).satisfies(error -> { assertThat(error.getString(TYPE)).isEqualTo("TestError"); - assertThat(error.getString(DSPACE_PROPERTY_CODE)).isEqualTo("409"); + assertThat(error.getString(DSPACE_PROPERTY_CODE_IRI)).isEqualTo("409"); assertThat(error.getString(DSPACE_PROPERTY_PROCESS_ID)).isEqualTo("processId"); - assertThat(error.get(DSPACE_PROPERTY_REASON)).isNotNull(); + assertThat(error.get(DSPACE_PROPERTY_REASON_IRI)).isNotNull(); }); } diff --git a/data-protocols/dsp/dsp-negotiation/build.gradle.kts b/data-protocols/dsp/dsp-negotiation/build.gradle.kts index def7fbfe44c..8ddf836bf79 100644 --- a/data-protocols/dsp/dsp-negotiation/build.gradle.kts +++ b/data-protocols/dsp/dsp-negotiation/build.gradle.kts @@ -22,4 +22,5 @@ dependencies { api(project(":data-protocols:dsp:dsp-negotiation:dsp-negotiation-http-dispatcher")) api(project(":data-protocols:dsp:dsp-negotiation:dsp-negotiation-transform")) api(project(":data-protocols:dsp:dsp-negotiation:lib:dsp-negotiation-validation-lib")) + api(project(":data-protocols:dsp:dsp-negotiation:lib:dsp-negotiation-transform-lib")) } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/build.gradle.kts b/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/build.gradle.kts index 58f62c7a1c4..83db89ddbfd 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/build.gradle.kts +++ b/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/build.gradle.kts @@ -17,10 +17,8 @@ plugins { } dependencies { - api(project(":data-protocols:dsp:dsp-spi")) - api(project(":data-protocols:dsp:dsp-http-spi")) - api(project(":extensions:common:json-ld")) - api(project(":spi:common:json-ld-spi")) + api(project(":spi:common:core-spi")) api(project(":spi:common:transform-spi")) - api(project(":spi:control-plane:contract-spi")) + + implementation(project(":data-protocols:dsp:dsp-negotiation:lib:dsp-negotiation-transform-lib")) } diff --git a/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/build.gradle.kts b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/build.gradle.kts new file mode 100644 index 00000000000..1dae9134eb3 --- /dev/null +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/build.gradle.kts @@ -0,0 +1,28 @@ +/* + * 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` +} + +dependencies { + api(project(":spi:common:json-ld-spi")) + api(project(":data-protocols:dsp:dsp-spi")) + api(project(":spi:control-plane:contract-spi")) + implementation(project(":core:common:lib:transform-lib")) + + testImplementation(project(":core:common:junit")) + testImplementation(project(":extensions:common:json-ld")) + +} \ No newline at end of file diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementMessageTransformer.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementMessageTransformer.java similarity index 71% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementMessageTransformer.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementMessageTransformer.java index c14b86c91d0..863fb5939c0 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementMessageTransformer.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementMessageTransformer.java @@ -18,7 +18,7 @@ import jakarta.json.JsonBuilderFactory; import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.contract.spi.types.agreement.ContractAgreementMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -26,24 +26,29 @@ import static java.time.Instant.ofEpochSecond; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_ASSIGNEE_ATTRIBUTE; import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_ASSIGNER_ATTRIBUTE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_AGREEMENT; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_TIMESTAMP; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_AGREEMENT_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_TIMESTAMP_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; /** * Creates a dspace:ContractAgreementMessage as {@link JsonObject} from {@link ContractAgreementMessage}. */ -public class JsonObjectFromContractAgreementMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectFromContractAgreementMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { private final JsonBuilderFactory jsonFactory; public JsonObjectFromContractAgreementMessageTransformer(JsonBuilderFactory jsonFactory) { - super(ContractAgreementMessage.class, JsonObject.class); + this(jsonFactory, DSPACE_SCHEMA); + } + + public JsonObjectFromContractAgreementMessageTransformer(JsonBuilderFactory jsonFactory, String namespace) { + super(ContractAgreementMessage.class, JsonObject.class, namespace); this.jsonFactory = jsonFactory; } @@ -67,15 +72,15 @@ public JsonObjectFromContractAgreementMessageTransformer(JsonBuilderFactory json .add(ID, agreement.getId()) .add(ODRL_ASSIGNEE_ATTRIBUTE, agreement.getConsumerId()) .add(ODRL_ASSIGNER_ATTRIBUTE, agreement.getProviderId()) - .add(DSPACE_PROPERTY_TIMESTAMP, signing) + .add(forNamespace(DSPACE_PROPERTY_TIMESTAMP_TERM), signing) .build(); return jsonFactory.createObjectBuilder() .add(ID, agreementMessage.getId()) - .add(TYPE, DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_IRI) - .add(DSPACE_PROPERTY_PROVIDER_PID, agreementMessage.getProviderPid()) - .add(DSPACE_PROPERTY_CONSUMER_PID, agreementMessage.getConsumerPid()) - .add(DSPACE_PROPERTY_AGREEMENT, copiedPolicy) + .add(TYPE, forNamespace(DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_TERM)) + .add(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM), agreementMessage.getProviderPid()) + .add(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM), agreementMessage.getConsumerPid()) + .add(forNamespace(DSPACE_PROPERTY_AGREEMENT_TERM), copiedPolicy) .build(); } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementVerificationMessageTransformer.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementVerificationMessageTransformer.java similarity index 68% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementVerificationMessageTransformer.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementVerificationMessageTransformer.java index f8eacf65b67..25d5ef36d3d 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementVerificationMessageTransformer.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementVerificationMessageTransformer.java @@ -17,26 +17,31 @@ import jakarta.json.JsonBuilderFactory; import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.contract.spi.types.agreement.ContractAgreementVerificationMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_AGREEMENT_VERIFICATION_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_AGREEMENT_VERIFICATION_MESSAGE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; /** * Creates a {@link JsonObject} from a {@link ContractAgreementVerificationMessage}. */ -public class JsonObjectFromContractAgreementVerificationMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectFromContractAgreementVerificationMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { private final JsonBuilderFactory jsonFactory; public JsonObjectFromContractAgreementVerificationMessageTransformer(JsonBuilderFactory jsonFactory) { - super(ContractAgreementVerificationMessage.class, JsonObject.class); + this(jsonFactory, DSPACE_SCHEMA); + } + + public JsonObjectFromContractAgreementVerificationMessageTransformer(JsonBuilderFactory jsonFactory, String namespace) { + super(ContractAgreementVerificationMessage.class, JsonObject.class, namespace); this.jsonFactory = jsonFactory; } @@ -44,9 +49,9 @@ public JsonObjectFromContractAgreementVerificationMessageTransformer(JsonBuilder public @Nullable JsonObject transform(@NotNull ContractAgreementVerificationMessage verificationMessage, @NotNull TransformerContext context) { return jsonFactory.createObjectBuilder() .add(ID, verificationMessage.getId()) - .add(TYPE, DSPACE_TYPE_CONTRACT_AGREEMENT_VERIFICATION_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, verificationMessage.getConsumerPid()) - .add(DSPACE_PROPERTY_PROVIDER_PID, verificationMessage.getProviderPid()) + .add(TYPE, forNamespace(DSPACE_TYPE_CONTRACT_AGREEMENT_VERIFICATION_MESSAGE_TERM)) + .add(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM), verificationMessage.getConsumerPid()) + .add(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM), verificationMessage.getProviderPid()) .build(); } } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationErrorTransformer.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationErrorTransformer.java similarity index 64% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationErrorTransformer.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationErrorTransformer.java index 9b7936ba41f..c7e3e9b3bd7 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationErrorTransformer.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationErrorTransformer.java @@ -17,34 +17,39 @@ import jakarta.json.JsonBuilderFactory; import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractNegotiationError; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION_ERROR; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION_ERROR_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON_TERM; /** * Transforms a {@link ContractNegotiationError} to a {@link JsonObject} in JSON-LD expanded form. */ -public class JsonObjectFromContractNegotiationErrorTransformer extends AbstractJsonLdTransformer { +public class JsonObjectFromContractNegotiationErrorTransformer extends AbstractNamespaceAwareJsonLdTransformer { private final JsonBuilderFactory jsonFactory; public JsonObjectFromContractNegotiationErrorTransformer(JsonBuilderFactory jsonFactory) { - super(ContractNegotiationError.class, JsonObject.class); + this(jsonFactory, DSPACE_SCHEMA); + } + + public JsonObjectFromContractNegotiationErrorTransformer(JsonBuilderFactory jsonFactory, String namespace) { + super(ContractNegotiationError.class, JsonObject.class, namespace); this.jsonFactory = jsonFactory; } @Override public @Nullable JsonObject transform(@NotNull ContractNegotiationError error, @NotNull TransformerContext context) { return jsonFactory.createObjectBuilder() - .add(TYPE, DSPACE_TYPE_CONTRACT_NEGOTIATION_ERROR) - .add(DSPACE_PROPERTY_CODE, error.getCode()) - .add(DSPACE_PROPERTY_REASON, jsonFactory.createArrayBuilder(error.getMessages())) + .add(TYPE, forNamespace(DSPACE_TYPE_CONTRACT_NEGOTIATION_ERROR_TERM)) + .add(forNamespace(DSPACE_PROPERTY_CODE_TERM), error.getCode()) + .add(forNamespace(DSPACE_PROPERTY_REASON_TERM), jsonFactory.createArrayBuilder(error.getMessages())) .build(); } } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationEventMessageTransformer.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationEventMessageTransformer.java similarity index 64% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationEventMessageTransformer.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationEventMessageTransformer.java index 41a1ebe8bd5..011f1a6597a 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationEventMessageTransformer.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationEventMessageTransformer.java @@ -17,30 +17,35 @@ import jakarta.json.JsonBuilderFactory; import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.contract.spi.types.agreement.ContractNegotiationEventMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_EVENT_TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION_EVENT_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_FINALIZED; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_EVENT_TYPE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION_EVENT_MESSAGE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_FINALIZED_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; /** * Creates a {@link JsonObject} from a {@link ContractNegotiationEventMessage}. */ -public class JsonObjectFromContractNegotiationEventMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectFromContractNegotiationEventMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { private final JsonBuilderFactory jsonFactory; public JsonObjectFromContractNegotiationEventMessageTransformer(JsonBuilderFactory jsonFactory) { - super(ContractNegotiationEventMessage.class, JsonObject.class); + this(jsonFactory, DSPACE_SCHEMA); + } + + public JsonObjectFromContractNegotiationEventMessageTransformer(JsonBuilderFactory jsonFactory, String namespace) { + super(ContractNegotiationEventMessage.class, JsonObject.class, namespace); this.jsonFactory = jsonFactory; } @@ -48,12 +53,12 @@ public JsonObjectFromContractNegotiationEventMessageTransformer(JsonBuilderFacto public @Nullable JsonObject transform(@NotNull ContractNegotiationEventMessage eventMessage, @NotNull TransformerContext context) { return jsonFactory.createObjectBuilder() .add(ID, eventMessage.getId()) - .add(TYPE, DSPACE_TYPE_CONTRACT_NEGOTIATION_EVENT_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, eventMessage.getConsumerPid()) - .add(DSPACE_PROPERTY_PROVIDER_PID, eventMessage.getProviderPid()) - .add(DSPACE_PROPERTY_EVENT_TYPE, switch (eventMessage.getType()) { - case ACCEPTED -> DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED; - case FINALIZED -> DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_FINALIZED; + .add(TYPE, forNamespace(DSPACE_TYPE_CONTRACT_NEGOTIATION_EVENT_MESSAGE_TERM)) + .add(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM), eventMessage.getConsumerPid()) + .add(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM), eventMessage.getProviderPid()) + .add(forNamespace(DSPACE_PROPERTY_EVENT_TYPE_TERM), switch (eventMessage.getType()) { + case ACCEPTED -> forNamespace(DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED_TERM); + case FINALIZED -> forNamespace(DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_FINALIZED_TERM); }) .build(); } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTerminationMessageTransformer.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTerminationMessageTransformer.java similarity index 63% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTerminationMessageTransformer.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTerminationMessageTransformer.java index 3043bcc871b..aeedcf61df4 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTerminationMessageTransformer.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTerminationMessageTransformer.java @@ -17,28 +17,33 @@ import jakarta.json.JsonBuilderFactory; import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractNegotiationTerminationMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION_TERMINATION_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION_TERMINATION_MESSAGE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON_TERM; /** * Creates a {@link JsonObject} from a {@link ContractNegotiationTerminationMessage}. */ -public class JsonObjectFromContractNegotiationTerminationMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectFromContractNegotiationTerminationMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { private final JsonBuilderFactory jsonFactory; public JsonObjectFromContractNegotiationTerminationMessageTransformer(JsonBuilderFactory jsonFactory) { - super(ContractNegotiationTerminationMessage.class, JsonObject.class); + this(jsonFactory, DSPACE_SCHEMA); + } + + public JsonObjectFromContractNegotiationTerminationMessageTransformer(JsonBuilderFactory jsonFactory, String namespace) { + super(ContractNegotiationTerminationMessage.class, JsonObject.class, namespace); this.jsonFactory = jsonFactory; } @@ -46,12 +51,12 @@ public JsonObjectFromContractNegotiationTerminationMessageTransformer(JsonBuilde public @Nullable JsonObject transform(@NotNull ContractNegotiationTerminationMessage terminationMessage, @NotNull TransformerContext context) { var builder = jsonFactory.createObjectBuilder() .add(ID, terminationMessage.getId()) - .add(TYPE, DSPACE_TYPE_CONTRACT_NEGOTIATION_TERMINATION_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, terminationMessage.getConsumerPid()) - .add(DSPACE_PROPERTY_PROVIDER_PID, terminationMessage.getProviderPid()); + .add(TYPE, forNamespace(DSPACE_TYPE_CONTRACT_NEGOTIATION_TERMINATION_MESSAGE_TERM)) + .add(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM), terminationMessage.getConsumerPid()) + .add(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM), terminationMessage.getProviderPid()); - addIfNotNull(terminationMessage.getRejectionReason(), DSPACE_PROPERTY_REASON, builder); - addIfNotNull(terminationMessage.getCode(), DSPACE_PROPERTY_CODE, builder); + addIfNotNull(terminationMessage.getRejectionReason(), forNamespace(DSPACE_PROPERTY_REASON_TERM), builder); + addIfNotNull(terminationMessage.getCode(), forNamespace(DSPACE_PROPERTY_CODE_TERM), builder); return builder.build(); } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTransformer.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTransformer.java similarity index 60% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTransformer.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTransformer.java index f077e12b7af..7a2d2241951 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTransformer.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTransformer.java @@ -18,35 +18,40 @@ import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractNegotiation; import org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractNegotiationStates; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_ACCEPTED; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_AGREED; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_FINALIZED; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_OFFERED; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_REQUESTED; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_TERMINATED; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_VERIFIED; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_STATE; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_ACCEPTED_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_AGREED_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_FINALIZED_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_OFFERED_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_REQUESTED_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_TERMINATED_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_VERIFIED_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_STATE_TERM; /** * Creates a {@link JsonObject} from a {@link ContractNegotiation}. */ -public class JsonObjectFromContractNegotiationTransformer extends AbstractJsonLdTransformer { +public class JsonObjectFromContractNegotiationTransformer extends AbstractNamespaceAwareJsonLdTransformer { private final JsonBuilderFactory jsonFactory; public JsonObjectFromContractNegotiationTransformer(JsonBuilderFactory jsonFactory) { - super(ContractNegotiation.class, JsonObject.class); + this(jsonFactory, DSPACE_SCHEMA); + } + + public JsonObjectFromContractNegotiationTransformer(JsonBuilderFactory jsonFactory, String namespace) { + super(ContractNegotiation.class, JsonObject.class, namespace); this.jsonFactory = jsonFactory; } @@ -54,10 +59,10 @@ public JsonObjectFromContractNegotiationTransformer(JsonBuilderFactory jsonFacto public @Nullable JsonObject transform(@NotNull ContractNegotiation contractNegotiation, @NotNull TransformerContext context) { return jsonFactory.createObjectBuilder() .add(ID, pidFor(contractNegotiation, contractNegotiation.getType())) - .add(TYPE, DSPACE_TYPE_CONTRACT_NEGOTIATION) - .add(DSPACE_PROPERTY_CONSUMER_PID, pidFor(contractNegotiation, ContractNegotiation.Type.CONSUMER)) - .add(DSPACE_PROPERTY_PROVIDER_PID, pidFor(contractNegotiation, ContractNegotiation.Type.PROVIDER)) - .add(DSPACE_PROPERTY_STATE, state(contractNegotiation.getState(), context)) + .add(TYPE, DSPACE_TYPE_CONTRACT_NEGOTIATION_IRI) + .add(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM), pidFor(contractNegotiation, ContractNegotiation.Type.CONSUMER)) + .add(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM), pidFor(contractNegotiation, ContractNegotiation.Type.PROVIDER)) + .add(forNamespace(DSPACE_PROPERTY_STATE_TERM), state(contractNegotiation.getState(), context)) .build(); } @@ -71,19 +76,19 @@ private String state(Integer state, TransformerContext context) { context.problem() .nullProperty() .type(ContractNegotiation.class) - .property(DSPACE_PROPERTY_STATE) + .property(forNamespace(DSPACE_PROPERTY_STATE_TERM)) .report(); return null; } return switch (negotiationState) { - case REQUESTING, REQUESTED -> DSPACE_VALUE_NEGOTIATION_STATE_REQUESTED; - case OFFERING, OFFERED -> DSPACE_VALUE_NEGOTIATION_STATE_OFFERED; - case ACCEPTING, ACCEPTED -> DSPACE_VALUE_NEGOTIATION_STATE_ACCEPTED; - case AGREEING, AGREED -> DSPACE_VALUE_NEGOTIATION_STATE_AGREED; - case VERIFYING, VERIFIED -> DSPACE_VALUE_NEGOTIATION_STATE_VERIFIED; - case FINALIZING, FINALIZED -> DSPACE_VALUE_NEGOTIATION_STATE_FINALIZED; - case TERMINATING, TERMINATED -> DSPACE_VALUE_NEGOTIATION_STATE_TERMINATED; + case REQUESTING, REQUESTED -> forNamespace(DSPACE_VALUE_NEGOTIATION_STATE_REQUESTED_TERM); + case OFFERING, OFFERED -> forNamespace(DSPACE_VALUE_NEGOTIATION_STATE_OFFERED_TERM); + case ACCEPTING, ACCEPTED -> forNamespace(DSPACE_VALUE_NEGOTIATION_STATE_ACCEPTED_TERM); + case AGREEING, AGREED -> forNamespace(DSPACE_VALUE_NEGOTIATION_STATE_AGREED_TERM); + case VERIFYING, VERIFIED -> forNamespace(DSPACE_VALUE_NEGOTIATION_STATE_VERIFIED_TERM); + case FINALIZING, FINALIZED -> forNamespace(DSPACE_VALUE_NEGOTIATION_STATE_FINALIZED_TERM); + case TERMINATING, TERMINATED -> forNamespace(DSPACE_VALUE_NEGOTIATION_STATE_TERMINATED_TERM); default -> { context.problem() .unexpectedType() diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractOfferMessageTransformer.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractOfferMessageTransformer.java similarity index 66% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractOfferMessageTransformer.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractOfferMessageTransformer.java index 0e9d4532de9..c649d83dda3 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractOfferMessageTransformer.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractOfferMessageTransformer.java @@ -18,28 +18,33 @@ import jakarta.json.JsonBuilderFactory; import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractOfferMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_OFFER_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_OFFER_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_OFFER_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_OFFER_MESSAGE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; /** * Creates a {@link JsonObject} from a {@link ContractOfferMessage}. */ -public class JsonObjectFromContractOfferMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectFromContractOfferMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { private final JsonBuilderFactory jsonFactory; public JsonObjectFromContractOfferMessageTransformer(JsonBuilderFactory jsonFactory) { - super(ContractOfferMessage.class, JsonObject.class); + this(jsonFactory, DSPACE_SCHEMA); + } + + public JsonObjectFromContractOfferMessageTransformer(JsonBuilderFactory jsonFactory, String namespace) { + super(ContractOfferMessage.class, JsonObject.class, namespace); this.jsonFactory = jsonFactory; } @@ -47,11 +52,11 @@ public JsonObjectFromContractOfferMessageTransformer(JsonBuilderFactory jsonFact public @Nullable JsonObject transform(@NotNull ContractOfferMessage message, @NotNull TransformerContext context) { var builder = jsonFactory.createObjectBuilder() .add(ID, message.getId()) - .add(TYPE, DSPACE_TYPE_CONTRACT_OFFER_MESSAGE_IRI) - .add(DSPACE_PROPERTY_PROVIDER_PID, message.getProviderPid()); + .add(TYPE, forNamespace(DSPACE_TYPE_CONTRACT_OFFER_MESSAGE_TERM)) + .add(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM), message.getProviderPid()); - addIfNotNull(message.getConsumerPid(), DSPACE_PROPERTY_CONSUMER_PID, builder); - addIfNotNull(message.getCallbackAddress(), DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI, builder); + addIfNotNull(message.getConsumerPid(), forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM), builder); + addIfNotNull(message.getCallbackAddress(), forNamespace(DSPACE_PROPERTY_CALLBACK_ADDRESS_TERM), builder); var offer = message.getContractOffer(); var policy = context.transform(offer.getPolicy(), JsonObject.class); @@ -66,7 +71,7 @@ public JsonObjectFromContractOfferMessageTransformer(JsonBuilderFactory jsonFact var enrichedPolicy = Json.createObjectBuilder(policy) .add(ID, offer.getId()) .build(); - builder.add(DSPACE_PROPERTY_OFFER_IRI, enrichedPolicy); + builder.add(forNamespace(DSPACE_PROPERTY_OFFER_TERM), enrichedPolicy); return builder.build(); } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractRequestMessageTransformer.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractRequestMessageTransformer.java similarity index 66% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractRequestMessageTransformer.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractRequestMessageTransformer.java index d90e8310d6b..3a3058a964f 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractRequestMessageTransformer.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractRequestMessageTransformer.java @@ -18,29 +18,34 @@ import jakarta.json.JsonBuilderFactory; import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractRequestMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_OFFER_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_REQUEST_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_OFFER_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_REQUEST_MESSAGE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; /** * Creates a {@link JsonObject} from a {@link ContractRequestMessage}. */ -public class JsonObjectFromContractRequestMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectFromContractRequestMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { private final JsonBuilderFactory jsonFactory; public JsonObjectFromContractRequestMessageTransformer(JsonBuilderFactory jsonFactory) { - super(ContractRequestMessage.class, JsonObject.class); + this(jsonFactory, DSPACE_SCHEMA); + } + + public JsonObjectFromContractRequestMessageTransformer(JsonBuilderFactory jsonFactory, String namespace) { + super(ContractRequestMessage.class, JsonObject.class, namespace); this.jsonFactory = jsonFactory; } @@ -48,11 +53,11 @@ public JsonObjectFromContractRequestMessageTransformer(JsonBuilderFactory jsonFa public @Nullable JsonObject transform(@NotNull ContractRequestMessage requestMessage, @NotNull TransformerContext context) { var builder = jsonFactory.createObjectBuilder() .add(ID, requestMessage.getId()) - .add(TYPE, DSPACE_TYPE_CONTRACT_REQUEST_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, requestMessage.getConsumerPid()); + .add(TYPE, forNamespace(DSPACE_TYPE_CONTRACT_REQUEST_MESSAGE_TERM)) + .add(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM), requestMessage.getConsumerPid()); - addIfNotNull(requestMessage.getProviderPid(), DSPACE_PROPERTY_PROVIDER_PID, builder); - addIfNotNull(requestMessage.getCallbackAddress(), DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI, builder); + addIfNotNull(requestMessage.getProviderPid(), forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM), builder); + addIfNotNull(requestMessage.getCallbackAddress(), forNamespace(DSPACE_PROPERTY_CALLBACK_ADDRESS_TERM), builder); var policy = context.transform(requestMessage.getContractOffer().getPolicy(), JsonObject.class); if (policy == null) { @@ -67,7 +72,7 @@ public JsonObjectFromContractRequestMessageTransformer(JsonBuilderFactory jsonFa var enrichedPolicy = Json.createObjectBuilder(policy) .add(ID, requestMessage.getContractOffer().getId()) .build(); - builder.add(DSPACE_PROPERTY_OFFER_IRI, enrichedPolicy); + builder.add(forNamespace(DSPACE_PROPERTY_OFFER_TERM), enrichedPolicy); return builder.build(); } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementMessageTransformer.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementMessageTransformer.java similarity index 64% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementMessageTransformer.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementMessageTransformer.java index e219e15d021..10934cfd145 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementMessageTransformer.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementMessageTransformer.java @@ -18,7 +18,7 @@ import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.contract.spi.types.agreement.ContractAgreement; import org.eclipse.edc.connector.controlplane.contract.spi.types.agreement.ContractAgreementMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.policy.model.Policy; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; @@ -29,45 +29,54 @@ import java.util.Set; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_AGREEMENT; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_ID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_ID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_TIMESTAMP; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_AGREEMENT_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_ID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_ID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_TIMESTAMP_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; /** * Creates a {@link ContractAgreementMessage} from a {@link JsonObject}. */ -public class JsonObjectToContractAgreementMessageTransformer extends AbstractJsonLdTransformer { - private static final Set EXCLUDED_POLICY_KEYWORDS = Set.of(DSPACE_PROPERTY_TIMESTAMP, DSPACE_PROPERTY_CONSUMER_ID, DSPACE_PROPERTY_PROVIDER_ID); +public class JsonObjectToContractAgreementMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { + private final Set excludedPolicyKeywords; public JsonObjectToContractAgreementMessageTransformer() { - super(JsonObject.class, ContractAgreementMessage.class); + this(DSPACE_SCHEMA); } + public JsonObjectToContractAgreementMessageTransformer(String namespace) { + super(JsonObject.class, ContractAgreementMessage.class, namespace); + excludedPolicyKeywords = Set.of(forNamespace(DSPACE_PROPERTY_TIMESTAMP_TERM), + forNamespace(forNamespace(DSPACE_PROPERTY_CONSUMER_ID_TERM)), + forNamespace(DSPACE_PROPERTY_PROVIDER_ID_TERM)); + } + + @Override public @Nullable ContractAgreementMessage transform(@NotNull JsonObject object, @NotNull TransformerContext context) { var messageBuilder = ContractAgreementMessage.Builder.newInstance(); - if (!transformMandatoryString(object.get(DSPACE_PROPERTY_CONSUMER_PID), messageBuilder::consumerPid, context)) { + if (!transformMandatoryString(object.get(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)), messageBuilder::consumerPid, context)) { context.problem() .missingProperty() - .type(DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_IRI) - .property(DSPACE_PROPERTY_CONSUMER_PID) + .type(forNamespace(DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)) .report(); return null; } - if (!transformMandatoryString(object.get(DSPACE_PROPERTY_PROVIDER_PID), messageBuilder::providerPid, context)) { + if (!transformMandatoryString(object.get(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM)), messageBuilder::providerPid, context)) { context.problem() .missingProperty() - .type(DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_IRI) - .property(DSPACE_PROPERTY_PROVIDER_PID) + .type(forNamespace(DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM)) .report(); return null; } - var jsonAgreement = returnMandatoryJsonObject(object.get(DSPACE_PROPERTY_AGREEMENT), context, DSPACE_PROPERTY_AGREEMENT); + var jsonAgreement = returnMandatoryJsonObject(object.get(forNamespace(DSPACE_PROPERTY_AGREEMENT_TERM)), context, forNamespace(DSPACE_PROPERTY_AGREEMENT_TERM)); if (jsonAgreement == null) { return null; } @@ -78,8 +87,8 @@ public JsonObjectToContractAgreementMessageTransformer() { if (policy == null) { context.problem() .invalidProperty() - .type(DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_IRI) - .property(DSPACE_PROPERTY_AGREEMENT) + .type(forNamespace(DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_AGREEMENT_TERM)) .report(); return null; } @@ -98,7 +107,7 @@ public JsonObjectToContractAgreementMessageTransformer() { private JsonObject filterAgreementProperties(JsonObject jsonAgreement) { var copiedJsonAgreement = Json.createObjectBuilder(); jsonAgreement.entrySet().stream() - .filter(e -> !EXCLUDED_POLICY_KEYWORDS.contains(e.getKey())) + .filter(e -> !excludedPolicyKeywords.contains(e.getKey())) .forEach(e -> copiedJsonAgreement.add(e.getKey(), e.getValue())); return copiedJsonAgreement.build(); } @@ -110,7 +119,7 @@ private ContractAgreement contractAgreement(JsonObject jsonAgreement, Policy pol if (agreementId == null) { context.problem() .missingProperty() - .type(DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_IRI) + .type(forNamespace(DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_TERM)) .property(ID) .report(); return null; @@ -125,12 +134,12 @@ private ContractAgreement contractAgreement(JsonObject jsonAgreement, Policy pol .policy(policy) .assetId(policy.getTarget()); - var timestamp = transformString(jsonAgreement.get(DSPACE_PROPERTY_TIMESTAMP), context); + var timestamp = transformString(jsonAgreement.get(forNamespace(DSPACE_PROPERTY_TIMESTAMP_TERM)), context); if (timestamp == null) { context.problem() .missingProperty() - .type(DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_IRI) - .property(DSPACE_PROPERTY_TIMESTAMP) + .type(forNamespace(DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_TIMESTAMP_TERM)) .report(); return null; } @@ -139,8 +148,8 @@ private ContractAgreement contractAgreement(JsonObject jsonAgreement, Policy pol } catch (DateTimeParseException e) { context.problem() .invalidProperty() - .type(DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_IRI) - .property(DSPACE_PROPERTY_TIMESTAMP) + .type(forNamespace(DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_TIMESTAMP_TERM)) .value(timestamp) .error(e.getMessage()) .report(); diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementVerificationMessageTransformer.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementVerificationMessageTransformer.java similarity index 62% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementVerificationMessageTransformer.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementVerificationMessageTransformer.java index 55763e030d7..773fdf60bac 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementVerificationMessageTransformer.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementVerificationMessageTransformer.java @@ -16,40 +16,46 @@ import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.contract.spi.types.agreement.ContractAgreementVerificationMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_AGREEMENT_VERIFICATION_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_AGREEMENT_VERIFICATION_MESSAGE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; /** * Creates a {@link ContractAgreementVerificationMessage} from a {@link JsonObject}. */ -public class JsonObjectToContractAgreementVerificationMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectToContractAgreementVerificationMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { public JsonObjectToContractAgreementVerificationMessageTransformer() { - super(JsonObject.class, ContractAgreementVerificationMessage.class); + this(DSPACE_SCHEMA); } + public JsonObjectToContractAgreementVerificationMessageTransformer(String namespace) { + super(JsonObject.class, ContractAgreementVerificationMessage.class, namespace); + } + + @Override public @Nullable ContractAgreementVerificationMessage transform(@NotNull JsonObject object, @NotNull TransformerContext context) { var builder = ContractAgreementVerificationMessage.Builder.newInstance(); - if (!transformMandatoryString(object.get(DSPACE_PROPERTY_CONSUMER_PID), builder::consumerPid, context)) { + if (!transformMandatoryString(object.get(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)), builder::consumerPid, context)) { context.problem() .missingProperty() - .type(DSPACE_TYPE_CONTRACT_AGREEMENT_VERIFICATION_MESSAGE_IRI) - .property(DSPACE_PROPERTY_CONSUMER_PID) + .type(forNamespace(DSPACE_TYPE_CONTRACT_AGREEMENT_VERIFICATION_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)) .report(); return null; } - if (!transformMandatoryString(object.get(DSPACE_PROPERTY_PROVIDER_PID), builder::providerPid, context)) { + if (!transformMandatoryString(object.get(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM)), builder::providerPid, context)) { context.problem() .missingProperty() - .type(DSPACE_TYPE_CONTRACT_AGREEMENT_VERIFICATION_MESSAGE_IRI) - .property(DSPACE_PROPERTY_PROVIDER_PID) + .type(forNamespace(DSPACE_TYPE_CONTRACT_AGREEMENT_VERIFICATION_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM)) .report(); return null; } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationAckTransformer.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationAckTransformer.java similarity index 61% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationAckTransformer.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationAckTransformer.java index e916f0dd3c7..dacdccfee5e 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationAckTransformer.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationAckTransformer.java @@ -16,33 +16,38 @@ import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.contract.spi.types.protocol.ContractNegotiationAck; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_STATE; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_STATE_TERM; /** * Create a {@link ContractNegotiationAck} from {@link JsonObject} */ -public class JsonObjectToContractNegotiationAckTransformer extends AbstractJsonLdTransformer { +public class JsonObjectToContractNegotiationAckTransformer extends AbstractNamespaceAwareJsonLdTransformer { public JsonObjectToContractNegotiationAckTransformer() { - super(JsonObject.class, ContractNegotiationAck.class); + this(DSPACE_SCHEMA); + } + + public JsonObjectToContractNegotiationAckTransformer(String namespace) { + super(JsonObject.class, ContractNegotiationAck.class, namespace); } @Override public @Nullable ContractNegotiationAck transform(@NotNull JsonObject jsonObject, @NotNull TransformerContext context) { var builder = ContractNegotiationAck.Builder.newInstance(); - transformMandatoryString(jsonObject.get(DSPACE_PROPERTY_CONSUMER_PID), builder::consumerPid, context); - transformMandatoryString(jsonObject.get(DSPACE_PROPERTY_PROVIDER_PID), builder::providerPid, context); + transformMandatoryString(jsonObject.get(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)), builder::consumerPid, context); + transformMandatoryString(jsonObject.get(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM)), builder::providerPid, context); return builder - .state(transformString(jsonObject.get(DSPACE_PROPERTY_STATE), context)) + .state(transformString(jsonObject.get(forNamespace(DSPACE_PROPERTY_STATE_TERM)), context)) .build(); } } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationEventMessageTransformer.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationEventMessageTransformer.java similarity index 59% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationEventMessageTransformer.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationEventMessageTransformer.java index adbd9d403af..6e791372fee 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationEventMessageTransformer.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationEventMessageTransformer.java @@ -16,62 +16,67 @@ import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.contract.spi.types.agreement.ContractNegotiationEventMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import static org.eclipse.edc.connector.controlplane.contract.spi.types.agreement.ContractNegotiationEventMessage.Type.ACCEPTED; import static org.eclipse.edc.connector.controlplane.contract.spi.types.agreement.ContractNegotiationEventMessage.Type.FINALIZED; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_EVENT_TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION_EVENT_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_FINALIZED; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_EVENT_TYPE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION_EVENT_MESSAGE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_FINALIZED_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; /** * Creates a {@link ContractNegotiationEventMessage} from a {@link JsonObject}. */ -public class JsonObjectToContractNegotiationEventMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectToContractNegotiationEventMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { public JsonObjectToContractNegotiationEventMessageTransformer() { - super(JsonObject.class, ContractNegotiationEventMessage.class); + this(DSPACE_SCHEMA); + } + + public JsonObjectToContractNegotiationEventMessageTransformer(String namespace) { + super(JsonObject.class, ContractNegotiationEventMessage.class, namespace); } @Override public @Nullable ContractNegotiationEventMessage transform(@NotNull JsonObject object, @NotNull TransformerContext context) { var builder = ContractNegotiationEventMessage.Builder.newInstance(); - if (!transformMandatoryString(object.get(DSPACE_PROPERTY_CONSUMER_PID), builder::consumerPid, context)) { + if (!transformMandatoryString(object.get(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)), builder::consumerPid, context)) { context.problem() .missingProperty() - .type(DSPACE_TYPE_CONTRACT_NEGOTIATION_EVENT_MESSAGE_IRI) - .property(DSPACE_PROPERTY_CONSUMER_PID) + .type(forNamespace(DSPACE_TYPE_CONTRACT_NEGOTIATION_EVENT_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)) .report(); return null; } - if (!transformMandatoryString(object.get(DSPACE_PROPERTY_PROVIDER_PID), builder::providerPid, context)) { + if (!transformMandatoryString(object.get(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM)), builder::providerPid, context)) { context.problem() .missingProperty() - .type(DSPACE_TYPE_CONTRACT_NEGOTIATION_EVENT_MESSAGE_IRI) - .property(DSPACE_PROPERTY_PROVIDER_PID) + .type(forNamespace(DSPACE_TYPE_CONTRACT_NEGOTIATION_EVENT_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM)) .report(); return null; } - var eventType = transformString(object.get(DSPACE_PROPERTY_EVENT_TYPE), context); - if (DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED.equals(eventType)) { + var eventType = transformString(object.get(forNamespace(DSPACE_PROPERTY_EVENT_TYPE_TERM)), context); + if (forNamespace(DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED_TERM).equals(eventType)) { builder.type(ACCEPTED); - } else if (DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_FINALIZED.equals(eventType)) { + } else if (forNamespace(DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_FINALIZED_TERM).equals(eventType)) { builder.type(FINALIZED); } else { context.problem() .unexpectedType() - .type(DSPACE_TYPE_CONTRACT_NEGOTIATION_EVENT_MESSAGE_IRI) - .property(DSPACE_PROPERTY_EVENT_TYPE) - .expected(DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED) - .expected(DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_FINALIZED) + .type(forNamespace(DSPACE_TYPE_CONTRACT_NEGOTIATION_EVENT_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_EVENT_TYPE_TERM)) + .expected(forNamespace(DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED_TERM)) + .expected(forNamespace(DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_FINALIZED_TERM)) .report(); return null; } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationTerminationMessageTransformer.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationTerminationMessageTransformer.java similarity index 64% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationTerminationMessageTransformer.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationTerminationMessageTransformer.java index 962270eceba..e11733ba24a 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationTerminationMessageTransformer.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationTerminationMessageTransformer.java @@ -17,54 +17,59 @@ import jakarta.json.JsonArray; import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractNegotiationTerminationMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import static jakarta.json.JsonValue.ValueType.ARRAY; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION_TERMINATION_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION_TERMINATION_MESSAGE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON_TERM; /** * Creates a {@link ContractNegotiationTerminationMessage} from a {@link JsonObject}. */ -public class JsonObjectToContractNegotiationTerminationMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectToContractNegotiationTerminationMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { public JsonObjectToContractNegotiationTerminationMessageTransformer() { - super(JsonObject.class, ContractNegotiationTerminationMessage.class); + this(DSPACE_SCHEMA); + } + + public JsonObjectToContractNegotiationTerminationMessageTransformer(String namespace) { + super(JsonObject.class, ContractNegotiationTerminationMessage.class, namespace); } @Override public @Nullable ContractNegotiationTerminationMessage transform(@NotNull JsonObject object, @NotNull TransformerContext context) { var builder = ContractNegotiationTerminationMessage.Builder.newInstance(); - if (!transformMandatoryString(object.get(DSPACE_PROPERTY_CONSUMER_PID), builder::consumerPid, context)) { + if (!transformMandatoryString(object.get(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)), builder::consumerPid, context)) { context.problem() .missingProperty() - .type(DSPACE_TYPE_CONTRACT_NEGOTIATION_TERMINATION_MESSAGE_IRI) - .property(DSPACE_PROPERTY_CONSUMER_PID) + .type(forNamespace(DSPACE_TYPE_CONTRACT_NEGOTIATION_TERMINATION_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)) .report(); return null; } - if (!transformMandatoryString(object.get(DSPACE_PROPERTY_PROVIDER_PID), builder::providerPid, context)) { + if (!transformMandatoryString(object.get(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM)), builder::providerPid, context)) { context.problem() .missingProperty() - .type(DSPACE_TYPE_CONTRACT_NEGOTIATION_TERMINATION_MESSAGE_IRI) - .property(DSPACE_PROPERTY_PROVIDER_PID) + .type(forNamespace(DSPACE_TYPE_CONTRACT_NEGOTIATION_TERMINATION_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM)) .report(); return null; } - var code = object.get(DSPACE_PROPERTY_CODE); + var code = object.get(forNamespace(DSPACE_PROPERTY_CODE_TERM)); if (code != null) { // optional property transformString(code, builder::code, context); } - var reasons = object.get(DSPACE_PROPERTY_REASON); + var reasons = object.get(forNamespace(DSPACE_PROPERTY_REASON_TERM)); if (reasons != null) { // optional property if (reasons instanceof JsonArray) { var array = (JsonArray) reasons; @@ -74,8 +79,8 @@ public JsonObjectToContractNegotiationTerminationMessageTransformer() { } else { context.problem() .unexpectedType() - .type(DSPACE_TYPE_CONTRACT_NEGOTIATION_TERMINATION_MESSAGE_IRI) - .property(DSPACE_PROPERTY_REASON) + .type(forNamespace(DSPACE_TYPE_CONTRACT_NEGOTIATION_TERMINATION_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_REASON_TERM)) .actual(reasons.getValueType().toString()) .expected(ARRAY) .report(); diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractOfferMessageTransformer.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractOfferMessageTransformer.java similarity index 64% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractOfferMessageTransformer.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractOfferMessageTransformer.java index 3213daa86c0..acc58e67806 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractOfferMessageTransformer.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractOfferMessageTransformer.java @@ -17,7 +17,7 @@ import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractOfferMessage; import org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractOffer; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.policy.model.Policy; import org.eclipse.edc.policy.model.PolicyType; import org.eclipse.edc.transform.spi.TransformerContext; @@ -26,50 +26,55 @@ import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_OFFER_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_OFFER_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_OFFER_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_OFFER_MESSAGE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; /** * Creates a {@link ContractOfferMessage} from a {@link JsonObject}. */ -public class JsonObjectToContractOfferMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectToContractOfferMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { public JsonObjectToContractOfferMessageTransformer() { - super(JsonObject.class, ContractOfferMessage.class); + this(DSPACE_SCHEMA); + } + + public JsonObjectToContractOfferMessageTransformer(String namespace) { + super(JsonObject.class, ContractOfferMessage.class, namespace); } @Override public @Nullable ContractOfferMessage transform(@NotNull JsonObject jsonObject, @NotNull TransformerContext context) { var builder = ContractOfferMessage.Builder.newInstance(); - if (!transformMandatoryString(jsonObject.get(DSPACE_PROPERTY_PROVIDER_PID), builder::providerPid, context)) { - reportMissingProperty(DSPACE_TYPE_CONTRACT_OFFER_MESSAGE_IRI, DSPACE_PROPERTY_PROVIDER_PID, context); + if (!transformMandatoryString(jsonObject.get(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM)), builder::providerPid, context)) { + reportMissingProperty(forNamespace(DSPACE_TYPE_CONTRACT_OFFER_MESSAGE_TERM), forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM), context); return null; } - var consumerPid = jsonObject.get(DSPACE_PROPERTY_CONSUMER_PID); + var consumerPid = jsonObject.get(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)); if (consumerPid != null) { builder.consumerPid(transformString(consumerPid, context)); } - var callback = jsonObject.get(DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI); + var callback = jsonObject.get(forNamespace(DSPACE_PROPERTY_CALLBACK_ADDRESS_TERM)); if (callback != null) { builder.callbackAddress(transformString(callback, context)); } - var contractOffer = returnJsonObject(jsonObject.get(DSPACE_PROPERTY_OFFER_IRI), context, DSPACE_PROPERTY_OFFER_IRI, false); + var contractOffer = returnJsonObject(jsonObject.get(forNamespace(DSPACE_PROPERTY_OFFER_TERM)), context, forNamespace(DSPACE_PROPERTY_OFFER_TERM), false); if (contractOffer != null) { context.setData(Policy.class, TYPE, PolicyType.OFFER); var policy = transformObject(contractOffer, Policy.class, context); if (policy == null) { - reportMissingProperty(DSPACE_TYPE_CONTRACT_OFFER_MESSAGE_IRI, DSPACE_PROPERTY_OFFER_IRI, context); + reportMissingProperty(forNamespace(DSPACE_TYPE_CONTRACT_OFFER_MESSAGE_TERM), forNamespace(DSPACE_PROPERTY_OFFER_TERM), context); return null; } var id = nodeId(contractOffer); if (id == null) { - reportMissingProperty(DSPACE_PROPERTY_OFFER_IRI, ID, context); + reportMissingProperty(forNamespace(DSPACE_PROPERTY_OFFER_TERM), ID, context); return null; } var offer = ContractOffer.Builder.newInstance() @@ -79,7 +84,7 @@ public JsonObjectToContractOfferMessageTransformer() { .build(); builder.contractOffer(offer); } else { - reportMissingProperty(DSPACE_TYPE_CONTRACT_OFFER_MESSAGE_IRI, DSPACE_PROPERTY_OFFER_IRI, context); + reportMissingProperty(forNamespace(DSPACE_TYPE_CONTRACT_OFFER_MESSAGE_TERM), forNamespace(DSPACE_PROPERTY_OFFER_TERM), context); return null; } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractRequestMessageTransformer.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractRequestMessageTransformer.java similarity index 64% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractRequestMessageTransformer.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractRequestMessageTransformer.java index 2dace6c43af..837f97b4ea5 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractRequestMessageTransformer.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractRequestMessageTransformer.java @@ -17,59 +17,64 @@ import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractRequestMessage; import org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractOffer; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.policy.model.Policy; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_OFFER_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_REQUEST_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_OFFER_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_REQUEST_MESSAGE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; /** * Creates a {@link ContractRequestMessage} from a {@link JsonObject}. */ -public class JsonObjectToContractRequestMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectToContractRequestMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { public JsonObjectToContractRequestMessageTransformer() { - super(JsonObject.class, ContractRequestMessage.class); + this(DSPACE_SCHEMA); + } + + public JsonObjectToContractRequestMessageTransformer(String namespace) { + super(JsonObject.class, ContractRequestMessage.class, namespace); } @Override public @Nullable ContractRequestMessage transform(@NotNull JsonObject requestObject, @NotNull TransformerContext context) { var builder = ContractRequestMessage.Builder.newInstance(); - if (!transformMandatoryString(requestObject.get(DSPACE_PROPERTY_CONSUMER_PID), builder::consumerPid, context)) { + if (!transformMandatoryString(requestObject.get(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)), builder::consumerPid, context)) { context.problem() .missingProperty() - .type(DSPACE_TYPE_CONTRACT_REQUEST_MESSAGE_IRI) - .property(DSPACE_PROPERTY_CONSUMER_PID) + .type(forNamespace(DSPACE_TYPE_CONTRACT_REQUEST_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)) .report(); return null; } - var providerPid = requestObject.get(DSPACE_PROPERTY_PROVIDER_PID); + var providerPid = requestObject.get(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM)); if (providerPid != null) { builder.providerPid(transformString(providerPid, context)); } - var callback = requestObject.get(DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI); + var callback = requestObject.get(forNamespace(DSPACE_PROPERTY_CALLBACK_ADDRESS_TERM)); if (callback != null) { builder.callbackAddress(transformString(callback, context)); } - var contractOffer = returnJsonObject(requestObject.get(DSPACE_PROPERTY_OFFER_IRI), context, DSPACE_PROPERTY_OFFER_IRI, false); + var contractOffer = returnJsonObject(requestObject.get(forNamespace(DSPACE_PROPERTY_OFFER_TERM)), context, forNamespace(DSPACE_PROPERTY_OFFER_TERM), false); if (contractOffer != null) { var policy = transformObject(contractOffer, Policy.class, context); if (policy == null) { context.problem() .missingProperty() - .type(DSPACE_TYPE_CONTRACT_REQUEST_MESSAGE_IRI) - .property(DSPACE_PROPERTY_OFFER_IRI) + .type(forNamespace(DSPACE_TYPE_CONTRACT_REQUEST_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_OFFER_TERM)) .report(); return null; } @@ -77,7 +82,7 @@ public JsonObjectToContractRequestMessageTransformer() { if (id == null) { context.problem() .missingProperty() - .type(DSPACE_PROPERTY_OFFER_IRI) + .type(forNamespace(DSPACE_PROPERTY_OFFER_TERM)) .property(ID) .report(); return null; @@ -89,8 +94,8 @@ public JsonObjectToContractRequestMessageTransformer() { } else { context.problem() .missingProperty() - .type(DSPACE_TYPE_CONTRACT_REQUEST_MESSAGE_IRI) - .property(DSPACE_PROPERTY_OFFER_IRI) + .type(forNamespace(DSPACE_TYPE_CONTRACT_REQUEST_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_OFFER_TERM)) .report(); return null; } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementMessageTransformerTest.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementMessageTransformerTest.java similarity index 95% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementMessageTransformerTest.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementMessageTransformerTest.java index 1c298ff4f06..5af452f59a5 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementMessageTransformerTest.java @@ -37,11 +37,11 @@ import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_ASSIGNEE_ATTRIBUTE; import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_ASSIGNER_ATTRIBUTE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_AGREEMENT; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_TIMESTAMP; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_AGREEMENT_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_TIMESTAMP_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -95,13 +95,13 @@ void transform() { assertThat(result.getString(ID)).isNotNull(); assertThat(result.getString(ID)).isNotEmpty(); assertThat(result.getString(TYPE)).isEqualTo(DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_IRI); - assertThat(result.getString(DSPACE_PROPERTY_PROVIDER_PID)).isEqualTo("providerPid"); - assertThat(result.getString(DSPACE_PROPERTY_CONSUMER_PID)).isEqualTo("consumerPid"); + assertThat(result.getString(DSPACE_PROPERTY_PROVIDER_PID_IRI)).isEqualTo("providerPid"); + assertThat(result.getString(DSPACE_PROPERTY_CONSUMER_PID_IRI)).isEqualTo("consumerPid"); - var jsonAgreement = result.getJsonObject(DSPACE_PROPERTY_AGREEMENT); + var jsonAgreement = result.getJsonObject(DSPACE_PROPERTY_AGREEMENT_IRI); assertThat(jsonAgreement).isNotNull(); assertThat(jsonAgreement.getString(ID)).isEqualTo(AGREEMENT_ID); - assertThat(jsonAgreement.getString(DSPACE_PROPERTY_TIMESTAMP)).isEqualTo(TIMESTAMP); + assertThat(jsonAgreement.getString(DSPACE_PROPERTY_TIMESTAMP_IRI)).isEqualTo(TIMESTAMP); assertThat(jsonAgreement.getString(ODRL_ASSIGNEE_ATTRIBUTE)).isEqualTo(CONSUMER_ID); assertThat(jsonAgreement.getString(ODRL_ASSIGNER_ATTRIBUTE)).isEqualTo(PROVIDER_ID); diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementVerificationMessageTransformerTest.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementVerificationMessageTransformerTest.java similarity index 93% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementVerificationMessageTransformerTest.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementVerificationMessageTransformerTest.java index 7e42185dc6e..b4cd5ec1a3f 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementVerificationMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractAgreementVerificationMessageTransformerTest.java @@ -26,8 +26,8 @@ import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_AGREEMENT_VERIFICATION_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -56,8 +56,8 @@ void transform() { assertThat(result).isNotNull(); assertThat(result.getJsonString(ID).getString()).isNotEmpty(); assertThat(result.getJsonString(TYPE).getString()).isEqualTo(DSPACE_TYPE_CONTRACT_AGREEMENT_VERIFICATION_MESSAGE_IRI); - assertThat(result.getJsonString(DSPACE_PROPERTY_CONSUMER_PID).getString()).isEqualTo("consumerPid"); - assertThat(result.getJsonString(DSPACE_PROPERTY_PROVIDER_PID).getString()).isEqualTo("providerPid"); + assertThat(result.getJsonString(DSPACE_PROPERTY_CONSUMER_PID_IRI).getString()).isEqualTo("consumerPid"); + assertThat(result.getJsonString(DSPACE_PROPERTY_PROVIDER_PID_IRI).getString()).isEqualTo("providerPid"); verify(context, never()).reportProblem(anyString()); } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationErrorTransformerTest.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationErrorTransformerTest.java similarity index 84% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationErrorTransformerTest.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationErrorTransformerTest.java index 77c68ca34e5..686f1d9be83 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationErrorTransformerTest.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationErrorTransformerTest.java @@ -26,9 +26,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION_ERROR; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION_ERROR_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON_IRI; import static org.mockito.Mockito.mock; class JsonObjectFromContractNegotiationErrorTransformerTest { @@ -54,8 +54,8 @@ void transform_returnJsonObject() { var result = transformer.transform(error, context); assertThat(result).isNotNull(); - assertThat(result.getJsonString(TYPE).getString()).isEqualTo(DSPACE_TYPE_CONTRACT_NEGOTIATION_ERROR); - assertThat(result.getString(DSPACE_PROPERTY_CODE)).isEqualTo("code"); - assertThat(result.getJsonArray(DSPACE_PROPERTY_REASON)).contains(Json.createValue("message")); + assertThat(result.getJsonString(TYPE).getString()).isEqualTo(DSPACE_TYPE_CONTRACT_NEGOTIATION_ERROR_IRI); + assertThat(result.getString(DSPACE_PROPERTY_CODE_IRI)).isEqualTo("code"); + assertThat(result.getJsonArray(DSPACE_PROPERTY_REASON_IRI)).contains(Json.createValue("message")); } } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationEventMessageTransformerTest.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationEventMessageTransformerTest.java similarity index 89% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationEventMessageTransformerTest.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationEventMessageTransformerTest.java index f11a54b0a42..d3c5c8245a4 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationEventMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationEventMessageTransformerTest.java @@ -27,11 +27,11 @@ import static org.eclipse.edc.connector.controlplane.contract.spi.types.agreement.ContractNegotiationEventMessage.Type.ACCEPTED; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_EVENT_TYPE; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_EVENT_TYPE_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION_EVENT_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -62,9 +62,9 @@ void transform() { assertThat(result).isNotNull(); assertThat(result.getString(ID)).isNotEmpty(); assertThat(result.getString(TYPE)).isEqualTo(DSPACE_TYPE_CONTRACT_NEGOTIATION_EVENT_MESSAGE_IRI); - assertThat(result.getString(DSPACE_PROPERTY_PROVIDER_PID)).isEqualTo("providerPid"); - assertThat(result.getString(DSPACE_PROPERTY_CONSUMER_PID)).isEqualTo("consumerPid"); - assertThat(result.getString(DSPACE_PROPERTY_EVENT_TYPE)).isEqualTo(DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED); + assertThat(result.getString(DSPACE_PROPERTY_PROVIDER_PID_IRI)).isEqualTo("providerPid"); + assertThat(result.getString(DSPACE_PROPERTY_CONSUMER_PID_IRI)).isEqualTo("consumerPid"); + assertThat(result.getString(DSPACE_PROPERTY_EVENT_TYPE_IRI)).isEqualTo(DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED_IRI); verify(context, never()).reportProblem(anyString()); } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTerminationMessageTransformerTest.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTerminationMessageTransformerTest.java similarity index 86% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTerminationMessageTransformerTest.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTerminationMessageTransformerTest.java index 437719250d9..9e5ca4f691c 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTerminationMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTerminationMessageTransformerTest.java @@ -26,10 +26,10 @@ import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION_TERMINATION_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON_IRI; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -62,10 +62,10 @@ void transform() { assertThat(result).isNotNull(); assertThat(result.getString(ID)).isNotEmpty(); assertThat(result.getString(TYPE)).isEqualTo(DSPACE_TYPE_CONTRACT_NEGOTIATION_TERMINATION_MESSAGE_IRI); - assertThat(result.getString(DSPACE_PROPERTY_CONSUMER_PID)).isEqualTo("consumerPid"); - assertThat(result.getString(DSPACE_PROPERTY_PROVIDER_PID)).isEqualTo("providerPid"); - assertThat(result.getString(DSPACE_PROPERTY_CODE)).isEqualTo(REJECTION_CODE); - assertThat(result.getString(DSPACE_PROPERTY_REASON)).isEqualTo(REJECTION_REASON); + assertThat(result.getString(DSPACE_PROPERTY_CONSUMER_PID_IRI)).isEqualTo("consumerPid"); + assertThat(result.getString(DSPACE_PROPERTY_PROVIDER_PID_IRI)).isEqualTo("providerPid"); + assertThat(result.getString(DSPACE_PROPERTY_CODE_IRI)).isEqualTo(REJECTION_CODE); + assertThat(result.getString(DSPACE_PROPERTY_REASON_IRI)).isEqualTo(REJECTION_REASON); verify(context, never()).reportProblem(anyString()); } @@ -83,8 +83,8 @@ void verify_noReasonNoCode() { var result = transformer.transform(message, context); assertThat(result).isNotNull(); - assertThat(result.getJsonString(DSPACE_PROPERTY_CODE)).isNull(); - assertThat(result.getJsonString(DSPACE_PROPERTY_REASON)).isNull(); + assertThat(result.getJsonString(DSPACE_PROPERTY_CODE_IRI)).isNull(); + assertThat(result.getJsonString(DSPACE_PROPERTY_REASON_IRI)).isNull(); verify(context, never()).reportProblem(anyString()); } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTransformerTest.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTransformerTest.java similarity index 85% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTransformerTest.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTransformerTest.java index e58174214d6..2647887d051 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTransformerTest.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractNegotiationTransformerTest.java @@ -47,17 +47,17 @@ import static org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractNegotiationStates.VERIFYING; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_ACCEPTED; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_AGREED; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_FINALIZED; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_OFFERED; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_REQUESTED; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_TERMINATED; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_VERIFIED; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_STATE; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_ACCEPTED_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_AGREED_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_FINALIZED_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_OFFERED_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_REQUESTED_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_TERMINATED_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_STATE_VERIFIED_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_STATE_IRI; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -91,9 +91,9 @@ void transform_consumer() { assertThat(result).isNotNull(); assertThat(result.getString(ID)).isEqualTo("consumerPid"); - assertThat(result.getString(TYPE)).isEqualTo(DSPACE_TYPE_CONTRACT_NEGOTIATION); - assertThat(result.getString(DSPACE_PROPERTY_CONSUMER_PID)).isEqualTo("consumerPid"); - assertThat(result.getString(DSPACE_PROPERTY_PROVIDER_PID)).isEqualTo("providerPid"); + assertThat(result.getString(TYPE)).isEqualTo(DSPACE_TYPE_CONTRACT_NEGOTIATION_IRI); + assertThat(result.getString(DSPACE_PROPERTY_CONSUMER_PID_IRI)).isEqualTo("consumerPid"); + assertThat(result.getString(DSPACE_PROPERTY_PROVIDER_PID_IRI)).isEqualTo("providerPid"); verify(context, never()).reportProblem(anyString()); } @@ -114,9 +114,9 @@ void transform_provider() { assertThat(result).isNotNull(); assertThat(result.getString(ID)).isEqualTo("providerPid"); - assertThat(result.getString(TYPE)).isEqualTo(DSPACE_TYPE_CONTRACT_NEGOTIATION); - assertThat(result.getString(DSPACE_PROPERTY_CONSUMER_PID)).isEqualTo("consumerPid"); - assertThat(result.getString(DSPACE_PROPERTY_PROVIDER_PID)).isEqualTo("providerPid"); + assertThat(result.getString(TYPE)).isEqualTo(DSPACE_TYPE_CONTRACT_NEGOTIATION_IRI); + assertThat(result.getString(DSPACE_PROPERTY_CONSUMER_PID_IRI)).isEqualTo("consumerPid"); + assertThat(result.getString(DSPACE_PROPERTY_PROVIDER_PID_IRI)).isEqualTo("providerPid"); verify(context, never()).reportProblem(anyString()); } @@ -137,7 +137,7 @@ void transform_status(ContractNegotiationStates inputState, String expectedDspSt var result = transformer.transform(negotiation, context); assertThat(result).isNotNull(); - assertThat(result.getString(DSPACE_PROPERTY_STATE)).isEqualTo(expectedDspState); + assertThat(result.getString(DSPACE_PROPERTY_STATE_IRI)).isEqualTo(expectedDspState); verify(context, never()).reportProblem(anyString()); } @@ -147,20 +147,20 @@ public static class Status implements ArgumentsProvider { @Override public Stream provideArguments(ExtensionContext context) { return Stream.of( - Arguments.arguments(REQUESTING, DSPACE_VALUE_NEGOTIATION_STATE_REQUESTED), - Arguments.arguments(REQUESTED, DSPACE_VALUE_NEGOTIATION_STATE_REQUESTED), - Arguments.arguments(OFFERING, DSPACE_VALUE_NEGOTIATION_STATE_OFFERED), - Arguments.arguments(OFFERED, DSPACE_VALUE_NEGOTIATION_STATE_OFFERED), - Arguments.arguments(ACCEPTING, DSPACE_VALUE_NEGOTIATION_STATE_ACCEPTED), - Arguments.arguments(ACCEPTED, DSPACE_VALUE_NEGOTIATION_STATE_ACCEPTED), - Arguments.arguments(AGREEING, DSPACE_VALUE_NEGOTIATION_STATE_AGREED), - Arguments.arguments(AGREED, DSPACE_VALUE_NEGOTIATION_STATE_AGREED), - Arguments.arguments(VERIFYING, DSPACE_VALUE_NEGOTIATION_STATE_VERIFIED), - Arguments.arguments(VERIFIED, DSPACE_VALUE_NEGOTIATION_STATE_VERIFIED), - Arguments.arguments(FINALIZING, DSPACE_VALUE_NEGOTIATION_STATE_FINALIZED), - Arguments.arguments(FINALIZED, DSPACE_VALUE_NEGOTIATION_STATE_FINALIZED), - Arguments.arguments(TERMINATING, DSPACE_VALUE_NEGOTIATION_STATE_TERMINATED), - Arguments.arguments(TERMINATED, DSPACE_VALUE_NEGOTIATION_STATE_TERMINATED) + Arguments.arguments(REQUESTING, DSPACE_VALUE_NEGOTIATION_STATE_REQUESTED_IRI), + Arguments.arguments(REQUESTED, DSPACE_VALUE_NEGOTIATION_STATE_REQUESTED_IRI), + Arguments.arguments(OFFERING, DSPACE_VALUE_NEGOTIATION_STATE_OFFERED_IRI), + Arguments.arguments(OFFERED, DSPACE_VALUE_NEGOTIATION_STATE_OFFERED_IRI), + Arguments.arguments(ACCEPTING, DSPACE_VALUE_NEGOTIATION_STATE_ACCEPTED_IRI), + Arguments.arguments(ACCEPTED, DSPACE_VALUE_NEGOTIATION_STATE_ACCEPTED_IRI), + Arguments.arguments(AGREEING, DSPACE_VALUE_NEGOTIATION_STATE_AGREED_IRI), + Arguments.arguments(AGREED, DSPACE_VALUE_NEGOTIATION_STATE_AGREED_IRI), + Arguments.arguments(VERIFYING, DSPACE_VALUE_NEGOTIATION_STATE_VERIFIED_IRI), + Arguments.arguments(VERIFIED, DSPACE_VALUE_NEGOTIATION_STATE_VERIFIED_IRI), + Arguments.arguments(FINALIZING, DSPACE_VALUE_NEGOTIATION_STATE_FINALIZED_IRI), + Arguments.arguments(FINALIZED, DSPACE_VALUE_NEGOTIATION_STATE_FINALIZED_IRI), + Arguments.arguments(TERMINATING, DSPACE_VALUE_NEGOTIATION_STATE_TERMINATED_IRI), + Arguments.arguments(TERMINATED, DSPACE_VALUE_NEGOTIATION_STATE_TERMINATED_IRI) ); } } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractOfferMessageTransformerTest.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractOfferMessageTransformerTest.java similarity index 97% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractOfferMessageTransformerTest.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractOfferMessageTransformerTest.java index 1a5173a97cb..34450689666 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractOfferMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractOfferMessageTransformerTest.java @@ -33,8 +33,8 @@ import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_OFFER_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_OFFER_MESSAGE_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -84,8 +84,8 @@ void transform_shouldReturnJsonObject_whenValidMessage() { assertThat(result.getJsonObject(DSPACE_PROPERTY_OFFER_IRI)).isNotNull(); assertThat(result.getJsonObject(DSPACE_PROPERTY_OFFER_IRI)).isNotNull(); assertThat(result.getJsonObject(DSPACE_PROPERTY_OFFER_IRI).getJsonString(ID).getString()).isEqualTo(CONTRACT_OFFER_ID); - assertThat(result.getString(DSPACE_PROPERTY_PROVIDER_PID)).isEqualTo("providerPid"); - assertThat(result.getString(DSPACE_PROPERTY_CONSUMER_PID)).isEqualTo("consumerPid"); + assertThat(result.getString(DSPACE_PROPERTY_PROVIDER_PID_IRI)).isEqualTo("providerPid"); + assertThat(result.getString(DSPACE_PROPERTY_CONSUMER_PID_IRI)).isEqualTo("consumerPid"); verify(context, never()).reportProblem(anyString()); } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractRequestMessageTransformerTest.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractRequestMessageTransformerTest.java similarity index 96% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractRequestMessageTransformerTest.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractRequestMessageTransformerTest.java index 232edd90e49..4996338f145 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractRequestMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/from/JsonObjectFromContractRequestMessageTransformerTest.java @@ -33,8 +33,8 @@ import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_OFFER_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_REQUEST_MESSAGE_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -81,8 +81,8 @@ void verify_contractOffer() { assertThat(result.getJsonString(DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI).getString()).isEqualTo(CALLBACK_ADDRESS); assertThat(result.getJsonObject(DSPACE_PROPERTY_OFFER_IRI)).isNotNull(); assertThat(result.getJsonObject(DSPACE_PROPERTY_OFFER_IRI).getString(ID)).isEqualTo(CONTRACT_OFFER_ID); - assertThat(result.getJsonString(DSPACE_PROPERTY_CONSUMER_PID).getString()).isEqualTo("consumerPid"); - assertThat(result.getJsonString(DSPACE_PROPERTY_PROVIDER_PID).getString()).isEqualTo("providerPid"); + assertThat(result.getJsonString(DSPACE_PROPERTY_CONSUMER_PID_IRI).getString()).isEqualTo("consumerPid"); + assertThat(result.getJsonString(DSPACE_PROPERTY_PROVIDER_PID_IRI).getString()).isEqualTo("providerPid"); verify(context, never()).reportProblem(anyString()); } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementMessageTransformerTest.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementMessageTransformerTest.java similarity index 85% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementMessageTransformerTest.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementMessageTransformerTest.java index 175dc4d53b9..b69fdc5720f 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementMessageTransformerTest.java @@ -39,11 +39,11 @@ import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_ASSIGNER_ATTRIBUTE; import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_POLICY_TYPE_AGREEMENT; import static org.eclipse.edc.protocol.dsp.negotiation.transform.to.TestInput.getExpanded; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_AGREEMENT; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_TIMESTAMP; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_AGREEMENT_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_TIMESTAMP_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.contains; @@ -92,14 +92,14 @@ void transform() { var message = jsonFactory.createObjectBuilder() .add(ID, MESSAGE_ID) .add(TYPE, DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") - .add(DSPACE_PROPERTY_AGREEMENT, jsonFactory.createObjectBuilder() + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") + .add(DSPACE_PROPERTY_AGREEMENT_IRI, jsonFactory.createObjectBuilder() .add(ID, AGREEMENT_ID) .add(TYPE, ODRL_POLICY_TYPE_AGREEMENT) .add(ODRL_ASSIGNEE_ATTRIBUTE, CONSUMER_ID) .add(ODRL_ASSIGNER_ATTRIBUTE, PROVIDER_ID) - .add(DSPACE_PROPERTY_TIMESTAMP, TIMESTAMP) + .add(DSPACE_PROPERTY_TIMESTAMP_IRI, TIMESTAMP) .build()) .build(); @@ -131,16 +131,16 @@ void transform_nullPolicy() { var message = jsonFactory.createObjectBuilder() .add(ID, value) .add(TYPE, DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") - .add(DSPACE_PROPERTY_AGREEMENT, jsonFactory.createObjectBuilder() + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") + .add(DSPACE_PROPERTY_AGREEMENT_IRI, jsonFactory.createObjectBuilder() .add(ID, AGREEMENT_ID) .add(TYPE, ODRL_POLICY_TYPE_AGREEMENT) .add(ODRL_ASSIGNEE_ATTRIBUTE, CONSUMER_ID) .add(ODRL_ASSIGNER_ATTRIBUTE, PROVIDER_ID) - .add(DSPACE_PROPERTY_TIMESTAMP, TIMESTAMP) + .add(DSPACE_PROPERTY_TIMESTAMP_IRI, TIMESTAMP) .build()) - .add(DSPACE_PROPERTY_TIMESTAMP, "123") + .add(DSPACE_PROPERTY_TIMESTAMP_IRI, "123") .build(); when(context.transform(any(JsonObject.class), eq(Policy.class))).thenReturn(null); @@ -157,22 +157,22 @@ void transform_invalidTimestamp() { .add(TYPE, ODRL_POLICY_TYPE_AGREEMENT) .add(ODRL_ASSIGNEE_ATTRIBUTE, CONSUMER_ID) .add(ODRL_ASSIGNER_ATTRIBUTE, PROVIDER_ID) - .add(DSPACE_PROPERTY_TIMESTAMP, "Invalid Timestamp") + .add(DSPACE_PROPERTY_TIMESTAMP_IRI, "Invalid Timestamp") .build(); var message = jsonFactory.createObjectBuilder() .add(ID, "messageId") .add(TYPE, DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") - .add(DSPACE_PROPERTY_AGREEMENT, agreement) + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") + .add(DSPACE_PROPERTY_AGREEMENT_IRI, agreement) .build(); when(context.transform(any(JsonObject.class), eq(Policy.class))).thenReturn(policy()); assertThat(transformer.transform(getExpanded(message), context)).isNull(); - verify(context, times(1)).reportProblem(contains(DSPACE_PROPERTY_TIMESTAMP)); + verify(context, times(1)).reportProblem(contains(DSPACE_PROPERTY_TIMESTAMP_IRI)); } @Test @@ -187,16 +187,16 @@ void transform_missingTimestamp() { var message = jsonFactory.createObjectBuilder() .add(ID, "messageId") .add(TYPE, DSPACE_TYPE_CONTRACT_AGREEMENT_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") - .add(DSPACE_PROPERTY_AGREEMENT, agreement) + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") + .add(DSPACE_PROPERTY_AGREEMENT_IRI, agreement) .build(); when(context.transform(any(JsonObject.class), eq(Policy.class))).thenReturn(policy()); assertThat(transformer.transform(getExpanded(message), context)).isNull(); - verify(context, times(1)).reportProblem(contains(DSPACE_PROPERTY_TIMESTAMP)); + verify(context, times(1)).reportProblem(contains(DSPACE_PROPERTY_TIMESTAMP_IRI)); } private Policy policy() { diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementVerificationMessageTransformerTest.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementVerificationMessageTransformerTest.java similarity index 92% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementVerificationMessageTransformerTest.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementVerificationMessageTransformerTest.java index da0e21100f1..d057f801eb8 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementVerificationMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractAgreementVerificationMessageTransformerTest.java @@ -28,8 +28,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.eclipse.edc.protocol.dsp.negotiation.transform.to.TestInput.getExpanded; import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_AGREEMENT_VERIFICATION_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.contains; import static org.mockito.Mockito.mock; @@ -56,8 +56,8 @@ void transform() { var message = jsonFactory.createObjectBuilder() .add(JsonLdKeywords.ID, "messageId") .add(JsonLdKeywords.TYPE, DSPACE_TYPE_CONTRACT_AGREEMENT_VERIFICATION_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") .build(); var result = transformer.transform(getExpanded(message), context); @@ -82,6 +82,6 @@ void verify_failTransformWhenConsumerPidMissing() { assertThat(result).isNull(); - verify(context, times(1)).reportProblem(contains(DSPACE_PROPERTY_CONSUMER_PID)); + verify(context, times(1)).reportProblem(contains(DSPACE_PROPERTY_CONSUMER_PID_IRI)); } } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationAckTransformerTest.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationAckTransformerTest.java similarity index 83% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationAckTransformerTest.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationAckTransformerTest.java index 9c2d4b97dca..b136bde9393 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationAckTransformerTest.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationAckTransformerTest.java @@ -24,10 +24,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.eclipse.edc.protocol.dsp.negotiation.transform.to.TestInput.getExpanded; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_STATE; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_STATE_IRI; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verifyNoInteractions; @@ -40,10 +40,10 @@ class JsonObjectToContractNegotiationAckTransformerTest { @Test void shouldTransform() { var message = jsonFactory.createObjectBuilder() - .add(JsonLdKeywords.TYPE, DSPACE_TYPE_CONTRACT_NEGOTIATION) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") - .add(DSPACE_PROPERTY_STATE, "STATE") + .add(JsonLdKeywords.TYPE, DSPACE_TYPE_CONTRACT_NEGOTIATION_IRI) + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") + .add(DSPACE_PROPERTY_STATE_IRI, "STATE") .build(); var result = transformer.transform(getExpanded(message), context); diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationEventMessageTransformerTest.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationEventMessageTransformerTest.java similarity index 83% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationEventMessageTransformerTest.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationEventMessageTransformerTest.java index 876cc20c815..81ebbd9ffc5 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationEventMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationEventMessageTransformerTest.java @@ -27,11 +27,11 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.eclipse.edc.protocol.dsp.negotiation.transform.to.TestInput.getExpanded; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_EVENT_TYPE; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_EVENT_TYPE_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION_EVENT_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.contains; import static org.mockito.Mockito.mock; @@ -58,9 +58,9 @@ void transform() { var message = jsonFactory.createObjectBuilder() .add(JsonLdKeywords.ID, "id1") .add(JsonLdKeywords.TYPE, DSPACE_TYPE_CONTRACT_NEGOTIATION_EVENT_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") - .add(DSPACE_PROPERTY_EVENT_TYPE, DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED) + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") + .add(DSPACE_PROPERTY_EVENT_TYPE_IRI, DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED_IRI) .build(); var result = transformer.transform(getExpanded(message), context); @@ -80,14 +80,14 @@ void verify_failTransformWhenProcessIdMissing() { var message = jsonFactory.createObjectBuilder() .add(JsonLdKeywords.ID, "id1") .add(JsonLdKeywords.TYPE, DSPACE_TYPE_CONTRACT_NEGOTIATION_EVENT_MESSAGE_IRI) - .add(DSPACE_PROPERTY_EVENT_TYPE, DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED) + .add(DSPACE_PROPERTY_EVENT_TYPE_IRI, DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED_IRI) .build(); var result = transformer.transform(getExpanded(message), context); assertThat(result).isNull(); - verify(context, times(1)).reportProblem(contains(DSPACE_PROPERTY_CONSUMER_PID)); + verify(context, times(1)).reportProblem(contains(DSPACE_PROPERTY_CONSUMER_PID_IRI)); } @Test @@ -95,15 +95,15 @@ void verify_failTransformWhenEventTypeMissing() { var message = jsonFactory.createObjectBuilder() .add(JsonLdKeywords.ID, "id1") .add(JsonLdKeywords.TYPE, DSPACE_TYPE_CONTRACT_NEGOTIATION_EVENT_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") .build(); var result = transformer.transform(getExpanded(message), context); assertThat(result).isNull(); - verify(context, times(1)).reportProblem(contains(DSPACE_PROPERTY_EVENT_TYPE)); + verify(context, times(1)).reportProblem(contains(DSPACE_PROPERTY_EVENT_TYPE_IRI)); } @Test @@ -111,15 +111,15 @@ void verify_failTransformWhenEventTypeInvalid() { var message = jsonFactory.createObjectBuilder() .add(JsonLdKeywords.ID, "id1") .add(JsonLdKeywords.TYPE, DSPACE_TYPE_CONTRACT_NEGOTIATION_EVENT_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") - .add(DSPACE_PROPERTY_EVENT_TYPE, "InvalidType") + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") + .add(DSPACE_PROPERTY_EVENT_TYPE_IRI, "InvalidType") .build(); var result = transformer.transform(getExpanded(message), context); assertThat(result).isNull(); - verify(context, times(1)).reportProblem(contains(DSPACE_PROPERTY_EVENT_TYPE)); + verify(context, times(1)).reportProblem(contains(DSPACE_PROPERTY_EVENT_TYPE_IRI)); } } diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationTerminationMessageTransformerTest.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationTerminationMessageTransformerTest.java similarity index 87% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationTerminationMessageTransformerTest.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationTerminationMessageTransformerTest.java index ff539ed8e0e..f3ca6c5ffe5 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationTerminationMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractNegotiationTerminationMessageTransformerTest.java @@ -27,10 +27,10 @@ import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; import static org.eclipse.edc.protocol.dsp.negotiation.transform.to.TestInput.getExpanded; import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_NEGOTIATION_TERMINATION_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON_IRI; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -53,10 +53,10 @@ void transform() { var message = jsonFactory.createObjectBuilder() .add(JsonLdKeywords.ID, "id1") .add(JsonLdKeywords.TYPE, DSPACE_TYPE_CONTRACT_NEGOTIATION_TERMINATION_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") - .add(DSPACE_PROPERTY_CODE, CODE) - .add(DSPACE_PROPERTY_REASON, reasonArray) + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") + .add(DSPACE_PROPERTY_CODE_IRI, CODE) + .add(DSPACE_PROPERTY_REASON_IRI, reasonArray) .build(); var result = transformer.transform(getExpanded(message), context); @@ -79,8 +79,8 @@ void verify_noCodeNodReason() { var message = jsonFactory.createObjectBuilder() .add(JsonLdKeywords.ID, "id1") .add(JsonLdKeywords.TYPE, DSPACE_TYPE_CONTRACT_NEGOTIATION_TERMINATION_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") .build(); var result = transformer.transform(getExpanded(message), context); diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractOfferMessageTransformerTest.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractOfferMessageTransformerTest.java similarity index 91% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractOfferMessageTransformerTest.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractOfferMessageTransformerTest.java index 974cf430634..e555024b97a 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractOfferMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractOfferMessageTransformerTest.java @@ -33,8 +33,8 @@ import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_OFFER_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_OFFER_MESSAGE_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -66,8 +66,8 @@ void transform_shouldReturnMessage_whenValidJsonObject() { var message = jsonFactory.createObjectBuilder() .add(ID, MESSAGE_ID) .add(JsonLdKeywords.TYPE, DSPACE_TYPE_CONTRACT_OFFER_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") .add(DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI, CALLBACK_ADDRESS) .add(DSPACE_PROPERTY_OFFER_IRI, jsonFactory.createObjectBuilder() .add(ID, CONTRACT_OFFER_ID) @@ -117,8 +117,8 @@ void transform_shouldReportProblem_whenMissingContractOffer() { var message = jsonFactory.createObjectBuilder() .add(ID, MESSAGE_ID) .add(JsonLdKeywords.TYPE, DSPACE_TYPE_CONTRACT_OFFER_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") .add(DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI, CALLBACK_ADDRESS) .build(); @@ -133,8 +133,8 @@ void transform_shouldReportProblem_whenMissingContractOfferId() { var message = jsonFactory.createObjectBuilder() .add(ID, MESSAGE_ID) .add(JsonLdKeywords.TYPE, DSPACE_TYPE_CONTRACT_OFFER_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") .add(DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI, CALLBACK_ADDRESS) .add(DSPACE_PROPERTY_OFFER_IRI, jsonFactory.createObjectBuilder().build()) .build(); @@ -153,8 +153,8 @@ void transform_shouldReportProblem_whenPolicyTransformationFails() { var message = jsonFactory.createObjectBuilder() .add(ID, MESSAGE_ID) .add(JsonLdKeywords.TYPE, DSPACE_TYPE_CONTRACT_OFFER_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") .add(DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI, CALLBACK_ADDRESS) .add(DSPACE_PROPERTY_OFFER_IRI, jsonFactory.createObjectBuilder() .add(ID, CONTRACT_OFFER_ID) diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractRequestMessageTransformerTest.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractRequestMessageTransformerTest.java similarity index 91% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractRequestMessageTransformerTest.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractRequestMessageTransformerTest.java index 2c5f1a11f20..d5cf18be5d8 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractRequestMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/JsonObjectToContractRequestMessageTransformerTest.java @@ -36,8 +36,8 @@ import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_PROPERTY_OFFER_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspNegotiationPropertyAndTypeNames.DSPACE_TYPE_CONTRACT_REQUEST_MESSAGE_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -69,8 +69,8 @@ void verify_usingOffer() { var message = jsonFactory.createObjectBuilder() .add(JsonLdKeywords.ID, OBJECT_ID) .add(JsonLdKeywords.TYPE, DSPACE_TYPE_CONTRACT_REQUEST_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") .add(DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI, CALLBACK) .add(DSPACE_PROPERTY_OFFER_IRI, contractOffer()) .build(); @@ -99,8 +99,8 @@ void verify_noCallbackOrDatasetOk() { var message = jsonFactory.createObjectBuilder() .add(JsonLdKeywords.ID, OBJECT_ID) .add(JsonLdKeywords.TYPE, DSPACE_TYPE_CONTRACT_REQUEST_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") .add(DSPACE_PROPERTY_OFFER_IRI, contractOffer()) .build(); @@ -121,8 +121,8 @@ void verify_noIdContractOfferFails() { var message = jsonFactory.createObjectBuilder() .add(JsonLdKeywords.ID, OBJECT_ID) .add(JsonLdKeywords.TYPE, DSPACE_TYPE_CONTRACT_REQUEST_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") .add(DSPACE_PROPERTY_OFFER_IRI, offer) .build(); @@ -140,8 +140,8 @@ void transform_nullPolicyFails() { var message = jsonFactory.createObjectBuilder() .add(JsonLdKeywords.ID, OBJECT_ID) .add(JsonLdKeywords.TYPE, DSPACE_TYPE_CONTRACT_REQUEST_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") .add(DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI, CALLBACK) .add(DSPACE_PROPERTY_OFFER_IRI, contractOffer()) .build(); diff --git a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/TestInput.java b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/TestInput.java similarity index 86% rename from data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/TestInput.java rename to data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/TestInput.java index d83f03e1104..781d758dca3 100644 --- a/data-protocols/dsp/dsp-negotiation/dsp-negotiation-transform/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/TestInput.java +++ b/data-protocols/dsp/dsp-negotiation/lib/dsp-negotiation-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/negotiation/transform/to/TestInput.java @@ -14,27 +14,26 @@ package org.eclipse.edc.protocol.dsp.negotiation.transform.to; +import com.apicatalog.jsonld.JsonLd; import com.apicatalog.jsonld.document.JsonDocument; import jakarta.json.JsonObject; -import static com.apicatalog.jsonld.JsonLd.expand; - /** * Functions for shaping test input. */ public class TestInput { + private TestInput() { + } + /** * 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); + return JsonLd.expand(JsonDocument.of(message)).get().asJsonArray().getJsonObject(0); } catch (Exception e) { throw new AssertionError(e); } } - - private TestInput() { - } } diff --git a/data-protocols/dsp/dsp-spi/src/main/java/org/eclipse/edc/protocol/dsp/spi/type/DspCatalogPropertyAndTypeNames.java b/data-protocols/dsp/dsp-spi/src/main/java/org/eclipse/edc/protocol/dsp/spi/type/DspCatalogPropertyAndTypeNames.java index e2cf3007e17..81bcf8239f9 100644 --- a/data-protocols/dsp/dsp-spi/src/main/java/org/eclipse/edc/protocol/dsp/spi/type/DspCatalogPropertyAndTypeNames.java +++ b/data-protocols/dsp/dsp-spi/src/main/java/org/eclipse/edc/protocol/dsp/spi/type/DspCatalogPropertyAndTypeNames.java @@ -23,8 +23,8 @@ public interface DspCatalogPropertyAndTypeNames { String DSPACE_TYPE_CATALOG_REQUEST_MESSAGE_TERM = "CatalogRequestMessage"; String DSPACE_TYPE_CATALOG_REQUEST_MESSAGE_IRI = DSPACE_SCHEMA + DSPACE_TYPE_CATALOG_REQUEST_MESSAGE_TERM; - - String DSPACE_TYPE_CATALOG_ERROR = DSPACE_SCHEMA + "CatalogError"; + String DSPACE_TYPE_CATALOG_ERROR_TERM = "CatalogError"; + String DSPACE_TYPE_CATALOG_ERROR_IRI = DSPACE_SCHEMA + DSPACE_TYPE_CATALOG_ERROR_TERM; String DSPACE_PROPERTY_FILTER_TERM = "filter"; String DSPACE_PROPERTY_FILTER_IRI = DSPACE_SCHEMA + DSPACE_PROPERTY_FILTER_TERM; diff --git a/data-protocols/dsp/dsp-spi/src/main/java/org/eclipse/edc/protocol/dsp/spi/type/DspNegotiationPropertyAndTypeNames.java b/data-protocols/dsp/dsp-spi/src/main/java/org/eclipse/edc/protocol/dsp/spi/type/DspNegotiationPropertyAndTypeNames.java index 7a78e00d80a..1b904a020cc 100644 --- a/data-protocols/dsp/dsp-spi/src/main/java/org/eclipse/edc/protocol/dsp/spi/type/DspNegotiationPropertyAndTypeNames.java +++ b/data-protocols/dsp/dsp-spi/src/main/java/org/eclipse/edc/protocol/dsp/spi/type/DspNegotiationPropertyAndTypeNames.java @@ -20,9 +20,10 @@ public interface DspNegotiationPropertyAndTypeNames { // types - String DSPACE_TYPE_CONTRACT_NEGOTIATION = DSPACE_SCHEMA + "ContractNegotiation"; - String DSPACE_TYPE_CONTRACT_NEGOTIATION_ERROR = DSPACE_SCHEMA + "ContractNegotiationError"; - + String DSPACE_TYPE_CONTRACT_NEGOTIATION_TERM = "ContractNegotiation"; + String DSPACE_TYPE_CONTRACT_NEGOTIATION_IRI = DSPACE_SCHEMA + DSPACE_TYPE_CONTRACT_NEGOTIATION_TERM; + String DSPACE_TYPE_CONTRACT_NEGOTIATION_ERROR_TERM = "ContractNegotiationError"; + String DSPACE_TYPE_CONTRACT_NEGOTIATION_ERROR_IRI = DSPACE_SCHEMA + DSPACE_TYPE_CONTRACT_NEGOTIATION_ERROR_TERM; // messages String DSPACE_TYPE_CONTRACT_REQUEST_MESSAGE_TERM = "ContractRequestMessage"; String DSPACE_TYPE_CONTRACT_REQUEST_MESSAGE_IRI = DSPACE_SCHEMA + DSPACE_TYPE_CONTRACT_REQUEST_MESSAGE_TERM; @@ -38,27 +39,38 @@ public interface DspNegotiationPropertyAndTypeNames { String DSPACE_TYPE_CONTRACT_NEGOTIATION_TERMINATION_MESSAGE_IRI = DSPACE_SCHEMA + DSPACE_TYPE_CONTRACT_NEGOTIATION_TERMINATION_MESSAGE_TERM; // properties - String DSPACE_PROPERTY_EVENT_TYPE = DSPACE_SCHEMA + "eventType"; - String DSPACE_PROPERTY_AGREEMENT = DSPACE_SCHEMA + "agreement"; + String DSPACE_PROPERTY_EVENT_TYPE_TERM = "eventType"; + String DSPACE_PROPERTY_EVENT_TYPE_IRI = DSPACE_SCHEMA + DSPACE_PROPERTY_EVENT_TYPE_TERM; + String DSPACE_PROPERTY_AGREEMENT_TERM = "agreement"; + String DSPACE_PROPERTY_AGREEMENT_IRI = DSPACE_SCHEMA + DSPACE_PROPERTY_AGREEMENT_TERM; String DSPACE_PROPERTY_OFFER_TERM = "offer"; String DSPACE_PROPERTY_OFFER_IRI = DSPACE_SCHEMA + DSPACE_PROPERTY_OFFER_TERM; - String DSPACE_PROPERTY_TIMESTAMP = DSPACE_SCHEMA + "timestamp"; - String DSPACE_PROPERTY_CONSUMER_ID = DSPACE_SCHEMA + "consumerId"; - String DSPACE_PROPERTY_PROVIDER_ID = DSPACE_SCHEMA + "providerId"; - + String DSPACE_PROPERTY_TIMESTAMP_TERM = "timestamp"; + String DSPACE_PROPERTY_TIMESTAMP_IRI = DSPACE_SCHEMA + DSPACE_PROPERTY_TIMESTAMP_TERM; + String DSPACE_PROPERTY_CONSUMER_ID_TERM = "consumerId"; + String DSPACE_PROPERTY_CONSUMER_ID_IRI = DSPACE_SCHEMA + DSPACE_PROPERTY_CONSUMER_ID_TERM; + String DSPACE_PROPERTY_PROVIDER_ID_TERM = "providerId"; + String DSPACE_PROPERTY_PROVIDER_ID_IRI = DSPACE_SCHEMA + DSPACE_PROPERTY_PROVIDER_ID_TERM; // event types - - String DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED = DSPACE_SCHEMA + "ACCEPTED"; - String DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_FINALIZED = DSPACE_SCHEMA + "FINALIZED"; - + String DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED_TERM = "ACCEPTED"; + String DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED_IRI = DSPACE_SCHEMA + DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_ACCEPTED_TERM; + String DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_FINALIZED_TERM = "FINALIZED"; + String DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_FINALIZED_IRI = DSPACE_SCHEMA + DSPACE_VALUE_NEGOTIATION_EVENT_TYPE_FINALIZED_TERM; // negotiation states - String DSPACE_VALUE_NEGOTIATION_STATE_REQUESTED = DSPACE_SCHEMA + "REQUESTED"; - String DSPACE_VALUE_NEGOTIATION_STATE_OFFERED = DSPACE_SCHEMA + "OFFERED"; - String DSPACE_VALUE_NEGOTIATION_STATE_ACCEPTED = DSPACE_SCHEMA + "ACCEPTED"; - String DSPACE_VALUE_NEGOTIATION_STATE_AGREED = DSPACE_SCHEMA + "AGREED"; - String DSPACE_VALUE_NEGOTIATION_STATE_VERIFIED = DSPACE_SCHEMA + "VERIFIED"; - String DSPACE_VALUE_NEGOTIATION_STATE_FINALIZED = DSPACE_SCHEMA + "FINALIZED"; - String DSPACE_VALUE_NEGOTIATION_STATE_TERMINATED = DSPACE_SCHEMA + "TERMINATED"; + String DSPACE_VALUE_NEGOTIATION_STATE_REQUESTED_TERM = "REQUESTED"; + String DSPACE_VALUE_NEGOTIATION_STATE_REQUESTED_IRI = DSPACE_SCHEMA + DSPACE_VALUE_NEGOTIATION_STATE_REQUESTED_TERM; + String DSPACE_VALUE_NEGOTIATION_STATE_OFFERED_TERM = "OFFERED"; + String DSPACE_VALUE_NEGOTIATION_STATE_OFFERED_IRI = DSPACE_SCHEMA + DSPACE_VALUE_NEGOTIATION_STATE_OFFERED_TERM; + String DSPACE_VALUE_NEGOTIATION_STATE_ACCEPTED_TERM = "ACCEPTED"; + String DSPACE_VALUE_NEGOTIATION_STATE_ACCEPTED_IRI = DSPACE_SCHEMA + DSPACE_VALUE_NEGOTIATION_STATE_ACCEPTED_TERM; + String DSPACE_VALUE_NEGOTIATION_STATE_AGREED_TERM = "AGREED"; + String DSPACE_VALUE_NEGOTIATION_STATE_AGREED_IRI = DSPACE_SCHEMA + DSPACE_VALUE_NEGOTIATION_STATE_AGREED_TERM; + String DSPACE_VALUE_NEGOTIATION_STATE_VERIFIED_TERM = "VERIFIED"; + String DSPACE_VALUE_NEGOTIATION_STATE_VERIFIED_IRI = DSPACE_SCHEMA + DSPACE_VALUE_NEGOTIATION_STATE_VERIFIED_TERM; + String DSPACE_VALUE_NEGOTIATION_STATE_FINALIZED_TERM = "FINALIZED"; + String DSPACE_VALUE_NEGOTIATION_STATE_FINALIZED_IRI = DSPACE_SCHEMA + DSPACE_VALUE_NEGOTIATION_STATE_FINALIZED_TERM; + String DSPACE_VALUE_NEGOTIATION_STATE_TERMINATED_TERM = "TERMINATED"; + String DSPACE_VALUE_NEGOTIATION_STATE_TERMINATED_IRI = DSPACE_SCHEMA + DSPACE_VALUE_NEGOTIATION_STATE_TERMINATED_TERM; } diff --git a/data-protocols/dsp/dsp-spi/src/main/java/org/eclipse/edc/protocol/dsp/spi/type/DspPropertyAndTypeNames.java b/data-protocols/dsp/dsp-spi/src/main/java/org/eclipse/edc/protocol/dsp/spi/type/DspPropertyAndTypeNames.java index b793d5d9c63..cff899af8f5 100644 --- a/data-protocols/dsp/dsp-spi/src/main/java/org/eclipse/edc/protocol/dsp/spi/type/DspPropertyAndTypeNames.java +++ b/data-protocols/dsp/dsp-spi/src/main/java/org/eclipse/edc/protocol/dsp/spi/type/DspPropertyAndTypeNames.java @@ -21,12 +21,17 @@ */ public interface DspPropertyAndTypeNames { - String DSPACE_PROPERTY_CODE = DSPACE_SCHEMA + "code"; - String DSPACE_PROPERTY_REASON = DSPACE_SCHEMA + "reason"; - String DSPACE_PROPERTY_CONSUMER_PID = DSPACE_SCHEMA + "consumerPid"; - String DSPACE_PROPERTY_PROVIDER_PID = DSPACE_SCHEMA + "providerPid"; + String DSPACE_PROPERTY_CODE_TERM = "code"; + String DSPACE_PROPERTY_CODE_IRI = DSPACE_SCHEMA + DSPACE_PROPERTY_CODE_TERM; + String DSPACE_PROPERTY_REASON_TERM = "reason"; + String DSPACE_PROPERTY_REASON_IRI = DSPACE_SCHEMA + DSPACE_PROPERTY_REASON_TERM; + String DSPACE_PROPERTY_CONSUMER_PID_TERM = "consumerPid"; + String DSPACE_PROPERTY_CONSUMER_PID_IRI = DSPACE_SCHEMA + DSPACE_PROPERTY_CONSUMER_PID_TERM; + String DSPACE_PROPERTY_PROVIDER_PID_TERM = "providerPid"; + String DSPACE_PROPERTY_PROVIDER_PID_IRI = DSPACE_SCHEMA + DSPACE_PROPERTY_PROVIDER_PID_TERM; String DSPACE_PROPERTY_PROCESS_ID = DSPACE_SCHEMA + "processId"; String DSPACE_PROPERTY_CALLBACK_ADDRESS_TERM = "callbackAddress"; String DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI = DSPACE_SCHEMA + DSPACE_PROPERTY_CALLBACK_ADDRESS_TERM; - String DSPACE_PROPERTY_STATE = DSPACE_SCHEMA + "state"; + String DSPACE_PROPERTY_STATE_TERM = "state"; + String DSPACE_PROPERTY_STATE_IRI = DSPACE_SCHEMA + DSPACE_PROPERTY_STATE_TERM; } diff --git a/data-protocols/dsp/dsp-spi/src/main/java/org/eclipse/edc/protocol/dsp/spi/type/DspTransferProcessPropertyAndTypeNames.java b/data-protocols/dsp/dsp-spi/src/main/java/org/eclipse/edc/protocol/dsp/spi/type/DspTransferProcessPropertyAndTypeNames.java index e16a257fc65..c18d6134fb9 100644 --- a/data-protocols/dsp/dsp-spi/src/main/java/org/eclipse/edc/protocol/dsp/spi/type/DspTransferProcessPropertyAndTypeNames.java +++ b/data-protocols/dsp/dsp-spi/src/main/java/org/eclipse/edc/protocol/dsp/spi/type/DspTransferProcessPropertyAndTypeNames.java @@ -27,12 +27,16 @@ public interface DspTransferProcessPropertyAndTypeNames { String DSPACE_TYPE_TRANSFER_START_MESSAGE_IRI = DSPACE_SCHEMA + DSPACE_TYPE_TRANSFER_START_MESSAGE_TERM; String DSPACE_TYPE_TRANSFER_COMPLETION_MESSAGE_TERM = "TransferCompletionMessage"; String DSPACE_TYPE_TRANSFER_COMPLETION_MESSAGE_IRI = DSPACE_SCHEMA + DSPACE_TYPE_TRANSFER_COMPLETION_MESSAGE_TERM; - String DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE = DSPACE_SCHEMA + "TransferSuspensionMessage"; + String DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE_TERM = "TransferSuspensionMessage"; + String DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE_IRI = DSPACE_SCHEMA + DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE_TERM; String DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_TERM = "TransferTerminationMessage"; String DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_IRI = DSPACE_SCHEMA + DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_TERM; - String DSPACE_TYPE_TRANSFER_PROCESS = DSPACE_SCHEMA + "TransferProcess"; - String DSPACE_TYPE_TRANSFER_ERROR = DSPACE_SCHEMA + "TransferError"; - - String DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID = DSPACE_SCHEMA + "agreementId"; - String DSPACE_PROPERTY_DATA_ADDRESS = DSPACE_SCHEMA + "dataAddress"; + String DSPACE_TYPE_TRANSFER_PROCESS_TERM = "TransferProcess"; + String DSPACE_TYPE_TRANSFER_PROCESS_IRI = DSPACE_SCHEMA + DSPACE_TYPE_TRANSFER_PROCESS_TERM; + String DSPACE_TYPE_TRANSFER_ERROR_TERM = "TransferError"; + String DSPACE_TYPE_TRANSFER_ERROR_IRI = DSPACE_SCHEMA + DSPACE_TYPE_TRANSFER_ERROR_TERM; + String DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID_TERM = "agreementId"; + String DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID_IRI = DSPACE_SCHEMA + DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID_TERM; + String DSPACE_PROPERTY_DATA_ADDRESS_TERM = "dataAddress"; + String DSPACE_PROPERTY_DATA_ADDRESS_IRI = DSPACE_SCHEMA + DSPACE_PROPERTY_DATA_ADDRESS_TERM; } diff --git a/data-protocols/dsp/dsp-transfer-process/build.gradle.kts b/data-protocols/dsp/dsp-transfer-process/build.gradle.kts index dca105cc8f3..a4899db98f4 100644 --- a/data-protocols/dsp/dsp-transfer-process/build.gradle.kts +++ b/data-protocols/dsp/dsp-transfer-process/build.gradle.kts @@ -22,4 +22,5 @@ dependencies { api(project(":data-protocols:dsp:dsp-transfer-process:dsp-transfer-process-http-dispatcher")) api(project(":data-protocols:dsp:dsp-transfer-process:dsp-transfer-process-transform")) api(project(":data-protocols:dsp:dsp-transfer-process:lib:dsp-transfer-process-validation-lib")) + api(project(":data-protocols:dsp:dsp-transfer-process:lib:dsp-transfer-process-transform-lib")) } diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-http-api/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/http/api/controller/DspTransferProcessApiController.java b/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-http-api/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/http/api/controller/DspTransferProcessApiController.java index 832b0cc53f5..fc6c0b0e91c 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-http-api/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/http/api/controller/DspTransferProcessApiController.java +++ b/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-http-api/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/http/api/controller/DspTransferProcessApiController.java @@ -41,7 +41,7 @@ import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_COMPLETION_MESSAGE_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_START_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_IRI; import static org.eclipse.edc.protocol.dsp.transferprocess.http.api.TransferProcessApiPaths.BASE_PATH; import static org.eclipse.edc.protocol.dsp.transferprocess.http.api.TransferProcessApiPaths.TRANSFER_COMPLETION; @@ -200,7 +200,7 @@ public Response transferProcessTermination(@PathParam("id") String id, JsonObjec public Response transferProcessSuspension(@PathParam("id") String id, JsonObject jsonObject, @HeaderParam(AUTHORIZATION) String token) { var request = PostDspRequest.Builder.newInstance(TransferSuspensionMessage.class, TransferProcess.class, TransferError.class) .processId(id) - .expectedMessageType(DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE) + .expectedMessageType(DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE_IRI) .message(jsonObject) .token(token) .serviceCall(protocolService::notifySuspended) diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-http-api/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/http/api/controller/DspTransferProcessApiControllerTest.java b/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-http-api/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/http/api/controller/DspTransferProcessApiControllerTest.java index 00cea4a6941..5dd71432e3f 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-http-api/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/http/api/controller/DspTransferProcessApiControllerTest.java +++ b/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-http-api/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/http/api/controller/DspTransferProcessApiControllerTest.java @@ -49,7 +49,7 @@ import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_COMPLETION_MESSAGE_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_START_MESSAGE_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_IRI; import static org.eclipse.edc.protocol.dsp.transferprocess.http.api.TransferProcessApiPaths.BASE_PATH; import static org.eclipse.edc.protocol.dsp.transferprocess.http.api.TransferProcessApiPaths.TRANSFER_COMPLETION; @@ -171,7 +171,7 @@ public Stream provideArguments(ExtensionContext context) { Arguments.of( BASE_PATH + PROCESS_ID + TRANSFER_SUSPENSION, TransferSuspensionMessage.class, - DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE), + DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE_IRI), Arguments.of( BASE_PATH + PROCESS_ID + TRANSFER_TERMINATION, TransferTerminationMessage.class, diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/build.gradle.kts b/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/build.gradle.kts index 01e7e4d01ad..be08c843bc3 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/build.gradle.kts +++ b/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/build.gradle.kts @@ -23,6 +23,7 @@ dependencies { api(project(":data-protocols:dsp:dsp-spi")) api(project(":data-protocols:dsp:dsp-http-spi")) implementation(project(":core:common:lib:transform-lib")) + implementation(project(":data-protocols:dsp:dsp-transfer-process:lib:dsp-transfer-process-transform-lib")) testImplementation(project(":core:common:lib:json-ld-lib")) testImplementation(project(":core:common:junit")) diff --git a/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/build.gradle.kts b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/build.gradle.kts new file mode 100644 index 00000000000..f1425d0e0ca --- /dev/null +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/build.gradle.kts @@ -0,0 +1,29 @@ +/* + * 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` +} + +dependencies { + api(project(":spi:common:json-ld-spi")) + api(project(":data-protocols:dsp:dsp-spi")) + api(project(":spi:control-plane:transfer-spi")) + implementation(project(":core:common:lib:transform-lib")) + + testImplementation(project(":core:common:junit")) + testImplementation(project(":extensions:common:json-ld")) + testImplementation(project(":core:common:lib:json-ld-lib")) + +} \ No newline at end of file diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferCompletionMessageTransformer.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferCompletionMessageTransformer.java similarity index 66% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferCompletionMessageTransformer.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferCompletionMessageTransformer.java index 20d4b6134d1..e0c7efbd390 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferCompletionMessageTransformer.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferCompletionMessageTransformer.java @@ -17,24 +17,29 @@ import jakarta.json.JsonBuilderFactory; import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.transfer.spi.types.protocol.TransferCompletionMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_COMPLETION_MESSAGE_IRI; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_COMPLETION_MESSAGE_TERM; -public class JsonObjectFromTransferCompletionMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectFromTransferCompletionMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { private final JsonBuilderFactory jsonBuilderFactory; public JsonObjectFromTransferCompletionMessageTransformer(JsonBuilderFactory jsonBuilderFactory) { - super(TransferCompletionMessage.class, JsonObject.class); + this(jsonBuilderFactory, DSPACE_SCHEMA); + } + + public JsonObjectFromTransferCompletionMessageTransformer(JsonBuilderFactory jsonBuilderFactory, String namespace) { + super(TransferCompletionMessage.class, JsonObject.class, namespace); this.jsonBuilderFactory = jsonBuilderFactory; } @@ -42,9 +47,9 @@ public JsonObjectFromTransferCompletionMessageTransformer(JsonBuilderFactory jso public @Nullable JsonObject transform(@NotNull TransferCompletionMessage transferCompletionMessage, @NotNull TransformerContext context) { return jsonBuilderFactory.createObjectBuilder() .add(ID, transferCompletionMessage.getId()) - .add(TYPE, DSPACE_TYPE_TRANSFER_COMPLETION_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, transferCompletionMessage.getConsumerPid()) - .add(DSPACE_PROPERTY_PROVIDER_PID, transferCompletionMessage.getProviderPid()) + .add(TYPE, forNamespace(DSPACE_TYPE_TRANSFER_COMPLETION_MESSAGE_TERM)) + .add(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM), transferCompletionMessage.getConsumerPid()) + .add(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM), transferCompletionMessage.getProviderPid()) .build(); } } diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferErrorTransformer.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferErrorTransformer.java similarity index 65% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferErrorTransformer.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferErrorTransformer.java index 6cb7533d690..7d97a5feb67 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferErrorTransformer.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferErrorTransformer.java @@ -17,34 +17,39 @@ import jakarta.json.JsonBuilderFactory; import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.transfer.spi.types.protocol.TransferError; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_ERROR; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_ERROR_TERM; /** * Transforms a {@link TransferError} to a {@link JsonObject} in JSON-LD expanded form. */ -public class JsonObjectFromTransferErrorTransformer extends AbstractJsonLdTransformer { +public class JsonObjectFromTransferErrorTransformer extends AbstractNamespaceAwareJsonLdTransformer { private final JsonBuilderFactory jsonFactory; public JsonObjectFromTransferErrorTransformer(JsonBuilderFactory jsonFactory) { - super(TransferError.class, JsonObject.class); + this(jsonFactory, DSPACE_SCHEMA); + } + + public JsonObjectFromTransferErrorTransformer(JsonBuilderFactory jsonFactory, String namespace) { + super(TransferError.class, JsonObject.class, namespace); this.jsonFactory = jsonFactory; } @Override public @Nullable JsonObject transform(@NotNull TransferError error, @NotNull TransformerContext context) { return jsonFactory.createObjectBuilder() - .add(TYPE, DSPACE_TYPE_TRANSFER_ERROR) - .add(DSPACE_PROPERTY_CODE, error.getCode()) - .add(DSPACE_PROPERTY_REASON, jsonFactory.createArrayBuilder(error.getMessages())) + .add(TYPE, forNamespace(DSPACE_TYPE_TRANSFER_ERROR_TERM)) + .add(forNamespace(DSPACE_PROPERTY_CODE_TERM), error.getCode()) + .add(forNamespace(DSPACE_PROPERTY_REASON_TERM), jsonFactory.createArrayBuilder(error.getMessages())) .build(); } } diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferProcessTransformer.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferProcessTransformer.java similarity index 60% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferProcessTransformer.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferProcessTransformer.java index 64b72d2b46f..57ce2697b8d 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferProcessTransformer.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferProcessTransformer.java @@ -18,24 +18,29 @@ import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcess; import org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcessStates; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_STATE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_PROCESS; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_STATE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_PROCESS_TERM; -public class JsonObjectFromTransferProcessTransformer extends AbstractJsonLdTransformer { +public class JsonObjectFromTransferProcessTransformer extends AbstractNamespaceAwareJsonLdTransformer { private final JsonBuilderFactory jsonBuilderFactory; public JsonObjectFromTransferProcessTransformer(JsonBuilderFactory jsonBuilderFactory) { - super(TransferProcess.class, JsonObject.class); + this(jsonBuilderFactory, DSPACE_SCHEMA); + } + + public JsonObjectFromTransferProcessTransformer(JsonBuilderFactory jsonBuilderFactory, String namespace) { + super(TransferProcess.class, JsonObject.class, namespace); this.jsonBuilderFactory = jsonBuilderFactory; } @@ -43,15 +48,15 @@ public JsonObjectFromTransferProcessTransformer(JsonBuilderFactory jsonBuilderFa public @Nullable JsonObject transform(@NotNull TransferProcess transferProcess, @NotNull TransformerContext context) { var builder = jsonBuilderFactory.createObjectBuilder() .add(ID, transferProcess.getId()) - .add(TYPE, DSPACE_TYPE_TRANSFER_PROCESS) - .add(DSPACE_PROPERTY_STATE, TransferProcessStates.from(transferProcess.getState()).name()); + .add(TYPE, forNamespace(DSPACE_TYPE_TRANSFER_PROCESS_TERM)) + .add(forNamespace(DSPACE_PROPERTY_STATE_TERM), TransferProcessStates.from(transferProcess.getState()).name()); if (transferProcess.getType() == TransferProcess.Type.PROVIDER) { - builder.add(DSPACE_PROPERTY_PROVIDER_PID, transferProcess.getId()); - addIfNotNull(transferProcess.getCorrelationId(), DSPACE_PROPERTY_CONSUMER_PID, builder); + builder.add(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM), transferProcess.getId()); + addIfNotNull(transferProcess.getCorrelationId(), forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM), builder); } else { - builder.add(DSPACE_PROPERTY_CONSUMER_PID, transferProcess.getId()); - addIfNotNull(transferProcess.getCorrelationId(), DSPACE_PROPERTY_PROVIDER_PID, builder); + builder.add(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM), transferProcess.getId()); + addIfNotNull(transferProcess.getCorrelationId(), forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM), builder); } return builder.build(); diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferRequestMessageTransformer.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferRequestMessageTransformer.java similarity index 66% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferRequestMessageTransformer.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferRequestMessageTransformer.java index 33c94c5fcf4..24c94c70054 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferRequestMessageTransformer.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferRequestMessageTransformer.java @@ -17,7 +17,7 @@ import jakarta.json.JsonBuilderFactory; import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.transfer.spi.types.protocol.TransferRequestMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -26,20 +26,25 @@ import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCT_FORMAT_ATTRIBUTE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_DATA_ADDRESS; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_DATA_ADDRESS_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE_TERM; -public class JsonObjectFromTransferRequestMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectFromTransferRequestMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { private final JsonBuilderFactory jsonBuilderFactory; public JsonObjectFromTransferRequestMessageTransformer(JsonBuilderFactory jsonBuilderFactory) { - super(TransferRequestMessage.class, JsonObject.class); + this(jsonBuilderFactory, DSPACE_SCHEMA); + } + + public JsonObjectFromTransferRequestMessageTransformer(JsonBuilderFactory jsonBuilderFactory, String namespace) { + super(TransferRequestMessage.class, JsonObject.class, namespace); this.jsonBuilderFactory = jsonBuilderFactory; } @@ -50,14 +55,14 @@ public JsonObjectFromTransferRequestMessageTransformer(JsonBuilderFactory jsonBu var builder = jsonBuilderFactory.createObjectBuilder() .add(ID, transferRequestMessage.getId()) - .add(TYPE, DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID, transferRequestMessage.getContractId()) + .add(TYPE, forNamespace(DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE_TERM)) + .add(forNamespace(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID_TERM), transferRequestMessage.getContractId()) .add(DCT_FORMAT_ATTRIBUTE, format) - .add(DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI, transferRequestMessage.getCallbackAddress()) - .add(DSPACE_PROPERTY_CONSUMER_PID, transferRequestMessage.getConsumerPid()); + .add(forNamespace(DSPACE_PROPERTY_CALLBACK_ADDRESS_TERM), transferRequestMessage.getCallbackAddress()) + .add(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM), transferRequestMessage.getConsumerPid()); if (transferRequestMessage.getDataDestination() != null && transferRequestMessage.getDataDestination().getProperties().size() > 1) { - builder.add(DSPACE_PROPERTY_DATA_ADDRESS, context.transform(transferRequestMessage.getDataDestination(), JsonObject.class)); + builder.add(forNamespace(DSPACE_PROPERTY_DATA_ADDRESS_TERM), context.transform(transferRequestMessage.getDataDestination(), JsonObject.class)); } return builder.build(); } diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferStartMessageTransformer.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferStartMessageTransformer.java similarity index 61% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferStartMessageTransformer.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferStartMessageTransformer.java index 19cac8951ab..68d102d7cb5 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferStartMessageTransformer.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferStartMessageTransformer.java @@ -17,24 +17,29 @@ import jakarta.json.JsonBuilderFactory; import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.transfer.spi.types.protocol.TransferStartMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_DATA_ADDRESS; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_START_MESSAGE_IRI; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_DATA_ADDRESS_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_START_MESSAGE_TERM; -public class JsonObjectFromTransferStartMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectFromTransferStartMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { private final JsonBuilderFactory jsonBuilderFactory; public JsonObjectFromTransferStartMessageTransformer(JsonBuilderFactory jsonBuilderFactory) { - super(TransferStartMessage.class, JsonObject.class); + this(jsonBuilderFactory, DSPACE_SCHEMA); + } + + public JsonObjectFromTransferStartMessageTransformer(JsonBuilderFactory jsonBuilderFactory, String namespace) { + super(TransferStartMessage.class, JsonObject.class, namespace); this.jsonBuilderFactory = jsonBuilderFactory; } @@ -42,12 +47,12 @@ public JsonObjectFromTransferStartMessageTransformer(JsonBuilderFactory jsonBuil public @Nullable JsonObject transform(@NotNull TransferStartMessage transferStartMessage, @NotNull TransformerContext context) { var builder = jsonBuilderFactory.createObjectBuilder() .add(ID, transferStartMessage.getId()) - .add(TYPE, DSPACE_TYPE_TRANSFER_START_MESSAGE_IRI) - .add(DSPACE_PROPERTY_PROVIDER_PID, transferStartMessage.getProviderPid()) - .add(DSPACE_PROPERTY_CONSUMER_PID, transferStartMessage.getConsumerPid()); + .add(TYPE, forNamespace(DSPACE_TYPE_TRANSFER_START_MESSAGE_TERM)) + .add(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM), transferStartMessage.getProviderPid()) + .add(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM), transferStartMessage.getConsumerPid()); if (transferStartMessage.getDataAddress() != null) { - builder.add(DSPACE_PROPERTY_DATA_ADDRESS, context.transform(transferStartMessage.getDataAddress(), JsonObject.class)); + builder.add(forNamespace(DSPACE_PROPERTY_DATA_ADDRESS_TERM), context.transform(transferStartMessage.getDataAddress(), JsonObject.class)); } return builder.build(); diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferSuspensionMessageTransformer.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferSuspensionMessageTransformer.java similarity index 61% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferSuspensionMessageTransformer.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferSuspensionMessageTransformer.java index 0026139eadf..f63e81fb9a4 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferSuspensionMessageTransformer.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferSuspensionMessageTransformer.java @@ -17,25 +17,30 @@ import jakarta.json.JsonBuilderFactory; import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.transfer.spi.types.protocol.TransferSuspensionMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE_TERM; -public class JsonObjectFromTransferSuspensionMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectFromTransferSuspensionMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { private final JsonBuilderFactory jsonBuilderFactory; public JsonObjectFromTransferSuspensionMessageTransformer(JsonBuilderFactory jsonBuilderFactory) { - super(TransferSuspensionMessage.class, JsonObject.class); + this(jsonBuilderFactory, DSPACE_SCHEMA); + } + + public JsonObjectFromTransferSuspensionMessageTransformer(JsonBuilderFactory jsonBuilderFactory, String namespace) { + super(TransferSuspensionMessage.class, JsonObject.class, namespace); this.jsonBuilderFactory = jsonBuilderFactory; } @@ -43,12 +48,12 @@ public JsonObjectFromTransferSuspensionMessageTransformer(JsonBuilderFactory jso public @Nullable JsonObject transform(@NotNull TransferSuspensionMessage message, @NotNull TransformerContext context) { var builder = jsonBuilderFactory.createObjectBuilder() .add(ID, message.getId()) - .add(TYPE, DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE) - .add(DSPACE_PROPERTY_CONSUMER_PID, message.getConsumerPid()) - .add(DSPACE_PROPERTY_PROVIDER_PID, message.getProviderPid()) - .add(DSPACE_PROPERTY_REASON, jsonBuilderFactory.createArrayBuilder(message.getReason())); + .add(TYPE, forNamespace(DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE_TERM)) + .add(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM), message.getConsumerPid()) + .add(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM), message.getProviderPid()) + .add(forNamespace(DSPACE_PROPERTY_REASON_TERM), jsonBuilderFactory.createArrayBuilder(message.getReason())); - addIfNotNull(message.getCode(), DSPACE_PROPERTY_CODE, builder); + addIfNotNull(message.getCode(), forNamespace(DSPACE_PROPERTY_CODE_TERM), builder); return builder.build(); diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferTerminationMessageTransformer.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferTerminationMessageTransformer.java similarity index 63% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferTerminationMessageTransformer.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferTerminationMessageTransformer.java index b4569753b53..2731d0a0ba2 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferTerminationMessageTransformer.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/from/JsonObjectFromTransferTerminationMessageTransformer.java @@ -17,25 +17,30 @@ import jakarta.json.JsonBuilderFactory; import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.transfer.spi.types.protocol.TransferTerminationMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_IRI; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_TERM; -public class JsonObjectFromTransferTerminationMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectFromTransferTerminationMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { private final JsonBuilderFactory jsonBuilderFactory; public JsonObjectFromTransferTerminationMessageTransformer(JsonBuilderFactory jsonBuilderFactory) { - super(TransferTerminationMessage.class, JsonObject.class); + this(jsonBuilderFactory, DSPACE_SCHEMA); + } + + public JsonObjectFromTransferTerminationMessageTransformer(JsonBuilderFactory jsonBuilderFactory, String namespace) { + super(TransferTerminationMessage.class, JsonObject.class, namespace); this.jsonBuilderFactory = jsonBuilderFactory; } @@ -43,12 +48,12 @@ public JsonObjectFromTransferTerminationMessageTransformer(JsonBuilderFactory js public @Nullable JsonObject transform(@NotNull TransferTerminationMessage transferTerminationMessage, @NotNull TransformerContext context) { var builder = jsonBuilderFactory.createObjectBuilder() .add(ID, transferTerminationMessage.getId()) - .add(TYPE, DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, transferTerminationMessage.getConsumerPid()) - .add(DSPACE_PROPERTY_PROVIDER_PID, transferTerminationMessage.getProviderPid()); + .add(TYPE, forNamespace(DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_TERM)) + .add(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM), transferTerminationMessage.getConsumerPid()) + .add(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM), transferTerminationMessage.getProviderPid()); - addIfNotNull(transferTerminationMessage.getCode(), DSPACE_PROPERTY_CODE, builder); - addIfNotNull(transferTerminationMessage.getReason(), DSPACE_PROPERTY_REASON, builder); + addIfNotNull(transferTerminationMessage.getCode(), forNamespace(DSPACE_PROPERTY_CODE_TERM), builder); + addIfNotNull(transferTerminationMessage.getReason(), forNamespace(DSPACE_PROPERTY_REASON_TERM), builder); return builder.build(); diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferCompletionMessageTransformer.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferCompletionMessageTransformer.java similarity index 60% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferCompletionMessageTransformer.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferCompletionMessageTransformer.java index 907d53ce32d..748e1cbe9b7 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferCompletionMessageTransformer.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferCompletionMessageTransformer.java @@ -16,39 +16,44 @@ import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.transfer.spi.types.protocol.TransferCompletionMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_COMPLETION_MESSAGE_IRI; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_COMPLETION_MESSAGE_TERM; -public class JsonObjectToTransferCompletionMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectToTransferCompletionMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { public JsonObjectToTransferCompletionMessageTransformer() { - super(JsonObject.class, TransferCompletionMessage.class); + this(DSPACE_SCHEMA); + } + + public JsonObjectToTransferCompletionMessageTransformer(String namespace) { + super(JsonObject.class, TransferCompletionMessage.class, namespace); } @Override public @Nullable TransferCompletionMessage transform(@NotNull JsonObject messageObject, @NotNull TransformerContext context) { var builder = TransferCompletionMessage.Builder.newInstance(); - if (!transformMandatoryString(messageObject.get(DSPACE_PROPERTY_CONSUMER_PID), builder::consumerPid, context)) { + if (!transformMandatoryString(messageObject.get(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)), builder::consumerPid, context)) { context.problem() .missingProperty() - .type(DSPACE_TYPE_TRANSFER_COMPLETION_MESSAGE_IRI) - .property(DSPACE_PROPERTY_CONSUMER_PID) + .type(forNamespace(DSPACE_TYPE_TRANSFER_COMPLETION_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)) .report(); return null; } - if (!transformMandatoryString(messageObject.get(DSPACE_PROPERTY_PROVIDER_PID), builder::providerPid, context)) { + if (!transformMandatoryString(messageObject.get(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM)), builder::providerPid, context)) { context.problem() .missingProperty() - .type(DSPACE_TYPE_TRANSFER_COMPLETION_MESSAGE_IRI) - .property(DSPACE_PROPERTY_PROVIDER_PID) + .type(forNamespace(DSPACE_TYPE_TRANSFER_COMPLETION_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM)) .report(); return null; } diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferProcessAckTransformer.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferProcessAckTransformer.java similarity index 61% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferProcessAckTransformer.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferProcessAckTransformer.java index b6d40a9841a..def7023f1bd 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferProcessAckTransformer.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferProcessAckTransformer.java @@ -16,32 +16,37 @@ import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.transfer.spi.types.protocol.TransferProcessAck; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_STATE; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_STATE_TERM; /** * Create a {@link TransferProcessAck} from {@link JsonObject} */ -public class JsonObjectToTransferProcessAckTransformer extends AbstractJsonLdTransformer { +public class JsonObjectToTransferProcessAckTransformer extends AbstractNamespaceAwareJsonLdTransformer { public JsonObjectToTransferProcessAckTransformer() { - super(JsonObject.class, TransferProcessAck.class); + this(DSPACE_SCHEMA); + } + + public JsonObjectToTransferProcessAckTransformer(String namespace) { + super(JsonObject.class, TransferProcessAck.class, namespace); } @Override public @Nullable TransferProcessAck transform(@NotNull JsonObject jsonObject, @NotNull TransformerContext context) { var builder = TransferProcessAck.Builder.newInstance(); - transformMandatoryString(jsonObject.get(DSPACE_PROPERTY_CONSUMER_PID), builder::consumerPid, context); - transformMandatoryString(jsonObject.get(DSPACE_PROPERTY_PROVIDER_PID), builder::providerPid, context); + transformMandatoryString(jsonObject.get(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)), builder::consumerPid, context); + transformMandatoryString(jsonObject.get(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM)), builder::providerPid, context); return builder - .state(transformString(jsonObject.get(DSPACE_PROPERTY_STATE), context)) + .state(transformString(jsonObject.get(forNamespace(DSPACE_PROPERTY_STATE_TERM)), context)) .build(); } } diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferRequestMessageTransformer.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferRequestMessageTransformer.java similarity index 55% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferRequestMessageTransformer.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferRequestMessageTransformer.java index 8838819c6ce..e32f238beec 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferRequestMessageTransformer.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferRequestMessageTransformer.java @@ -16,46 +16,52 @@ import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.transfer.spi.types.protocol.TransferRequestMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.spi.types.domain.DataAddress; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCT_FORMAT_ATTRIBUTE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_DATA_ADDRESS; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_DATA_ADDRESS_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE_TERM; -public class JsonObjectToTransferRequestMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectToTransferRequestMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { public JsonObjectToTransferRequestMessageTransformer() { - super(JsonObject.class, TransferRequestMessage.class); + this(DSPACE_SCHEMA); + } + + public JsonObjectToTransferRequestMessageTransformer(String namespace) { + super(JsonObject.class, TransferRequestMessage.class, namespace); } @Override public @Nullable TransferRequestMessage transform(@NotNull JsonObject messageObject, @NotNull TransformerContext context) { var builder = TransferRequestMessage.Builder.newInstance(); - if (!transformMandatoryString(messageObject.get(DSPACE_PROPERTY_CONSUMER_PID), builder::consumerPid, context)) { + if (!transformMandatoryString(messageObject.get(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)), builder::consumerPid, context)) { context.problem() .missingProperty() - .type(DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE_IRI) - .property(DSPACE_PROPERTY_CONSUMER_PID) + .type(forNamespace(DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)) .report(); return null; } - visitProperties(messageObject, k -> switch (k) { - case DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID -> v -> builder.contractId(transformString(v, context)); - case DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI -> v -> builder.callbackAddress(transformString(v, context)); - case DSPACE_PROPERTY_DATA_ADDRESS -> - v -> builder.dataDestination(transformObject(v, DataAddress.class, context)); - case DCT_FORMAT_ATTRIBUTE -> v -> builder.transferType(transformString(v, context)); - default -> doNothing(); - }); + transformString(messageObject.get(forNamespace(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID_TERM)), builder::contractId, context); + transformString(messageObject.get(forNamespace(DSPACE_PROPERTY_CALLBACK_ADDRESS_TERM)), builder::callbackAddress, context); + + var dataAddressObject = messageObject.get(forNamespace(DSPACE_PROPERTY_DATA_ADDRESS_TERM)); + if (dataAddressObject != null) { + builder.dataDestination(transformObject(dataAddressObject, DataAddress.class, context)); + } + + transformString(messageObject.get(DCT_FORMAT_ATTRIBUTE), builder::transferType, context); return builder.build(); } diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferStartMessageTransformer.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferStartMessageTransformer.java similarity index 59% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferStartMessageTransformer.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferStartMessageTransformer.java index dc4e6317990..26bfbd6f5e1 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferStartMessageTransformer.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferStartMessageTransformer.java @@ -16,46 +16,51 @@ import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.transfer.spi.types.protocol.TransferStartMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.spi.types.domain.DataAddress; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_DATA_ADDRESS; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_START_MESSAGE_IRI; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_DATA_ADDRESS_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_START_MESSAGE_TERM; -public class JsonObjectToTransferStartMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectToTransferStartMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { public JsonObjectToTransferStartMessageTransformer() { - super(JsonObject.class, TransferStartMessage.class); + this(DSPACE_SCHEMA); + } + + public JsonObjectToTransferStartMessageTransformer(String namespace) { + super(JsonObject.class, TransferStartMessage.class, namespace); } @Override public @Nullable TransferStartMessage transform(@NotNull JsonObject messageObject, @NotNull TransformerContext context) { var builder = TransferStartMessage.Builder.newInstance(); - if (!transformMandatoryString(messageObject.get(DSPACE_PROPERTY_CONSUMER_PID), builder::consumerPid, context)) { + if (!transformMandatoryString(messageObject.get(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)), builder::consumerPid, context)) { context.problem() .missingProperty() - .type(DSPACE_TYPE_TRANSFER_START_MESSAGE_IRI) - .property(DSPACE_PROPERTY_CONSUMER_PID) + .type(forNamespace(DSPACE_TYPE_TRANSFER_START_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)) .report(); return null; } - if (!transformMandatoryString(messageObject.get(DSPACE_PROPERTY_PROVIDER_PID), builder::providerPid, context)) { + if (!transformMandatoryString(messageObject.get(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM)), builder::providerPid, context)) { context.problem() .missingProperty() - .type(DSPACE_TYPE_TRANSFER_START_MESSAGE_IRI) - .property(DSPACE_PROPERTY_PROVIDER_PID) + .type(forNamespace(DSPACE_TYPE_TRANSFER_START_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM)) .report(); return null; } - var dataAddressObject = returnJsonObject(messageObject.get(DSPACE_PROPERTY_DATA_ADDRESS), context, DSPACE_PROPERTY_DATA_ADDRESS, false); + var dataAddressObject = returnJsonObject(messageObject.get(forNamespace(DSPACE_PROPERTY_DATA_ADDRESS_TERM)), context, forNamespace(DSPACE_PROPERTY_DATA_ADDRESS_TERM), false); if (dataAddressObject != null) { builder.dataAddress(context.transform(dataAddressObject, DataAddress.class)); } diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferSuspensionMessageTransformer.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferSuspensionMessageTransformer.java similarity index 64% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferSuspensionMessageTransformer.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferSuspensionMessageTransformer.java index 6b4dcd4b31b..24338c42d86 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferSuspensionMessageTransformer.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferSuspensionMessageTransformer.java @@ -20,7 +20,7 @@ import jakarta.json.JsonObject; import jakarta.json.JsonValue; import org.eclipse.edc.connector.controlplane.transfer.spi.types.protocol.TransferSuspensionMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.spi.EdcException; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; @@ -29,57 +29,63 @@ import java.util.Map; import static jakarta.json.JsonValue.ValueType.ARRAY; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_IRI; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_TERM; -public class JsonObjectToTransferSuspensionMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectToTransferSuspensionMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { private final ObjectMapper objectMapper; public JsonObjectToTransferSuspensionMessageTransformer(ObjectMapper objectMapper) { - super(JsonObject.class, TransferSuspensionMessage.class); + this(objectMapper, DSPACE_SCHEMA); + } + + public JsonObjectToTransferSuspensionMessageTransformer(ObjectMapper objectMapper, String namespace) { + super(JsonObject.class, TransferSuspensionMessage.class, namespace); this.objectMapper = objectMapper; } + @Override public @Nullable TransferSuspensionMessage transform(@NotNull JsonObject messageObject, @NotNull TransformerContext context) { var builder = TransferSuspensionMessage.Builder.newInstance(); - if (!transformMandatoryString(messageObject.get(DSPACE_PROPERTY_CONSUMER_PID), builder::consumerPid, context)) { + if (!transformMandatoryString(messageObject.get(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)), builder::consumerPid, context)) { context.problem() .missingProperty() - .type(DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE) - .property(DSPACE_PROPERTY_CONSUMER_PID) + .type(forNamespace(DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)) .report(); return null; } - if (!transformMandatoryString(messageObject.get(DSPACE_PROPERTY_PROVIDER_PID), builder::providerPid, context)) { + if (!transformMandatoryString(messageObject.get(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM)), builder::providerPid, context)) { context.problem() .missingProperty() - .type(DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE) - .property(DSPACE_PROPERTY_PROVIDER_PID) + .type(forNamespace(DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM)) .report(); return null; } - if (messageObject.containsKey(DSPACE_PROPERTY_CODE)) { - transformString(messageObject.get(DSPACE_PROPERTY_CODE), builder::code, context); + if (messageObject.containsKey(forNamespace(DSPACE_PROPERTY_CODE_TERM))) { + transformString(messageObject.get(forNamespace(DSPACE_PROPERTY_CODE_TERM)), builder::code, context); } - var reasons = messageObject.get(DSPACE_PROPERTY_REASON); + var reasons = messageObject.get(forNamespace(DSPACE_PROPERTY_REASON_TERM)); if (reasons != null) { if (reasons instanceof JsonArray array && !array.isEmpty()) { builder.reason(array.stream().map(this::deserialize).toList()); } else { context.problem() .unexpectedType() - .type(DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_IRI) - .property(DSPACE_PROPERTY_REASON) + .type(forNamespace(DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_REASON_TERM)) .actual(reasons.getValueType()) .expected(ARRAY) .report(); diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferTerminationMessageTransformer.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferTerminationMessageTransformer.java similarity index 61% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferTerminationMessageTransformer.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferTerminationMessageTransformer.java index a9f4cd23f3e..86c24bc2916 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferTerminationMessageTransformer.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/main/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/type/to/JsonObjectToTransferTerminationMessageTransformer.java @@ -17,57 +17,62 @@ import jakarta.json.JsonArray; import jakarta.json.JsonObject; import org.eclipse.edc.connector.controlplane.transfer.spi.types.protocol.TransferTerminationMessage; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.jsonld.spi.transformer.AbstractNamespaceAwareJsonLdTransformer; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import static jakarta.json.JsonValue.ValueType.ARRAY; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_IRI; +import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON_TERM; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_TERM; -public class JsonObjectToTransferTerminationMessageTransformer extends AbstractJsonLdTransformer { +public class JsonObjectToTransferTerminationMessageTransformer extends AbstractNamespaceAwareJsonLdTransformer { public JsonObjectToTransferTerminationMessageTransformer() { - super(JsonObject.class, TransferTerminationMessage.class); + this(DSPACE_SCHEMA); + } + + public JsonObjectToTransferTerminationMessageTransformer(String namespace) { + super(JsonObject.class, TransferTerminationMessage.class, namespace); } @Override public @Nullable TransferTerminationMessage transform(@NotNull JsonObject messageObject, @NotNull TransformerContext context) { var builder = TransferTerminationMessage.Builder.newInstance(); - if (!transformMandatoryString(messageObject.get(DSPACE_PROPERTY_CONSUMER_PID), builder::consumerPid, context)) { + if (!transformMandatoryString(messageObject.get(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)), builder::consumerPid, context)) { context.problem() .missingProperty() - .type(DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_IRI) - .property(DSPACE_PROPERTY_CONSUMER_PID) + .type(forNamespace(DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_CONSUMER_PID_TERM)) .report(); return null; } - if (!transformMandatoryString(messageObject.get(DSPACE_PROPERTY_PROVIDER_PID), builder::providerPid, context)) { + if (!transformMandatoryString(messageObject.get(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM)), builder::providerPid, context)) { context.problem() .missingProperty() - .type(DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_IRI) - .property(DSPACE_PROPERTY_PROVIDER_PID) + .type(forNamespace(DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_PROVIDER_PID_TERM)) .report(); return null; } - if (messageObject.containsKey(DSPACE_PROPERTY_CODE)) { - transformString(messageObject.get(DSPACE_PROPERTY_CODE), builder::code, context); + if (messageObject.containsKey(forNamespace(DSPACE_PROPERTY_CODE_TERM))) { + transformString(messageObject.get(forNamespace(DSPACE_PROPERTY_CODE_TERM)), builder::code, context); } - var reasons = messageObject.get(DSPACE_PROPERTY_REASON); + var reasons = messageObject.get(forNamespace(DSPACE_PROPERTY_REASON_TERM)); if (reasons != null) { // optional property if (!(reasons instanceof JsonArray)) { context.problem() .unexpectedType() - .type(DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_IRI) - .property(DSPACE_PROPERTY_REASON) + .type(forNamespace(DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_TERM)) + .property(forNamespace(DSPACE_PROPERTY_REASON_TERM)) .actual(reasons.getValueType()) .expected(ARRAY) .report(); diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromDataAddressTransformerTest.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromDataAddressTransformerTest.java similarity index 100% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromDataAddressTransformerTest.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromDataAddressTransformerTest.java diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferCompletionMessageTransformerTest.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferCompletionMessageTransformerTest.java similarity index 94% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferCompletionMessageTransformerTest.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferCompletionMessageTransformerTest.java index 9e6b478e40c..efea5e53b5b 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferCompletionMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferCompletionMessageTransformerTest.java @@ -25,8 +25,8 @@ import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_COMPLETION_MESSAGE_IRI; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; @@ -55,8 +55,8 @@ void transformTransferCompletionMessage() { assertThat(result).isNotNull(); assertThat(result.getString(JsonLdKeywords.TYPE)).isEqualTo(DSPACE_TYPE_TRANSFER_COMPLETION_MESSAGE_IRI); - assertThat(result.getString(DSPACE_PROPERTY_CONSUMER_PID)).isEqualTo("consumerPid"); - assertThat(result.getString(DSPACE_PROPERTY_PROVIDER_PID)).isEqualTo("providerPid"); + assertThat(result.getString(DSPACE_PROPERTY_CONSUMER_PID_IRI)).isEqualTo("consumerPid"); + assertThat(result.getString(DSPACE_PROPERTY_PROVIDER_PID_IRI)).isEqualTo("providerPid"); verify(context, never()).reportProblem(anyString()); } diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferErrorTransformerTest.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferErrorTransformerTest.java similarity index 85% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferErrorTransformerTest.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferErrorTransformerTest.java index 4ac37310a81..f2105343dbf 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferErrorTransformerTest.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferErrorTransformerTest.java @@ -27,9 +27,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_ERROR; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_ERROR_IRI; import static org.mockito.Mockito.mock; class JsonObjectFromTransferErrorTransformerTest { @@ -55,8 +55,8 @@ void transform_returnJsonObject() { var result = transformer.transform(error, context); assertThat(result).isNotNull(); - assertThat(result.getJsonString(TYPE).getString()).isEqualTo(DSPACE_TYPE_TRANSFER_ERROR); - assertThat(result.getString(DSPACE_PROPERTY_CODE)).isEqualTo("code"); - assertThat(result.getJsonArray(DSPACE_PROPERTY_REASON)).contains(Json.createValue("message")); + assertThat(result.getJsonString(TYPE).getString()).isEqualTo(DSPACE_TYPE_TRANSFER_ERROR_IRI); + assertThat(result.getString(DSPACE_PROPERTY_CODE_IRI)).isEqualTo("code"); + assertThat(result.getJsonArray(DSPACE_PROPERTY_REASON_IRI)).contains(Json.createValue("message")); } } diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferProcessTransformerTest.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferProcessTransformerTest.java similarity index 85% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferProcessTransformerTest.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferProcessTransformerTest.java index 835a9611ca3..6a81208818d 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferProcessTransformerTest.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferProcessTransformerTest.java @@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_STATE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_PROCESS; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_STATE_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_PROCESS_IRI; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -65,11 +65,11 @@ void transformTransferProcessProvider() { var result = transformer.transform(transferProcess, context); assertThat(result).isNotNull(); - assertThat(result.getJsonString(TYPE).getString()).isEqualTo(DSPACE_TYPE_TRANSFER_PROCESS); + assertThat(result.getJsonString(TYPE).getString()).isEqualTo(DSPACE_TYPE_TRANSFER_PROCESS_IRI); assertThat(result.getJsonString(ID).getString()).isEqualTo("providerPid"); - assertThat(result.getJsonString(DSPACE_PROPERTY_STATE).getString()).isEqualTo("INITIAL"); - assertThat(result.getJsonString(DSPACE_PROPERTY_CONSUMER_PID).getString()).isEqualTo("consumerPid"); - assertThat(result.getJsonString(DSPACE_PROPERTY_PROVIDER_PID).getString()).isEqualTo("providerPid"); + assertThat(result.getJsonString(DSPACE_PROPERTY_STATE_IRI).getString()).isEqualTo("INITIAL"); + assertThat(result.getJsonString(DSPACE_PROPERTY_CONSUMER_PID_IRI).getString()).isEqualTo("consumerPid"); + assertThat(result.getJsonString(DSPACE_PROPERTY_PROVIDER_PID_IRI).getString()).isEqualTo("providerPid"); verify(context, never()).reportProblem(anyString()); } @@ -93,11 +93,11 @@ void transformTransferProcessConsumer() { var result = transformer.transform(transferProcess, context); assertThat(result).isNotNull(); - assertThat(result.getJsonString(TYPE).getString()).isEqualTo(DSPACE_TYPE_TRANSFER_PROCESS); + assertThat(result.getJsonString(TYPE).getString()).isEqualTo(DSPACE_TYPE_TRANSFER_PROCESS_IRI); assertThat(result.getJsonString(ID).getString()).isEqualTo("consumerPid"); - assertThat(result.getJsonString(DSPACE_PROPERTY_STATE).getString()).isEqualTo("INITIAL"); - assertThat(result.getJsonString(DSPACE_PROPERTY_CONSUMER_PID).getString()).isEqualTo("consumerPid"); - assertThat(result.getJsonString(DSPACE_PROPERTY_PROVIDER_PID).getString()).isEqualTo("providerPid"); + assertThat(result.getJsonString(DSPACE_PROPERTY_STATE_IRI).getString()).isEqualTo("INITIAL"); + assertThat(result.getJsonString(DSPACE_PROPERTY_CONSUMER_PID_IRI).getString()).isEqualTo("consumerPid"); + assertThat(result.getJsonString(DSPACE_PROPERTY_PROVIDER_PID_IRI).getString()).isEqualTo("providerPid"); verify(context, never()).reportProblem(anyString()); } diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferRequestMessageTransformerTest.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferRequestMessageTransformerTest.java similarity index 93% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferRequestMessageTransformerTest.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferRequestMessageTransformerTest.java index 54eb8335f3f..2f9d829b57c 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferRequestMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferRequestMessageTransformerTest.java @@ -30,9 +30,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCT_FORMAT_ATTRIBUTE; import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_DATA_ADDRESS; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_DATA_ADDRESS_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE_IRI; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -82,11 +82,11 @@ void transformTransferRequestMessageWithDataAddress() { assertThat(result).isNotNull(); assertThat(result.getJsonString(JsonLdKeywords.TYPE).getString()).isEqualTo(DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE_IRI); - assertThat(result.getJsonString(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID).getString()).isEqualTo(contractId); + assertThat(result.getJsonString(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID_IRI).getString()).isEqualTo(contractId); assertThat(result.getJsonString(DCT_FORMAT_ATTRIBUTE).getString()).isEqualTo(dataAddressType); assertThat(result.getJsonString(DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI).getString()).isEqualTo(callbackAddress); - assertThat(result.getJsonString(DSPACE_PROPERTY_CONSUMER_PID).getString()).isEqualTo("consumerPid"); - assertThat(result.getJsonObject(DSPACE_PROPERTY_DATA_ADDRESS).getString("keyName")).isEqualTo(dataAddressKey); + assertThat(result.getJsonString(DSPACE_PROPERTY_CONSUMER_PID_IRI).getString()).isEqualTo("consumerPid"); + assertThat(result.getJsonObject(DSPACE_PROPERTY_DATA_ADDRESS_IRI).getString("keyName")).isEqualTo(dataAddressKey); verify(context, never()).reportProblem(anyString()); } @@ -106,10 +106,10 @@ void transformTransferRequestMessageWithoutDataAddress() { assertThat(result).isNotNull(); assertThat(result.getJsonString(JsonLdKeywords.TYPE).getString()).isEqualTo(DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE_IRI); - assertThat(result.getJsonString(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID).getString()).isEqualTo(contractId); + assertThat(result.getJsonString(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID_IRI).getString()).isEqualTo(contractId); assertThat(result.getJsonString(DCT_FORMAT_ATTRIBUTE).getString()).isEqualTo(dataAddressType); assertThat(result.getJsonString(DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI).getString()).isEqualTo(callbackAddress); - assertThat(result.getJsonObject(DSPACE_PROPERTY_DATA_ADDRESS)).isEqualTo(null); + assertThat(result.getJsonObject(DSPACE_PROPERTY_DATA_ADDRESS_IRI)).isEqualTo(null); verify(context, never()).reportProblem(anyString()); } @@ -130,10 +130,10 @@ void transformTransferRequestMessageWithTransferType() { assertThat(result).isNotNull(); assertThat(result.getJsonString(JsonLdKeywords.TYPE).getString()).isEqualTo(DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE_IRI); - assertThat(result.getJsonString(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID).getString()).isEqualTo(contractId); + assertThat(result.getJsonString(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID_IRI).getString()).isEqualTo(contractId); assertThat(result.getJsonString(DCT_FORMAT_ATTRIBUTE).getString()).isEqualTo(transferType); assertThat(result.getJsonString(DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI).getString()).isEqualTo(callbackAddress); - assertThat(result.getJsonObject(DSPACE_PROPERTY_DATA_ADDRESS)).isEqualTo(null); + assertThat(result.getJsonObject(DSPACE_PROPERTY_DATA_ADDRESS_IRI)).isEqualTo(null); verify(context, never()).reportProblem(anyString()); } diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferStartMessageTransformerTest.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferStartMessageTransformerTest.java similarity index 92% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferStartMessageTransformerTest.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferStartMessageTransformerTest.java index 2992b3b822b..3f00c4150df 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferStartMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferStartMessageTransformerTest.java @@ -27,9 +27,9 @@ import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_DATA_ADDRESS; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_DATA_ADDRESS_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_START_MESSAGE_IRI; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; @@ -63,9 +63,9 @@ void transformTransferStartMessage() { assertThat(result).isNotNull(); assertThat(result.getString(JsonLdKeywords.TYPE)).isEqualTo(DSPACE_TYPE_TRANSFER_START_MESSAGE_IRI); - assertThat(result.getString(DSPACE_PROPERTY_PROVIDER_PID)).isEqualTo("providerPid"); - assertThat(result.getString(DSPACE_PROPERTY_CONSUMER_PID)).isEqualTo("consumerPid"); - assertThat(result.getJsonObject(DSPACE_PROPERTY_DATA_ADDRESS)).isEqualTo(dataAddressJson); + assertThat(result.getString(DSPACE_PROPERTY_PROVIDER_PID_IRI)).isEqualTo("providerPid"); + assertThat(result.getString(DSPACE_PROPERTY_CONSUMER_PID_IRI)).isEqualTo("consumerPid"); + assertThat(result.getJsonObject(DSPACE_PROPERTY_DATA_ADDRESS_IRI)).isEqualTo(dataAddressJson); verify(context, times(1)).transform(dataAddress, JsonObject.class); verify(context, never()).reportProblem(anyString()); diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferSuspensionMessageTransformerTest.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferSuspensionMessageTransformerTest.java similarity index 84% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferSuspensionMessageTransformerTest.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferSuspensionMessageTransformerTest.java index cd88df5b79b..c4850d23542 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferSuspensionMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferSuspensionMessageTransformerTest.java @@ -26,11 +26,11 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE_IRI; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -58,11 +58,11 @@ void transformTransferSuspensionMessage() { var result = transformer.transform(message, context); assertThat(result).isNotNull(); - assertThat(result.getJsonString(TYPE).getString()).isEqualTo(DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE); - assertThat(result.getJsonString(DSPACE_PROPERTY_CONSUMER_PID).getString()).isEqualTo("consumerPid"); - assertThat(result.getJsonString(DSPACE_PROPERTY_PROVIDER_PID).getString()).isEqualTo("providerPid"); - assertThat(result.getJsonString(DSPACE_PROPERTY_CODE).getString()).isEqualTo("testCode"); - assertThat(result.getJsonArray(DSPACE_PROPERTY_REASON)).hasSize(1).first() + assertThat(result.getJsonString(TYPE).getString()).isEqualTo(DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE_IRI); + assertThat(result.getJsonString(DSPACE_PROPERTY_CONSUMER_PID_IRI).getString()).isEqualTo("consumerPid"); + assertThat(result.getJsonString(DSPACE_PROPERTY_PROVIDER_PID_IRI).getString()).isEqualTo("providerPid"); + assertThat(result.getJsonString(DSPACE_PROPERTY_CODE_IRI).getString()).isEqualTo("testCode"); + assertThat(result.getJsonArray(DSPACE_PROPERTY_REASON_IRI)).hasSize(1).first() .isInstanceOfSatisfying(JsonString.class, reason -> assertThat(reason.getString()).isEqualTo("testReason")); verify(context, never()).reportProblem(anyString()); diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferTerminationMessageTransformerTest.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferTerminationMessageTransformerTest.java similarity index 85% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferTerminationMessageTransformerTest.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferTerminationMessageTransformerTest.java index 9485fa891e9..810f6bc8ec3 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferTerminationMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/from/JsonObjectFromTransferTerminationMessageTransformerTest.java @@ -25,10 +25,10 @@ import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_IRI; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; @@ -58,10 +58,10 @@ void transformTransferTerminationMessage() { assertThat(result).isNotNull(); assertThat(result.getJsonString(JsonLdKeywords.TYPE).getString()).isEqualTo(DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_IRI); - assertThat(result.getJsonString(DSPACE_PROPERTY_CONSUMER_PID).getString()).isEqualTo("consumerPid"); - assertThat(result.getJsonString(DSPACE_PROPERTY_PROVIDER_PID).getString()).isEqualTo("providerPid"); - assertThat(result.getJsonString(DSPACE_PROPERTY_CODE).getString()).isEqualTo("testCode"); - assertThat(result.getJsonString(DSPACE_PROPERTY_REASON).getString()).isEqualTo("testReason"); + assertThat(result.getJsonString(DSPACE_PROPERTY_CONSUMER_PID_IRI).getString()).isEqualTo("consumerPid"); + assertThat(result.getJsonString(DSPACE_PROPERTY_PROVIDER_PID_IRI).getString()).isEqualTo("providerPid"); + assertThat(result.getJsonString(DSPACE_PROPERTY_CODE_IRI).getString()).isEqualTo("testCode"); + assertThat(result.getJsonString(DSPACE_PROPERTY_REASON_IRI).getString()).isEqualTo("testReason"); verify(context, never()).reportProblem(anyString()); } diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferCompletionMessageTransformerTest.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferCompletionMessageTransformerTest.java similarity index 92% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferCompletionMessageTransformerTest.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferCompletionMessageTransformerTest.java index ad0cd99cc0d..b7f57bb741d 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferCompletionMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferCompletionMessageTransformerTest.java @@ -22,8 +22,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_COMPLETION_MESSAGE_IRI; import static org.eclipse.edc.protocol.dsp.transferprocess.transform.to.TestInput.getExpanded; import static org.mockito.ArgumentMatchers.anyString; @@ -43,8 +43,8 @@ class JsonObjectToTransferCompletionMessageTransformerTest { void shouldTransform() { var json = Json.createObjectBuilder() .add(TYPE, DSPACE_TYPE_TRANSFER_COMPLETION_MESSAGE_IRI) - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") .build(); var result = transformer.transform(getExpanded(json), context); diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferProcessAckTransformerTest.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferProcessAckTransformerTest.java similarity index 82% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferProcessAckTransformerTest.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferProcessAckTransformerTest.java index f2707156ad5..0b00bcbbb68 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferProcessAckTransformerTest.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferProcessAckTransformerTest.java @@ -24,10 +24,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_STATE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_PROCESS; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_STATE_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_PROCESS_IRI; import static org.eclipse.edc.protocol.dsp.transferprocess.transform.to.TestInput.getExpanded; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verifyNoInteractions; @@ -41,10 +41,10 @@ class JsonObjectToTransferProcessAckTransformerTest { @Test void shouldTransform() { var message = jsonFactory.createObjectBuilder() - .add(TYPE, DSPACE_TYPE_TRANSFER_PROCESS) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") - .add(DSPACE_PROPERTY_STATE, "STATE") + .add(TYPE, DSPACE_TYPE_TRANSFER_PROCESS_IRI) + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") + .add(DSPACE_PROPERTY_STATE_IRI, "STATE") .build(); var result = transformer.transform(getExpanded(message), context); diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferRequestMessageTransformerTest.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferRequestMessageTransformerTest.java similarity index 89% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferRequestMessageTransformerTest.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferRequestMessageTransformerTest.java index e101dc6500b..b82a3853afb 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferRequestMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferRequestMessageTransformerTest.java @@ -26,9 +26,9 @@ import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCT_FORMAT_ATTRIBUTE; import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_DATA_ADDRESS; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_DATA_ADDRESS_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE_IRI; import static org.eclipse.edc.protocol.dsp.transferprocess.transform.to.TestInput.getExpanded; import static org.eclipse.edc.spi.constants.CoreConstants.EDC_NAMESPACE; @@ -55,10 +55,10 @@ class JsonObjectToTransferRequestMessageTransformerTest { void jsonObjectToTransferRequestWithoutDataAddress() { var json = Json.createObjectBuilder() .add(TYPE, DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID, contractId) + .add(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID_IRI, contractId) .add(DCT_FORMAT_ATTRIBUTE, destinationType) .add(DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI, callbackAddress) - .add(DSPACE_PROPERTY_CONSUMER_PID, "processId") + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "processId") .build(); var result = transformer.transform(getExpanded(json), context); @@ -79,11 +79,11 @@ void jsonObjectToTransferRequestWithDataAddress() { when(context.transform(any(), eq(DataAddress.class))).thenReturn(dataDestination); var json = Json.createObjectBuilder() .add(TYPE, DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID, contractId) + .add(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID_IRI, contractId) .add(DCT_FORMAT_ATTRIBUTE, destinationType) - .add(DSPACE_PROPERTY_DATA_ADDRESS, createDataAddress()) + .add(DSPACE_PROPERTY_DATA_ADDRESS_IRI, createDataAddress()) .add(DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI, callbackAddress) - .add(DSPACE_PROPERTY_CONSUMER_PID, "processId") + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "processId") .build(); var result = transformer.transform(getExpanded(json), context); @@ -102,9 +102,9 @@ void shouldReturnNullAndReportError_whenConsumerPidNotSet() { when(context.problem()).thenReturn(new ProblemBuilder(context)); var json = Json.createObjectBuilder() .add(TYPE, DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID, contractId) + .add(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID_IRI, contractId) .add(DCT_FORMAT_ATTRIBUTE, destinationType) - .add(DSPACE_PROPERTY_DATA_ADDRESS, Json.createObjectBuilder().build()) + .add(DSPACE_PROPERTY_DATA_ADDRESS_IRI, Json.createObjectBuilder().build()) .add(DSPACE_PROPERTY_CALLBACK_ADDRESS_IRI, callbackAddress) .build(); diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferStartMessageTransformerTest.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferStartMessageTransformerTest.java similarity index 85% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferStartMessageTransformerTest.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferStartMessageTransformerTest.java index 80a6dd3bdaf..bee4a2853fb 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferStartMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferStartMessageTransformerTest.java @@ -24,9 +24,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_DATA_ADDRESS; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_PROPERTY_DATA_ADDRESS_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_START_MESSAGE_IRI; import static org.eclipse.edc.protocol.dsp.transferprocess.transform.to.TestInput.getExpanded; import static org.eclipse.edc.spi.constants.CoreConstants.EDC_NAMESPACE; @@ -49,8 +49,8 @@ class JsonObjectToTransferStartMessageTransformerTest { void jsonObjectToTransferStartMessage() { var json = Json.createObjectBuilder() .add(TYPE, DSPACE_TYPE_TRANSFER_START_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") .build(); var result = transformer.transform(getExpanded(json), context); @@ -80,9 +80,9 @@ void jsonObjectToTransferStartMessageWithDataAddress() { var dataAddressObject = Json.createObjectBuilder().add(EDC_NAMESPACE + "type", "AWS").build(); var json = Json.createObjectBuilder() .add(TYPE, DSPACE_TYPE_TRANSFER_START_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") - .add(DSPACE_PROPERTY_DATA_ADDRESS, dataAddressObject) + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") + .add(DSPACE_PROPERTY_DATA_ADDRESS_IRI, dataAddressObject) .build(); var dataAddress = DataAddress.Builder.newInstance().type("AWS").build(); @@ -101,9 +101,9 @@ void jsonObjectToTransferStartMessageWithDataAddress() { void jsonObjectToTransferStartMessageWithEmptyDataAddress() { var json = Json.createObjectBuilder() .add(TYPE, DSPACE_TYPE_TRANSFER_START_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") - .add(DSPACE_PROPERTY_DATA_ADDRESS, Json.createObjectBuilder().build()) + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") + .add(DSPACE_PROPERTY_DATA_ADDRESS_IRI, Json.createObjectBuilder().build()) .build(); var result = transformer.transform(getExpanded(json), context); diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferSuspensionMessageTransformerTest.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferSuspensionMessageTransformerTest.java similarity index 85% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferSuspensionMessageTransformerTest.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferSuspensionMessageTransformerTest.java index 2742956b8d6..a78cc9842d2 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferSuspensionMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferSuspensionMessageTransformerTest.java @@ -32,11 +32,11 @@ import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.VALUE; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.VOCAB; import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON; -import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE_IRI; import static org.eclipse.edc.protocol.dsp.transferprocess.transform.to.TestInput.getExpanded; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; @@ -55,11 +55,11 @@ class JsonObjectToTransferSuspensionMessageTransformerTest { void shouldTransform() { var json = createObjectBuilder() .add(CONTEXT, createObjectBuilder().add(VOCAB, DSPACE_SCHEMA)) - .add(TYPE, DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") - .add(DSPACE_PROPERTY_CODE, "testCode") - .add(DSPACE_PROPERTY_REASON, Json.createArrayBuilder() + .add(TYPE, DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE_IRI) + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") + .add(DSPACE_PROPERTY_CODE_IRI, "testCode") + .add(DSPACE_PROPERTY_REASON_IRI, Json.createArrayBuilder() .add(createObjectBuilder().add("complex", "reason")) .add("reason")) .build(); @@ -84,9 +84,9 @@ void shouldReportError_whenMissingPids() { var reasonArray = Json.createBuilderFactory(Map.of()).createArrayBuilder().add(reason).build(); var json = createObjectBuilder() - .add(TYPE, DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE) - .add(DSPACE_PROPERTY_CODE, "testCode") - .add(DSPACE_PROPERTY_REASON, Json.createBuilderFactory(Map.of()).createArrayBuilder().add(reasonArray).build()) + .add(TYPE, DSPACE_TYPE_TRANSFER_SUSPENSION_MESSAGE_IRI) + .add(DSPACE_PROPERTY_CODE_IRI, "testCode") + .add(DSPACE_PROPERTY_REASON_IRI, Json.createBuilderFactory(Map.of()).createArrayBuilder().add(reasonArray).build()) .build(); var result = transformer.transform(getExpanded(json), context); diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferTerminationMessageTransformerTest.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferTerminationMessageTransformerTest.java similarity index 83% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferTerminationMessageTransformerTest.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferTerminationMessageTransformerTest.java index 9567941ac33..f1c35b09dc6 100644 --- a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferTerminationMessageTransformerTest.java +++ b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/JsonObjectToTransferTerminationMessageTransformerTest.java @@ -26,10 +26,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROVIDER_PID_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspTransferProcessPropertyAndTypeNames.DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_IRI; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; @@ -50,10 +50,10 @@ void shouldTransform() { var json = Json.createObjectBuilder() .add(TYPE, DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CONSUMER_PID, "consumerPid") - .add(DSPACE_PROPERTY_PROVIDER_PID, "providerPid") - .add(DSPACE_PROPERTY_CODE, "testCode") - .add(DSPACE_PROPERTY_REASON, Json.createBuilderFactory(Map.of()).createArrayBuilder().add(reasonArray).build()) + .add(DSPACE_PROPERTY_CONSUMER_PID_IRI, "consumerPid") + .add(DSPACE_PROPERTY_PROVIDER_PID_IRI, "providerPid") + .add(DSPACE_PROPERTY_CODE_IRI, "testCode") + .add(DSPACE_PROPERTY_REASON_IRI, Json.createBuilderFactory(Map.of()).createArrayBuilder().add(reasonArray).build()) .build(); var result = transformer.transform(TestInput.getExpanded(json), context); @@ -76,8 +76,8 @@ void shouldReportError_whenMissingPids() { var json = Json.createObjectBuilder() .add(TYPE, DSPACE_TYPE_TRANSFER_TERMINATION_MESSAGE_IRI) - .add(DSPACE_PROPERTY_CODE, "testCode") - .add(DSPACE_PROPERTY_REASON, Json.createBuilderFactory(Map.of()).createArrayBuilder().add(reasonArray).build()) + .add(DSPACE_PROPERTY_CODE_IRI, "testCode") + .add(DSPACE_PROPERTY_REASON_IRI, Json.createBuilderFactory(Map.of()).createArrayBuilder().add(reasonArray).build()) .build(); var result = transformer.transform(TestInput.getExpanded(json), context); diff --git a/data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/TestInput.java b/data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/TestInput.java similarity index 100% rename from data-protocols/dsp/dsp-transfer-process/dsp-transfer-process-transform/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/TestInput.java rename to data-protocols/dsp/dsp-transfer-process/lib/dsp-transfer-process-transform-lib/src/test/java/org/eclipse/edc/protocol/dsp/transferprocess/transform/to/TestInput.java diff --git a/data-protocols/dsp/dsp-version/dsp-version-http-api/src/main/java/org/eclipse/edc/protocol/dsp/version/http/api/transformer/JsonObjectFromVersionsError.java b/data-protocols/dsp/dsp-version/dsp-version-http-api/src/main/java/org/eclipse/edc/protocol/dsp/version/http/api/transformer/JsonObjectFromVersionsError.java index 90afca469a6..f275aca3390 100644 --- a/data-protocols/dsp/dsp-version/dsp-version-http-api/src/main/java/org/eclipse/edc/protocol/dsp/version/http/api/transformer/JsonObjectFromVersionsError.java +++ b/data-protocols/dsp/dsp-version/dsp-version-http-api/src/main/java/org/eclipse/edc/protocol/dsp/version/http/api/transformer/JsonObjectFromVersionsError.java @@ -23,8 +23,8 @@ import org.jetbrains.annotations.Nullable; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspVersionPropertyAndTypeNames.DSPACE_TYPE_VERSIONS_ERROR; /** @@ -43,8 +43,8 @@ public JsonObjectFromVersionsError(JsonBuilderFactory jsonFactory) { public @Nullable JsonObject transform(@NotNull VersionsError error, @NotNull TransformerContext context) { return jsonFactory.createObjectBuilder() .add(TYPE, DSPACE_TYPE_VERSIONS_ERROR) - .add(DSPACE_PROPERTY_CODE, error.getCode()) - .add(DSPACE_PROPERTY_REASON, jsonFactory.createArrayBuilder(error.getMessages())) + .add(DSPACE_PROPERTY_CODE_IRI, error.getCode()) + .add(DSPACE_PROPERTY_REASON_IRI, jsonFactory.createArrayBuilder(error.getMessages())) .build(); } } diff --git a/data-protocols/dsp/dsp-version/dsp-version-http-api/src/test/java/org/eclipse/edc/protocol/dsp/version/http/api/transformer/JsonObjectFromVersionsErrorTransformerTest.java b/data-protocols/dsp/dsp-version/dsp-version-http-api/src/test/java/org/eclipse/edc/protocol/dsp/version/http/api/transformer/JsonObjectFromVersionsErrorTransformerTest.java index 2036c1a552d..dbfecfa4e04 100644 --- a/data-protocols/dsp/dsp-version/dsp-version-http-api/src/test/java/org/eclipse/edc/protocol/dsp/version/http/api/transformer/JsonObjectFromVersionsErrorTransformerTest.java +++ b/data-protocols/dsp/dsp-version/dsp-version-http-api/src/test/java/org/eclipse/edc/protocol/dsp/version/http/api/transformer/JsonObjectFromVersionsErrorTransformerTest.java @@ -26,8 +26,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE; -import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CODE_IRI; +import static org.eclipse.edc.protocol.dsp.spi.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_REASON_IRI; import static org.eclipse.edc.protocol.dsp.spi.type.DspVersionPropertyAndTypeNames.DSPACE_TYPE_VERSIONS_ERROR; import static org.mockito.Mockito.mock; @@ -55,7 +55,7 @@ void transform_returnJsonObject() { assertThat(result).isNotNull(); assertThat(result.getJsonString(TYPE).getString()).isEqualTo(DSPACE_TYPE_VERSIONS_ERROR); - assertThat(result.getString(DSPACE_PROPERTY_CODE)).isEqualTo("code"); - assertThat(result.getJsonArray(DSPACE_PROPERTY_REASON)).contains(Json.createValue("message")); + assertThat(result.getString(DSPACE_PROPERTY_CODE_IRI)).isEqualTo("code"); + assertThat(result.getJsonArray(DSPACE_PROPERTY_REASON_IRI)).contains(Json.createValue("message")); } } diff --git a/settings.gradle.kts b/settings.gradle.kts index 4948a783224..5f572b01e63 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -85,12 +85,14 @@ include(":data-protocols:dsp:dsp-catalog:dsp-catalog-http-api") include(":data-protocols:dsp:dsp-catalog:dsp-catalog-http-dispatcher") include(":data-protocols:dsp:dsp-catalog:dsp-catalog-transform") include(":data-protocols:dsp:dsp-catalog:lib:dsp-catalog-validation-lib") +include(":data-protocols:dsp:dsp-catalog:lib:dsp-catalog-transform-lib") include(":data-protocols:dsp:dsp-spi") include(":data-protocols:dsp:dsp-negotiation") include(":data-protocols:dsp:dsp-negotiation:dsp-negotiation-http-api") include(":data-protocols:dsp:dsp-negotiation:dsp-negotiation-http-dispatcher") include(":data-protocols:dsp:dsp-negotiation:dsp-negotiation-transform") include(":data-protocols:dsp:dsp-negotiation:lib:dsp-negotiation-validation-lib") +include(":data-protocols:dsp:dsp-negotiation:lib:dsp-negotiation-transform-lib") include(":data-protocols:dsp:dsp-http-core") include(":data-protocols:dsp:dsp-http-spi") include(":data-protocols:dsp:dsp-transfer-process") @@ -98,6 +100,7 @@ include(":data-protocols:dsp:dsp-transfer-process:dsp-transfer-process-http-api" include(":data-protocols:dsp:dsp-transfer-process:dsp-transfer-process-http-dispatcher") include(":data-protocols:dsp:dsp-transfer-process:dsp-transfer-process-transform") include(":data-protocols:dsp:dsp-transfer-process:lib:dsp-transfer-process-validation-lib") +include(":data-protocols:dsp:dsp-transfer-process:lib:dsp-transfer-process-transform-lib") include(":data-protocols:dsp:dsp-version:dsp-version-http-api") // modules for technology- or cloud-provider extensions -------------------------------------------- diff --git a/spi/common/json-ld-spi/src/main/java/org/eclipse/edc/jsonld/spi/PropertyAndTypeNames.java b/spi/common/json-ld-spi/src/main/java/org/eclipse/edc/jsonld/spi/PropertyAndTypeNames.java index 9faccf4c85b..46e7c713005 100644 --- a/spi/common/json-ld-spi/src/main/java/org/eclipse/edc/jsonld/spi/PropertyAndTypeNames.java +++ b/spi/common/json-ld-spi/src/main/java/org/eclipse/edc/jsonld/spi/PropertyAndTypeNames.java @@ -75,6 +75,6 @@ public interface PropertyAndTypeNames { String ODRL_XONE_CONSTRAINT_ATTRIBUTE = ODRL_SCHEMA + "xone"; String ODRL_USE_ACTION_ATTRIBUTE = ODRL_SCHEMA + "use"; String ODRL_PROFILE_ATTRIBUTE = ODRL_SCHEMA + "profile"; - - String DSPACE_PROPERTY_PARTICIPANT_ID = DSPACE_SCHEMA + "participantId"; + String DSPACE_PROPERTY_PARTICIPANT_ID_TERM = "participantId"; + String DSPACE_PROPERTY_PARTICIPANT_ID_IRI = DSPACE_SCHEMA + DSPACE_PROPERTY_PARTICIPANT_ID_TERM; } diff --git a/spi/common/json-ld-spi/src/main/java/org/eclipse/edc/jsonld/spi/transformer/AbstractNamespaceAwareJsonLdTransformer.java b/spi/common/json-ld-spi/src/main/java/org/eclipse/edc/jsonld/spi/transformer/AbstractNamespaceAwareJsonLdTransformer.java new file mode 100644 index 00000000000..1b506faf1b6 --- /dev/null +++ b/spi/common/json-ld-spi/src/main/java/org/eclipse/edc/jsonld/spi/transformer/AbstractNamespaceAwareJsonLdTransformer.java @@ -0,0 +1,38 @@ +/* + * 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.jsonld.spi.transformer; + +/** + * Abstract base class for JSON-LD transformers that are aware of a specific namespace. + * This class extends {@link AbstractJsonLdTransformer} and provides additional functionality + * to handle namespace-specific transformations. + * + * @param the type of the input object to be transformed + * @param the type of the output object after transformation + */ +public abstract class AbstractNamespaceAwareJsonLdTransformer extends AbstractJsonLdTransformer { + + private final String namespace; + + protected AbstractNamespaceAwareJsonLdTransformer(Class input, Class output, String namespace) { + super(input, output); + this.namespace = namespace; + } + + protected String forNamespace(String term) { + return namespace + term; + } + +}