diff --git a/.config/pmd-rules.xml b/.config/pmd-rules.xml index c34c6d437f..f6e5a59671 100644 --- a/.config/pmd-rules.xml +++ b/.config/pmd-rules.xml @@ -59,7 +59,7 @@ - + diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d7724cf0d..bec05ce70c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,18 +8,13 @@ _**For better traceability add the corresponding GitHub issue number in each cha ## [Unreleased] -### Changed - -- BPN lookup feature was removed #568 - -## [5.1.0] - 2024-04-30 - - ### Changed - Removed obsolete entries from acceptedPolicies configuration. #530 - Support of building relationships based on SingleLevelUsageAsBuilt v3.0.0 #558 - Support of building relationships based on SingleLevelBomAsPlanned v3.0.0 #558 +- BPN lookup feature was removed #568 +- Update IRS EDC client to use EDC 0.7.0 #358 ### Fixed diff --git a/DEPENDENCIES b/DEPENDENCIES index ed985c44a1..6b6bec90a4 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -7,7 +7,7 @@ maven/mavencentral/com.aayushatharva.brotli4j/native-osx-aarch64/1.11.0, Apache- maven/mavencentral/com.aayushatharva.brotli4j/native-osx-x86_64/1.11.0, Apache-2.0, approved, clearlydefined maven/mavencentral/com.aayushatharva.brotli4j/native-windows-x86_64/1.11.0, Apache-2.0, approved, clearlydefined maven/mavencentral/com.aayushatharva.brotli4j/service/1.11.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/com.apicatalog/titanium-json-ld/1.3.2, Apache-2.0, approved, #8912 +maven/mavencentral/com.apicatalog/titanium-json-ld/1.4.0, Apache-2.0, approved, #13683 maven/mavencentral/com.carrotsearch.thirdparty/simple-xml-safe/2.7.1, Apache-2.0, approved, clearlydefined maven/mavencentral/com.eatthepath/fast-uuid/0.2.0, MIT, approved, clearlydefined maven/mavencentral/com.ethlo.time/itu/1.8.0, Apache-2.0, approved, #12927 @@ -20,12 +20,10 @@ maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.15.4, Apache-2. maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.16.1, Apache-2.0, approved, #11605 maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.15.3, Apache-2.0, approved, #8802 maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.15.4, Apache-2.0, approved, #8802 -maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jakarta-jsonp/2.15.2, Apache-2.0, approved, #9179 maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jakarta-jsonp/2.15.4, Apache-2.0, approved, #9179 +maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jakarta-jsonp/2.16.2, Apache-2.0, approved, #11854 maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jdk8/2.15.4, Apache-2.0, approved, #8808 maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.15.4, Apache-2.0, approved, #7930 -maven/mavencentral/com.fasterxml.jackson.module/jackson-module-jakarta-xmlbind-annotations/2.14.1, Apache-2.0, approved, #5308 -maven/mavencentral/com.fasterxml.jackson.module/jackson-module-jakarta-xmlbind-annotations/2.15.4, Apache-2.0, approved, #9241 maven/mavencentral/com.fasterxml.jackson.module/jackson-module-parameter-names/2.15.4, Apache-2.0, approved, #8803 maven/mavencentral/com.fasterxml/classmate/1.5.1, Apache-2.0, approved, clearlydefined maven/mavencentral/com.github.ben-manes.caffeine/caffeine/3.1.8, Apache-2.0, approved, clearlydefined @@ -39,12 +37,16 @@ maven/mavencentral/com.github.mifmif/generex/1.0.2, Apache-2.0, approved, clearl maven/mavencentral/com.github.scopt/scopt_2.13/3.7.1, MIT, approved, clearlydefined maven/mavencentral/com.github.stephenc.jcip/jcip-annotations/1.0-1, Apache-2.0, approved, CQ21949 maven/mavencentral/com.google.code.findbugs/jsr305/3.0.2, Apache-2.0, approved, #20 +maven/mavencentral/com.google.code.gson/gson/2.10.1, Apache-2.0, approved, #6159 +maven/mavencentral/com.google.crypto.tink/tink/1.12.0, Apache-2.0, approved, #12041 maven/mavencentral/com.google.errorprone/error_prone_annotations/2.21.1, Apache-2.0, approved, #9834 +maven/mavencentral/com.google.errorprone/error_prone_annotations/2.22.0, Apache-2.0, approved, #10661 maven/mavencentral/com.google.errorprone/error_prone_annotations/2.23.0, Apache-2.0, approved, #11083 maven/mavencentral/com.google.guava/failureaccess/1.0.2, Apache-2.0, approved, CQ22654 maven/mavencentral/com.google.guava/guava/33.0.0-jre, Apache-2.0 AND CC0-1.0, approved, #12173 maven/mavencentral/com.google.guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava, Apache-2.0, approved, CQ22657 maven/mavencentral/com.google.j2objc/j2objc-annotations/2.8, Apache-2.0, approved, clearlydefined +maven/mavencentral/com.google.protobuf/protobuf-java/3.24.3, BSD-3-Clause, approved, clearlydefined maven/mavencentral/com.jayway.jsonpath/json-path/2.9.0, Apache-2.0, approved, clearlydefined maven/mavencentral/com.networknt/json-schema-validator/1.4.0, Apache-2.0 AND Unicode-TOU, approved, #13812 maven/mavencentral/com.nimbusds/content-type/2.2, Apache-2.0, approved, clearlydefined @@ -53,7 +55,7 @@ maven/mavencentral/com.nimbusds/nimbus-jose-jwt/9.37.3, Apache-2.0, approved, #1 maven/mavencentral/com.nimbusds/oauth2-oidc-sdk/9.43.3, Apache-2.0, approved, clearlydefined maven/mavencentral/com.softwaremill.quicklens/quicklens_2.13/1.9.3, Apache-2.0, approved, #9635 maven/mavencentral/com.squareup.okhttp3/okhttp-dnsoverhttps/4.10.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/com.squareup.okhttp3/okhttp-dnsoverhttps/4.11.0, Apache-2.0, approved, clearlydefined +maven/mavencentral/com.squareup.okhttp3/okhttp-dnsoverhttps/4.12.0, Apache-2.0, approved, #11159 maven/mavencentral/com.squareup.okhttp3/okhttp/4.10.0, Apache-2.0 AND MPL-2.0, approved, #3057 maven/mavencentral/com.squareup.okhttp3/okhttp/4.12.0, Apache-2.0, approved, #11156 maven/mavencentral/com.squareup.okio/okio-jvm/3.5.0, Apache-2.0, approved, #9851 @@ -158,9 +160,9 @@ maven/mavencentral/io.netty/netty-transport-native-epoll/4.1.109.Final, Apache-2 maven/mavencentral/io.netty/netty-transport-native-unix-common/4.1.109.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-transport/4.1.109.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.opentelemetry/opentelemetry-api/1.25.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/io.opentelemetry/opentelemetry-api/1.29.0, Apache-2.0, approved, #10088 +maven/mavencentral/io.opentelemetry/opentelemetry-api/1.32.0, Apache-2.0, approved, #11682 maven/mavencentral/io.opentelemetry/opentelemetry-context/1.25.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/io.opentelemetry/opentelemetry-context/1.29.0, Apache-2.0, approved, #10090 +maven/mavencentral/io.opentelemetry/opentelemetry-context/1.32.0, Apache-2.0, approved, #11683 maven/mavencentral/io.pebbletemplates/pebble/3.2.1, BSD-3-Clause, approved, clearlydefined maven/mavencentral/io.prometheus/simpleclient/0.16.0, Apache-2.0, approved, clearlydefined maven/mavencentral/io.prometheus/simpleclient_common/0.16.0, Apache-2.0, approved, clearlydefined @@ -175,17 +177,14 @@ maven/mavencentral/io.rest-assured/rest-assured/5.4.0, Apache-2.0, approved, #12 maven/mavencentral/io.rest-assured/xml-path/5.3.2, Apache-2.0, approved, #9267 maven/mavencentral/io.rest-assured/xml-path/5.4.0, Apache-2.0, approved, #12038 maven/mavencentral/io.suzaku/boopickle_2.13/1.3.3, Apache-2.0, approved, clearlydefined -maven/mavencentral/io.swagger.core.v3/swagger-annotations-jakarta/2.2.15, Apache-2.0, approved, #5947 +maven/mavencentral/io.swagger.core.v3/swagger-annotations-jakarta/2.2.20, Apache-2.0, approved, #5947 maven/mavencentral/io.swagger.core.v3/swagger-annotations/2.2.18, Apache-2.0, approved, #11362 maven/mavencentral/io.swagger.core.v3/swagger-core-jakarta/2.2.15, Apache-2.0, approved, #5929 maven/mavencentral/io.swagger.core.v3/swagger-models-jakarta/2.2.15, Apache-2.0, approved, #5919 maven/mavencentral/jakarta.activation/jakarta.activation-api/2.1.3, EPL-2.0 OR BSD-3-Clause OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jaf maven/mavencentral/jakarta.annotation/jakarta.annotation-api/2.1.1, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.ca -maven/mavencentral/jakarta.inject/jakarta.inject-api/2.0.1, Apache-2.0, approved, ee4j.cdi maven/mavencentral/jakarta.json/jakarta.json-api/2.1.1, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jsonp maven/mavencentral/jakarta.json/jakarta.json-api/2.1.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jsonp -maven/mavencentral/jakarta.transaction/jakarta.transaction-api/2.0.0, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jta -maven/mavencentral/jakarta.transaction/jakarta.transaction-api/2.0.1, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jta maven/mavencentral/jakarta.validation/jakarta.validation-api/3.0.2, Apache-2.0, approved, ee4j.validation maven/mavencentral/jakarta.ws.rs/jakarta.ws.rs-api/3.1.0, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.rest maven/mavencentral/jakarta.xml.bind/jakarta.xml.bind-api/4.0.2, BSD-3-Clause, approved, ee4j.jaxb @@ -208,6 +207,7 @@ maven/mavencentral/net.minidev/accessors-smart/2.5.1, Apache-2.0, approved, clea maven/mavencentral/net.minidev/json-smart/2.4.11, Apache-2.0, approved, #3288 maven/mavencentral/net.minidev/json-smart/2.5.1, Apache-2.0, approved, clearlydefined maven/mavencentral/net.sf.saxon/Saxon-HE/10.6, MPL-2.0 AND W3C, approved, #7945 +maven/mavencentral/org.apache.commons/commons-collections4/4.4, Apache-2.0, approved, clearlydefined maven/mavencentral/org.apache.commons/commons-compress/1.26.0, Apache-2.0 AND (Apache-2.0 AND BSD-3-Clause), approved, #13288 maven/mavencentral/org.apache.commons/commons-compress/1.26.1, Apache-2.0 AND (Apache-2.0 AND BSD-3-Clause), approved, #13288 maven/mavencentral/org.apache.commons/commons-lang3/3.12.0, Apache-2.0, approved, clearlydefined @@ -236,136 +236,84 @@ maven/mavencentral/org.bouncycastle/bcutil-jdk18on/1.78, MIT, approved, #14435 maven/mavencentral/org.ccil.cowan.tagsoup/tagsoup/1.2.1, Apache-2.0, approved, clearlydefined maven/mavencentral/org.checkerframework/checker-qual/3.37.0, MIT, approved, clearlydefined maven/mavencentral/org.checkerframework/checker-qual/3.41.0, MIT, approved, #12032 -maven/mavencentral/org.eclipse.edc/aggregate-service-spi/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/asset-spi/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/catalog-spi/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/connector-core/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/contract-spi/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/control-plane-spi/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/core-spi/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/dsp-api-configuration/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/dsp-catalog-api/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/dsp-catalog-http-dispatcher/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/dsp-catalog-transform/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/dsp-catalog/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/dsp-http-core/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/dsp-http-spi/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/dsp-negotiation-api/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/dsp-negotiation-http-dispatcher/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/dsp-negotiation-transform/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/dsp-negotiation/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/dsp-spi/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/dsp-transfer-process-api/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/dsp-transfer-process-http-dispatcher/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/dsp-transfer-process-transform/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/dsp-transfer-process/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/dsp/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/http-spi/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/http/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/jersey-core/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/jersey-providers/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/jetty-core/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/json-ld-spi/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/json-ld/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/policy-engine-spi/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/policy-engine/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/policy-evaluator/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/policy-model/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/policy-spi/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/runtime-metamodel/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/transaction-datasource-spi/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/transaction-spi/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/transfer-data-plane-spi/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/transfer-spi/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/transform-core/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/transform-spi/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/util/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/validator-core/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/validator-spi/0.2.1, Apache-2.0, approved, technology.edc -maven/mavencentral/org.eclipse.edc/web-spi/0.2.1, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/api-core/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/asset-api/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/auth-spi/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/boot-lib/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/catalog-api/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/catalog-spi/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/connector-core/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/contract-agreement-api/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/contract-definition-api/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/contract-negotiation-api/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/contract-spi/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/control-plane-spi/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/core-spi/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-api-configuration/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-catalog-api/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-catalog-http-dispatcher/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-catalog-transform/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-catalog/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-http-core/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-http-spi/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-negotiation-api/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-negotiation-http-dispatcher/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-negotiation-transform/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-negotiation/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-spi/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-transfer-process-api/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-transfer-process-http-dispatcher/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-transfer-process-transform/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-transfer-process/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp-version-api/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/dsp/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/http-lib/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/http-spi/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/jersey-providers-lib/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/json-ld-lib/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/json-ld-spi/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/json-ld/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/keys-lib/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/keys-spi/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/management-api-configuration/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/management-api/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/policy-definition-api/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/policy-engine-lib/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/policy-engine-spi/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/policy-evaluator-lib/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/policy-model/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/policy-spi/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/query-lib/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/runtime-metamodel/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/state-machine-lib/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/token-spi/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/transaction-datasource-spi/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/transaction-spi/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/transfer-process-api/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/transfer-spi/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/transform-core/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/transform-spi/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/util/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/validator-core/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/validator-spi/0.6.0, Apache-2.0, approved, technology.edc +maven/mavencentral/org.eclipse.edc/web-spi/0.6.0, Apache-2.0, approved, technology.edc maven/mavencentral/org.eclipse.jetty.toolchain/jetty-jakarta-servlet-api/5.0.2, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty.toolchain/jetty-jakarta-websocket-api/2.0.0, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty.websocket/websocket-core-client/11.0.17, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty.websocket/websocket-core-client/11.0.20, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty.websocket/websocket-core-common/11.0.17, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty.websocket/websocket-core-common/11.0.20, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty.websocket/websocket-core-server/11.0.17, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty.websocket/websocket-core-server/11.0.20, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty.websocket/websocket-jakarta-client/11.0.17, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty.websocket/websocket-jakarta-client/11.0.20, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty.websocket/websocket-jakarta-common/11.0.17, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty.websocket/websocket-jakarta-common/11.0.20, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty.websocket/websocket-jakarta-server/11.0.17, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty.websocket/websocket-jakarta-server/11.0.20, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty.websocket/websocket-servlet/11.0.17, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty.websocket/websocket-servlet/11.0.20, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-alpn-client/11.0.17, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-alpn-client/11.0.20, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-annotations/11.0.17, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-annotations/11.0.20, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-client/11.0.17, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-client/11.0.20, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-http/11.0.17, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-http/11.0.20, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-io/11.0.17, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-io/11.0.20, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-jndi/11.0.17, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-jndi/11.0.20, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-plus/11.0.17, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-plus/11.0.20, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-security/11.0.17, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-security/11.0.20, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-server/11.0.17, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-server/11.0.20, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-servlet/11.0.17, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-servlet/11.0.20, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-util/11.0.17, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-util/11.0.20, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-webapp/11.0.17, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-webapp/11.0.20, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-xml/11.0.17, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.eclipse.jetty/jetty-xml/11.0.20, EPL-2.0 OR Apache-2.0, approved, rt.jetty +maven/mavencentral/org.eclipse.tractusx.edc/callback-spi/0.6.0, Apache-2.0, approved, automotive.tractusx +maven/mavencentral/org.eclipse.tractusx.edc/core-spi/0.6.0, Apache-2.0, approved, automotive.tractusx +maven/mavencentral/org.eclipse.tractusx.edc/edr-api/0.6.0, Apache-2.0, approved, automotive.tractusx +maven/mavencentral/org.eclipse.tractusx.edc/edr-spi/0.6.0, Apache-2.0, approved, automotive.tractusx maven/mavencentral/org.eclipse.tractusx.irs/irs-api/0.0.2-SNAPSHOT, Apache-2.0, approved, automotive.tractusx -maven/mavencentral/org.eclipse.tractusx.irs/irs-common/1.10.0-SNAPSHOT, Apache-2.0, approved, automotive.tractusx -maven/mavencentral/org.eclipse.tractusx.irs/irs-edc-client/1.10.0-SNAPSHOT, Apache-2.0, approved, automotive.tractusx -maven/mavencentral/org.eclipse.tractusx.irs/irs-models/1.10.0-SNAPSHOT, Apache-2.0, approved, automotive.tractusx +maven/mavencentral/org.eclipse.tractusx.irs/irs-common/1.11.0-SNAPSHOT, Apache-2.0, approved, automotive.tractusx +maven/mavencentral/org.eclipse.tractusx.irs/irs-edc-client/1.11.0-SNAPSHOT, Apache-2.0, approved, automotive.tractusx +maven/mavencentral/org.eclipse.tractusx.irs/irs-models/1.11.0-SNAPSHOT, Apache-2.0, approved, automotive.tractusx maven/mavencentral/org.eclipse.tractusx.irs/irs-policy-store/0.0.2-SNAPSHOT, Apache-2.0, approved, automotive.tractusx -maven/mavencentral/org.eclipse.tractusx.irs/irs-registry-client/1.10.0-SNAPSHOT, Apache-2.0, approved, automotive.tractusx -maven/mavencentral/org.eclipse.tractusx.irs/irs-testing/1.10.0-SNAPSHOT, Apache-2.0, approved, automotive.tractusx -maven/mavencentral/org.glassfish.hk2.external/aopalliance-repackaged/3.0.4, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.glassfish -maven/mavencentral/org.glassfish.hk2.external/aopalliance-repackaged/3.0.6, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.glassfish -maven/mavencentral/org.glassfish.hk2/hk2-api/3.0.4, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.glassfish -maven/mavencentral/org.glassfish.hk2/hk2-api/3.0.6, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.glassfish -maven/mavencentral/org.glassfish.hk2/hk2-locator/3.0.4, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.glassfish -maven/mavencentral/org.glassfish.hk2/hk2-locator/3.0.6, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.glassfish -maven/mavencentral/org.glassfish.hk2/hk2-utils/3.0.4, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.glassfish -maven/mavencentral/org.glassfish.hk2/hk2-utils/3.0.6, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.glassfish -maven/mavencentral/org.glassfish.hk2/osgi-resource-locator/1.0.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.glassfish -maven/mavencentral/org.glassfish.jersey.containers/jersey-container-servlet-core/3.1.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.containers/jersey-container-servlet-core/3.1.6, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.containers/jersey-container-servlet/3.1.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.containers/jersey-container-servlet/3.1.6, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.core/jersey-client/3.1.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.core/jersey-client/3.1.6, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.core/jersey-common/3.1.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.core/jersey-common/3.1.6, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.core/jersey-server/3.1.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.core/jersey-server/3.1.6, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.ext/jersey-entity-filtering/3.1.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.ext/jersey-entity-filtering/3.1.6, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.inject/jersey-hk2/3.1.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.inject/jersey-hk2/3.1.6, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.media/jersey-media-json-jackson/3.1.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.media/jersey-media-json-jackson/3.1.6, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.media/jersey-media-multipart/3.1.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.media/jersey-media-multipart/3.1.6, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey +maven/mavencentral/org.eclipse.tractusx.irs/irs-registry-client/1.11.0-SNAPSHOT, Apache-2.0, approved, automotive.tractusx +maven/mavencentral/org.eclipse.tractusx.irs/irs-testing/1.11.0-SNAPSHOT, Apache-2.0, approved, automotive.tractusx maven/mavencentral/org.glassfish/jakarta.json/2.0.1, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jsonp maven/mavencentral/org.hamcrest/hamcrest-core/2.2, BSD-3-Clause, approved, clearlydefined maven/mavencentral/org.hamcrest/hamcrest/2.2, BSD-3-Clause, approved, clearlydefined maven/mavencentral/org.hdrhistogram/HdrHistogram/2.1.12, BSD-2-Clause OR LicenseRef-Public-Domain, approved, CQ13192 maven/mavencentral/org.hibernate.validator/hibernate-validator/8.0.1.Final, Apache-2.0, approved, clearlydefined -maven/mavencentral/org.javassist/javassist/3.29.2-GA, Apache-2.0 AND LGPL-2.1-or-later AND MPL-1.1, approved, #6023 -maven/mavencentral/org.javassist/javassist/3.30.2-GA, Apache-2.0 AND LGPL-2.1-or-later AND MPL-1.1, approved, #12108 maven/mavencentral/org.jboss.logging/jboss-logging/3.4.3.Final, Apache-2.0, approved, CQ21255 maven/mavencentral/org.jboss.logging/jboss-logging/3.5.3.Final, Apache-2.0, approved, #9471 maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-common/1.8.22, Apache-2.0, approved, #8910 @@ -378,7 +326,7 @@ maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib/1.8.21, Apache-2.0, approv maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib/1.8.22, Apache-2.0, approved, #8865 maven/mavencentral/org.jetbrains/annotations/13.0, Apache-2.0, approved, clearlydefined maven/mavencentral/org.jetbrains/annotations/17.0.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/org.jetbrains/annotations/24.0.1, Apache-2.0, approved, #7417 +maven/mavencentral/org.jetbrains/annotations/24.1.0, Apache-2.0, approved, clearlydefined maven/mavencentral/org.jodd/jodd-lagarto/6.0.6, BSD-2-Clause, approved, clearlydefined maven/mavencentral/org.jodd/jodd-util/6.1.0, BSD-2-Clause, approved, clearlydefined maven/mavencentral/org.jsoup/jsoup/1.17.2, MIT AND Apache-2.0, approved, #11785 @@ -399,14 +347,11 @@ maven/mavencentral/org.junit.platform/junit-platform-suite-api/1.9.2, EPL-2.0, a maven/mavencentral/org.junit.platform/junit-platform-suite-commons/1.9.2, EPL-2.0, approved, #3131 maven/mavencentral/org.junit.platform/junit-platform-suite-engine/1.9.2, EPL-2.0, approved, #3135 maven/mavencentral/org.junit.platform/junit-platform-suite/1.9.2, EPL-2.0, approved, #10175 -maven/mavencentral/org.jvnet.mimepull/mimepull/1.9.15, CDDL-1.1 OR GPL-2.0-only WITH Classpath-exception-2.0, approved, CQ21484 maven/mavencentral/org.latencyutils/LatencyUtils/2.0.3, BSD-2-Clause, approved, CQ17408 maven/mavencentral/org.mockito/mockito-core/5.3.1, MIT AND (Apache-2.0 AND MIT) AND Apache-2.0, approved, #7925 maven/mavencentral/org.mockito/mockito-junit-jupiter/5.3.1, MIT, approved, clearlydefined maven/mavencentral/org.objenesis/objenesis/3.3, Apache-2.0, approved, clearlydefined maven/mavencentral/org.opentest4j/opentest4j/1.2.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/org.ow2.asm/asm-commons/9.6, BSD-3-Clause, approved, #10775 -maven/mavencentral/org.ow2.asm/asm-tree/9.6, BSD-3-Clause, approved, #10773 maven/mavencentral/org.ow2.asm/asm/9.3, BSD-3-Clause, approved, clearlydefined maven/mavencentral/org.ow2.asm/asm/9.6, BSD-3-Clause, approved, #10776 maven/mavencentral/org.projectlombok/lombok/1.18.32, MIT AND LicenseRef-Public-Domain, approved, CQ23907 diff --git a/charts/item-relationship-service/CHANGELOG.md b/charts/item-relationship-service/CHANGELOG.md index 13e3089fc4..3dc58e9af0 100644 --- a/charts/item-relationship-service/CHANGELOG.md +++ b/charts/item-relationship-service/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fix for incomplete renaming of Helm chart (see #489) - +- Fixed missing Spring attribute #358 ## [7.0.1] - 2024-04-17 diff --git a/charts/item-relationship-service/templates/configmap-spring-app-config.yaml b/charts/item-relationship-service/templates/configmap-spring-app-config.yaml index 3b20ef49e3..1fbb9c2e46 100644 --- a/charts/item-relationship-service/templates/configmap-spring-app-config.yaml +++ b/charts/item-relationship-service/templates/configmap-spring-app-config.yaml @@ -57,9 +57,11 @@ data: client: registration: semantics: + authorization-grant-type: client_credentials client-id: "${SEMANTICS_OAUTH2_CLIENT_ID}" # taken from secret ENV client-secret: "${SEMANTICS_OAUTH2_CLIENT_SECRET}" # taken from secret ENV discovery: + authorization-grant-type: client_credentials client-id: ${DISCOVERY_OAUTH2_CLIENT_ID} # taken from secret ENV client-secret: ${DISCOVERY_OAUTH2_CLIENT_SECRET} # taken from secret ENV provider: diff --git a/irs-api/src/main/resources/application.yml b/irs-api/src/main/resources/application.yml index f315165d93..324a19dbe3 100644 --- a/irs-api/src/main/resources/application.yml +++ b/irs-api/src/main/resources/application.yml @@ -9,7 +9,7 @@ spring: oauth2: client: registration: - semantics : + semantics: authorization-grant-type: client_credentials client-id: ${SEMANTICS_OAUTH2_CLIENT_ID} # Semantic Hub OAuth2 client ID used to authenticate with the IAM client-secret: ${SEMANTICS_OAUTH2_CLIENT_SECRET} # Semantic Hub OAuth2 client secret used to authenticate with the IAM diff --git a/irs-api/src/test/java/org/eclipse/tractusx/irs/IrsWireMockIntegrationTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/IrsWireMockIntegrationTest.java index af019fd55b..562083bfac 100644 --- a/irs-api/src/test/java/org/eclipse/tractusx/irs/IrsWireMockIntegrationTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/IrsWireMockIntegrationTest.java @@ -28,6 +28,8 @@ import static org.eclipse.tractusx.irs.WiremockSupport.createEndpointDataReference; import static org.eclipse.tractusx.irs.WiremockSupport.encodedAssetIds; import static org.eclipse.tractusx.irs.WiremockSupport.randomUUID; +import static org.eclipse.tractusx.irs.component.enums.AspectType.AspectTypesConstants.BATCH; +import static org.eclipse.tractusx.irs.component.enums.AspectType.AspectTypesConstants.SINGLE_LEVEL_BOM_AS_BUILT; import static org.eclipse.tractusx.irs.testing.wiremock.DiscoveryServiceWiremockSupport.DISCOVERY_FINDER_PATH; import static org.eclipse.tractusx.irs.testing.wiremock.DiscoveryServiceWiremockSupport.DISCOVERY_FINDER_URL; import static org.eclipse.tractusx.irs.testing.wiremock.DiscoveryServiceWiremockSupport.EDC_DISCOVERY_PATH; @@ -58,7 +60,6 @@ import org.eclipse.tractusx.irs.component.Jobs; import org.eclipse.tractusx.irs.component.RegisterJob; import org.eclipse.tractusx.irs.component.enums.JobState; -import org.eclipse.tractusx.irs.data.StringMapper; import org.eclipse.tractusx.irs.edc.client.EndpointDataReferenceStorage; import org.eclipse.tractusx.irs.semanticshub.AspectModels; import org.eclipse.tractusx.irs.semanticshub.SemanticHubWireMockSupport; @@ -111,12 +112,6 @@ static void startContainer() { WiremockSupport.successfulSemanticModelRequest(); } - @AfterEach - void tearDown() { - cacheManager.getCacheNames() - .forEach(cacheName -> Objects.requireNonNull(cacheManager.getCache(cacheName)).clear()); - } - @AfterAll static void stopContainer() { minioContainer.stop(); @@ -141,6 +136,12 @@ static void configureProperties(DynamicPropertyRegistry registry) { registry.add("resilience4j.retry.configs.default.waitDuration", () -> "1s"); } + @AfterEach + void tearDown() { + cacheManager.getCacheNames() + .forEach(cacheName -> Objects.requireNonNull(cacheManager.getCache(cacheName)).clear()); + } + @Test void shouldStartApplicationAndCollectSemanticModels() throws SchemaNotFoundException { // Arrange @@ -264,7 +265,6 @@ void shouldStartRecursiveProcesses() { assertThat(jobHandle.getId()).isNotNull(); waitForCompletion(jobHandle); final Jobs jobForJobId = irsService.getJobForJobId(jobHandle.getId(), false); - System.out.println(StringMapper.mapToString(jobForJobId)); assertThat(jobForJobId.getJob().getState()).isEqualTo(JobState.COMPLETED); assertThat(jobForJobId.getShells()).hasSize(3); @@ -280,10 +280,9 @@ private void successfulRegistryAndDataRequest(final String globalAssetId, final final String batchFileName, final String sbomFileName) { final String edcAssetId = WiremockSupport.randomUUIDwithPrefix(); - final String batch = WiremockSupport.submodelRequest(edcAssetId, "Batch", - batchAspectName, batchFileName); + final String batch = WiremockSupport.submodelRequest(edcAssetId, BATCH, batchAspectName, batchFileName); - final String singleLevelBomAsBuilt = WiremockSupport.submodelRequest(edcAssetId, "SingleLevelBomAsBuilt", + final String singleLevelBomAsBuilt = WiremockSupport.submodelRequest(edcAssetId, SINGLE_LEVEL_BOM_AS_BUILT, singleLevelBomAsBuiltAspectName, sbomFileName); final List submodelDescriptors = List.of(batch, singleLevelBomAsBuilt); diff --git a/irs-api/src/test/java/org/eclipse/tractusx/irs/WiremockSupport.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/WiremockSupport.java index 33fe3a36c4..58d4a1fe29 100644 --- a/irs-api/src/test/java/org/eclipse/tractusx/irs/WiremockSupport.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/WiremockSupport.java @@ -66,7 +66,9 @@ public static EndpointDataReference createEndpointDataReference(final String con .getBytes(StandardCharsets.UTF_8)); final String jwtToken = "eyJhbGciOiJSUzI1NiJ9." + b64EncodedAuthCode + ".test"; return EndpointDataReference.Builder.newInstance() - .authKey("testkey") + .contractId(contractAgreementId) + .authKey("Authorization") + .id("test") .authCode(jwtToken) .properties( Map.of(JsonLdConfiguration.NAMESPACE_EDC_CID, contractAgreementId)) diff --git a/irs-edc-client/pom.xml b/irs-edc-client/pom.xml index 0ebeaecf83..6d88117cab 100644 --- a/irs-edc-client/pom.xml +++ b/irs-edc-client/pom.xml @@ -59,6 +59,11 @@ commons-validator ${commons-validator.version} + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + org.apache.commons commons-lang3 @@ -96,78 +101,80 @@ swagger-annotations ${swagger-annotations.version} + org.eclipse.edc - connector-core + management-api ${edc.version} - runtime-metamodel - org.eclipse.edc - - - org.bouncycastle - bcprov-jdk18on - - - org.bouncycastle - bcpkix-jdk18on + swagger-jaxrs2-jakarta + io.swagger.core.v3 - - - com.squareup.okio - okio-jvm - ${okio-jvm.version} - - org.bouncycastle - bcpkix-jdk18on - ${bc-jdk18on.version} - - - org.bouncycastle - bcprov-jdk18on - ${bc-jdk18on.version} + org.eclipse.edc + policy-engine-lib + ${edc.version} org.eclipse.edc - dsp + connector-core ${edc.version} - runtime-metamodel + bcpkix-jdk18on + org.bouncycastle + + + policy-engine-lib org.eclipse.edc - websocket-jakarta-server - org.eclipse.jetty.websocket + policy-engine-spi + org.eclipse.edc - - org.eclipse.jetty.websocket - websocket-jakarta-server - 11.0.17 - org.eclipse.edc - json-ld + dsp ${edc.version} - runtime-metamodel - org.eclipse.edc + swagger-jaxrs2-jakarta + io.swagger.core.v3 - runtime-metamodel org.eclipse.edc + json-ld-lib ${edc.version} + + org.eclipse.tractusx.edc + edr-api + ${edc.version} + + + management-api + org.eclipse.edc + + + validator-core + org.eclipse.edc + + + swagger-jaxrs2-jakarta + io.swagger.core.v3 + + + + + org.eclipse.tractusx.irs irs-common diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/ContractNegotiationService.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/ContractNegotiationService.java index 00205d2ec7..e944066e97 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/ContractNegotiationService.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/ContractNegotiationService.java @@ -23,8 +23,10 @@ ********************************************************************************/ package org.eclipse.tractusx.irs.edc.client; +import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -34,12 +36,13 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.eclipse.edc.spi.types.domain.DataAddress; +import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; import org.eclipse.tractusx.irs.edc.client.cache.endpointdatareference.EndpointDataReferenceStatus; import org.eclipse.tractusx.irs.edc.client.exceptions.ContractNegotiationException; import org.eclipse.tractusx.irs.edc.client.exceptions.TransferProcessException; import org.eclipse.tractusx.irs.edc.client.exceptions.UsagePolicyException; import org.eclipse.tractusx.irs.edc.client.model.CatalogItem; -import org.eclipse.tractusx.irs.edc.client.model.ContractOfferDescription; +import org.eclipse.tractusx.irs.edc.client.model.ContractOffer; import org.eclipse.tractusx.irs.edc.client.model.EDRAuthCode; import org.eclipse.tractusx.irs.edc.client.model.NegotiationRequest; import org.eclipse.tractusx.irs.edc.client.model.NegotiationResponse; @@ -60,6 +63,8 @@ public class ContractNegotiationService { public static final String EDC_PROTOCOL = "dataspace-protocol-http"; + public static final String EVENT_TRANSFER_PROCESS_STARTED = "transfer.process.started"; + public static final String HTTP_DATA_PULL = "HttpData-PULL"; private final EdcControlPlaneClient edcControlPlaneClient; private final PolicyCheckerService policyCheckerService; private final EdcConfiguration config; @@ -94,7 +99,7 @@ public NegotiationResponse negotiate(final String providerConnectorUrl, final Ca if (authCode == null) { throw new IllegalStateException("Missing information about AuthKey."); } - log.error("AuthCode to be parsed: " + authCode); + log.error("AuthCode to be parsed: {}", authCode); contractAgreementId = EDRAuthCode.fromAuthCodeToken(authCode).getCid(); log.info( "Cached endpoint data reference has expired token. Refreshing token without new contract negotiation for contractAgreementId: {}", @@ -148,30 +153,34 @@ private TransferProcessRequest createTransferProcessRequest(final String provide .managedResources( TransferProcessRequest.DEFAULT_MANAGED_RESOURCES) .connectorId(catalogItem.getConnectorId()) - .connectorAddress(providerConnectorUrl) + .counterPartyAddress(providerConnectorUrl) + .transferType(HTTP_DATA_PULL) .contractId(agreementId) .assetId(catalogItem.getAssetPropId()) .dataDestination(destination); if (StringUtils.isNotBlank(config.getCallbackUrl())) { log.info("Setting EDR callback to {}", config.getCallbackUrl()); transferProcessRequestBuilder.privateProperties(Map.of("receiverHttpEndpoint", config.getCallbackUrl())); + final CallbackAddress callbackAddress = CallbackAddress.Builder.newInstance() + .uri(config.getCallbackUrl()) + .events(Set.of( + EVENT_TRANSFER_PROCESS_STARTED)) + .build(); + transferProcessRequestBuilder.callbackAddresses(List.of(callbackAddress)); } return transferProcessRequestBuilder.build(); } private NegotiationRequest createNegotiationRequestFromCatalogItem(final String providerConnectorUrl, final CatalogItem catalogItem) { - final var contractOfferDescription = ContractOfferDescription.builder() - .offerId(catalogItem.getOfferId()) - .assetId(catalogItem.getPolicy().getTarget()) - .policy(catalogItem.getPolicy()) - .build(); return NegotiationRequest.builder() - .connectorId(catalogItem.getConnectorId()) - .connectorAddress(providerConnectorUrl) + .counterPartyAddress(providerConnectorUrl) + .counterPartyId(catalogItem.getConnectorId()) .protocol(EDC_PROTOCOL) - .offer(contractOfferDescription) + .contractOffer( + ContractOffer.fromPolicy(catalogItem.getPolicy(), catalogItem.getOfferId(), + catalogItem.getAssetPropId(), catalogItem.getConnectorId())) .build(); } diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EDCCatalogFacade.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EDCCatalogFacade.java index 2c7e5976ef..e4e309cae5 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EDCCatalogFacade.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EDCCatalogFacade.java @@ -24,6 +24,7 @@ package org.eclipse.tractusx.irs.edc.client; import static java.util.stream.Collectors.toSet; +import static org.apache.commons.collections4.ListUtils.emptyIfNull; import static org.eclipse.tractusx.irs.edc.client.configuration.JsonLdConfiguration.NAMESPACE_EDC_ID; import java.util.ArrayList; @@ -51,6 +52,7 @@ @Slf4j public class EDCCatalogFacade { + public static final String NAMESPACE_DSPACE_PARTICIPANT_ID = "https://w3id.org/dspace/v0.8/participantId"; private final EdcControlPlaneClient controlPlaneClient; private final EdcConfiguration config; @@ -65,17 +67,25 @@ private static CatalogItem createCatalogItem(final Catalog pageableCatalog, fina .findFirst() .orElseThrow(); final var builder = CatalogItem.builder() - .itemId(dataset.getId()) + .itemId(pageableCatalog.getId()) .offerId(stringPolicyEntry.getKey()) - .assetPropId(dataset.getProperty(NAMESPACE_EDC_ID).toString()) - .policy(stringPolicyEntry.getValue()); - if (pageableCatalog.getProperties().containsKey(JsonLdConfiguration.NAMESPACE_EDC_PARTICIPANT_ID)) { - builder.connectorId( - pageableCatalog.getProperties().get(JsonLdConfiguration.NAMESPACE_EDC_PARTICIPANT_ID).toString()); - } + .assetPropId(dataset.getId()) + .policy(stringPolicyEntry.getValue()) + .connectorId(getParticipantId(pageableCatalog)); + return builder.build(); } + private static String getParticipantId(final Catalog catalog) { + if (catalog.getProperties().containsKey(JsonLdConfiguration.NAMESPACE_EDC_PARTICIPANT_ID)) { + return catalog.getProperties().get(JsonLdConfiguration.NAMESPACE_EDC_PARTICIPANT_ID).toString(); + } else if (catalog.getProperties().containsKey(NAMESPACE_DSPACE_PARTICIPANT_ID)) { + return catalog.getProperties().get(NAMESPACE_DSPACE_PARTICIPANT_ID).toString(); + } else { + return catalog.getParticipantId(); + } + } + /** * Fetches a list of {@link CatalogItem} objects based on the given {@link CatalogRequest}. * This method communicates with the control plane client to retrieve the catalog @@ -88,32 +98,24 @@ public List fetchCatalogItems(final CatalogRequest catalogRequest) final Catalog catalog = controlPlaneClient.getCatalog(catalogRequest); return mapToCatalogItems(catalog); } - - private static List mapToCatalogItems(final Catalog catalog) { - if (catalog.getDatasets() == null) { - return List.of(); - } else { - return catalog.getDatasets().stream().map(contractOffer -> { - final Map.Entry offer = contractOffer.getOffers() - .entrySet() - .stream() - .findFirst() - .orElseThrow(); - final var catalogItem = CatalogItem.builder() - .itemId(contractOffer.getId()) - .assetPropId(contractOffer.getProperty(NAMESPACE_EDC_ID).toString()) - .connectorId(catalog.getId()) - .offerId(offer.getKey()) - .policy(offer.getValue()); - if (catalog.getProperties().containsKey(JsonLdConfiguration.NAMESPACE_EDC_PARTICIPANT_ID)) { - catalogItem.connectorId( - catalog.getProperties().get(JsonLdConfiguration.NAMESPACE_EDC_PARTICIPANT_ID).toString()); - } - - return catalogItem.build(); - }).toList(); - } + private static List mapToCatalogItems(final Catalog catalog) { + return emptyIfNull(catalog.getDatasets()).stream().map(dataset -> { + final Map.Entry offer = dataset.getOffers().entrySet().stream().findFirst().orElseThrow(); + final Policy policy = offer.getValue() + .toBuilder() + .assigner(getParticipantId(catalog)) + .target(dataset.getId()) + .build(); + + return CatalogItem.builder() + .itemId(dataset.getId()) + .assetPropId(dataset.getId()) + .offerId(offer.getKey()) + .policy(policy) + .connectorId(getParticipantId(catalog)) + .build(); + }).toList(); } /** @@ -122,14 +124,16 @@ private static List mapToCatalogItems(final Catalog catalog) { * * @param connectorUrl The EDC Connector from which the Catalog will be requested * @param target The target assetID which will be searched for + * @param bpn The BPN of the company to which the EDC Connector belongs * @return The list of catalog Items up to the point where the target CatalogItem is included. */ - public List fetchCatalogItemsUntilMatch(final String connectorUrl, final String target) { + public List fetchCatalogItemsUntilMatch(final String connectorUrl, final String target, + final String bpn) { int offset = 0; final int pageSize = config.getControlplane().getCatalogPageSize(); log.info("Get catalog from EDC provider."); - final Catalog pageableCatalog = controlPlaneClient.getCatalog(connectorUrl, offset); + final Catalog pageableCatalog = controlPlaneClient.getCatalog(connectorUrl, offset, bpn); final List datasets = new ArrayList<>(pageableCatalog.getDatasets()); boolean isLastPage = pageableCatalog.getDatasets().size() < pageSize; @@ -138,7 +142,7 @@ public List fetchCatalogItemsUntilMatch(final String connectorUrl, while (!isLastPage && !isTheSamePage && optionalContractOffer.isEmpty()) { offset += pageSize; - final Catalog newPageableCatalog = controlPlaneClient.getCatalog(connectorUrl, offset); + final Catalog newPageableCatalog = controlPlaneClient.getCatalog(connectorUrl, offset, bpn); isTheSamePage = theSameCatalog(pageableCatalog, newPageableCatalog); isLastPage = newPageableCatalog.getDatasets().size() < pageSize; optionalContractOffer = findOfferIfExist(target, newPageableCatalog); @@ -152,33 +156,38 @@ public List fetchCatalogItemsUntilMatch(final String connectorUrl, return datasets.stream().map(dataset -> createCatalogItem(pageableCatalog, dataset)).toList(); } - public List fetchCatalogById(final String connectorUrl, final String target) { - return fetchCatalogByFilter(connectorUrl, NAMESPACE_EDC_ID, target); + /** + * @param connectorUrl The EDC Connector from which the Catalog will be requested + * @param target The target assetID which will be searched for + * @param bpn The BPN of the company to which the EDC Connector belongs + * @return The list of catalog Items matching the target id + * @deprecated + */ + @Deprecated(since = "5.0.0") + public List fetchCatalogById(final String connectorUrl, final String target, final String bpn) { + return fetchCatalogByFilter(connectorUrl, NAMESPACE_EDC_ID, target, bpn); } - public List fetchCatalogByFilter(final String connectorUrl, final String key, final String value) { - final Catalog catalog = controlPlaneClient.getCatalogWithFilter(connectorUrl, key, value); + @SuppressWarnings("PMD.UseObjectForClearerAPI") // TODO (ds-jhartmann) see https://github.com/eclipse-tractusx/item-relationship-service/issues/547 + public List fetchCatalogByFilter(final String connectorUrl, final String key, final String value, + final String bpn) { + final Catalog catalog = controlPlaneClient.getCatalogWithFilter(connectorUrl, key, value, bpn); return mapToCatalogItems(catalog); } private Optional findOfferIfExist(final String target, final Catalog catalog) { - return catalog.getDatasets() - .stream() - .filter(dataset -> dataset.getProperty(NAMESPACE_EDC_ID).toString().equals(target)) - .findFirst(); + return emptyIfNull(catalog.getDatasets()).stream() + .filter(dataset -> target.equals(dataset.getId())) + .findFirst(); } private boolean theSameCatalog(final Catalog pageableCatalog, final Catalog newPageableCatalog) { - final Set previousOffers = pageableCatalog.getDatasets() - .stream() - .map(dataset -> dataset.getProperty(NAMESPACE_EDC_ID) - .toString()) - .collect(toSet()); - final Set nextOffers = newPageableCatalog.getDatasets() - .stream() - .map(dataset -> dataset.getProperty(NAMESPACE_EDC_ID) - .toString()) - .collect(toSet()); + final Set previousOffers = emptyIfNull(pageableCatalog.getDatasets()).stream() + .map(Dataset::getId) + .collect(toSet()); + final Set nextOffers = emptyIfNull(newPageableCatalog.getDatasets()).stream() + .map(Dataset::getId) + .collect(toSet()); return previousOffers.equals(nextOffers); } } diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcCallbackController.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcCallbackController.java index f6a94a890f..a7571b7ef9 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcCallbackController.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcCallbackController.java @@ -23,13 +23,22 @@ ********************************************************************************/ package org.eclipse.tractusx.irs.edc.client; +import java.util.NoSuchElementException; +import java.util.Optional; + import io.swagger.v3.oas.annotations.Hidden; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.eclipse.edc.spi.types.domain.edr.EndpointDataReference; +import org.eclipse.tractusx.irs.data.JsonParseException; import org.eclipse.tractusx.irs.data.StringMapper; -import org.eclipse.tractusx.irs.edc.client.model.EDRAuthCode; +import org.eclipse.tractusx.irs.edc.client.exceptions.EdcClientException; +import org.eclipse.tractusx.irs.edc.client.model.edr.DataAddress; +import org.eclipse.tractusx.irs.edc.client.model.edr.EndpointDataReferenceCallback; +import org.eclipse.tractusx.irs.edc.client.model.edr.Properties; +import org.eclipse.tractusx.irs.edc.client.model.edr.TransferProcessCallbackPayload; import org.eclipse.tractusx.irs.edc.client.util.Masker; +import org.springframework.http.HttpHeaders; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -48,19 +57,50 @@ public class EdcCallbackController { private final EndpointDataReferenceStorage storage; @PostMapping - public void receiveEdcCallback(final @RequestBody EndpointDataReference dataReference) { - log.debug("Received EndpointDataReference: {}", StringMapper.mapToString(dataReference)); - log.debug("Received EndpointDataReference with ID {} and endpoint {}", dataReference.getId(), - dataReference.getEndpoint()); - final String authCode = dataReference.getAuthCode(); - if (authCode != null) { - final var contractAgreementId = EDRAuthCode.fromAuthCodeToken(authCode).getCid(); - storage.put(contractAgreementId, dataReference); - log.info("Endpoint Data Reference received and cached for agreement: {}", Masker.mask(contractAgreementId)); - } else { - log.error("ContractAgreementId could not be extracted from Endpoint Data Reference {}", - StringMapper.mapToString(dataReference)); + public void receiveEdcCallback(final @RequestBody String endpointDataReferenceCallback) { + final EndpointDataReference endpointDataReference; + + try { + endpointDataReference = mapToEndpointDataReference(endpointDataReferenceCallback); + + log.debug("Received EndpointDataReference: {}", StringMapper.mapToString(endpointDataReference)); + log.debug("Received EndpointDataReference with ID {} and endpoint {}", endpointDataReference.getId(), + endpointDataReference.getEndpoint()); + + final String contractId = endpointDataReference.getContractId(); + storeEdr(contractId, endpointDataReference); + } catch (EdcClientException e) { + log.error("Could not deserialize Endpoint Data Reference {}", endpointDataReferenceCallback); + } + } + + private static EndpointDataReference mapToEndpointDataReference(final String endpointDataReference) + throws EdcClientException { + final EndpointDataReference dataReference; + + try { + final EndpointDataReferenceCallback endpointDataReferenceCallback = StringMapper.mapFromString( + endpointDataReference, EndpointDataReferenceCallback.class); + final TransferProcessCallbackPayload payload = Optional.ofNullable( + endpointDataReferenceCallback.getPayload()).orElseThrow(); + final DataAddress dataAddress = Optional.ofNullable(payload.dataAddress()).orElseThrow(); + final Properties properties = Optional.ofNullable(dataAddress.properties()).orElseThrow(); + + dataReference = EndpointDataReference.Builder.newInstance() + .contractId(properties.agreementId()) + .id(properties.processId()) + .authKey(HttpHeaders.AUTHORIZATION) + .authCode(properties.authorization()) + .endpoint(properties.endpoint()) + .build(); + return dataReference; + } catch (JsonParseException | NoSuchElementException e) { + throw new EdcClientException(e); } } + private void storeEdr(final String contractId, final EndpointDataReference dataReference) { + storage.put(contractId, dataReference); + log.info("Endpoint Data Reference received and cached for agreement: {}", Masker.mask(contractId)); + } } diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcControlPlaneClient.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcControlPlaneClient.java index b91032a86d..b337bc2ce8 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcControlPlaneClient.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcControlPlaneClient.java @@ -86,10 +86,10 @@ private static String getResponseBody(final ResponseEntity response) { return responseBody; } - /* package */ Catalog getCatalog(final String providerConnectorUrl, final int offset) { + /* package */ Catalog getCatalog(final String providerConnectorUrl, final int offset, final String bpn) { final var limit = config.getControlplane().getCatalogPageSize(); - final CatalogRequest request = buildCatalogRequest(offset, providerConnectorUrl, limit); + final CatalogRequest request = buildCatalogRequest(offset, providerConnectorUrl, limit, bpn); return getCatalog(request); } @@ -105,23 +105,26 @@ private static String getResponseBody(final ResponseEntity response) { return edcTransformer.transformCatalog(catalog, StandardCharsets.UTF_8); } - private CatalogRequest buildCatalogRequest(final int offset, final String providerUrl, final int limit) { + private CatalogRequest buildCatalogRequest(final int offset, final String providerUrl, final int limit, + final String bpn) { final QuerySpec.Builder querySpec = QuerySpec.Builder.newInstance().offset(offset); if (config.getControlplane().getCatalogPageSize() > 0) { querySpec.limit(limit); } return CatalogRequest.Builder.newInstance() .counterPartyAddress(providerUrl) + .counterPartyId(bpn) .protocol(DATASPACE_PROTOCOL_HTTP) .querySpec(querySpec.build()) .build(); } - /* package */ Catalog getCatalogWithFilter(final String providerConnectorUrl, final String key, - final String value) { + /* package */ Catalog getCatalogWithFilter(final String providerConnectorUrl, final String key, final String value, + final String bpn) { final QuerySpec querySpec = QuerySpec.Builder.newInstance().filter(new Criterion(key, "=", value)).build(); final var catalogRequest = CatalogRequest.Builder.newInstance() .counterPartyAddress(providerConnectorUrl) + .counterPartyId(bpn) .protocol(DATASPACE_PROTOCOL_HTTP) .querySpec(querySpec) .build(); diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientImpl.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientImpl.java index 68779159a2..73c50742f6 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientImpl.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientImpl.java @@ -234,7 +234,7 @@ public List> getEndpointReferencesForAs // CatalogItem = contract offer final List contractOffers = catalogFacade.fetchCatalogByFilter(providerWithSuffix, filterKey, - filterValue); + filterValue, bpn); if (contractOffers.isEmpty()) { throw new EdcClientException( @@ -294,7 +294,8 @@ private CompletableFuture awaitEndpointReferenceForAsset( stopWatch.start("Get EDC Submodel task for shell descriptor, endpoint " + endpointAddress); final String providerWithSuffix = appendSuffix(endpointAddress, config.getControlplane().getProviderSuffix()); - final List items = catalogFacade.fetchCatalogByFilter(providerWithSuffix, filterKey, filterValue); + final List items = catalogFacade.fetchCatalogByFilter(providerWithSuffix, filterKey, filterValue, + bpn); final NegotiationResponse response = contractNegotiationService.negotiate(providerWithSuffix, items.stream().findFirst().orElseThrow(), endpointDataReferenceStatus, bpn); @@ -315,11 +316,7 @@ private static String getStorageId(final EndpointDataReferenceStatus endpointDat if (response != null) { storageId = response.getContractAgreementId(); } else { - final String authCode = endpointDataReferenceStatus.endpointDataReference().getAuthCode(); - if (authCode == null) { - throw new IllegalStateException("Missing information about AuthCode."); - } - storageId = EDRAuthCode.fromAuthCodeToken(authCode).getCid(); + storageId = endpointDataReferenceStatus.endpointDataReference().getContractId(); } return storageId; } diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/SingleLevelBomAsSpecified.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/SingleLevelBomAsSpecified.java index 9f5277a9c9..15292df84c 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/SingleLevelBomAsSpecified.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/SingleLevelBomAsSpecified.java @@ -31,6 +31,7 @@ import com.fasterxml.jackson.annotation.JsonAlias; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import lombok.extern.jackson.Jacksonized; @@ -46,6 +47,7 @@ * SingleLevelBomAsSpecified */ @Data +@Builder @Jacksonized @AllArgsConstructor @NoArgsConstructor @@ -65,6 +67,7 @@ public List asRelationships() { * ChildData */ @Data + @Builder @AllArgsConstructor @NoArgsConstructor /* package */ static class ChildData { @@ -75,7 +78,7 @@ public List asRelationships() { private String businessPartner; public Relationship toRelationship(final String catenaXId) { - final Part childPart = this.part.stream().findFirst().orElse(new Part()); + final Part childPart = this.part.stream().findFirst().orElse(Part.builder().build()); final LinkedItem.LinkedItemBuilder linkedItem = LinkedItem.builder() .childCatenaXId(GlobalAssetIdentification.of(this.childCatenaXId)) @@ -103,6 +106,7 @@ public Relationship toRelationship(final String catenaXId) { * Part */ @Data + @Builder @Jacksonized @SuppressWarnings("PMD.ShortClassName") /* package */ static class Part { @@ -118,6 +122,7 @@ public Relationship toRelationship(final String catenaXId) { * Part Quantity */ @Data + @Builder @Jacksonized /* package */ static class PartQuantity { @JsonAlias({ "quantityNumber", "value" }) diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/asset/EdcAssetService.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/asset/EdcAssetService.java index 9652f7b7ca..4691f5226b 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/asset/EdcAssetService.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/asset/EdcAssetService.java @@ -20,7 +20,6 @@ package org.eclipse.tractusx.irs.edc.client.asset; import static org.eclipse.edc.spi.types.domain.DataAddress.EDC_DATA_ADDRESS_TYPE_PROPERTY; -import static org.eclipse.edc.spi.types.domain.HttpDataAddress.HTTP_DATA; import java.util.Map; import java.util.UUID; @@ -67,6 +66,7 @@ public class EdcAssetService { private static final String ASSET_CREATION_PROPERTY_TYPE = "https://w3id.org/edc/v0.0.1/ns/type"; private static final String ASSET_CREATION_PROPERTY_NOTIFICATION_TYPE = "https://w3id.org/edc/v0.0.1/ns/notificationtype"; private static final String ASSET_CREATION_PROPERTY_NOTIFICATION_METHOD = "https://w3id.org/edc/v0.0.1/ns/notificationmethod"; + public static final String DATA_ADDRESS_TYPE_HTTP_DATA = "HttpData"; private final EdcTransformer edcTransformer; private final EdcConfiguration config; @@ -133,8 +133,9 @@ private Asset createNotificationAssetRequest(final String assetName, final Strin ASSET_CREATION_PROPERTY_NOTIFICATION_METHOD, notificationMethod.getValue()); final DataAddress dataAddress = DataAddress.Builder.newInstance() - .type(HTTP_DATA) - .property(EDC_DATA_ADDRESS_TYPE_PROPERTY, HTTP_DATA) + .type(DATA_ADDRESS_TYPE_HTTP_DATA) + .property(EDC_DATA_ADDRESS_TYPE_PROPERTY, + DATA_ADDRESS_TYPE_HTTP_DATA) .property(ASSET_CREATION_DATA_ADDRESS_BASE_URL, baseUrl) .property(ASSET_CREATION_DATA_ADDRESS_PROXY_METHOD, Boolean.TRUE.toString()) @@ -156,7 +157,8 @@ private Asset createDtrAssetRequest(final String assetId, final String baseUrl) final DataAddress dataAddress = DataAddress.Builder.newInstance() .type("DataAddress") - .property(EDC_DATA_ADDRESS_TYPE_PROPERTY, HTTP_DATA) + .property(EDC_DATA_ADDRESS_TYPE_PROPERTY, + DATA_ADDRESS_TYPE_HTTP_DATA) .property(ASSET_CREATION_DATA_ADDRESS_BASE_URL, baseUrl) .property(ASSET_CREATION_DATA_ADDRESS_PROXY_METHOD, Boolean.TRUE.toString()) @@ -181,7 +183,8 @@ private Asset createSubmodelAssetRequest(final String assetId, final String base final DataAddress dataAddress = DataAddress.Builder.newInstance() .type("DataAddress") - .property(EDC_DATA_ADDRESS_TYPE_PROPERTY, HTTP_DATA) + .property(EDC_DATA_ADDRESS_TYPE_PROPERTY, + DATA_ADDRESS_TYPE_HTTP_DATA) .property(ASSET_CREATION_DATA_ADDRESS_BASE_URL, baseUrl) .property(ASSET_CREATION_DATA_ADDRESS_PROXY_METHOD, Boolean.FALSE.toString()) diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/ContractOffer.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/ContractOffer.java new file mode 100644 index 0000000000..6d011171d1 --- /dev/null +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/ContractOffer.java @@ -0,0 +1,83 @@ +/******************************************************************************** + * Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (c) 2021,2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * 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. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ +package org.eclipse.tractusx.irs.edc.client.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +import lombok.Singular; +import lombok.Value; +import lombok.extern.jackson.Jacksonized; +import org.eclipse.edc.policy.model.Duty; +import org.eclipse.edc.policy.model.Permission; +import org.eclipse.edc.policy.model.Policy; +import org.eclipse.edc.policy.model.Prohibition; + +/** + * Represents a contract offer like it is used in a EDC {@link NegotiationRequest}. + */ +@Value +@Builder +@Jacksonized +public class ContractOffer { + public static final String ID_PROPERTY = "@id"; + public static final String TYPE_PROPERTY = "@type"; + public static final String ODRL_NAMESPACE = "http://www.w3.org/ns/odrl/2/"; + public static final String ODRL_PERMISSION_ATTRIBUTE = ODRL_NAMESPACE + "permission"; + public static final String ODRL_PROHIBITION_ATTRIBUTE = ODRL_NAMESPACE + "prohibition"; + public static final String ODRL_OBLIGATION_ATTRIBUTE = ODRL_NAMESPACE + "obligation"; + public static final String ODRL_ASSIGNER_ATTRIBUTE = ODRL_NAMESPACE + "assigner"; + public static final String ODRL_TARGET_ATTRIBUTE = ODRL_NAMESPACE + "target"; + public static final String ODRL_ASSIGNEE_ATTRIBUTE = ODRL_NAMESPACE + "assignee"; + public static final String ODRL_POLICY_TYPE_OFFER = ODRL_NAMESPACE + "Offer"; + + @JsonProperty(TYPE_PROPERTY) + private String type = ODRL_POLICY_TYPE_OFFER; + @JsonProperty(ID_PROPERTY) + private String offerId; + @Singular + @JsonProperty(ODRL_PERMISSION_ATTRIBUTE) + private List permissions; + @Singular + @JsonProperty(ODRL_PROHIBITION_ATTRIBUTE) + private List prohibitions; + @Singular + @JsonProperty(ODRL_OBLIGATION_ATTRIBUTE) + private List obligations; + @JsonProperty(ODRL_ASSIGNER_ATTRIBUTE) + private String assigner; + @JsonProperty(ODRL_ASSIGNEE_ATTRIBUTE) + private String assignee; + @JsonProperty(ODRL_TARGET_ATTRIBUTE) + private String target; + + public static ContractOffer fromPolicy(final Policy policy, final String offerId, final String target, + final String assigner) { + return ContractOffer.builder() + .prohibitions(policy.getProhibitions()) + .obligations(policy.getObligations()) + .permissions(policy.getPermissions()) + .offerId(offerId) + .target(target) + .assigner(assigner) + .build(); + } +} diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/ContractOfferInCatalogResponse.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/ContractOfferInCatalogResponse.java index cc1fc5ae0e..5ccda1a68e 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/ContractOfferInCatalogResponse.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/ContractOfferInCatalogResponse.java @@ -25,7 +25,7 @@ import lombok.Builder; import lombok.Value; -import org.eclipse.edc.connector.contract.spi.types.offer.ContractOffer; +import org.eclipse.edc.spi.types.domain.offer.ContractOffer; /** * EDC catalog and contract offer response. diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/NegotiationRequest.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/NegotiationRequest.java index d2d357315f..243fa888cf 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/NegotiationRequest.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/NegotiationRequest.java @@ -40,7 +40,8 @@ @Builder(toBuilder = true) @Jacksonized public class NegotiationRequest { - public static final String NEGOTIATION_CONNECTOR_ADDRESS = "https://w3id.org/edc/v0.0.1/ns/connectorAddress"; + public static final String NEGOTIATION_COUNTER_PARTY_ADDRESS = "https://w3id.org/edc/v0.0.1/ns/counterPartyAddress"; + public static final String NEGOTIATION_COUNTER_PARTY_ID = "https://w3id.org/edc/v0.0.1/ns/counterPartyId"; public static final String NEGOTIATION_PROTOCOL = "https://w3id.org/edc/v0.0.1/ns/protocol"; public static final String NEGOTIATION_CONNECTOR_ID = "https://w3id.org/edc/v0.0.1/ns/connectorId"; public static final String NEGOTIATION_PROVIDER_ID = "https://w3id.org/edc/v0.0.1/ns/providerId"; @@ -51,16 +52,14 @@ public class NegotiationRequest { public static final String NEGOTIATION_ASSET_ID = "https://w3id.org/edc/v0.0.1/ns/assetId"; public static final String NEGOTIATION_POLICY = "https://w3id.org/edc/v0.0.1/ns/policy"; - @NotBlank(message = "connectorAddress is mandatory") - private String connectorAddress; + @NotBlank(message = "counterPartyAddress is mandatory") + private String counterPartyAddress; + @NotBlank(message = "counterPartyId is mandatory") + private String counterPartyId; @NotBlank(message = "protocol is mandatory") private String protocol; - @NotBlank(message = "connectorId is mandatory") - private String connectorId; @NotNull(message = "offer cannot be null") - private ContractOfferDescription offer; - private String providerId; - private String consumerId; + private ContractOffer contractOffer; private List callbackAddresses = new ArrayList<>(); } diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/NegotiationResponse.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/NegotiationResponse.java index 84eb52a370..be6bf26f57 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/NegotiationResponse.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/NegotiationResponse.java @@ -40,19 +40,19 @@ public class NegotiationResponse { @JsonProperty("@id") private String responseId; - @JsonProperty("edc:contractAgreementId") + @JsonProperty("contractAgreementId") private String contractAgreementId; - @JsonProperty("edc:counterPartyAddress") + @JsonProperty("counterPartyAddress") private String counterPartyAddress; - @JsonProperty("edc:errorDetail") + @JsonProperty("errorDetail") private String errorDetail; - @JsonProperty("edc:protocol") + @JsonProperty("protocol") private String protocol; - @JsonProperty("edc:state") + @JsonProperty("state") private String state; - @JsonProperty("edc:type") + @JsonProperty("type") private String type; - @JsonProperty("edc:callbackAddresses") + @JsonProperty("callbackAddresses") private List callbackAddresses; } diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/NegotiationState.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/NegotiationState.java index 39a04ff7e2..ed4b05020a 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/NegotiationState.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/NegotiationState.java @@ -35,6 +35,6 @@ @Builder(toBuilder = true) @Jacksonized public class NegotiationState { - @JsonProperty("edc:state") + @JsonProperty("state") private String state; } diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/TransferProcessRequest.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/TransferProcessRequest.java index f4e5dc1fb3..b55d01de72 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/TransferProcessRequest.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/TransferProcessRequest.java @@ -41,11 +41,12 @@ public class TransferProcessRequest { public static final String EDC_TRANSFER_REQUEST_DTO_ASSET_ID = "https://w3id.org/edc/v0.0.1/ns/assetId"; - public static final String EDC_TRANSFER_REQUEST_DTO_CONNECTOR_ADDRESS = "https://w3id.org/edc/v0.0.1/ns/connectorAddress"; + public static final String EDC_TRANSFER_REQUEST_DTO_COUNTER_PARTY_ADDRESS = "https://w3id.org/edc/v0.0.1/ns/counterPartyAddress"; public static final String EDC_TRANSFER_REQUEST_DTO_CONNECTOR_ID = "https://w3id.org/edc/v0.0.1/ns/connectorId"; public static final String EDC_TRANSFER_REQUEST_DTO_CONTRACT_ID = "https://w3id.org/edc/v0.0.1/ns/contractId"; public static final String EDC_TRANSFER_REQUEST_DTO_DATA_DESTINATION = "https://w3id.org/edc/v0.0.1/ns/dataDestination"; public static final String EDC_TRANSFER_REQUEST_DTO_PROTOCOL = "https://w3id.org/edc/v0.0.1/ns/protocol"; + public static final String EDC_TRANSFER_REQUEST_DTO_TRANSFER_TYPE = "https://w3id.org/edc/v0.0.1/ns/transferType"; public static final String EDC_TRANSFER_REQUEST_DTO_MANAGED_RESOURCES = "https://w3id.org/edc/v0.0.1/ns/managedResources"; public static final String EDC_TRANSFER_REQUEST_DTO_CALLBACK_ADDRESSES = "https://w3id.org/edc/v0.0.1/ns/callbackAddresses"; public static final String EDC_TRANSFER_REQUEST_DTO_PROPERTIES = "https://w3id.org/edc/v0.0.1/ns/properties"; @@ -55,11 +56,12 @@ public class TransferProcessRequest { public static final boolean DEFAULT_MANAGED_RESOURCES = false; private String assetId; - private String connectorAddress; + private String counterPartyAddress; private String connectorId; private String contractId; private DataAddress dataDestination; private String protocol; + private String transferType; private boolean managedResources; private List callbackAddresses; private Map properties; diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/TransferProcessResponse.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/TransferProcessResponse.java index 5f2b7048f3..98fd21cc65 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/TransferProcessResponse.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/TransferProcessResponse.java @@ -38,11 +38,12 @@ public class TransferProcessResponse { @JsonProperty("@id") private String responseId; - @JsonProperty("edc:type") private String type; - @JsonProperty("edc:state") private String state; - @JsonProperty("edc:errorDetail") private String errorDetail; + private String correlationId; + private String assetId; + private String contractId; + private String transferType; } diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/edr/CallbackAddress.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/edr/CallbackAddress.java new file mode 100644 index 0000000000..dfb9729715 --- /dev/null +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/edr/CallbackAddress.java @@ -0,0 +1,39 @@ +/******************************************************************************** + * Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (c) 2021,2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * 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. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ +package org.eclipse.tractusx.irs.edc.client.model.edr; + +import java.util.List; + +import lombok.Builder; +import lombok.extern.jackson.Jacksonized; + +/** + * CallbackAddress represents the properties of a callback address. + * + * @param uri The URI of the callback. + * @param events The list of events for the callback. + * @param transactional Indicates if the callback is transactional. + * @param authKey The authentication key. + * @param authCode The authentication code. + */ +@Builder +@Jacksonized +public record CallbackAddress(String uri, List events, boolean transactional, String authKey, String authCode) { +} diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/edr/DataAddress.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/edr/DataAddress.java new file mode 100644 index 0000000000..11ab6832b5 --- /dev/null +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/edr/DataAddress.java @@ -0,0 +1,33 @@ +/******************************************************************************** + * Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (c) 2021,2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * 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. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ +package org.eclipse.tractusx.irs.edc.client.model.edr; + +import lombok.Builder; +import lombok.extern.jackson.Jacksonized; + +/** + * DataAddress containing the EDR callback properties. + * + * @param properties The properties of the EDR callback. + */ +@Builder +@Jacksonized +public record DataAddress(Properties properties) { +} diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/edr/EndpointDataReferenceCallback.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/edr/EndpointDataReferenceCallback.java new file mode 100644 index 0000000000..b3987fb288 --- /dev/null +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/edr/EndpointDataReferenceCallback.java @@ -0,0 +1,41 @@ +/******************************************************************************** + * Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (c) 2021,2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * 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. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ +package org.eclipse.tractusx.irs.edc.client.model.edr; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +import lombok.Value; +import lombok.extern.jackson.Jacksonized; + +/** + * EndpointDataReferenceCallback represents a transfer process callback containing the EndpointDataReference. + */ +@Builder +@Value +@Jacksonized +public class EndpointDataReferenceCallback { + @JsonProperty("id") + private String callbackId; + @JsonProperty("at") + private long createdAt; + private TransferProcessCallbackPayload payload; + private String type; +} + diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/edr/Properties.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/edr/Properties.java new file mode 100644 index 0000000000..87e498ae17 --- /dev/null +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/edr/Properties.java @@ -0,0 +1,63 @@ +/******************************************************************************** + * Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (c) 2021,2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * 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. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ +package org.eclipse.tractusx.irs.edc.client.model.edr; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +import lombok.extern.jackson.Jacksonized; + +/** + * Properties represents the properties of a transfer process EDR callback. + * + * @param processId The process ID of the callback. + * @param participantId The participant ID i.e. BPN. + * @param assetId The EDC asset ID of the negotiation. + * @param endpointType The type of the endpoint. E.g. "https://w3id.org/idsa/v4.1/HTTP" + * @param refreshEndpoint The refresh endpoint to get a new Token. + * @param audience The audience DID. + * @param agreementId The EDC contract agreement ID. + * @param flowType The flow type. E.g. "PULL" + * @param type The type. E.g. "https://w3id.org/idsa/v4.1/HTTP" + * @param endpoint The EDC dataplane endpoint. + * @param refreshToken The refresh JWT token. + * @param expiresIn The expiration time in seconds. + * @param authorization The authorization JWT token. + * @param refreshAudience The refresh audience DID. + */ +@Builder +@Jacksonized +public record Properties(@JsonProperty("process_id") String processId, + @JsonProperty("participant_id") String participantId, + @JsonProperty("asset_id") String assetId, + @JsonProperty(NAMESPACE_EDC + "endpointType") String endpointType, + @JsonProperty(NAMESPACE_TRACTUSX_AUTH + "refreshEndpoint") String refreshEndpoint, + @JsonProperty(NAMESPACE_TRACTUSX_AUTH + "audience") String audience, + @JsonProperty("agreement_id") String agreementId, + @JsonProperty("flow_type") String flowType, + @JsonProperty(NAMESPACE_EDC + "type") String type, + @JsonProperty(NAMESPACE_EDC + "endpoint") String endpoint, + @JsonProperty(NAMESPACE_TRACTUSX_AUTH + "refreshToken") String refreshToken, + @JsonProperty(NAMESPACE_TRACTUSX_AUTH + "expiresIn") String expiresIn, + @JsonProperty(NAMESPACE_EDC + "authorization") String authorization, + @JsonProperty(NAMESPACE_TRACTUSX_AUTH + "refreshAudience") String refreshAudience) { + + public static final String NAMESPACE_EDC = "https://w3id.org/edc/v0.0.1/ns/"; + public static final String NAMESPACE_TRACTUSX_AUTH = "https://w3id.org/tractusx/auth/"; +} diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/edr/TransferProcessCallbackPayload.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/edr/TransferProcessCallbackPayload.java new file mode 100644 index 0000000000..fdf14fc953 --- /dev/null +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/model/edr/TransferProcessCallbackPayload.java @@ -0,0 +1,45 @@ +/******************************************************************************** + * Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (c) 2021,2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * 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. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ +package org.eclipse.tractusx.irs.edc.client.model.edr; + +import java.util.List; + +import lombok.Builder; +import lombok.extern.jackson.Jacksonized; + +/** + * Payload represents the payload of a transfer process. + * + * @param transferProcessId The ID of the transfer process. + * @param callbackAddresses The list of callback addresses. + * @param assetId The ID of the EDC asset. + * @param type The type of payload. + * @param contractId The ID of the contract agreement. + * @param dataAddress The data address. + */ +@Builder +@Jacksonized +public record TransferProcessCallbackPayload(String transferProcessId, + List callbackAddresses, + String assetId, + String type, + String contractId, + DataAddress dataAddress) { +} diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/EdcTransformer.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/EdcTransformer.java index ce9f63911d..504f851619 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/EdcTransformer.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/EdcTransformer.java @@ -35,41 +35,42 @@ import jakarta.json.JsonBuilderFactory; import jakarta.json.JsonObject; import jakarta.json.JsonReader; +import org.eclipse.edc.api.transformer.JsonObjectFromCallbackAddressTransformer; +import org.eclipse.edc.api.transformer.JsonObjectToCallbackAddressTransformer; import org.eclipse.edc.catalog.spi.Catalog; import org.eclipse.edc.catalog.spi.CatalogRequest; +import org.eclipse.edc.connector.api.management.contractnegotiation.transform.JsonObjectToContractRequestTransformer; +import org.eclipse.edc.connector.core.base.agent.NoOpParticipantIdMapper; import org.eclipse.edc.core.transform.TransformerContextImpl; -import org.eclipse.edc.core.transform.transformer.from.JsonObjectFromAssetTransformer; -import org.eclipse.edc.core.transform.transformer.from.JsonObjectFromCatalogTransformer; -import org.eclipse.edc.core.transform.transformer.from.JsonObjectFromCriterionTransformer; -import org.eclipse.edc.core.transform.transformer.from.JsonObjectFromDataAddressTransformer; -import org.eclipse.edc.core.transform.transformer.from.JsonObjectFromDataServiceTransformer; -import org.eclipse.edc.core.transform.transformer.from.JsonObjectFromDatasetTransformer; -import org.eclipse.edc.core.transform.transformer.from.JsonObjectFromDistributionTransformer; -import org.eclipse.edc.core.transform.transformer.from.JsonObjectFromPolicyTransformer; -import org.eclipse.edc.core.transform.transformer.from.JsonObjectFromQuerySpecTransformer; -import org.eclipse.edc.core.transform.transformer.to.JsonObjectToActionTransformer; -import org.eclipse.edc.core.transform.transformer.to.JsonObjectToAssetTransformer; -import org.eclipse.edc.core.transform.transformer.to.JsonObjectToCatalogTransformer; -import org.eclipse.edc.core.transform.transformer.to.JsonObjectToConstraintTransformer; -import org.eclipse.edc.core.transform.transformer.to.JsonObjectToCriterionTransformer; -import org.eclipse.edc.core.transform.transformer.to.JsonObjectToDataServiceTransformer; -import org.eclipse.edc.core.transform.transformer.to.JsonObjectToDatasetTransformer; -import org.eclipse.edc.core.transform.transformer.to.JsonObjectToDistributionTransformer; -import org.eclipse.edc.core.transform.transformer.to.JsonObjectToDutyTransformer; -import org.eclipse.edc.core.transform.transformer.to.JsonObjectToOperatorTransformer; -import org.eclipse.edc.core.transform.transformer.to.JsonObjectToPermissionTransformer; -import org.eclipse.edc.core.transform.transformer.to.JsonObjectToPolicyTransformer; -import org.eclipse.edc.core.transform.transformer.to.JsonObjectToProhibitionTransformer; -import org.eclipse.edc.core.transform.transformer.to.JsonObjectToQuerySpecTransformer; -import org.eclipse.edc.core.transform.transformer.to.JsonValueToGenericTypeTransformer; +import org.eclipse.edc.core.transform.transformer.dcat.from.JsonObjectFromCatalogTransformer; +import org.eclipse.edc.core.transform.transformer.dcat.from.JsonObjectFromDataServiceTransformer; +import org.eclipse.edc.core.transform.transformer.dcat.from.JsonObjectFromDatasetTransformer; +import org.eclipse.edc.core.transform.transformer.dcat.from.JsonObjectFromDistributionTransformer; +import org.eclipse.edc.core.transform.transformer.edc.from.JsonObjectFromAssetTransformer; +import org.eclipse.edc.core.transform.transformer.edc.from.JsonObjectFromCriterionTransformer; +import org.eclipse.edc.core.transform.transformer.edc.from.JsonObjectFromDataAddressTransformer; +import org.eclipse.edc.core.transform.transformer.edc.from.JsonObjectFromQuerySpecTransformer; +import org.eclipse.edc.core.transform.transformer.edc.to.JsonObjectToActionTransformer; +import org.eclipse.edc.core.transform.transformer.edc.to.JsonObjectToAssetTransformer; +import org.eclipse.edc.core.transform.transformer.edc.to.JsonObjectToCriterionTransformer; +import org.eclipse.edc.core.transform.transformer.edc.to.JsonObjectToQuerySpecTransformer; +import org.eclipse.edc.core.transform.transformer.edc.to.JsonValueToGenericTypeTransformer; +import org.eclipse.edc.core.transform.transformer.odrl.to.JsonObjectToConstraintTransformer; +import org.eclipse.edc.core.transform.transformer.odrl.to.JsonObjectToDutyTransformer; +import org.eclipse.edc.core.transform.transformer.odrl.to.JsonObjectToOperatorTransformer; +import org.eclipse.edc.core.transform.transformer.odrl.to.JsonObjectToPermissionTransformer; +import org.eclipse.edc.core.transform.transformer.odrl.to.JsonObjectToPolicyTransformer; +import org.eclipse.edc.core.transform.transformer.odrl.to.JsonObjectToProhibitionTransformer; import org.eclipse.edc.jsonld.TitaniumJsonLd; +import org.eclipse.edc.protocol.dsp.negotiation.transform.from.JsonObjectFromContractNegotiationTransformer; import org.eclipse.edc.spi.result.Result; import org.eclipse.edc.spi.types.domain.asset.Asset; +import org.eclipse.edc.transform.spi.TransformerContext; import org.eclipse.edc.transform.spi.TypeTransformerRegistry; import org.eclipse.tractusx.irs.edc.client.model.ContractOfferDescription; import org.eclipse.tractusx.irs.edc.client.model.NegotiationRequest; import org.eclipse.tractusx.irs.edc.client.model.TransferProcessRequest; -import org.eclipse.tractusx.irs.edc.client.policy.Policy; +import org.jetbrains.annotations.Nullable; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; @@ -84,37 +85,40 @@ public class EdcTransformer { private final JsonObjectFromTransferProcessRequestTransformer jsonObjectFromTransferProcessRequestTransformer; private final JsonObjectFromContractOfferDescriptionTransformer jsonObjectFromContractOfferDescriptionTransformer; private final JsonObjectFromCatalogRequestTransformer jsonObjectFromCatalogRequestTransformer; - private final org.eclipse.tractusx.irs.edc.client.transformer.JsonObjectToPolicyTransformer jsonObjectToPolicyTransformer; private final TitaniumJsonLd titaniumJsonLd; - private final TransformerContextImpl transformerContext; + private final TransformerContext transformerContext; private final JsonObjectFromAssetTransformer jsonObjectFromAssetTransformer; + private final JsonObjectToIrsPolicyTransformer jsonObjectToIrsPolicyTransformer; public EdcTransformer(@Qualifier(JSON_LD_OBJECT_MAPPER) final ObjectMapper objectMapper, final TitaniumJsonLd titaniumJsonLd, final TypeTransformerRegistry typeTransformerRegistry) { this.titaniumJsonLd = titaniumJsonLd; + transformerContext = new TransformerContextImpl(typeTransformerRegistry); + final NoOpParticipantIdMapper participantIdMapper = new NoOpParticipantIdMapper(); final JsonBuilderFactory jsonBuilderFactory = Json.createBuilderFactory(Map.of()); + jsonObjectToCatalogTransformer = new JsonObjectToCatalogTransformer(); + jsonObjectToIrsPolicyTransformer = new JsonObjectToIrsPolicyTransformer(objectMapper); + jsonObjectFromNegotiationInitiateDtoTransformer = new JsonObjectFromNegotiationInitiateDtoTransformer( jsonBuilderFactory); - jsonObjectToCatalogTransformer = new JsonObjectToCatalogTransformer(); jsonObjectFromTransferProcessRequestTransformer = new JsonObjectFromTransferProcessRequestTransformer( jsonBuilderFactory); jsonObjectFromContractOfferDescriptionTransformer = new JsonObjectFromContractOfferDescriptionTransformer( jsonBuilderFactory); jsonObjectFromCatalogRequestTransformer = new JsonObjectFromCatalogRequestTransformer(jsonBuilderFactory); jsonObjectFromAssetTransformer = new JsonObjectFromAssetTransformer(jsonBuilderFactory, objectMapper); - jsonObjectToPolicyTransformer = new org.eclipse.tractusx.irs.edc.client.transformer.JsonObjectToPolicyTransformer( - objectMapper); - - transformerContext = new TransformerContextImpl(typeTransformerRegistry); // JSON to Object typeTransformerRegistry.register(jsonObjectToCatalogTransformer); + typeTransformerRegistry.register(jsonObjectToIrsPolicyTransformer); + typeTransformerRegistry.register(new JsonObjectToPolicyTransformer(participantIdMapper)); + typeTransformerRegistry.register(new JsonObjectFromContractOfferTransformer(participantIdMapper, jsonBuilderFactory)); typeTransformerRegistry.register(new JsonValueToGenericTypeTransformer(objectMapper)); typeTransformerRegistry.register(new JsonObjectToDataServiceTransformer()); typeTransformerRegistry.register(new JsonObjectToConstraintTransformer()); typeTransformerRegistry.register(new JsonObjectToDatasetTransformer()); - typeTransformerRegistry.register(new JsonObjectToPolicyTransformer()); + typeTransformerRegistry.register(new JsonObjectToContractRequestTransformer()); typeTransformerRegistry.register(new JsonObjectToPermissionTransformer()); typeTransformerRegistry.register(new JsonObjectToActionTransformer()); typeTransformerRegistry.register(new JsonObjectToDistributionTransformer()); @@ -124,30 +128,41 @@ public EdcTransformer(@Qualifier(JSON_LD_OBJECT_MAPPER) final ObjectMapper objec typeTransformerRegistry.register(new JsonObjectToQuerySpecTransformer()); typeTransformerRegistry.register(new JsonObjectToCriterionTransformer()); typeTransformerRegistry.register(new JsonObjectToOperatorTransformer()); + typeTransformerRegistry.register(new JsonObjectToCallbackAddressTransformer()); + // JSON from Object typeTransformerRegistry.register(jsonObjectFromNegotiationInitiateDtoTransformer); typeTransformerRegistry.register(jsonObjectFromCatalogRequestTransformer); typeTransformerRegistry.register(jsonObjectFromTransferProcessRequestTransformer); typeTransformerRegistry.register(jsonObjectFromContractOfferDescriptionTransformer); + typeTransformerRegistry.register(jsonObjectFromAssetTransformer); + typeTransformerRegistry.register(new JsonObjectFromContractNegotiationTransformer(jsonBuilderFactory)); typeTransformerRegistry.register(new JsonObjectFromQuerySpecTransformer(jsonBuilderFactory)); - typeTransformerRegistry.register(new JsonObjectFromCatalogTransformer(jsonBuilderFactory, objectMapper)); + typeTransformerRegistry.register( + new JsonObjectFromCatalogTransformer(jsonBuilderFactory, objectMapper, participantIdMapper)); typeTransformerRegistry.register(new JsonObjectFromDatasetTransformer(jsonBuilderFactory, objectMapper)); - typeTransformerRegistry.register(new JsonObjectFromPolicyTransformer(jsonBuilderFactory)); + typeTransformerRegistry.register(new JsonObjectFromPolicyTransformer(jsonBuilderFactory, participantIdMapper)); typeTransformerRegistry.register(new JsonObjectFromDistributionTransformer(jsonBuilderFactory)); typeTransformerRegistry.register(new JsonObjectFromDataServiceTransformer(jsonBuilderFactory)); - typeTransformerRegistry.register(jsonObjectFromAssetTransformer); typeTransformerRegistry.register(new JsonObjectFromCriterionTransformer(jsonBuilderFactory, objectMapper)); typeTransformerRegistry.register(new JsonObjectFromDataAddressTransformer(jsonBuilderFactory)); + typeTransformerRegistry.register(new JsonObjectFromCallbackAddressTransformer(jsonBuilderFactory)); } public Catalog transformCatalog(final String jsonString, final Charset charset) { + final Result expand; + expand = expandJsonLd(jsonString, charset); + return jsonObjectToCatalogTransformer.transform(expand.getContent(), transformerContext); + } + + public Result expandJsonLd(final String jsonString, final Charset charset) { final Result expand; try (JsonReader reader = Json.createReader(new ByteArrayInputStream(jsonString.getBytes(charset)))) { expand = titaniumJsonLd.expand( JsonDocument.of(reader.read()).getJsonContent().orElseThrow().asJsonObject()); } - return jsonObjectToCatalogTransformer.transform(expand.getContent(), transformerContext); + return expand; } public JsonObject transformNegotiationRequestToJson(final NegotiationRequest negotiationRequest) { @@ -180,7 +195,7 @@ public JsonObject transformAssetToJson(final Asset assetRequest) { return titaniumJsonLd.compact(transform).asOptional().orElseThrow(); } - public Policy transformToPolicy(final JsonObject body) { - return jsonObjectToPolicyTransformer.transform(body, transformerContext); + public org.eclipse.tractusx.irs.edc.client.policy.@Nullable Policy transformToIrsPolicy(final JsonObject body) { + return jsonObjectToIrsPolicyTransformer.transform(body, transformerContext); } } diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectFromCatalogRequestTransformer.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectFromCatalogRequestTransformer.java index 5b219ed99d..18d8bda921 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectFromCatalogRequestTransformer.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectFromCatalogRequestTransformer.java @@ -52,6 +52,7 @@ public JsonObjectFromCatalogRequestTransformer(final JsonBuilderFactory jsonFact final JsonObjectBuilder builder = this.jsonFactory.createObjectBuilder(); builder.add(JsonLdKeywords.TYPE, CatalogRequest.CATALOG_REQUEST_TYPE) .add(CatalogRequest.CATALOG_REQUEST_COUNTER_PARTY_ADDRESS, dto.getCounterPartyAddress()) + .add(CatalogRequest.CATALOG_REQUEST_COUNTER_PARTY_ID, dto.getCounterPartyId()) .add(CatalogRequest.CATALOG_REQUEST_PROTOCOL, dto.getProtocol()); Optional.ofNullable(dto.getQuerySpec()) .ifPresent(s -> builder.add(CatalogRequest.CATALOG_REQUEST_QUERY_SPEC, diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectFromContractOfferTransformer.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectFromContractOfferTransformer.java new file mode 100644 index 0000000000..3890e6dd20 --- /dev/null +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectFromContractOfferTransformer.java @@ -0,0 +1,95 @@ +/******************************************************************************** + * Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (c) 2021,2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * 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. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ +package org.eclipse.tractusx.irs.edc.client.transformer; + +import static org.eclipse.tractusx.irs.edc.client.model.ContractOffer.ID_PROPERTY; +import static org.eclipse.tractusx.irs.edc.client.model.ContractOffer.ODRL_ASSIGNEE_ATTRIBUTE; +import static org.eclipse.tractusx.irs.edc.client.model.ContractOffer.ODRL_ASSIGNER_ATTRIBUTE; +import static org.eclipse.tractusx.irs.edc.client.model.ContractOffer.ODRL_OBLIGATION_ATTRIBUTE; +import static org.eclipse.tractusx.irs.edc.client.model.ContractOffer.ODRL_PERMISSION_ATTRIBUTE; +import static org.eclipse.tractusx.irs.edc.client.model.ContractOffer.ODRL_PROHIBITION_ATTRIBUTE; +import static org.eclipse.tractusx.irs.edc.client.model.ContractOffer.ODRL_TARGET_ATTRIBUTE; +import static org.eclipse.tractusx.irs.edc.client.model.ContractOffer.TYPE_PROPERTY; + +import java.util.Optional; + +import jakarta.json.JsonBuilderFactory; +import jakarta.json.JsonObject; +import jakarta.json.JsonObjectBuilder; +import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.policy.model.Policy; +import org.eclipse.edc.spi.agent.ParticipantIdMapper; +import org.eclipse.edc.transform.spi.TransformerContext; +import org.eclipse.tractusx.irs.edc.client.model.ContractOffer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Converts from a {@link ContractOffer} to a DCAT catalog as a {@link JsonObject} in JSON-LD expanded form. + */ +@SuppressWarnings("PMD.TooManyStaticImports") +public class JsonObjectFromContractOfferTransformer extends AbstractJsonLdTransformer { + + private final ParticipantIdMapper participantIdMapper; + private final JsonBuilderFactory jsonFactory; + + public JsonObjectFromContractOfferTransformer(final ParticipantIdMapper participantIdMapper, + final JsonBuilderFactory jsonFactory) { + super(ContractOffer.class, JsonObject.class); + this.participantIdMapper = participantIdMapper; + this.jsonFactory = jsonFactory; + } + + @Override + public @Nullable JsonObject transform(final @NotNull ContractOffer contractOffer, + final @NotNull TransformerContext context) { + + final Policy policy = Policy.Builder.newInstance() + .duties(contractOffer.getObligations()) + .prohibitions(contractOffer.getProhibitions()) + .permissions(contractOffer.getPermissions()) + .build(); + final JsonObject transform = context.transform(policy, JsonObject.class); + final var builder = jsonFactory.createObjectBuilder() + .add(ID_PROPERTY, contractOffer.getOfferId()) + .add(TYPE_PROPERTY, contractOffer.getType()); + + if (Optional.ofNullable(transform).isPresent()) { + builder.add(ODRL_PERMISSION_ATTRIBUTE, transform.getJsonArray(ODRL_PERMISSION_ATTRIBUTE)) + .add(ODRL_PROHIBITION_ATTRIBUTE, transform.getJsonArray(ODRL_PROHIBITION_ATTRIBUTE)) + .add(ODRL_OBLIGATION_ATTRIBUTE, transform.getJsonArray(ODRL_OBLIGATION_ATTRIBUTE)); + } + + addIfPresent(Optional.ofNullable(contractOffer.getAssignee()).map(participantIdMapper::toIri), builder, + ODRL_ASSIGNEE_ATTRIBUTE); + addIfPresent(Optional.ofNullable(contractOffer.getAssigner()).map(participantIdMapper::toIri), builder, + ODRL_ASSIGNER_ATTRIBUTE); + addIfPresent(Optional.ofNullable(contractOffer.getTarget()), builder, ODRL_TARGET_ATTRIBUTE); + + return builder.build(); + } + + private void addIfPresent(final Optional property, final JsonObjectBuilder builder, + final String attribute) { + property.ifPresent(target -> builder.add(attribute, + jsonFactory.createArrayBuilder().add(jsonFactory.createObjectBuilder().add(ID_PROPERTY, target)))); + } + +} diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectFromNegotiationInitiateDtoTransformer.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectFromNegotiationInitiateDtoTransformer.java index 7a727db69f..30d51df67d 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectFromNegotiationInitiateDtoTransformer.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectFromNegotiationInitiateDtoTransformer.java @@ -54,17 +54,13 @@ public JsonObjectFromNegotiationInitiateDtoTransformer(final JsonBuilderFactory public @Nullable JsonObject transform(@NotNull final NegotiationRequest dto, @NotNull final TransformerContext context) { final JsonObjectBuilder builder = this.jsonFactory.createObjectBuilder(); - builder.add(NegotiationRequest.NEGOTIATION_CONNECTOR_ADDRESS, dto.getConnectorAddress()) - .add(NegotiationRequest.NEGOTIATION_CONNECTOR_ID, dto.getConnectorId()) - .add(NegotiationRequest.NEGOTIATION_OFFER, context.transform(dto.getOffer(), JsonObject.class)) + builder.add(NegotiationRequest.NEGOTIATION_COUNTER_PARTY_ADDRESS, dto.getCounterPartyAddress()) + .add(NegotiationRequest.NEGOTIATION_COUNTER_PARTY_ID, dto.getCounterPartyId()) + .add(NegotiationRequest.NEGOTIATION_POLICY, context.transform(dto.getContractOffer(), JsonObject.class)) .add(NegotiationRequest.NEGOTIATION_PROTOCOL, dto.getProtocol()); - Optional.ofNullable(dto.getProviderId()) - .ifPresent(s -> builder.add(NegotiationRequest.NEGOTIATION_PROVIDER_ID, dto.getProviderId())); Optional.ofNullable(dto.getCallbackAddresses()) .ifPresent(s -> builder.add(NegotiationRequest.NEGOTIATION_CALLBACK_ADDRESSES, asArray(dto.getCallbackAddresses(), context))); - Optional.ofNullable(dto.getConsumerId()) - .ifPresent(s -> builder.add(NegotiationRequest.NEGOTIATION_CONSUMER_ID, dto.getConsumerId())); return builder.build(); } diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectFromPolicyTransformer.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectFromPolicyTransformer.java new file mode 100644 index 0000000000..cdeea1d430 --- /dev/null +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectFromPolicyTransformer.java @@ -0,0 +1,272 @@ +/******************************************************************************** + * Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (c) 2021,2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * 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. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ +package org.eclipse.tractusx.irs.edc.client.transformer; + +import static java.util.UUID.randomUUID; +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.JsonLdKeywords.VALUE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_ACTION_ATTRIBUTE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_ACTION_TYPE_ATTRIBUTE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_AND_CONSTRAINT_ATTRIBUTE; +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.jsonld.spi.PropertyAndTypeNames.ODRL_CONSEQUENCE_ATTRIBUTE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_CONSTRAINT_ATTRIBUTE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_DUTY_ATTRIBUTE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_INCLUDED_IN_ATTRIBUTE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_LEFT_OPERAND_ATTRIBUTE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_OBLIGATION_ATTRIBUTE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_OPERATOR_ATTRIBUTE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_OR_CONSTRAINT_ATTRIBUTE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_PERMISSION_ATTRIBUTE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_POLICY_TYPE_AGREEMENT; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_POLICY_TYPE_OFFER; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_POLICY_TYPE_SET; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_PROHIBITION_ATTRIBUTE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_REFINEMENT_ATTRIBUTE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_RIGHT_OPERAND_ATTRIBUTE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_TARGET_ATTRIBUTE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_XONE_CONSTRAINT_ATTRIBUTE; + +import java.util.Optional; + +import jakarta.json.Json; +import jakarta.json.JsonArray; +import jakarta.json.JsonBuilderFactory; +import jakarta.json.JsonObject; +import jakarta.json.JsonObjectBuilder; +import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.policy.model.Action; +import org.eclipse.edc.policy.model.AndConstraint; +import org.eclipse.edc.policy.model.AtomicConstraint; +import org.eclipse.edc.policy.model.Constraint; +import org.eclipse.edc.policy.model.Duty; +import org.eclipse.edc.policy.model.Expression; +import org.eclipse.edc.policy.model.LiteralExpression; +import org.eclipse.edc.policy.model.MultiplicityConstraint; +import org.eclipse.edc.policy.model.OrConstraint; +import org.eclipse.edc.policy.model.Permission; +import org.eclipse.edc.policy.model.Policy; +import org.eclipse.edc.policy.model.PolicyType; +import org.eclipse.edc.policy.model.Prohibition; +import org.eclipse.edc.policy.model.Rule; +import org.eclipse.edc.policy.model.XoneConstraint; +import org.eclipse.edc.spi.agent.ParticipantIdMapper; +import org.eclipse.edc.transform.spi.TransformerContext; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Transforms a {@link Policy} to an ODRL type as a {@link JsonObject} in expanded JSON-LD form. + */ +@SuppressWarnings({ "PMD.TooManyStaticImports", + "PMD.ExcessiveImports", + "PMD.TooManyMethods" +}) +public class JsonObjectFromPolicyTransformer extends AbstractJsonLdTransformer { + private final JsonBuilderFactory jsonFactory; + private final ParticipantIdMapper participantIdMapper; + + public JsonObjectFromPolicyTransformer(final JsonBuilderFactory jsonFactory, + final ParticipantIdMapper participantIdMapper) { + super(Policy.class, JsonObject.class); + this.jsonFactory = jsonFactory; + this.participantIdMapper = participantIdMapper; + } + + @Override + public @Nullable JsonObject transform(final @NotNull Policy policy, final @NotNull TransformerContext context) { + return policy.accept(new Visitor(jsonFactory, participantIdMapper)); + } + + /** + * Walks the policy object model, transforming it to a JsonObject. + */ + private static class Visitor + implements Policy.Visitor, Rule.Visitor, Constraint.Visitor, + Expression.Visitor { + private final JsonBuilderFactory jsonFactory; + private final ParticipantIdMapper participantIdMapper; + + /* default */ Visitor(final JsonBuilderFactory jsonFactory, final ParticipantIdMapper participantIdMapper) { + this.jsonFactory = jsonFactory; + this.participantIdMapper = participantIdMapper; + } + + @Override + public JsonObject visitAndConstraint(final AndConstraint andConstraint) { + return visitMultiplicityConstraint(ODRL_AND_CONSTRAINT_ATTRIBUTE, andConstraint); + } + + @Override + public JsonObject visitOrConstraint(final OrConstraint orConstraint) { + return visitMultiplicityConstraint(ODRL_OR_CONSTRAINT_ATTRIBUTE, orConstraint); + } + + @Override + public JsonObject visitXoneConstraint(final XoneConstraint xoneConstraint) { + return visitMultiplicityConstraint(ODRL_XONE_CONSTRAINT_ATTRIBUTE, xoneConstraint); + } + + private JsonObject visitMultiplicityConstraint(final String operandType, + final MultiplicityConstraint multiplicityConstraint) { + final var constraintsBuilder = jsonFactory.createArrayBuilder(); + for (final var constraint : multiplicityConstraint.getConstraints()) { + Optional.of(constraint).map(c -> c.accept(this)).ifPresent(constraintsBuilder::add); + } + + return jsonFactory.createObjectBuilder().add(operandType, constraintsBuilder.build()).build(); + } + + @Override + public JsonObject visitAtomicConstraint(final AtomicConstraint atomicConstraint) { + final var constraintBuilder = jsonFactory.createObjectBuilder(); + + constraintBuilder.add(ODRL_LEFT_OPERAND_ATTRIBUTE, atomicConstraint.getLeftExpression().accept(this)); + final var operator = atomicConstraint.getOperator().getOdrlRepresentation(); + constraintBuilder.add(ODRL_OPERATOR_ATTRIBUTE, + jsonFactory.createArrayBuilder().add(jsonFactory.createObjectBuilder().add(ID, operator))); + constraintBuilder.add(ODRL_RIGHT_OPERAND_ATTRIBUTE, atomicConstraint.getRightExpression().accept(this)); + + return constraintBuilder.build(); + } + + @Override + public JsonObject visitLiteralExpression(final LiteralExpression expression) { + return jsonFactory.createObjectBuilder() + .add(VALUE, Json.createValue(expression.getValue().toString())) + .build(); + } + + @Override + public JsonObject visitPolicy(final Policy policy) { + final var permissionsBuilder = jsonFactory.createArrayBuilder(); + policy.getPermissions().forEach(permission -> permissionsBuilder.add(permission.accept(this))); + + final var prohibitionsBuilder = jsonFactory.createArrayBuilder(); + policy.getProhibitions().forEach(prohibition -> prohibitionsBuilder.add(prohibition.accept(this))); + + final var obligationsBuilder = jsonFactory.createArrayBuilder(); + policy.getObligations().forEach(duty -> obligationsBuilder.add(duty.accept(this))); + + final var builder = jsonFactory.createObjectBuilder() + .add(ID, randomUUID().toString()) + .add(TYPE, getTypeAsString(policy.getType())) + .add(ODRL_PERMISSION_ATTRIBUTE, permissionsBuilder) + .add(ODRL_PROHIBITION_ATTRIBUTE, prohibitionsBuilder) + .add(ODRL_OBLIGATION_ATTRIBUTE, obligationsBuilder); + + Optional.ofNullable(policy.getAssignee()) + .map(participantIdMapper::toIri) + .ifPresent(target -> builder.add(ODRL_ASSIGNEE_ATTRIBUTE, + jsonFactory.createArrayBuilder().add(jsonFactory.createObjectBuilder().add(ID, target)))); + Optional.ofNullable(policy.getAssigner()) + .map(participantIdMapper::toIri) + .ifPresent(target -> builder.add(ODRL_ASSIGNER_ATTRIBUTE, + jsonFactory.createArrayBuilder().add(jsonFactory.createObjectBuilder().add(ID, target)))); + Optional.ofNullable(policy.getTarget()) + .ifPresent(target -> builder.add(ODRL_TARGET_ATTRIBUTE, + jsonFactory.createArrayBuilder().add(jsonFactory.createObjectBuilder().add(ID, target)))); + + return builder.build(); + } + + @Override + public JsonObject visitPermission(final Permission permission) { + final var permissionBuilder = visitRule(permission); + + if (permission.getDuties() != null && !permission.getDuties().isEmpty()) { + final var dutiesBuilder = jsonFactory.createArrayBuilder(); + for (final var duty : permission.getDuties()) { + dutiesBuilder.add(visitDuty(duty)); + } + permissionBuilder.add(ODRL_DUTY_ATTRIBUTE, dutiesBuilder.build()); + } + + return permissionBuilder.build(); + } + + @Override + public JsonObject visitProhibition(final Prohibition prohibition) { + final var prohibitionBuilder = visitRule(prohibition); + + return prohibitionBuilder.build(); + } + + @Override + public JsonObject visitDuty(final Duty duty) { + final var obligationBuilder = visitRule(duty); + + if (duty.getConsequence() != null) { + final var consequence = visitDuty(duty.getConsequence()); + obligationBuilder.add(ODRL_CONSEQUENCE_ATTRIBUTE, consequence); + } + + return obligationBuilder.build(); + } + + private JsonObjectBuilder visitRule(final Rule rule) { + final var ruleBuilder = jsonFactory.createObjectBuilder(); + + ruleBuilder.add(ODRL_ACTION_ATTRIBUTE, visitAction(rule.getAction())); + if (rule.getConstraints() != null && !rule.getConstraints().isEmpty()) { + ruleBuilder.add(ODRL_CONSTRAINT_ATTRIBUTE, visitConstraints(rule)); + } + + return ruleBuilder; + } + + private JsonArray visitConstraints(final Rule rule) { + final var constraintsBuilder = jsonFactory.createArrayBuilder(); + + for (final var constraint : rule.getConstraints()) { + Optional.of(constraint).map(c -> c.accept(this)).ifPresent(constraintsBuilder::add); + } + + return constraintsBuilder.build(); + } + + private JsonObject visitAction(final @Nullable Action action) { + final var actionBuilder = jsonFactory.createObjectBuilder(); + if (action == null) { + return actionBuilder.build(); + } + actionBuilder.add(ODRL_ACTION_TYPE_ATTRIBUTE, action.getType()); + if (action.getIncludedIn() != null) { + actionBuilder.add(ODRL_INCLUDED_IN_ATTRIBUTE, action.getIncludedIn()); + } + if (action.getConstraint() != null) { + actionBuilder.add(ODRL_REFINEMENT_ATTRIBUTE, action.getConstraint().accept(this)); + } + return actionBuilder.build(); + } + + private String getTypeAsString(final PolicyType type) { + return switch (type) { + case SET -> ODRL_POLICY_TYPE_SET; + case OFFER -> ODRL_POLICY_TYPE_OFFER; + case CONTRACT -> ODRL_POLICY_TYPE_AGREEMENT; + }; + } + + } + +} diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectFromTransferProcessRequestTransformer.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectFromTransferProcessRequestTransformer.java index d1d151dd9c..4755b3d9bf 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectFromTransferProcessRequestTransformer.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectFromTransferProcessRequestTransformer.java @@ -56,7 +56,7 @@ public JsonObjectFromTransferProcessRequestTransformer(final JsonBuilderFactory public @Nullable JsonObject transform(@NotNull final TransferProcessRequest dto, @NotNull final TransformerContext context) { final JsonObjectBuilder builder = this.jsonFactory.createObjectBuilder(); builder.add(TransferProcessRequest.EDC_TRANSFER_REQUEST_DTO_ASSET_ID, dto.getAssetId()) - .add(TransferProcessRequest.EDC_TRANSFER_REQUEST_DTO_CONNECTOR_ADDRESS, dto.getConnectorAddress()) + .add(TransferProcessRequest.EDC_TRANSFER_REQUEST_DTO_COUNTER_PARTY_ADDRESS, dto.getCounterPartyAddress()) .add(TransferProcessRequest.EDC_TRANSFER_REQUEST_DTO_CONTRACT_ID, dto.getContractId()) .add(TransferProcessRequest.EDC_TRANSFER_REQUEST_DTO_DATA_DESTINATION, context.transform(dto.getDataDestination(), JsonObject.class)) @@ -66,6 +66,9 @@ public JsonObjectFromTransferProcessRequestTransformer(final JsonBuilderFactory Optional.ofNullable(dto.getConnectorId()) .ifPresent(s -> builder.add(TransferProcessRequest.EDC_TRANSFER_REQUEST_DTO_CONNECTOR_ID, dto.getConnectorId())); + Optional.ofNullable(dto.getTransferType()) + .ifPresent(s -> builder.add(TransferProcessRequest.EDC_TRANSFER_REQUEST_DTO_TRANSFER_TYPE, + dto.getTransferType())); Optional.ofNullable(dto.getCallbackAddresses()) .ifPresent(s -> builder.add(TransferProcessRequest.EDC_TRANSFER_REQUEST_DTO_CALLBACK_ADDRESSES, asArray(dto.getCallbackAddresses(), context))); diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToCatalogTransformer.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToCatalogTransformer.java new file mode 100644 index 0000000000..e34c45bf20 --- /dev/null +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToCatalogTransformer.java @@ -0,0 +1,64 @@ +/******************************************************************************** + * Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (c) 2021,2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * 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. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ +package org.eclipse.tractusx.irs.edc.client.transformer; + +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCAT_DATASET_ATTRIBUTE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCAT_DATA_SERVICE_ATTRIBUTE; + +import jakarta.json.JsonObject; +import jakarta.json.JsonValue; +import org.eclipse.edc.catalog.spi.Catalog; +import org.eclipse.edc.catalog.spi.DataService; +import org.eclipse.edc.catalog.spi.Dataset; +import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.transform.spi.TransformerContext; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Converts from a DCAT catalog as a {@link JsonObject} in JSON-LD expanded form to a {@link Catalog}. + */ +public class JsonObjectToCatalogTransformer extends AbstractJsonLdTransformer { + + public JsonObjectToCatalogTransformer() { + super(JsonObject.class, Catalog.class); + } + + @Override + public @Nullable Catalog transform(final @NotNull JsonObject object, final @NotNull TransformerContext context) { + final var builder = Catalog.Builder.newInstance(); + + builder.id(nodeId(object)); + visitProperties(object, (key, value) -> transformProperties(key, value, builder, context)); + + return builderResult(builder::build, context); + } + + private void transformProperties(final String key, final JsonValue value, final Catalog.Builder builder, + final TransformerContext context) { + if (DCAT_DATASET_ATTRIBUTE.equals(key)) { + transformArrayOrObject(value, Dataset.class, builder::dataset, context); + } else if (DCAT_DATA_SERVICE_ATTRIBUTE.equals(key)) { + transformArrayOrObject(value, DataService.class, builder::dataService, context); + } else { + builder.property(key, transformGenericProperty(value, context)); + } + } +} diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToDataServiceTransformer.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToDataServiceTransformer.java new file mode 100644 index 0000000000..f0c056c92a --- /dev/null +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToDataServiceTransformer.java @@ -0,0 +1,61 @@ +/******************************************************************************** + * Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (c) 2021,2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * 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. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ +package org.eclipse.tractusx.irs.edc.client.transformer; + +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCT_ENDPOINT_URL_ATTRIBUTE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCT_TERMS_ATTRIBUTE; + +import jakarta.json.JsonObject; +import jakarta.json.JsonValue; +import org.eclipse.edc.catalog.spi.DataService; +import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.transform.spi.TransformerContext; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Converts from a DCAT data service as a {@link JsonObject} in JSON-LD expanded form to a {@link DataService}. + */ +public class JsonObjectToDataServiceTransformer extends AbstractJsonLdTransformer { + + public JsonObjectToDataServiceTransformer() { + super(JsonObject.class, DataService.class); + } + + @Override + public @Nullable DataService transform(final @NotNull JsonObject object, + final @NotNull TransformerContext context) { + final var builder = DataService.Builder.newInstance(); + + builder.id(nodeId(object)); + visitProperties(object, (key, value) -> transformProperties(key, value, builder, context)); + + return builderResult(builder::build, context); + } + + private void transformProperties(final String key, final JsonValue value, final DataService.Builder builder, + final TransformerContext context) { + if (DCT_TERMS_ATTRIBUTE.equals(key)) { + transformString(value, builder::terms, context); + } else if (DCT_ENDPOINT_URL_ATTRIBUTE.equals(key)) { + transformString(value, builder::endpointUrl, context); + } + } +} diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToDatasetTransformer.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToDatasetTransformer.java new file mode 100644 index 0000000000..39025ca766 --- /dev/null +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToDatasetTransformer.java @@ -0,0 +1,85 @@ +/******************************************************************************** + * Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (c) 2021,2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * 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. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ +package org.eclipse.tractusx.irs.edc.client.transformer; + +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCAT_DATASET_TYPE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCAT_DISTRIBUTION_ATTRIBUTE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_POLICY_ATTRIBUTE; + +import jakarta.json.JsonArray; +import jakarta.json.JsonObject; +import jakarta.json.JsonValue; +import org.eclipse.edc.catalog.spi.Dataset; +import org.eclipse.edc.catalog.spi.Distribution; +import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.policy.model.Policy; +import org.eclipse.edc.transform.spi.TransformerContext; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Converts from a DCAT dataset as a {@link JsonObject} in JSON-LD expanded form to a {@link Dataset}. + */ +public class JsonObjectToDatasetTransformer extends AbstractJsonLdTransformer { + + public JsonObjectToDatasetTransformer() { + super(JsonObject.class, Dataset.class); + } + + @Override + public @Nullable Dataset transform(final @NotNull JsonObject object, final @NotNull TransformerContext context) { + final var builder = Dataset.Builder.newInstance(); + + builder.id(nodeId(object)); + visitProperties(object, (key, value) -> transformProperties(key, value, builder, context)); + + return builderResult(builder::build, context); + } + + private void transformProperties(final String key, final JsonValue value, final Dataset.Builder builder, + final TransformerContext context) { + switch (key) { + case ODRL_POLICY_ATTRIBUTE -> transformPolicies(value, builder, context); + case DCAT_DISTRIBUTION_ATTRIBUTE -> + transformArrayOrObject(value, Distribution.class, builder::distribution, context); + default -> builder.property(key, transformGenericProperty(value, context)); + } + } + + private void transformPolicies(final JsonValue value, final Dataset.Builder builder, + final TransformerContext context) { + if (value instanceof JsonObject object) { + final var offerId = nodeId(object); + final var policy = context.transform(object, Policy.class); + builder.offer(offerId, policy); + } else if (value instanceof JsonArray array) { + array.forEach(entry -> transformPolicies(entry, builder, context)); + } else { + context.problem() + .unexpectedType() + .type(DCAT_DATASET_TYPE) + .property(ODRL_POLICY_ATTRIBUTE) + .actual(value == null ? "null" : value.getValueType().toString()) + .expected(JsonValue.ValueType.OBJECT) + .expected(JsonValue.ValueType.ARRAY) + .report(); + } + } +} diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToDistributionTransformer.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToDistributionTransformer.java new file mode 100644 index 0000000000..99710fbb5f --- /dev/null +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToDistributionTransformer.java @@ -0,0 +1,61 @@ +/******************************************************************************** + * Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (c) 2021,2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * 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. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ +package org.eclipse.tractusx.irs.edc.client.transformer; + +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCAT_ACCESS_SERVICE_ATTRIBUTE; +import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCT_FORMAT_ATTRIBUTE; + +import jakarta.json.JsonObject; +import jakarta.json.JsonValue; +import org.eclipse.edc.catalog.spi.DataService; +import org.eclipse.edc.catalog.spi.Distribution; +import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.transform.spi.TransformerContext; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Converts from a DCAT distribution as a {@link JsonObject} in JSON-LD expanded form to a {@link Distribution}. + */ +public class JsonObjectToDistributionTransformer extends AbstractJsonLdTransformer { + + public JsonObjectToDistributionTransformer() { + super(JsonObject.class, Distribution.class); + } + + @Override + public @Nullable Distribution transform(final @NotNull JsonObject object, + final @NotNull TransformerContext context) { + final var builder = Distribution.Builder.newInstance(); + visitProperties(object, (key, value) -> transformProperties(key, value, builder, context)); + return builderResult(builder::build, context); + } + + private void transformProperties(final String key, final JsonValue value, final Distribution.Builder builder, + final TransformerContext context) { + if (DCAT_ACCESS_SERVICE_ATTRIBUTE.equals(key)) { + final var dataServiceBuilder = DataService.Builder.newInstance(); + transformString(value, dataServiceBuilder::id, context); + builder.dataService(dataServiceBuilder.build()); + } else if (DCT_FORMAT_ATTRIBUTE.equals(key)) { + transformString(value, builder::format, context); + } + } +} diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToPolicyTransformer.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToIrsPolicyTransformer.java similarity index 93% rename from irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToPolicyTransformer.java rename to irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToIrsPolicyTransformer.java index 7e14e41e82..ccb8b3ef5b 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToPolicyTransformer.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToIrsPolicyTransformer.java @@ -37,11 +37,11 @@ /** * Transformer to convert JSON-LD to Policy. */ -public class JsonObjectToPolicyTransformer extends AbstractJsonLdTransformer { +public class JsonObjectToIrsPolicyTransformer extends AbstractJsonLdTransformer { private final ObjectMapper objectMapper; - protected JsonObjectToPolicyTransformer(final ObjectMapper objectMapper) { + protected JsonObjectToIrsPolicyTransformer(final ObjectMapper objectMapper) { super(JsonObject.class, Policy.class); this.objectMapper = objectMapper; } diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/ContractNegotiationServiceTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/ContractNegotiationServiceTest.java index 18ee578180..25bbc9d1d3 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/ContractNegotiationServiceTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/ContractNegotiationServiceTest.java @@ -34,6 +34,7 @@ import org.eclipse.edc.policy.model.Permission; import org.eclipse.edc.policy.model.Policy; +import org.eclipse.edc.policy.model.PolicyType; import org.eclipse.edc.spi.types.domain.edr.EndpointDataReference; import org.eclipse.tractusx.irs.edc.client.cache.endpointdatareference.EndpointDataReferenceStatus; import org.eclipse.tractusx.irs.edc.client.exceptions.ContractNegotiationException; @@ -68,8 +69,8 @@ class ContractNegotiationServiceTest { private PolicyCheckerService policyCheckerService; private static Policy createPolicy(final String assetId) { - final Permission permission = Permission.Builder.newInstance().target(assetId).build(); - return Policy.Builder.newInstance().permission(permission).build(); + final Permission permission = Permission.Builder.newInstance().build(); + return Policy.Builder.newInstance().target(assetId).type(PolicyType.SET).permission(permission).build(); } private static CatalogItem createCatalogItem(final String assetId, final String offerId) { @@ -118,8 +119,9 @@ void shouldThrowErrorWhenRetrievingNegotiationResult() { when(edcControlPlaneClient.getNegotiationResult(any())).thenReturn(response); // act & assert - assertThatThrownBy(() -> testee.negotiate(CONNECTOR_URL, catalogItem, new EndpointDataReferenceStatus(null, - EndpointDataReferenceStatus.TokenStatus.REQUIRED_NEW), "bpn")).isInstanceOf(EdcClientException.class); + assertThatThrownBy(() -> testee.negotiate(CONNECTOR_URL, catalogItem, + new EndpointDataReferenceStatus(null, EndpointDataReferenceStatus.TokenStatus.REQUIRED_NEW), + "bpn")).isInstanceOf(EdcClientException.class); } @Test @@ -143,8 +145,9 @@ void shouldThrowErrorWhenRetrievingTransferResult() { when(edcControlPlaneClient.getTransferProcess(any())).thenReturn(transferError); // act & assert - assertThatThrownBy(() -> testee.negotiate(CONNECTOR_URL, catalogItem, new EndpointDataReferenceStatus(null, - EndpointDataReferenceStatus.TokenStatus.REQUIRED_NEW), "bpn")).isInstanceOf(EdcClientException.class); + assertThatThrownBy(() -> testee.negotiate(CONNECTOR_URL, catalogItem, + new EndpointDataReferenceStatus(null, EndpointDataReferenceStatus.TokenStatus.REQUIRED_NEW), + "bpn")).isInstanceOf(EdcClientException.class); } @Test @@ -159,8 +162,9 @@ void shouldThrowErrorWhenPolicyCheckerReturnFalse() { when(policyCheckerService.isValid(any(), any())).thenReturn(Boolean.FALSE); // act & assert - assertThatThrownBy(() -> testee.negotiate(CONNECTOR_URL, catalogItem, new EndpointDataReferenceStatus(null, - EndpointDataReferenceStatus.TokenStatus.REQUIRED_NEW), "bpn")).isInstanceOf(EdcClientException.class); + assertThatThrownBy(() -> testee.negotiate(CONNECTOR_URL, catalogItem, + new EndpointDataReferenceStatus(null, EndpointDataReferenceStatus.TokenStatus.REQUIRED_NEW), + "bpn")).isInstanceOf(EdcClientException.class); } @Test @@ -230,8 +234,13 @@ void shouldNotStartNewNegotiationWhenTokenIsExpired() // when testee.negotiate(CONNECTOR_URL, catalogItem, new EndpointDataReferenceStatus( - EndpointDataReference.Builder.newInstance().authKey("").authCode(encodedAuthCode).endpoint("").build(), - EndpointDataReferenceStatus.TokenStatus.EXPIRED), "bpn"); + EndpointDataReference.Builder.newInstance() + .authKey("") + .authCode(encodedAuthCode) + .endpoint("") + .id("testid") + .contractId("testContractId") + .build(), EndpointDataReferenceStatus.TokenStatus.EXPIRED), "bpn"); // then verify(edcControlPlaneClient, never()).startNegotiations(any()); @@ -247,8 +256,14 @@ void shouldThrowInvalidStateExceptionWhenTokenIsValid() { // when // then assertThatThrownBy(() -> testee.negotiate(CONNECTOR_URL, catalogItem, new EndpointDataReferenceStatus( - EndpointDataReference.Builder.newInstance().authKey("").endpoint("").authCode("").build(), - EndpointDataReferenceStatus.TokenStatus.VALID), "bpn")).isInstanceOf(IllegalStateException.class); + EndpointDataReference.Builder.newInstance() + .authKey("") + .endpoint("") + .authCode("") + .id("testid") + .contractId("testContractId") + .build(), EndpointDataReferenceStatus.TokenStatus.VALID), + "bpn")).isInstanceOf(IllegalStateException.class); } } \ No newline at end of file diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EDCCatalogFacadeTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EDCCatalogFacadeTest.java index 61117e30fd..2a1ef1d5d2 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EDCCatalogFacadeTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EDCCatalogFacadeTest.java @@ -28,6 +28,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -35,6 +36,9 @@ import java.util.List; +import org.eclipse.edc.catalog.spi.Catalog; +import org.eclipse.edc.policy.model.Policy; +import org.eclipse.edc.policy.model.PolicyType; import org.eclipse.tractusx.irs.edc.client.model.CatalogItem; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -60,18 +64,20 @@ void shouldReturnEntireCatalogIfAssetIdNotFound() { // arrange final var assetId = "testTarget"; final String connectorUrl = "testConnector"; + final String providerBpn = "BPN000123456"; final var firstPage = createCatalog("other", DEFAULT_PAGE_SIZE); final var secondPage = createCatalog("other", 2); - when(controlPlaneClient.getCatalog(connectorUrl, 0)).thenReturn(firstPage); - when(controlPlaneClient.getCatalog(connectorUrl, 3)).thenReturn(secondPage); + when(controlPlaneClient.getCatalog(connectorUrl, 0, providerBpn)).thenReturn(firstPage); + when(controlPlaneClient.getCatalog(connectorUrl, 3, providerBpn)).thenReturn(secondPage); // act - final List catalog = edcCatalogFacade.fetchCatalogItemsUntilMatch(connectorUrl, assetId); + final List catalog = edcCatalogFacade.fetchCatalogItemsUntilMatch(connectorUrl, assetId, + providerBpn); // assert assertThat(catalog).hasSize(5); - verify(controlPlaneClient, times(2)).getCatalog(any(), anyInt()); + verify(controlPlaneClient, times(2)).getCatalog(any(), anyInt(), eq(providerBpn)); } @Test @@ -79,16 +85,18 @@ void shouldReturnEntireCatalogIfAssetIdNotFoundAndPagesAreTheSame() { // arrange final var assetId = "testTarget"; final String connectorUrl = "testConnector"; + final String providerBpn = "BPN000123456"; final var firstPage = createCatalog("other", DEFAULT_PAGE_SIZE); - when(controlPlaneClient.getCatalog(anyString(), anyInt())).thenReturn(firstPage); + when(controlPlaneClient.getCatalog(anyString(), anyInt(), anyString())).thenReturn(firstPage); // act - final List catalog = edcCatalogFacade.fetchCatalogItemsUntilMatch(connectorUrl, assetId); + final List catalog = edcCatalogFacade.fetchCatalogItemsUntilMatch(connectorUrl, assetId, + providerBpn); // assert assertThat(catalog).hasSize(3); - verify(controlPlaneClient, times(2)).getCatalog(any(), anyInt()); + verify(controlPlaneClient, times(2)).getCatalog(any(), anyInt(), eq(providerBpn)); } @Test @@ -96,18 +104,55 @@ void shouldReturnOnePageIfOfferIsFound() { // arrange final var assetId = "testTarget2"; final String connectorUrl = "testConnector"; + final String providerBpn = "BPN000123456"; final var firstPage = createCatalog("testTarget", DEFAULT_PAGE_SIZE); final var secondPage = createCatalog("other", DEFAULT_PAGE_SIZE); - when(controlPlaneClient.getCatalog(connectorUrl, 0)).thenReturn(firstPage); - when(controlPlaneClient.getCatalog(connectorUrl, DEFAULT_PAGE_SIZE)).thenReturn(secondPage); + when(controlPlaneClient.getCatalog(connectorUrl, 0, providerBpn)).thenReturn(firstPage); + when(controlPlaneClient.getCatalog(connectorUrl, DEFAULT_PAGE_SIZE, providerBpn)).thenReturn(secondPage); // act - final List catalog = edcCatalogFacade.fetchCatalogItemsUntilMatch(connectorUrl, assetId); + final List catalog = edcCatalogFacade.fetchCatalogItemsUntilMatch(connectorUrl, assetId, + providerBpn); // assert assertThat(catalog).hasSize(3); - verify(controlPlaneClient, times(1)).getCatalog(any(), anyInt()); + verify(controlPlaneClient, times(1)).getCatalog(any(), anyInt(), anyString()); } + @Test + void shouldReturnAndMapCatalog() { + // arrange + final var assetId = "testTarget"; + final String connectorUrl = "testConnector"; + final String providerBpn = "BPN000123456"; + final String filterKey = "filterKey"; + final String offerId = "definitionId:%s:randomId".formatted(assetId); + final Policy policy = Policy.Builder.newInstance() + .type(PolicyType.OFFER) + .permissions(List.of()) + .prohibitions(List.of()) + .duties(List.of()) + .build(); + final Catalog catalog = createCatalog(assetId, policy, providerBpn, offerId); + when(controlPlaneClient.getCatalogWithFilter(connectorUrl, filterKey, assetId, providerBpn)).thenReturn( + catalog); + + // act + final List catalogItems = edcCatalogFacade.fetchCatalogByFilter(connectorUrl, filterKey, assetId, + providerBpn); + + // assert + assertThat(catalogItems).hasSize(1); + final CatalogItem catalogItem = catalogItems.get(0); + assertThat(catalogItem.getAssetPropId()).isEqualTo(assetId); + assertThat(catalogItem.getItemId()).isEqualTo(assetId); + assertThat(catalogItem.getConnectorId()).isEqualTo(providerBpn); + assertThat(catalogItem.getOfferId()).isEqualTo(offerId); + final Policy catalogPolicy = catalogItem.getPolicy(); + assertThat(catalogPolicy).isNotNull(); + assertThat(catalogPolicy.getAssigner()).isEqualTo(providerBpn); + assertThat(catalogPolicy.getTarget()).isEqualTo(assetId); + + } } \ No newline at end of file diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcCallbackControllerTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcCallbackControllerTest.java index 7da35a9435..f37cb85bd5 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcCallbackControllerTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcCallbackControllerTest.java @@ -26,6 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat; import java.time.Duration; +import java.util.Optional; import org.eclipse.edc.spi.types.domain.edr.EndpointDataReference; import org.junit.jupiter.api.Test; @@ -38,31 +39,120 @@ class EdcCallbackControllerTest { @Test void shouldStoreAgreementId() { // arrange - final var ref = EndpointDataReference.Builder.newInstance() - .endpoint("test") - .authKey("Authorization") - .authCode( - "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2ODkwODA5OTEsImRhZCI6InRlc3QiLCJjaWQiOiJ0ZXN0SWQiLCJpYXQiOjE2ODkwODI2ODF9.62AIg-k8Yz6xLUBPblv2AtA5fuhoBnm9KMxhdCUunhA") - .build(); + final String ref = """ + { + "id": "bc916834-61b8-4754-b3e2-1eb041d253c2", + "at": 1714645750814, + "payload": { + "assetId": "urn:uuid:df3aa078-567a-4b39-afa1-c92f32e6eaad", + "contractId": "testContractId", + "dataAddress": { + "properties": { + "process_id": "testid", + "https://w3id.org/edc/v0.0.1/ns/endpoint": "test", + "asset_id": "urn:uuid:df3aa078-567a-4b39-afa1-c92f32e6eaad", + "agreement_id": "testContractId", + "https://w3id.org/edc/v0.0.1/ns/authorization": "testToken" + } + } + } + } + """; + final String expectedId = "testid"; + final String expectedContractId = "testContractId"; + final String expectedEndpoint = "test"; + final String expectedAuthKey = "Authorization"; + final String expectedAuthCode = "testToken"; // act testee.receiveEdcCallback(ref); // assert - final var result = storage.get("testId"); - assertThat(result).isNotNull().contains(ref); + final var result = storage.get("testContractId"); + assertThat(result).isNotNull().isPresent(); + assertThat(result.get().getId()).isEqualTo(expectedId); + assertThat(result.get().getContractId()).isEqualTo(expectedContractId); + assertThat(result.get().getEndpoint()).isEqualTo(expectedEndpoint); + assertThat(result.get().getAuthKey()).isEqualTo(expectedAuthKey); + assertThat(result.get().getAuthCode()).isEqualTo(expectedAuthCode); } @Test void shouldDoNothingWhenEDRTokenIsInvalid() { // arrange - final var ref = EndpointDataReference.Builder.newInstance().endpoint("test").build(); + final String ref = """ + { + "id": "bc916834-61b8-4754-b3e2-1eb041d253c2", + "at": 1714645750814, + "payload": { + "assetId": "urn:uuid:df3aa078-567a-4b39-afa1-c92f32e6eaad", + "contractId": "testContractId" + } + } + """; // act testee.receiveEdcCallback(ref); // assert - final var result = storage.get("testId"); + final var result = storage.get("testContractId"); assertThat(result).isNotNull().isEmpty(); } + + @Test + void shouldDeserializeCallbackEDR() { + // arrange + final String callbackEDR = """ + { + "id": "b4d5d2f6-9da4-4236-864f-2803aeda1f56", + "at": 1714647576205, + "payload": { + "transferProcessId": "2a02c181-7bb4-4521-aeb2-867adb829556", + "callbackAddresses": [ + { + "uri": "http://callback.url", + "events": [ + "transfer.process.started" + ], + "transactional": false, + "authKey": null, + "authCodeId": null + } + ], + "assetId": "urn:uuid:df3aa078-567a-4b39-afa1-c92f32e6eaad", + "type": "CONSUMER", + "contractId": "e6a5704f-fdba-4ebd-975e-f650af8a70a8", + "dataAddress": { + "properties": { + "process_id": "ca06c205-71d6-4a0f-97a8-835189fa9856", + "participant_id": "BPNL00000001CRHK", + "asset_id": "urn:uuid:df3aa078-567a-4b39-afa1-c92f32e6eaad", + "https://w3id.org/edc/v0.0.1/ns/endpointType": "https://w3id.org/idsa/v4.1/HTTP", + "https://w3id.org/tractusx/auth/refreshEndpoint": "http://dataplane.url/api/public/token", + "https://w3id.org/tractusx/auth/audience": "did:web:issuer:did:BPNL000000012345", + "agreement_id": "e6a5704f-fdba-4ebd-975e-f650af8a70a8", + "flow_type": "PULL", + "https://w3id.org/edc/v0.0.1/ns/type": "https://w3id.org/idsa/v4.1/HTTP", + "https://w3id.org/edc/v0.0.1/ns/endpoint": "http://dataplane.url/api/public", + "https://w3id.org/tractusx/auth/refreshToken": "testRefreshToken", + "https://w3id.org/tractusx/auth/expiresIn": "300", + "https://w3id.org/edc/v0.0.1/ns/authorization": "testJWT", + "https://w3id.org/tractusx/auth/refreshAudience": "did:web:issuer:did:BPNL000000012345" + } + } + }, + "type": "TransferProcessStarted" + } + """; + + // act + testee.receiveEdcCallback(callbackEDR); + + // assert + final Optional actualEdr = storage.get("e6a5704f-fdba-4ebd-975e-f650af8a70a8"); + assertThat(actualEdr).isNotNull().isPresent(); + assertThat(actualEdr.get().getAuthCode()).isEqualTo("testJWT"); + assertThat(actualEdr.get().getAuthKey()).isEqualTo("Authorization"); + assertThat(actualEdr.get().getContractId()).isEqualTo("e6a5704f-fdba-4ebd-975e-f650af8a70a8"); + } } \ No newline at end of file diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcControlPlaneClientTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcControlPlaneClientTest.java index ad246bf767..d3d84a6f05 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcControlPlaneClientTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcControlPlaneClientTest.java @@ -102,6 +102,7 @@ void shouldReturnValidCatalog() { // arrange final var catalog = mock(Catalog.class); final var catalogString = "test"; + final String providerBpn = "BPN000123456"; final JsonObject emptyJsonObject = JsonObject.EMPTY_JSON_OBJECT; doReturn(emptyJsonObject).when(edcTransformer).transformCatalogRequestToJson(any(CatalogRequest.class)); doReturn(catalog).when(edcTransformer).transformCatalog(anyString(), eq(StandardCharsets.UTF_8)); @@ -109,7 +110,7 @@ void shouldReturnValidCatalog() { eq(String.class))).thenReturn(ResponseEntity.of(Optional.of(catalogString))); // act - final var result = testee.getCatalog("test", 0); + final var result = testee.getCatalog("test", 0, providerBpn); // assert assertThat(result).isEqualTo(catalog); @@ -120,6 +121,7 @@ void shouldReturnValidCatalogUsingFilters() { // arrange final var catalog = mock(Catalog.class); final var catalogString = "test"; + final String providerBpn = "BPN000123456"; final JsonObject emptyJsonObject = JsonObject.EMPTY_JSON_OBJECT; doReturn(emptyJsonObject).when(edcTransformer).transformCatalogRequestToJson(any(CatalogRequest.class)); doReturn(catalog).when(edcTransformer).transformCatalog(anyString(), eq(StandardCharsets.UTF_8)); @@ -127,7 +129,7 @@ void shouldReturnValidCatalogUsingFilters() { eq(String.class))).thenReturn(ResponseEntity.of(Optional.of(catalogString))); // act - final var result = testee.getCatalogWithFilter("test", "asset:prop:type", "data.core.digitalTwinRegistry"); + final var result = testee.getCatalogWithFilter("test", "asset:prop:type", "data.core.digitalTwinRegistry", providerBpn); // assert assertThat(result).isEqualTo(catalog); diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcDataPlaneClientTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcDataPlaneClientTest.java index 72f3e602ba..82c6069af4 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcDataPlaneClientTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcDataPlaneClientTest.java @@ -60,6 +60,8 @@ void shouldReturnValidData() { .authKey("testkey") .authCode("testcode") .endpoint("testEndpoint") + .id("testid") + .contractId("testContractId") .build(); when(restTemplate.exchange(anyString(), eq(HttpMethod.GET), any(), eq(String.class))).thenReturn( ResponseEntity.of(Optional.of(expectedData))); @@ -80,6 +82,8 @@ void shouldSendNotification() { .authKey("testkey") .authCode("testcode") .endpoint("testEndpoint") + .id("testid") + .contractId("testContractId") .build(); when(restTemplate.exchange(anyString(), eq(HttpMethod.POST), any(), eq(String.class))).thenReturn( ResponseEntity.of(Optional.of(expectedData))); diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientTest.java index 0451444002..0171c77e91 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/EdcSubmodelClientTest.java @@ -93,6 +93,7 @@ class EdcSubmodelClientTest extends LocalTestDataConfigurationAware { private static final String PROVIDER_SUFFIX = "/test"; private static final String CONNECTOR_ENDPOINT = "https://connector.endpoint.com"; private static final String existingCatenaXId = "urn:uuid:5e1908ed-e176-4f57-9616-1415097d0fdf"; + private static final String BPN = "BPNL00000003CRHK"; private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); private final TimeMachine clock = new TimeMachine(); @@ -136,7 +137,7 @@ void shouldRetrieveValidRelationship() throws Exception { when(config.getControlplane().getProviderSuffix()).thenReturn(PROVIDER_SUFFIX); final String agreementId = "agreementId"; - when(catalogFacade.fetchCatalogByFilter(any(), any(), any())).thenReturn( + when(catalogFacade.fetchCatalogByFilter(any(), any(), any(), any())).thenReturn( List.of(CatalogItem.builder().itemId("itemId").build())); when(contractNegotiationService.negotiate(any(), any(), eq(new EndpointDataReferenceStatus(null, TokenStatus.REQUIRED_NEW)), any())).thenReturn( @@ -164,7 +165,7 @@ void shouldSendNotificationSuccessfully() throws Exception { final String agreementId = "agreementId"; final EdcNotification notification = EdcNotification.builder().build(); - when(catalogFacade.fetchCatalogByFilter(any(), any(), any())).thenReturn( + when(catalogFacade.fetchCatalogByFilter(any(), any(), any(), any())).thenReturn( List.of(CatalogItem.builder().itemId("itemId").build())); when(contractNegotiationService.negotiate(any(), any(), any(), any())).thenReturn( NegotiationResponse.builder().contractAgreementId(agreementId).build()); @@ -199,7 +200,7 @@ void shouldReturnRelationshipsWhenRequestingWithCatenaXIdAndSingleLevelBomAsBuil // arrange when(config.getControlplane().getProviderSuffix()).thenReturn(PROVIDER_SUFFIX); - when(catalogFacade.fetchCatalogByFilter(any(), any(), any())).thenReturn( + when(catalogFacade.fetchCatalogByFilter(any(), any(), any(), any())).thenReturn( List.of(CatalogItem.builder().itemId(existingCatenaXId).build())); prepareTestdata(existingCatenaXId, "_singleLevelBomAsBuilt"); when(endpointDataReferenceCacheService.getEndpointDataReference(any())).thenReturn( @@ -220,7 +221,7 @@ void shouldReturnRelationshipsWhenRequestingWithCatenaXIdAndSingleLevelBomAsPlan when(config.getControlplane().getProviderSuffix()).thenReturn(PROVIDER_SUFFIX); final String catenaXId = "urn:uuid:aad27ddb-43aa-4e42-98c2-01e529ef127c"; - when(catalogFacade.fetchCatalogByFilter(any(), any(), any())).thenReturn( + when(catalogFacade.fetchCatalogByFilter(any(), any(), any(), any())).thenReturn( List.of(CatalogItem.builder().itemId(catenaXId).build())); prepareTestdata(catenaXId, "_singleLevelBomAsPlanned"); when(endpointDataReferenceCacheService.getEndpointDataReference(any())).thenReturn( @@ -240,7 +241,7 @@ void shouldReturnRelationshipsWhenRequestingWithCatenaXIdAndSingleLevelBomAsSpec // arrange when(config.getControlplane().getProviderSuffix()).thenReturn(PROVIDER_SUFFIX); - when(catalogFacade.fetchCatalogByFilter(any(), any(), any())).thenReturn( + when(catalogFacade.fetchCatalogByFilter(any(), any(), any(), any())).thenReturn( List.of(CatalogItem.builder().itemId(existingCatenaXId).build())); prepareTestdata(existingCatenaXId, "_singleLevelBomAsSpecified"); when(endpointDataReferenceCacheService.getEndpointDataReference(any())).thenReturn( @@ -261,7 +262,7 @@ void shouldReturnEmptyRelationshipsWhenRequestingWithCatenaXIdAndSingleLevelUsag when(config.getControlplane().getProviderSuffix()).thenReturn(PROVIDER_SUFFIX); final String catenaXId = "urn:uuid:61c83b41-def0-4742-a1a8-e4e8a8cb210e"; - when(catalogFacade.fetchCatalogByFilter(any(), any(), any())).thenReturn( + when(catalogFacade.fetchCatalogByFilter(any(), any(), any(), any())).thenReturn( List.of(CatalogItem.builder().itemId(catenaXId).build())); prepareTestdata(catenaXId, "_singleLevelUsageAsBuilt"); when(endpointDataReferenceCacheService.getEndpointDataReference(any())).thenReturn( @@ -283,7 +284,7 @@ void shouldReturnEmptyRelationshipsWhenRequestingWithNotExistingCatenaXIdAndSing when(config.getControlplane().getProviderSuffix()).thenReturn(PROVIDER_SUFFIX); final String notExistingCatenaXId = "urn:uuid:8a61c8db-561e-4db0-84ec-a693fc5ffdf6"; - when(catalogFacade.fetchCatalogByFilter(any(), any(), any())).thenReturn( + when(catalogFacade.fetchCatalogByFilter(any(), any(), any(), any())).thenReturn( List.of(CatalogItem.builder().itemId(notExistingCatenaXId).build())); prepareTestdata(notExistingCatenaXId, "_singleLevelBomAsBuilt"); when(endpointDataReferenceCacheService.getEndpointDataReference(ASSET_ID)).thenReturn( @@ -304,14 +305,14 @@ void shouldReturnRawSerialPartWhenExisting() throws Exception { when(config.getControlplane().getProviderSuffix()).thenReturn(PROVIDER_SUFFIX); when(catalogFacade.fetchCatalogByFilter("https://connector.endpoint.com" + PROVIDER_SUFFIX, - "https://w3id.org/edc/v0.0.1/ns/id", ASSET_ID)).thenReturn(createCatalog(ASSET_ID, 3)); + "https://w3id.org/edc/v0.0.1/ns/id", ASSET_ID, BPN)).thenReturn(createCatalog(ASSET_ID, 3)); prepareTestdata(existingCatenaXId, "_serialPart"); when(endpointDataReferenceCacheService.getEndpointDataReference(ASSET_ID)).thenReturn( new EndpointDataReferenceStatus(null, TokenStatus.REQUIRED_NEW)); // act final String submodelResponse = testee.getSubmodelPayload("https://connector.endpoint.com", - "/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel", ASSET_ID, "bpn") + "/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel", ASSET_ID, BPN) .get(5, TimeUnit.SECONDS) .getPayload(); @@ -328,13 +329,13 @@ void shouldUseDecodedTargetId() throws Exception { prepareTestdata(existingCatenaXId, "_serialPart"); final String target = URLEncoder.encode(ASSET_ID, StandardCharsets.UTF_8); when(catalogFacade.fetchCatalogByFilter("https://connector.endpoint.com" + PROVIDER_SUFFIX, - "https://w3id.org/edc/v0.0.1/ns/id", ASSET_ID)).thenReturn(createCatalog(target, 3)); + "https://w3id.org/edc/v0.0.1/ns/id", ASSET_ID, BPN)).thenReturn(createCatalog(target, 3)); when(endpointDataReferenceCacheService.getEndpointDataReference(ASSET_ID)).thenReturn( new EndpointDataReferenceStatus(null, TokenStatus.REQUIRED_NEW)); // act final String submodelResponse = testee.getSubmodelPayload("https://connector.endpoint.com", - "/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel", ASSET_ID, "bpn") + "/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel", ASSET_ID, BPN) .get(5, TimeUnit.SECONDS) .getPayload(); @@ -350,7 +351,7 @@ void shouldReturnSameRelationshipsForDifferentDirections() throws Exception { final String parentCatenaXId = "urn:uuid:6a424c78-ef94-4b33-aec9-e8a3653374df"; final BomLifecycle asBuilt = BomLifecycle.AS_BUILT; - when(catalogFacade.fetchCatalogByFilter(any(), any(), any())).thenReturn( + when(catalogFacade.fetchCatalogByFilter(any(), any(), any(), any())).thenReturn( List.of(CatalogItem.builder().itemId(parentCatenaXId).build())); prepareTestdata(parentCatenaXId, "_singleLevelBomAsBuilt"); when(endpointDataReferenceCacheService.getEndpointDataReference(ASSET_ID)).thenReturn( @@ -391,7 +392,7 @@ void shouldRetrieveEndpointReferenceForAsset() throws Exception { final String filterKey = "filter-key"; final String filterValue = "filter-value"; final String agreementId = "agreementId"; - when(catalogFacade.fetchCatalogByFilter(any(), any(), any())).thenReturn( + when(catalogFacade.fetchCatalogByFilter(any(), any(), any(), any())).thenReturn( List.of(CatalogItem.builder().itemId("asset-id").build())); when(contractNegotiationService.negotiate(any(), any(), eq(new EndpointDataReferenceStatus(null, TokenStatus.REQUIRED_NEW)), any())).thenReturn( @@ -418,7 +419,7 @@ void shouldRetrieveEndpointReferenceForAsset() throws Exception { void shouldNotThrowClassCastException() throws Exception { // arrange when(config.getControlplane().getProviderSuffix()).thenReturn(PROVIDER_SUFFIX); - when(catalogFacade.fetchCatalogByFilter(any(), any(), any())).thenReturn( + when(catalogFacade.fetchCatalogByFilter(any(), any(), any(), any())).thenReturn( List.of(CatalogItem.builder().itemId("asset-id").build())); when(contractNegotiationService.negotiate(any(), any(), eq(new EndpointDataReferenceStatus(null, TokenStatus.REQUIRED_NEW)), any())).thenThrow( @@ -444,7 +445,7 @@ void shouldRetrieveEndpointReferenceForAsset2() throws Exception { final String filterKey = "filter-key"; final String filterValue = "filter-value"; final String agreementId = "agreementId"; - when(catalogFacade.fetchCatalogByFilter(any(), any(), any())).thenReturn( + when(catalogFacade.fetchCatalogByFilter(any(), any(), any(), any())).thenReturn( List.of(CatalogItem.builder().itemId("asset-id").build())); when(contractNegotiationService.negotiate(any(), any(), eq(new EndpointDataReferenceStatus(null, TokenStatus.REQUIRED_NEW)), any())).thenReturn( @@ -485,7 +486,7 @@ void shouldCreateCacheRecordWhenTokenIsNotValid() throws EdcClientException { when(config.getControlplane().getProviderSuffix()).thenReturn(PROVIDER_SUFFIX); final String agreementId = "agreementId"; - when(catalogFacade.fetchCatalogByFilter(any(), any(), any())).thenReturn( + when(catalogFacade.fetchCatalogByFilter(any(), any(), any(), any())).thenReturn( List.of(CatalogItem.builder().itemId("itemId").build())); when(contractNegotiationService.negotiate(any(), any(), eq(new EndpointDataReferenceStatus(null, TokenStatus.REQUIRED_NEW)), any())).thenReturn( diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/SubmodelFacadeWiremockTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/SubmodelFacadeWiremockTest.java index a7fafce3b5..fe9a429048 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/SubmodelFacadeWiremockTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/SubmodelFacadeWiremockTest.java @@ -70,6 +70,7 @@ import org.eclipse.tractusx.irs.edc.client.policy.Operator; import org.eclipse.tractusx.irs.edc.client.policy.OperatorType; import org.eclipse.tractusx.irs.edc.client.policy.Permission; +import org.eclipse.tractusx.irs.edc.client.policy.Policy; import org.eclipse.tractusx.irs.edc.client.policy.PolicyCheckerService; import org.eclipse.tractusx.irs.edc.client.policy.PolicyType; import org.eclipse.tractusx.irs.testing.wiremock.SubmodelFacadeWiremockSupport; @@ -108,6 +109,7 @@ void configureSystemUnderTest(WireMockRuntimeInfo wireMockRuntimeInfo) { config.getControlplane().setRequestTtl(Duration.ofSeconds(5)); config.getControlplane().setProviderSuffix("/api/v1/dsp"); config.getSubmodel().setUrnPrefix("/urn"); + config.setCallbackUrl("http://callback.endpoint"); final List> messageConverters = restTemplate.getMessageConverters(); for (final HttpMessageConverter converter : messageConverters) { @@ -237,7 +239,7 @@ void shouldThrowExceptionWhenPoliciesAreNotAccepted() { givenThat(get(urlPathEqualTo(SUBMODEL_DATAPLANE_PATH)).willReturn(responseWithStatus(200).withBody("test"))); // Act & Assert - final String errorMessage = "Consumption of asset '58505404-4da1-427a-82aa-b79482bcd1f0' is not permitted as the required catalog offer policies do not comply with defined IRS policies."; + final String errorMessage = "Consumption of asset '5a7ab616-989f-46ae-bdf2-32027b9f6ee6-31b614f5-ec14-4ed2-a509-e7b7780083e7' is not permitted as the required catalog offer policies do not comply with defined IRS policies."; assertThatExceptionOfType(UsagePolicyException.class).isThrownBy( () -> edcSubmodelClient.getSubmodelPayload(CONNECTOR_ENDPOINT_URL, SUBMODEL_DATAPLANE_URL, ASSET_ID, "bpn") .get()).withMessageEndingWith(errorMessage); @@ -315,11 +317,17 @@ public static EndpointDataReference createEndpointDataReference(final String con .properties( Map.of(JsonLdConfiguration.NAMESPACE_EDC_CID, contractAgreementId)) .endpoint(DATAPLANE_HOST + PATH_DATAPLANE_PUBLIC) + .id("testid") + .contractId(contractAgreementId) .build(); } - private org.eclipse.tractusx.irs.edc.client.policy.Policy policy(String policyId, List permissions) { - return new org.eclipse.tractusx.irs.edc.client.policy.Policy(policyId, OffsetDateTime.now(), - OffsetDateTime.now().plusYears(1), permissions); + private Policy policy(String policyId, List permissions) { + return Policy.builder() + .policyId(policyId) + .validUntil(OffsetDateTime.now().plusYears(1)) + .createdOn(OffsetDateTime.now()) + .permissions(permissions) + .build(); } } diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/asset/EdcAssetServiceTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/asset/EdcAssetServiceTest.java index bf78328eee..48d0aec6e4 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/asset/EdcAssetServiceTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/asset/EdcAssetServiceTest.java @@ -20,7 +20,7 @@ package org.eclipse.tractusx.irs.edc.client.asset; import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.edc.spi.types.domain.HttpDataAddress.HTTP_DATA; +import static org.eclipse.tractusx.irs.edc.client.asset.EdcAssetService.DATA_ADDRESS_TYPE_HTTP_DATA; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; @@ -94,7 +94,7 @@ void setUp() { } @Test - void testAssetCreateRequestStructure() throws JSONException, JsonProcessingException { + void testAssetCreateRequestStructure() throws JSONException { Map properties = Map.of("https://w3id.org/edc/v0.0.1/ns/description", "endpoint to qualityinvestigation receive", "https://w3id.org/edc/v0.0.1/ns/contenttype", @@ -103,7 +103,7 @@ void testAssetCreateRequestStructure() throws JSONException, JsonProcessingExcep "qualityinvestigation", "https://w3id.org/edc/v0.0.1/ns/notificationmethod", "receive"); DataAddress dataAddress = DataAddress.Builder.newInstance() - .type(HTTP_DATA) + .type(DATA_ADDRESS_TYPE_HTTP_DATA) .property("https://w3id.org/edc/v0.0.1/ns/type", "HttpData") .property("https://w3id.org/edc/v0.0.1/ns/baseUrl", "https://traceability.dev.demo.catena-x.net/api/qualitynotifications/receive") @@ -118,11 +118,7 @@ void testAssetCreateRequestStructure() throws JSONException, JsonProcessingExcep .properties(properties) .dataAddress(dataAddress) .build(); - System.out.println(objectMapper().writeValueAsString(asset)); - System.out.println(objectMapper().writeValueAsString(dataAddress)); - System.out.println(objectMapper().writeValueAsString(properties)); JsonObject jsonObject = edcTransformer.transformAssetToJson(asset); - System.out.println(objectMapper().writeValueAsString(jsonObject)); JSONAssert.assertEquals(""" { diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/policy/ConstraintCheckerServiceTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/policy/ConstraintCheckerServiceTest.java index 5821bc6d11..1cf3ef0111 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/policy/ConstraintCheckerServiceTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/policy/ConstraintCheckerServiceTest.java @@ -224,7 +224,12 @@ private Policy createPolicyWithConstraint(Constraints constraints) { Permission permission = new Permission(PolicyType.ACCESS, constraints); List permissions = List.of(permission); final String policyId = "policyId"; - return new Policy(policyId, OffsetDateTime.now(), OffsetDateTime.now().plusYears(1), permissions); + return org.eclipse.tractusx.irs.edc.client.policy.Policy.builder() + .policyId(policyId) + .validUntil(OffsetDateTime.now().plusYears(1)) + .createdOn(OffsetDateTime.now()) + .permissions(permissions) + .build(); } public AndConstraint createAndConstraint(final List constraints) { diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/policy/PolicyCheckerServiceTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/policy/PolicyCheckerServiceTest.java index a429081888..f62c317d4d 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/policy/PolicyCheckerServiceTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/policy/PolicyCheckerServiceTest.java @@ -232,16 +232,24 @@ void shouldRejectXOneConstraintsWhenMoreThanOneMatch() { } private org.eclipse.tractusx.irs.edc.client.policy.Policy policy(final String policyId) { - return new org.eclipse.tractusx.irs.edc.client.policy.Policy(policyId, OffsetDateTime.now(), - OffsetDateTime.now().plusYears(1), Collections.emptyList()); + return org.eclipse.tractusx.irs.edc.client.policy.Policy.builder() + .policyId(policyId) + .createdOn(OffsetDateTime.now()) + .validUntil(OffsetDateTime.now().plusYears(1)) + .permissions(Collections.emptyList()) + .build(); } private org.eclipse.tractusx.irs.edc.client.policy.Policy policy(final String policyId, final List andConstraint, final List orConstraint) { final Constraints constraints = new Constraints(andConstraint, orConstraint); final List permissions = List.of(new Permission(PolicyType.USE, constraints)); - return new org.eclipse.tractusx.irs.edc.client.policy.Policy(policyId, OffsetDateTime.now(), - OffsetDateTime.now().plusYears(1), permissions); + return org.eclipse.tractusx.irs.edc.client.policy.Policy.builder() + .policyId(policyId) + .validUntil(OffsetDateTime.now().plusYears(1)) + .createdOn(OffsetDateTime.now()) + .permissions(permissions) + .build(); } } \ No newline at end of file diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/testutil/TestMother.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/testutil/TestMother.java index 973b10b22a..58a34c2d81 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/testutil/TestMother.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/testutil/TestMother.java @@ -27,7 +27,6 @@ import static org.eclipse.tractusx.irs.edc.client.configuration.JsonLdConfiguration.NAMESPACE_DCT; import static org.eclipse.tractusx.irs.edc.client.configuration.JsonLdConfiguration.NAMESPACE_DSPACE; import static org.eclipse.tractusx.irs.edc.client.configuration.JsonLdConfiguration.NAMESPACE_EDC; -import static org.eclipse.tractusx.irs.edc.client.configuration.JsonLdConfiguration.NAMESPACE_EDC_ID; import static org.eclipse.tractusx.irs.edc.client.configuration.JsonLdConfiguration.NAMESPACE_EDC_PARTICIPANT_ID; import static org.eclipse.tractusx.irs.edc.client.configuration.JsonLdConfiguration.NAMESPACE_ODRL; import static org.eclipse.tractusx.irs.edc.client.configuration.JsonLdConfiguration.NAMESPACE_TRACTUSX; @@ -104,13 +103,33 @@ public static Catalog createCatalog(final String assetId, final int numberOfOffe final List datasets = IntStream.range(0, numberOfOffers) .boxed() .map(i -> Dataset.Builder.newInstance() - .properties( - Map.of(NAMESPACE_EDC_ID, assetId + i)) + .id(assetId + i) .offer(getOfferId(assetId + i), policy) .distribution(distribution) .build()) .toList(); - return Catalog.Builder.newInstance().datasets(datasets).properties(Map.of(NAMESPACE_EDC_PARTICIPANT_ID, "BPNTEST")).build(); + return Catalog.Builder.newInstance() + .datasets(datasets) + .properties(Map.of(NAMESPACE_EDC_PARTICIPANT_ID, "BPNTEST")) + .build(); + } + + public static Catalog createCatalog(final String assetId, final Policy policy, final String bpn, + final String offerId) { + final Distribution distribution = Distribution.Builder.newInstance() + .format("HttpProxy") + .dataService(new DataService()) + .build(); + + final Dataset dataset = Dataset.Builder.newInstance() + .id(assetId) + .offer(offerId, policy) + .distribution(distribution) + .build(); + return Catalog.Builder.newInstance() + .dataset(dataset) + .properties(Map.of(NAMESPACE_EDC_PARTICIPANT_ID, bpn)) + .build(); } @NotNull @@ -164,6 +183,8 @@ public static EndpointDataReference endpointDataReference(final String contractA .properties( Map.of(JsonLdConfiguration.NAMESPACE_EDC_CID, contractAgreementId)) .endpoint("http://provider.dataplane/api/public") + .id("testid") + .contractId(contractAgreementId) .build(); } diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/EdcTransformerTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/EdcTransformerTest.java index 86c8bbf3f1..6d5f0e9c7d 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/EdcTransformerTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/EdcTransformerTest.java @@ -30,8 +30,8 @@ import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Optional; +import java.util.Set; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -51,8 +51,13 @@ import org.eclipse.edc.policy.model.OrConstraint; import org.eclipse.edc.policy.model.Permission; import org.eclipse.edc.policy.model.Policy; +import org.eclipse.edc.policy.model.PolicyType; import org.eclipse.edc.spi.monitor.ConsoleMonitor; +import org.eclipse.edc.spi.query.Criterion; +import org.eclipse.edc.spi.query.QuerySpec; import org.eclipse.edc.spi.types.domain.DataAddress; +import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; +import org.eclipse.tractusx.irs.edc.client.model.ContractOffer; import org.eclipse.tractusx.irs.edc.client.model.ContractOfferDescription; import org.eclipse.tractusx.irs.edc.client.model.NegotiationRequest; import org.eclipse.tractusx.irs.edc.client.model.TransferProcessRequest; @@ -71,19 +76,18 @@ class EdcTransformerTest { "@id": "78ff625c-0c05-4014-965c-bd3d0a6a0de0", "@type": "dcat:Catalog", "dcat:dataset": { - "@id": "58505404-4da1-427a-82aa-b79482bcd1f0", + "@id": "urn:uuid:ea32f6f7-c884-4bfd-af4a-778666a1fffb", "@type": "dcat:Dataset", "odrl:hasPolicy": { - "@id": "7681f966-36ea-4542-b5ea-0d0db81967de:35c78eca-db53-442c-9e01-467fc22c9434-55840861-5d7f-444b-972a-6e8b78552d8a:66131c58-32af-4df0-825d-77f7df6017c1", - "@type": "odrl:Set", + "@id": "YTYxMjJlNTUtZWY2Ni00MWM4LWFjMjgtZDA5ODhlMmQ2YzRi:dXJuOnV1aWQ6ZWEzMmY2ZjctYzg4NC00YmZkLWFmNGEtNzc4NjY2YTFmZmZi:NzBlZTJjZGMtOTg3Yi00NzU0LWI0M2EtMDhkNDAzMDI4NzNk", + "@type": "odrl:Offer", "odrl:permission": { - "odrl:target": "urn:uuid:35c78eca-db53-442c-9e01-467fc22c9434-urn:uuid:55840861-5d7f-444b-972a-6e8b78552d8a", "odrl:action": { "odrl:type": "USE" }, "odrl:constraint": { "odrl:or": { - "odrl:leftOperand": "idsc:PURPOSE", + "odrl:leftOperand": "PURPOSE", "odrl:operator": { "@id": "odrl:eq" }, @@ -92,27 +96,36 @@ class EdcTransformerTest { } }, "odrl:prohibition": [], - "odrl:obligation": [], - "odrl:target": "urn:uuid:35c78eca-db53-442c-9e01-467fc22c9434-urn:uuid:55840861-5d7f-444b-972a-6e8b78552d8a" + "odrl:obligation": [] }, "dcat:distribution": [ { "@type": "dcat:Distribution", "dct:format": { - "@id": "HttpProxy" + "@id": "HttpData-PULL" }, - "dcat:accessService": "4ba1faa1-7f1a-4fb7-a41c-317f450e7443" + "dcat:accessService": { + "@id": "7d021194-7e36-43bf-ba3e-ed59675e4576", + "@type": "dcat:DataService", + "dct:terms": "connector", + "dct:endpointUrl": "https://irs-test-controlplane-provider.dev.demo.catena-x.net/api/v1/dsp" + } }, { "@type": "dcat:Distribution", "dct:format": { - "@id": "AmazonS3" + "@id": "AmazonS3-PUSH" }, - "dcat:accessService": "4ba1faa1-7f1a-4fb7-a41c-317f450e7443" + "dcat:accessService": { + "@id": "7d021194-7e36-43bf-ba3e-ed59675e4576", + "@type": "dcat:DataService", + "dct:terms": "connector", + "dct:endpointUrl": "https://irs-test-controlplane-provider.dev.demo.catena-x.net/api/v1/dsp" + } } ], - "edc:description": "IRS EDC Demo Asset", - "edc:id": "urn:uuid:35c78eca-db53-442c-9e01-467fc22c9434-urn:uuid:55840861-5d7f-444b-972a-6e8b78552d8a" + "description": "IRS EDC Demo Asset", + "id": "urn:uuid:ea32f6f7-c884-4bfd-af4a-778666a1fffb" }, "dcat:service": { "@id": "4ba1faa1-7f1a-4fb7-a41c-317f450e7443", @@ -120,12 +133,16 @@ class EdcTransformerTest { "dct:terms": "connector", "dct:endpointUrl": "https://irs-test-controlplane-provider.dev.demo.catena-x.net/api/v1/dsp" }, - "edc:participantId": "BPNL00000003CRHK", + "dspace:participantId": "BPNL00000003CRHK", + "participantId": "BPNL00000003CRHK", "@context": { - "dct": "https://purl.org/dc/terms/", - "tx": "https://w3id.org/tractusx/v0.0.1/ns/", + "@vocab": "https://w3id.org/edc/v0.0.1/ns/", "edc": "https://w3id.org/edc/v0.0.1/ns/", - "dcat": "https://www.w3.org/ns/dcat/", + "tx": "https://w3id.org/tractusx/v0.0.1/ns/", + "tx-auth": "https://w3id.org/tractusx/auth/", + "cx-policy": "https://w3id.org/catenax/policy/", + "dcat": "http://www.w3.org/ns/dcat#", + "dct": "http://purl.org/dc/terms/", "odrl": "http://www.w3.org/ns/odrl/2/", "dspace": "https://w3id.org/dspace/v0.8/" } @@ -135,51 +152,45 @@ class EdcTransformerTest { private static Dataset createDataset() { final String edcNamespace = "https://w3id.org/edc/v0.0.1/ns/"; - final String target = "urn:uuid:35c78eca-db53-442c-9e01-467fc22c9434-urn:uuid:55840861-5d7f-444b-972a-6e8b78552d8a"; - final String distributionId = "4ba1faa1-7f1a-4fb7-a41c-317f450e7443"; - final String datasetId = "58505404-4da1-427a-82aa-b79482bcd1f0"; - final String offerId = "7681f966-36ea-4542-b5ea-0d0db81967de:35c78eca-db53-442c-9e01-467fc22c9434-55840861-5d7f-444b-972a-6e8b78552d8a:66131c58-32af-4df0-825d-77f7df6017c1"; + final String assetId = "urn:uuid:ea32f6f7-c884-4bfd-af4a-778666a1fffb"; + final String distributionId = "7d021194-7e36-43bf-ba3e-ed59675e4576"; + final String offerId = "YTYxMjJlNTUtZWY2Ni00MWM4LWFjMjgtZDA5ODhlMmQ2YzRi:dXJuOnV1aWQ6ZWEzMmY2ZjctYzg4NC00YmZkLWFmNGEtNzc4NjY2YTFmZmZi:NzBlZTJjZGMtOTg3Yi00NzU0LWI0M2EtMDhkNDAzMDI4NzNk"; final HashMap properties = new HashMap<>(); properties.put(edcNamespace + "description", "IRS EDC Demo Asset"); - properties.put(edcNamespace + "id", target); - final Policy policy = createPolicy(target); + properties.put(edcNamespace + "id", assetId); + final Policy policy = createPolicy(assetId); final Distribution httpProxy = Distribution.Builder.newInstance() - .format("HttpProxy") + .format("HttpData-PULL") .dataService(DataService.Builder.newInstance() .id(distributionId) .build()) .build(); final Distribution amazonS3 = Distribution.Builder.newInstance() - .format("AmazonS3") + .format("AmazonS3-PUSH") .dataService(DataService.Builder.newInstance() .id(distributionId) .build()) .build(); final List distributions = List.of(httpProxy, amazonS3); return Dataset.Builder.newInstance() - .id(datasetId) + .id(assetId) .offer(offerId, policy) .distributions(distributions) .properties(properties) .build(); } - private static NegotiationRequest createNegotiation(final String consumerBPN, final String providerBPN, - final String providerConnector, final String protocol, final String offerId, final String assetId) { - final Policy policy = createPolicy(assetId); + private static NegotiationRequest createNegotiation(final String providerBPN, final String providerConnector, + final String protocol, final String assetId, final String offerId) { + final Policy policy = createPolicy(assetId).toBuilder().type(PolicyType.OFFER).assigner(providerBPN).build(); - final ContractOfferDescription contractOfferDescription = ContractOfferDescription.builder() - .offerId(offerId) - .assetId(assetId) - .policy(policy) - .build(); + final ContractOffer contractOffer = ContractOffer.fromPolicy(policy, offerId, assetId, providerBPN); return NegotiationRequest.builder() - .connectorId(consumerBPN) - .connectorId(providerBPN) - .connectorAddress(providerConnector) + .contractOffer(contractOffer) + .counterPartyAddress(providerConnector) + .counterPartyId(providerBPN) .protocol(protocol) - .offer(contractOfferDescription) .build(); } @@ -187,17 +198,13 @@ private static Policy createPolicy(final String assetId) { final Action action = Action.Builder.newInstance().type("USE").build(); final AtomicConstraint atomicConstraint = AtomicConstraint.Builder.newInstance() .leftExpression( - new LiteralExpression("idsc:PURPOSE")) + new LiteralExpression("PURPOSE")) .operator(Operator.EQ) .rightExpression( new LiteralExpression("ID 3.1 Trace")) .build(); final OrConstraint orConstraint = OrConstraint.Builder.newInstance().constraint(atomicConstraint).build(); - final Permission permission = Permission.Builder.newInstance() - .action(action) - .constraint(orConstraint) - .target(assetId) - .build(); + final Permission permission = Permission.Builder.newInstance().action(action).constraint(orConstraint).build(); return Policy.Builder.newInstance().permission(permission).target(assetId).build(); } @@ -218,7 +225,7 @@ void setUp() { @Test void shouldDeserializeJsonLdResponseToCatalog() throws JsonProcessingException { // Arrange - final String key = "7681f966-36ea-4542-b5ea-0d0db81967de:35c78eca-db53-442c-9e01-467fc22c9434-55840861-5d7f-444b-972a-6e8b78552d8a:66131c58-32af-4df0-825d-77f7df6017c1"; + final String key = "YTYxMjJlNTUtZWY2Ni00MWM4LWFjMjgtZDA5ODhlMmQ2YzRi:dXJuOnV1aWQ6ZWEzMmY2ZjctYzg4NC00YmZkLWFmNGEtNzc4NjY2YTFmZmZi:NzBlZTJjZGMtOTg3Yi00NzU0LWI0M2EtMDhkNDAzMDI4NzNk"; final String catalogAsString = getCatalogAsString(); final DataService expectedDataService = DataService.Builder.newInstance() .id("4ba1faa1-7f1a-4fb7-a41c-317f450e7443") @@ -226,6 +233,11 @@ void shouldDeserializeJsonLdResponseToCatalog() throws JsonProcessingException { .endpointUrl( "https://irs-test-controlplane-provider.dev.demo.catena-x.net/api/v1/dsp") .build(); + final Dataset expectedDataset = createDataset(); + final Distribution expectedDistribution = expectedDataset.getDistributions().get(0); + final Policy expectedPolicy = expectedDataset.getOffers().get(key); + final String expectedPermission = objectMapper().writeValueAsString(expectedPolicy.getPermissions().get(0)); + // Act final Catalog actualCatalog = edcTransformer.transformCatalog(catalogAsString, StandardCharsets.UTF_8); @@ -235,25 +247,22 @@ void shouldDeserializeJsonLdResponseToCatalog() throws JsonProcessingException { assertThat(actualCatalog.getProperties()).containsEntry("https://w3id.org/edc/v0.0.1/ns/participantId", "BPNL00000003CRHK"); - final Dataset expectedDataset = createDataset(); - final Distribution expectedDistribution = expectedDataset.getDistributions().get(0); - final Policy expectedPolicy = expectedDataset.getOffers().get(key); - final String expectedPermission = objectMapper().writeValueAsString(expectedPolicy.getPermissions().get(0)); + assertThat(actualCatalog.getDatasets()).hasSize(1); + assertThat(actualCatalog.getDataServices().get(0)).isEqualTo(expectedDataService); final Dataset actualDataset = actualCatalog.getDatasets().get(0); - final Distribution actualDistribution = actualDataset.getDistributions().get(0); - final Policy actualPolicy = actualDataset.getOffers().get(key); - final String actualPermission = objectMapper().writeValueAsString(actualPolicy.getPermissions().get(0)); - assertThat(actualDataset.getId()).isEqualTo(expectedDataset.getId()); assertThat(actualDataset.getProperties()).isEqualTo(expectedDataset.getProperties()); + + final Distribution actualDistribution = actualDataset.getDistributions().get(0); assertThat(actualDistribution.getFormat()).isEqualTo(expectedDistribution.getFormat()); assertThat(actualDistribution.getDataService().getId()).isEqualTo( expectedDistribution.getDataService().getId()); - assertThat(actualPolicy.getTarget()).isEqualTo(expectedPolicy.getTarget()); + + final Policy actualPolicy = actualDataset.getOffers().get(key); + assertThat(actualPolicy).isNotNull(); + final String actualPermission = objectMapper().writeValueAsString(actualPolicy.getPermissions().get(0)); assertThat(actualPermission).isEqualTo(expectedPermission); - assertThat(actualCatalog.getDataServices().get(0)).isEqualTo(expectedDataService); - assertThat(actualCatalog.getContractOffers()).isNull(); } @Test @@ -276,23 +285,30 @@ void shouldSerializeContractOfferDescriptionToJsonObject() { } @Test - void shouldSerializeNegotiationInitiateDtoToJsonObject() { - final String consumerBPN = "BPNL00000003CRHK"; - final String providerBPN = "BPNL00000003CRHK"; + void shouldSerializeNegotiationRequestToJsonObject() { + final String providerBPN = "BPNL00000001CRHK"; final String providerConnector = "https://provider.edc/api/v1/dsp"; final String protocol = "dataspace-protocol-http"; - final String offerId = "7681f966-36ea-4542-b5ea-0d0db81967de:35c78eca-db53-442c-9e01-467fc22c9434-55840861-5d7f-444b-972a-6e8b78552d8a:66131c58-32af-4df0-825d-77f7df6017c"; final String assetId = "urn:uuid:35c78eca-db53-442c-9e01-467fc22c9434-urn:uuid:55840861-5d7f-444b-972a-6e8b78552d8a"; - final NegotiationRequest negotiationInitiateRequestDto = createNegotiation(consumerBPN, providerBPN, - providerConnector, protocol, offerId, assetId); + final String offerId = "test"; + + final NegotiationRequest negotiationInitiateRequestDto = createNegotiation(providerBPN, providerConnector, + protocol, assetId, offerId); final JsonObject negotiationJson = edcTransformer.transformNegotiationRequestToJson( negotiationInitiateRequestDto); assertThat(negotiationJson).isNotEmpty() - .contains(entry("edc:connectorAddress", Json.createValue(providerConnector))) - .contains(entry("edc:connectorId", Json.createValue(consumerBPN))) + .contains(entry("edc:counterPartyAddress", Json.createValue(providerConnector))) + .contains(entry("edc:counterPartyId", Json.createValue(providerBPN))) .contains(entry("edc:protocol", Json.createValue(protocol))); + final JsonObject policyJsonObject = negotiationJson.get("edc:policy").asJsonObject(); + assertThat(policyJsonObject).isNotEmpty() + .containsKey("odrl:assigner") + .contains(entry("@type", Json.createValue("odrl:Offer"))) + .contains(entry("@id", Json.createValue(offerId))); + assertThat(policyJsonObject.getJsonObject("odrl:assigner")).contains( + entry("@id", Json.createValue(providerBPN))); } @Test @@ -303,40 +319,69 @@ void shouldSerializeTransferRequestDtoToJsonObject() { final String assetId = "urn:uuid:35c78eca-db53-442c-9e01-467fc22c9434-urn:uuid:55840861-5d7f-444b-972a-6e8b78552d8a"; final String connectorId = "BPNL00000003CRHK"; final DataAddress dataAddress = DataAddress.Builder.newInstance().type("HttpProxy").build(); + final List callbackAddresses = List.of(CallbackAddress.Builder.newInstance() + .uri("https://backend.app/endpoint-data-reference") + .events(Set.of( + "transfer.process.started")) + .build()); final TransferProcessRequest transferRequestDto = TransferProcessRequest.builder() .assetId(assetId) .connectorId(connectorId) - .connectorAddress(providerConnector) + .counterPartyAddress(providerConnector) .protocol(protocol) .contractId(contractId) - .managedResources(false) + .transferType("HttpData-PULL") .dataDestination(dataAddress) - .privateProperties( - Map.of("receiverHttpEndpoint", - "https://backend.app/endpoint-data-reference")) + .callbackAddresses(callbackAddresses) .build(); final JsonObject jsonObject = edcTransformer.transformTransferProcessRequestToJson(transferRequestDto); final Optional optional = jsonLd.compact(jsonObject).asOptional(); assertThat(optional).isPresent(); - assertThat(optional.get().getJsonObject("edc:privateProperties")).isNotEmpty(); - assertThat(optional.get().getJsonObject("edc:privateProperties")).containsKey("edc:receiverHttpEndpoint"); - assertThat( - optional.get().getJsonObject("edc:privateProperties").getString("edc:receiverHttpEndpoint")).isEqualTo( - "https://backend.app/endpoint-data-reference"); + assertThat(optional.get()).contains(entry("edc:transferType", Json.createValue("HttpData-PULL"))); + assertThat(optional.get()).contains(entry("edc:transferType", Json.createValue("HttpData-PULL"))); + assertThat(optional.get()).contains(entry("edc:transferType", Json.createValue("HttpData-PULL"))); + assertThat(optional.get()).contains(entry("edc:transferType", Json.createValue("HttpData-PULL"))); + assertThat(optional.get()).contains(entry("edc:transferType", Json.createValue("HttpData-PULL"))); + assertThat(optional.get()).contains(entry("edc:transferType", Json.createValue("HttpData-PULL"))); + assertThat(optional.get().getJsonObject("edc:callbackAddresses")).isNotEmpty().containsKey("edc:uri"); + assertThat(optional.get().getJsonObject("edc:callbackAddresses")).contains( + entry("edc:uri", Json.createValue("https://backend.app/endpoint-data-reference"))); } @Test void shouldSerializeCatalogRequestToJsonObject() { final String providerConnector = "https://provider.edc/api/v1/dsp"; + final String providerBPN = "BPN123456789"; final String protocol = "dataspace-protocol-http"; + + final String operandLeft = "id"; + final String operator = "="; + final String operandRight = "assetId"; + final QuerySpec querySpec = QuerySpec.Builder.newInstance() + .filter(Criterion.criterion(operandLeft, operator, operandRight)) + .build(); final CatalogRequest catalogRequest = CatalogRequest.Builder.newInstance() .counterPartyAddress(providerConnector) + .counterPartyId(providerBPN) + .querySpec(querySpec) .protocol(protocol) .build(); final JsonObject requestJson = edcTransformer.transformCatalogRequestToJson(catalogRequest); final Optional optional = jsonLd.compact(requestJson).asOptional(); assertThat(optional).isPresent(); - assertThat(optional.get()).isNotEmpty(); - assertThat(optional.get()).contains(entry("@type", Json.createValue("edc:CatalogRequest"))); + final JsonObject catalogRequestJson = optional.get(); + assertThat(catalogRequestJson).isNotEmpty() + .contains(entry("@type", Json.createValue("edc:CatalogRequest"))) + .contains(entry("edc:counterPartyAddress", Json.createValue(providerConnector))) + .contains(entry("edc:counterPartyId", Json.createValue(providerBPN))) + .contains(entry("edc:protocol", Json.createValue(protocol))); + + final JsonObject jsonQuerySpec = catalogRequestJson.getJsonObject("edc:querySpec"); + assertThat(jsonQuerySpec).containsKey("edc:filterExpression"); + + final JsonObject jsonFilterExpression = jsonQuerySpec.getJsonObject("edc:filterExpression"); + assertThat(jsonFilterExpression).contains(entry("edc:operandLeft", Json.createValue(operandLeft))) + .contains(entry("edc:operator", Json.createValue(operator))) + .contains(entry("edc:operandRight", Json.createValue(operandRight))); } } \ No newline at end of file diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToCatalogTransformerTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToCatalogTransformerTest.java new file mode 100644 index 0000000000..07f8560167 --- /dev/null +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToCatalogTransformerTest.java @@ -0,0 +1,242 @@ +/* + * Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (c) 2021,2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * 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. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.eclipse.tractusx.irs.edc.client.transformer; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.eclipse.tractusx.irs.edc.client.testutil.TestMother.objectMapper; + +import java.nio.charset.StandardCharsets; +import java.util.Map; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.eclipse.edc.catalog.spi.Catalog; +import org.eclipse.edc.core.transform.TypeTransformerRegistryImpl; +import org.eclipse.edc.jsonld.TitaniumJsonLd; +import org.eclipse.edc.spi.monitor.ConsoleMonitor; +import org.jetbrains.annotations.NotNull; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class JsonObjectToCatalogTransformerTest { + + private EdcTransformer edcTransformer; + + @BeforeEach + void setUp() { + final TitaniumJsonLd jsonLd = new TitaniumJsonLd(new ConsoleMonitor()); + jsonLd.registerNamespace("odrl", "http://www.w3.org/ns/odrl/2/"); + jsonLd.registerNamespace("dct", "https://purl.org/dc/terms/"); + jsonLd.registerNamespace("tx", "https://w3id.org/tractusx/v0.0.1/ns/"); + jsonLd.registerNamespace("edc", "https://w3id.org/edc/v0.0.1/ns/"); + jsonLd.registerNamespace("dcat", "https://www.w3.org/ns/dcat/"); + jsonLd.registerNamespace("dspace", "https://w3id.org/dspace/v0.8/"); + + ObjectMapper objectMapper = objectMapper(); + edcTransformer = new EdcTransformer(objectMapper, jsonLd, new TypeTransformerRegistryImpl()); + } + + @Test + void shouldTransformJsonObjectToPolicyCorrectly() { + // Arrange + final String catalogJson = getCatalogJson(); + + // Act + final Catalog catalog = edcTransformer.transformCatalog(catalogJson, StandardCharsets.UTF_8); + + // Assert + assertThat(catalog).isNotNull(); + assertThat(catalog.getId()).isEqualTo("16d542da-7a7d-4419-b5e9-38e92a4e1395"); + assertThat(catalog.getDatasets()).hasSize(2); + assertThat(catalog.getDatasets().get(0).getDistributions()).hasSize(3); + assertThat(catalog.getDatasets().get(0).getOffers()).hasSize(1); + assertThat(catalog.getDatasets().get(0).getOffers()).containsKey( + "ZDU1MTA0YTUtOGJiZi00YjRhLTgzMTItZTQ4MzY5ZTlkNWIw:cmVnaXN0cnktYXNzZXQ=:YTA3ZjFkYjAtOGE4MS00ZWZkLTlmMGYtMmExZmNmMWI3ZmE3"); + assertThat(catalog.getParticipantId()).isNull(); + assertThat(catalog.getProperties()).hasSize(2); + assertThat(catalog.getProperties()).containsAllEntriesOf( + Map.of("https://w3id.org/dspace/v0.8/participantId", "BPNL00000001CRHK", + "https://w3id.org/edc/v0.0.1/ns/participantId", "BPNL00000001CRHK")); + assertThat(catalog.getDataServices()).hasSize(1); + assertThat(catalog.getDataServices().get(0).getEndpointUrl()).isEqualTo("https://irs-test2-cp.dev.demo.catena-x.net/api/v1/dsp"); + } + + private static @NotNull String getCatalogJson() { + return """ + { + "@id": "16d542da-7a7d-4419-b5e9-38e92a4e1395", + "@type": "dcat:Catalog", + "dspace:participantId": "BPNL00000001CRHK", + "dcat:dataset": [ + { + "@id": "registry-asset", + "@type": "dcat:Dataset", + "odrl:hasPolicy": { + "@id": "ZDU1MTA0YTUtOGJiZi00YjRhLTgzMTItZTQ4MzY5ZTlkNWIw:cmVnaXN0cnktYXNzZXQ=:YTA3ZjFkYjAtOGE4MS00ZWZkLTlmMGYtMmExZmNmMWI3ZmE3", + "@type": "odrl:Offer", + "odrl:permission": { + "odrl:action": { + "odrl:type": "USE" + }, + "odrl:constraint": { + "odrl:or": { + "odrl:leftOperand": "PURPOSE", + "odrl:operator": { + "@id": "odrl:eq" + }, + "odrl:rightOperand": "ID 3.1 Trace" + } + } + }, + "odrl:prohibition": [], + "odrl:obligation": [] + }, + "dcat:distribution": [ + { + "@type": "dcat:Distribution", + "dct:format": { + "@id": "AzureStorage-PUSH" + }, + "dcat:accessService": { + "@id": "7d021194-7e36-43bf-ba3e-ed59675e4576", + "@type": "dcat:DataService", + "dct:terms": "connector", + "dct:endpointUrl": "https://irs-test2-cp.dev.demo.catena-x.net/api/v1/dsp" + } + }, + { + "@type": "dcat:Distribution", + "dct:format": { + "@id": "HttpData-PULL" + }, + "dcat:accessService": { + "@id": "7d021194-7e36-43bf-ba3e-ed59675e4576", + "@type": "dcat:DataService", + "dct:terms": "connector", + "dct:endpointUrl": "https://irs-test2-cp.dev.demo.catena-x.net/api/v1/dsp" + } + }, + { + "@type": "dcat:Distribution", + "dct:format": { + "@id": "AmazonS3-PUSH" + }, + "dcat:accessService": { + "@id": "7d021194-7e36-43bf-ba3e-ed59675e4576", + "@type": "dcat:DataService", + "dct:terms": "connector", + "dct:endpointUrl": "https://irs-test2-cp.dev.demo.catena-x.net/api/v1/dsp" + } + } + ], + "type": "data.core.digitalTwinRegistry", + "description": "Digital Twin Registry Endpoint of IRS DEV", + "id": "registry-asset" + }, + { + "@id": "urn:uuid:ea32f6f7-c884-4bfd-af4a-778666a1fffb", + "@type": "dcat:Dataset", + "odrl:hasPolicy": { + "@id": "YTYxMjJlNTUtZWY2Ni00MWM4LWFjMjgtZDA5ODhlMmQ2YzRi:dXJuOnV1aWQ6ZWEzMmY2ZjctYzg4NC00YmZkLWFmNGEtNzc4NjY2YTFmZmZi:NGFmMjU0YTktNTg0OS00YmIwLTg2YTEtYTJjMDJjZTE0YTEy", + "@type": "odrl:Offer", + "odrl:permission": { + "odrl:action": { + "odrl:type": "USE" + }, + "odrl:constraint": { + "odrl:or": { + "odrl:leftOperand": "PURPOSE", + "odrl:operator": { + "@id": "odrl:eq" + }, + "odrl:rightOperand": "ID 3.1 Trace" + } + } + }, + "odrl:prohibition": [], + "odrl:obligation": [] + }, + "dcat:distribution": [ + { + "@type": "dcat:Distribution", + "dct:format": { + "@id": "AzureStorage-PUSH" + }, + "dcat:accessService": { + "@id": "7d021194-7e36-43bf-ba3e-ed59675e4576", + "@type": "dcat:DataService", + "dct:terms": "connector", + "dct:endpointUrl": "https://irs-test2-cp.dev.demo.catena-x.net/api/v1/dsp" + } + }, + { + "@type": "dcat:Distribution", + "dct:format": { + "@id": "HttpData-PULL" + }, + "dcat:accessService": { + "@id": "7d021194-7e36-43bf-ba3e-ed59675e4576", + "@type": "dcat:DataService", + "dct:terms": "connector", + "dct:endpointUrl": "https://irs-test2-cp.dev.demo.catena-x.net/api/v1/dsp" + } + }, + { + "@type": "dcat:Distribution", + "dct:format": { + "@id": "AmazonS3-PUSH" + }, + "dcat:accessService": { + "@id": "7d021194-7e36-43bf-ba3e-ed59675e4576", + "@type": "dcat:DataService", + "dct:terms": "connector", + "dct:endpointUrl": "https://irs-test2-cp.dev.demo.catena-x.net/api/v1/dsp" + } + } + ], + "description": "IRS EDC Test Asset", + "id": "urn:uuid:ea32f6f7-c884-4bfd-af4a-778666a1fffb" + } + ], + "dcat:service": { + "@id": "7d021194-7e36-43bf-ba3e-ed59675e4576", + "@type": "dcat:DataService", + "dct:terms": "connector", + "dct:endpointUrl": "https://irs-test2-cp.dev.demo.catena-x.net/api/v1/dsp" + }, + "participantId": "BPNL00000001CRHK", + "@context": { + "@vocab": "https://w3id.org/edc/v0.0.1/ns/", + "edc": "https://w3id.org/edc/v0.0.1/ns/", + "tx": "https://w3id.org/tractusx/v0.0.1/ns/", + "tx-auth": "https://w3id.org/tractusx/auth/", + "cx-policy": "https://w3id.org/catenax/policy/", + "dcat": "http://www.w3.org/ns/dcat#", + "dct": "http://purl.org/dc/terms/", + "odrl": "http://www.w3.org/ns/odrl/2/", + "dspace": "https://w3id.org/dspace/v0.8/" + } + } + """; + } +} \ No newline at end of file diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToPolicyTransformerTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToIrsPolicyTransformerTest.java similarity index 63% rename from irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToPolicyTransformerTest.java rename to irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToIrsPolicyTransformerTest.java index 1ffb52c740..8c5c83ed8c 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToPolicyTransformerTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/transformer/JsonObjectToIrsPolicyTransformerTest.java @@ -43,48 +43,53 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -class JsonObjectToPolicyTransformerTest { +class JsonObjectToIrsPolicyTransformerTest { public static final String EXAMPLE_PAYLOAD = """ - { - "@context": { - "odrl": "http://www.w3.org/ns/odrl/2/" - }, - "@id": "policy-id", - "policy": { - "odrl:permission": [ - { - "odrl:action": "USE", - "odrl:constraint": { - "odrl:and": [ - { - "odrl:leftOperand": "Membership", - "odrl:operator": { - "@id": "odrl:eq" - }, - "odrl:rightOperand": "active" + { + "@context": { + "@vocab": "https://w3id.org/edc/v0.0.1/ns/", + "edc": "https://w3id.org/edc/v0.0.1/ns/", + "tx": "https://w3id.org/tractusx/v0.0.1/ns/", + "tx-auth": "https://w3id.org/tractusx/auth/", + "cx-policy": "https://w3id.org/catenax/policy/", + "odrl": "http://www.w3.org/ns/odrl/2/" + }, + "@id": "policy-id", + "policy": { + "odrl:permission": [ + { + "odrl:action": "USE", + "odrl:constraint": { + "odrl:and": [ + { + "odrl:leftOperand": "Membership", + "odrl:operator": { + "@id": "odrl:eq" }, - { - "odrl:leftOperand": "PURPOSE", - "odrl:operator": { - "@id": "odrl:eq" - }, - "odrl:rightOperand": "ID 3.1 Trace" - } - ] - } + "odrl:rightOperand": "active" + }, + { + "odrl:leftOperand": "PURPOSE", + "odrl:operator": { + "@id": "odrl:eq" + }, + "odrl:rightOperand": "ID 3.1 Trace" + } + ] } - ] - } - } - """; + } + ] + } + } + """; - private JsonObjectToPolicyTransformer jsonObjectToPolicyTransformer; + private JsonObjectToIrsPolicyTransformer jsonObjectToIrsPolicyTransformer; private TransformerContext transformerContext; @BeforeEach public void setUp() { - jsonObjectToPolicyTransformer = new JsonObjectToPolicyTransformer(new ObjectMapper()); + jsonObjectToIrsPolicyTransformer = new JsonObjectToIrsPolicyTransformer(new ObjectMapper()); transformerContext = new TransformerContextImpl(new TypeTransformerRegistryImpl()); } @@ -96,7 +101,7 @@ void shouldTransformJsonObjectToPolicyCorrectly() { jsonReader.close(); // when - final Policy transformed = jsonObjectToPolicyTransformer.transform(jsonObject, transformerContext); + final Policy transformed = jsonObjectToIrsPolicyTransformer.transform(jsonObject, transformerContext); // then assertThat(transformed.getPolicyId()).isEqualTo("policy-id"); diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/util/EndpointDataReferenceCacheServiceTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/util/EndpointDataReferenceCacheServiceTest.java index 531d6b481e..c2bf6c0956 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/util/EndpointDataReferenceCacheServiceTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/util/EndpointDataReferenceCacheServiceTest.java @@ -71,6 +71,8 @@ void shouldReturnStatusExpiredAndCorrectEndpointDataReferenceWhenThereIsRecordIn .endpoint("") .authCode(authCode) .authKey("") + .id("testid") + .contractId("testContractId") .build(); when(endpointDataReferenceStorage.get(assetId)).thenReturn(Optional.of(endpointDataReferenceWithExpiredToken)); @@ -92,6 +94,8 @@ void shouldReturnStatusValidAndCorrectEndpointDataReferenceWhenThereIsRecordInCa .endpoint("") .authCode(authCode) .authKey("") + .id("testid") + .contractId("testContractId") .build(); when(endpointDataReferenceStorage.get(assetId)).thenReturn(Optional.of(endpointDataReferenceWithExpiredToken)); diff --git a/irs-edc-client/src/test/resources/__files/edc/responseCatalog.json b/irs-edc-client/src/test/resources/__files/edc/responseCatalog.json index 6362c2bd84..ba262b2acd 100644 --- a/irs-edc-client/src/test/resources/__files/edc/responseCatalog.json +++ b/irs-edc-client/src/test/resources/__files/edc/responseCatalog.json @@ -1,14 +1,14 @@ { "@id": "78ff625c-0c05-4014-965c-bd3d0a6a0de0", "@type": "dcat:Catalog", + "dspace:participantId": "BPNL00000003CRHK", "dcat:dataset": { - "@id": "58505404-4da1-427a-82aa-b79482bcd1f0", + "@id": "urn:uuid:ea32f6f7-c884-4bfd-af4a-778666a1fffb", "@type": "dcat:Dataset", "odrl:hasPolicy": { - "@id": "7681f966-36ea-4542-b5ea-0d0db81967de:5a7ab616-989f-46ae-bdf2-32027b9f6ee6-31b614f5-ec14-4ed2-a509-e7b7780083e7:66131c58-32af-4df0-825d-77f7df6017c1", - "@type": "odrl:Set", + "@id": "YTYxMjJlNTUtZWY2Ni00MWM4LWFjMjgtZDA5ODhlMmQ2YzRi:dXJuOnV1aWQ6ZWEzMmY2ZjctYzg4NC00YmZkLWFmNGEtNzc4NjY2YTFmZmZi:NzBlZTJjZGMtOTg3Yi00NzU0LWI0M2EtMDhkNDAzMDI4NzNk", + "@type": "odrl:Offer", "odrl:permission": { - "odrl:target": "5a7ab616-989f-46ae-bdf2-32027b9f6ee6-31b614f5-ec14-4ed2-a509-e7b7780083e7", "odrl:action": { "odrl:type": "USE" }, @@ -32,27 +32,48 @@ } }, "odrl:prohibition": [], - "odrl:obligation": [], - "odrl:target": "5a7ab616-989f-46ae-bdf2-32027b9f6ee6-31b614f5-ec14-4ed2-a509-e7b7780083e7" + "odrl:obligation": [] }, "dcat:distribution": [ { "@type": "dcat:Distribution", "dct:format": { - "@id": "HttpProxy" + "@id": "AzureStorage-PUSH" }, - "dcat:accessService": "4ba1faa1-7f1a-4fb7-a41c-317f450e7443" + "dcat:accessService": { + "@id": "7d021194-7e36-43bf-ba3e-ed59675e4576", + "@type": "dcat:DataService", + "dct:terms": "connector", + "dct:endpointUrl": "http://edc.io/api/v1/dsp" + } + }, + { + "@type": "dcat:Distribution", + "dct:format": { + "@id": "HttpData-PULL" + }, + "dcat:accessService": { + "@id": "4ba1faa1-7f1a-4fb7-a41c-317f450e7443", + "@type": "dcat:DataService", + "dct:terms": "connector", + "dct:endpointUrl": "http://edc.io/api/v1/dsp" + } }, { "@type": "dcat:Distribution", "dct:format": { - "@id": "AmazonS3" + "@id": "AmazonS3-PUSH" }, - "dcat:accessService": "4ba1faa1-7f1a-4fb7-a41c-317f450e7443" + "dcat:accessService": { + "@id": "4ba1faa1-7f1a-4fb7-a41c-317f450e7443", + "@type": "dcat:DataService", + "dct:terms": "connector", + "dct:endpointUrl": "http://edc.io/api/v1/dsp" + } } ], - "edc:description": "IRS EDC Demo Asset", - "edc:id": "5a7ab616-989f-46ae-bdf2-32027b9f6ee6-31b614f5-ec14-4ed2-a509-e7b7780083e7" + "description": "IRS EDC Demo Asset", + "id": "urn:uuid:ea32f6f7-c884-4bfd-af4a-778666a1fffb" }, "dcat:service": { "@id": "4ba1faa1-7f1a-4fb7-a41c-317f450e7443", @@ -60,12 +81,15 @@ "dct:terms": "connector", "dct:endpointUrl": "http://edc.io/api/v1/dsp" }, - "edc:participantId": "BPNL00000003CRHK", + "participantId": "BPNL00000003CRHK", "@context": { - "dct": "https://purl.org/dc/terms/", - "tx": "https://w3id.org/tractusx/v0.0.1/ns/", + "@vocab": "https://w3id.org/edc/v0.0.1/ns/", "edc": "https://w3id.org/edc/v0.0.1/ns/", - "dcat": "https://www.w3.org/ns/dcat/", + "tx": "https://w3id.org/tractusx/v0.0.1/ns/", + "tx-auth": "https://w3id.org/tractusx/auth/", + "cx-policy": "https://w3id.org/catenax/policy/", + "dcat": "http://www.w3.org/ns/dcat#", + "dct": "http://purl.org/dc/terms/", "odrl": "http://www.w3.org/ns/odrl/2/", "dspace": "https://w3id.org/dspace/v0.8/" } diff --git a/irs-policy-store/pom.xml b/irs-policy-store/pom.xml index f05e78038a..3f099ef12d 100644 --- a/irs-policy-store/pom.xml +++ b/irs-policy-store/pom.xml @@ -85,6 +85,13 @@ irs-common ${irs-registry-client.version} + + + org.eclipse.jetty.toolchain + jetty-jakarta-servlet-api + 5.0.2 + + diff --git a/irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/services/PolicyStoreService.java b/irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/services/PolicyStoreService.java index 7b9eb684dc..a47ba48ea5 100644 --- a/irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/services/PolicyStoreService.java +++ b/irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/services/PolicyStoreService.java @@ -117,7 +117,7 @@ public Policy registerPolicy(final CreatePolicyRequest request) { final Policy registeredPolicy; final JsonObject policyJson = request.payload(); - final Policy policy = edcTransformer.transformToPolicy(policyJson); + final Policy policy = edcTransformer.transformToIrsPolicy(policyJson); policy.setValidUntil(request.validUntil()); registeredPolicy = doRegisterPolicy(policy, diff --git a/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/DefaultConfigurationTest.java b/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/DefaultConfigurationTest.java index e6fdc50904..f5f47863ff 100644 --- a/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/DefaultConfigurationTest.java +++ b/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/DefaultConfigurationTest.java @@ -25,6 +25,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.eclipse.tractusx.irs.registryclient.TestMother.endpointDataReference; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; @@ -35,7 +36,6 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; -import org.eclipse.edc.spi.types.domain.edr.EndpointDataReference; import org.eclipse.tractusx.irs.edc.client.EdcConfiguration; import org.eclipse.tractusx.irs.edc.client.EdcSubmodelClient; import org.eclipse.tractusx.irs.edc.client.EdcSubmodelFacade; @@ -86,7 +86,8 @@ void endpointDataForConnectorsService() throws EdcClientException { // ARRANGE final var mock = mock(EdcSubmodelFacade.class); final var endpointAddress = "endpointaddress"; - final var endpointDataReference = EndpointDataReference.Builder.newInstance().endpoint(endpointAddress).build(); + final String contractAgreementId = "contractAgreementId"; + final var endpointDataReference = endpointDataReference(contractAgreementId, endpointAddress); when(mock.getEndpointReferencesForAsset(eq(endpointAddress), any(), any(), any())).thenReturn( List.of(CompletableFuture.completedFuture(endpointDataReference))); diff --git a/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/TestMother.java b/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/TestMother.java new file mode 100644 index 0000000000..bccf1f154c --- /dev/null +++ b/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/TestMother.java @@ -0,0 +1,64 @@ +/******************************************************************************** + * Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (c) 2021,2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * 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. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ +package org.eclipse.tractusx.irs.registryclient; + +import java.nio.charset.StandardCharsets; +import java.util.Base64; + +import org.eclipse.edc.spi.types.domain.edr.EndpointDataReference; +import org.eclipse.tractusx.irs.data.StringMapper; +import org.eclipse.tractusx.irs.edc.client.model.EDRAuthCode; +import org.eclipse.tractusx.irs.testing.wiremock.DtrWiremockSupport; +import org.springframework.http.HttpHeaders; + +public class TestMother { + + public static EndpointDataReference endpointDataReference(final String contractAgreementId) { + return endpointDataReference(contractAgreementId, DtrWiremockSupport.DATAPLANE_URL); + } + + public static EndpointDataReference endpointDataReference(final String contractAgreementId, final String endpointUrl) { + return endpointDataReference(contractAgreementId, HttpHeaders.AUTHORIZATION, edrAuthCode(contractAgreementId), + endpointUrl, "process-id"); + } + + public static EndpointDataReference endpointDataReference(final String contractAgreementId, + final String authorization, final String authCode, final String dataplaneUrl, final String processId) { + return EndpointDataReference.Builder.newInstance() + .authKey(authorization) + .authCode(authCode) + .endpoint(dataplaneUrl) + .contractId(contractAgreementId) + .id(processId) + .build(); + } + + private static String edrAuthCode(final String contractAgreementId) { + final EDRAuthCode edrAuthCode = EDRAuthCode.builder() + .cid(contractAgreementId) + .dad("test") + .exp(9999999999L) + .build(); + final String b64EncodedAuthCode = Base64.getUrlEncoder() + .encodeToString(StringMapper.mapToString(edrAuthCode) + .getBytes(StandardCharsets.UTF_8)); + return "eyJhbGciOiJSUzI1NiJ9." + b64EncodedAuthCode + ".test"; + } +} \ No newline at end of file diff --git a/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/DecentralDigitalTwinRegistryClientTest.java b/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/DecentralDigitalTwinRegistryClientTest.java index b9599b181f..8fb4337300 100644 --- a/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/DecentralDigitalTwinRegistryClientTest.java +++ b/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/DecentralDigitalTwinRegistryClientTest.java @@ -1,5 +1,6 @@ package org.eclipse.tractusx.irs.registryclient.decentral; +import static org.eclipse.tractusx.irs.registryclient.TestMother.endpointDataReference; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; @@ -7,7 +8,6 @@ import static org.mockito.Mockito.when; import java.net.URI; -import java.util.ArrayList; import java.util.Collections; import java.util.Optional; @@ -24,7 +24,7 @@ class DecentralDigitalTwinRegistryClientTest { public static final String SHELL_DESCRIPTORS = "/shell-descriptors/{aasIdentifier}"; public static final String LOOKUP_SHELLS = "/lookup/shells"; - RestTemplate restTemplate = mock(RestTemplate.class); + private final RestTemplate restTemplate = mock(RestTemplate.class); private DecentralDigitalTwinRegistryClient client; @BeforeEach @@ -35,9 +35,9 @@ void setUp() { @Test void shouldCallForAssetAdministrationShellDescriptor() { // given - EndpointDataReference endpointDataReference = EndpointDataReference.Builder.newInstance() - .endpoint("url.to.host") - .build(); + final String contractAgreementId = "contractAgreementId"; + final String endpointUrl = "url.to.host"; + final EndpointDataReference endpointDataReference = endpointDataReference(contractAgreementId, endpointUrl); when(restTemplate.exchange(any(), eq(HttpMethod.GET), any(), eq(AssetAdministrationShellDescriptor.class))).thenReturn( ResponseEntity.of(Optional.of(AssetAdministrationShellDescriptor.builder().build()))); @@ -53,8 +53,12 @@ void shouldCallForAssetAdministrationShellDescriptor() { @Test void shouldCallForAllAssetAdministrationShellIdsByAssetLink() { // given - EndpointDataReference endpointDataReference = EndpointDataReference.Builder.newInstance() + final EndpointDataReference endpointDataReference = EndpointDataReference.Builder.newInstance() .endpoint("url.to.host") + .contractId("contractId") + .id("test1") + .authKey("Authorization") + .authCode("authCode") .build(); when(restTemplate.exchange(any(), eq(HttpMethod.GET), any(), eq(LookupShellsResponse.class))).thenReturn( ResponseEntity.of(Optional.of(LookupShellsResponse.builder().result(Collections.emptyList()).build()))); diff --git a/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/DecentralDigitalTwinRegistryServiceTest.java b/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/DecentralDigitalTwinRegistryServiceTest.java index 7d2d8cd7c1..8a64391986 100644 --- a/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/DecentralDigitalTwinRegistryServiceTest.java +++ b/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/DecentralDigitalTwinRegistryServiceTest.java @@ -27,6 +27,7 @@ import static java.util.concurrent.CompletableFuture.completedFuture; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.eclipse.tractusx.irs.registryclient.TestMother.endpointDataReference; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyList; import static org.mockito.ArgumentMatchers.anyLong; @@ -40,7 +41,6 @@ import java.util.concurrent.TimeoutException; import org.assertj.core.api.ThrowableAssert.ThrowingCallable; -import org.eclipse.edc.spi.types.domain.edr.EndpointDataReference; import org.eclipse.tractusx.irs.common.util.concurrent.ResultFinder; import org.eclipse.tractusx.irs.component.Shell; import org.eclipse.tractusx.irs.component.assetadministrationshell.AssetAdministrationShellDescriptor; @@ -99,8 +99,8 @@ void shouldReturnExpectedShell() throws RegistryServiceException { when(connectorEndpointsService.fetchConnectorEndpoints(any())).thenReturn(List.of("address")); final var endpointDataRefFutures = List.of(completedFuture(endpointDataReference)); - when(endpointDataForConnectorsService.createFindEndpointDataForConnectorsFutures(anyList(), any())).thenReturn( - endpointDataRefFutures); + when(endpointDataForConnectorsService.createFindEndpointDataForConnectorsFutures(anyList(), + any())).thenReturn(endpointDataRefFutures); when(decentralDigitalTwinRegistryClient.getAllAssetAdministrationShellIdsByAssetLink(any(), any(IdentifierKeyValuePair.class))).thenReturn(lookupShellsResponse); @@ -128,8 +128,8 @@ void whenInterruptedExceptionOccurs() throws ExecutionException, InterruptedExce final var dataRefFutures = List.of( // completedFuture(endpointDataReference("url.to.host1")), // completedFuture(endpointDataReference("url.to.host2"))); - when(endpointDataForConnectorsService.createFindEndpointDataForConnectorsFutures( - connectorEndpoints, "bpn")).thenReturn(dataRefFutures); + when(endpointDataForConnectorsService.createFindEndpointDataForConnectorsFutures(connectorEndpoints, + "bpn")).thenReturn(dataRefFutures); when(decentralDigitalTwinRegistryClient.getAllAssetAdministrationShellIdsByAssetLink(any(), any(IdentifierKeyValuePair.class))).thenReturn(lookupShellsResponse); @@ -161,9 +161,9 @@ void whenExecutionExceptionOccurs() { final List connectorEndpoints = List.of("address"); when(connectorEndpointsService.fetchConnectorEndpoints(any())).thenReturn(connectorEndpoints); - final var dataRefFutures = List.of(completedFuture(endpointDataReference("url.to.host"))); - when(endpointDataForConnectorsService.createFindEndpointDataForConnectorsFutures( - connectorEndpoints, "bpn")).thenReturn(dataRefFutures); + final var dataRefFutures = List.of(completedFuture(endpointDataReference("contractId", "url.to.host"))); + when(endpointDataForConnectorsService.createFindEndpointDataForConnectorsFutures(connectorEndpoints, + "bpn")).thenReturn(dataRefFutures); when(decentralDigitalTwinRegistryClient.getAllAssetAdministrationShellIdsByAssetLink(any(), any(IdentifierKeyValuePair.class))).thenReturn(lookupShellsResponse); @@ -204,10 +204,6 @@ private void simulateResultFinderInterrupted() throws InterruptedException, Exec sut.setResultFinder(resultFinderMock); } - private static EndpointDataReference endpointDataReference(final String url) { - return endpointDataReferenceBuilder().endpoint(url).build(); - } - @Nested @DisplayName("lookupGlobalAssetIds") class LookupGlobalAssetIdsTests { @@ -222,13 +218,14 @@ void shouldReturnTheExpectedGlobalAssetId() throws RegistryServiceException { final var expectedShell = shellDescriptor(emptyList()).toBuilder() .globalAssetId(expectedGlobalAssetId) .build(); - final var dataRefFutures = List.of(completedFuture(endpointDataReference("url.to.host"))); + final var dataRefFutures = List.of( + completedFuture(endpointDataReference("contractAgreementId", "url.to.host"))); final var lookupShellsResponse = LookupShellsResponse.builder() .result(List.of(digitalTwinRegistryKey.shellId())) .build(); when(connectorEndpointsService.fetchConnectorEndpoints(any())).thenReturn(List.of("address")); - when(endpointDataForConnectorsService.createFindEndpointDataForConnectorsFutures(anyList(), any())).thenReturn( - dataRefFutures); + when(endpointDataForConnectorsService.createFindEndpointDataForConnectorsFutures(anyList(), + any())).thenReturn(dataRefFutures); when(decentralDigitalTwinRegistryClient.getAllAssetAdministrationShellIdsByAssetLink(any(), any(IdentifierKeyValuePair.class))).thenReturn(lookupShellsResponse); when(decentralDigitalTwinRegistryClient.getAssetAdministrationShellDescriptor(any(), any())).thenReturn( @@ -241,7 +238,8 @@ void shouldReturnTheExpectedGlobalAssetId() throws RegistryServiceException { .findFirst() .map(Shell::payload) .map(AssetAdministrationShellDescriptor::getGlobalAssetId) - .get();// then + .get(); + // then assertThat(actualGlobalAssetId).isEqualTo(expectedGlobalAssetId); } @@ -276,8 +274,4 @@ void whenExecutionExceptionOccurs() { } } - private static EndpointDataReference.Builder endpointDataReferenceBuilder() { - return EndpointDataReference.Builder.newInstance(); - } - } \ No newline at end of file diff --git a/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/DecentralDigitalTwinRegistryServiceWiremockTest.java b/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/DecentralDigitalTwinRegistryServiceWiremockTest.java index d4a816441a..59a09cccb1 100644 --- a/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/DecentralDigitalTwinRegistryServiceWiremockTest.java +++ b/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/DecentralDigitalTwinRegistryServiceWiremockTest.java @@ -28,6 +28,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.verify; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.eclipse.tractusx.irs.registryclient.TestMother.endpointDataReference; import static org.eclipse.tractusx.irs.testing.wiremock.DiscoveryServiceWiremockSupport.DISCOVERY_FINDER_PATH; import static org.eclipse.tractusx.irs.testing.wiremock.DiscoveryServiceWiremockSupport.DISCOVERY_FINDER_URL; import static org.eclipse.tractusx.irs.testing.wiremock.DiscoveryServiceWiremockSupport.EDC_DISCOVERY_PATH; @@ -36,7 +37,6 @@ import static org.eclipse.tractusx.irs.testing.wiremock.DiscoveryServiceWiremockSupport.postDiscoveryFinder404; import static org.eclipse.tractusx.irs.testing.wiremock.DiscoveryServiceWiremockSupport.postEdcDiscovery200; import static org.eclipse.tractusx.irs.testing.wiremock.DiscoveryServiceWiremockSupport.postEdcDiscovery404; -import static org.eclipse.tractusx.irs.testing.wiremock.DtrWiremockSupport.DATAPLANE_URL; import static org.eclipse.tractusx.irs.testing.wiremock.DtrWiremockSupport.LOOKUP_SHELLS_PATH; import static org.eclipse.tractusx.irs.testing.wiremock.DtrWiremockSupport.LOOKUP_SHELLS_TEMPLATE; import static org.eclipse.tractusx.irs.testing.wiremock.DtrWiremockSupport.SHELL_DESCRIPTORS_PATH; @@ -52,12 +52,9 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import java.nio.charset.StandardCharsets; -import java.util.Base64; import java.util.Collection; import java.util.Collections; import java.util.List; -import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.stream.Stream; @@ -65,11 +62,8 @@ import com.github.tomakehurst.wiremock.junit5.WireMockTest; import org.eclipse.edc.spi.types.domain.edr.EndpointDataReference; import org.eclipse.tractusx.irs.component.Shell; -import org.eclipse.tractusx.irs.data.StringMapper; import org.eclipse.tractusx.irs.edc.client.EdcConfiguration; -import org.eclipse.tractusx.irs.edc.client.configuration.JsonLdConfiguration; import org.eclipse.tractusx.irs.edc.client.exceptions.EdcClientException; -import org.eclipse.tractusx.irs.edc.client.model.EDRAuthCode; import org.eclipse.tractusx.irs.registryclient.DigitalTwinRegistryKey; import org.eclipse.tractusx.irs.registryclient.discovery.ConnectorEndpointsService; import org.eclipse.tractusx.irs.registryclient.discovery.DiscoveryFinderClientImpl; @@ -118,8 +112,8 @@ void shouldDiscoverEDCAndRequestRegistry() throws RegistryServiceException, EdcR givenThat(getShellDescriptor200()); final var endpointDataReference = endpointDataReference("assetId"); - when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(any(), any(), any(), any())).thenReturn( - List.of(CompletableFuture.completedFuture(endpointDataReference))); + when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(any(), any(), any(), + any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference))); // Act final Collection shells = decentralDigitalTwinRegistryService.fetchShells( @@ -167,8 +161,8 @@ void shouldThrowInCaseOfLookupShellsError() throws EdcRetrieverException { givenThat(postEdcDiscovery200()); final var endpointDataReference = endpointDataReference("assetId"); - when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(any(), any(), any(), any())).thenReturn( - List.of(CompletableFuture.completedFuture(endpointDataReference))); + when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(any(), any(), any(), + any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference))); givenThat(getLookupShells404()); final List testId = List.of(new DigitalTwinRegistryKey("testId", TEST_BPN)); @@ -188,8 +182,8 @@ void shouldThrowInCaseOfShellDescriptorsError() throws EdcRetrieverException { givenThat(postEdcDiscovery200()); final var endpointDataReference = endpointDataReference("assetId"); - when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(any(), any(), any(), any())).thenReturn( - List.of(CompletableFuture.completedFuture(endpointDataReference))); + when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(any(), any(), any(), + any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference))); givenThat(getLookupShells200()); givenThat(getShellDescriptor404()); @@ -211,8 +205,8 @@ void shouldThrowExceptionOnEmptyShells() throws EdcRetrieverException { givenThat(postEdcDiscovery200()); final var endpointDataReference = endpointDataReference("assetId"); - when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(any(), any(), any(), any())).thenReturn( - List.of(CompletableFuture.completedFuture(endpointDataReference))); + when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(any(), any(), any(), + any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference))); givenThat(getLookupShells200Empty()); givenThat(getShellDescriptor404()); @@ -241,8 +235,8 @@ void lookupShellIdentifiers_oneEDC_oneDTR() throws RegistryServiceException, Edc // simulate endpoint data reference final var endpointDataReference = endpointDataReference("assetId"); - when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(any(), any(), any(), any())).thenReturn( - List.of(CompletableFuture.completedFuture(endpointDataReference))); + when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(any(), any(), any(), + any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference))); // Act final Collection digitalTwinRegistryKeys = decentralDigitalTwinRegistryService.lookupShellIdentifiers( @@ -272,10 +266,10 @@ void lookupShellIdentifiers_multipleEDCs_oneDTR(String title, // simulate endpoint data reference final var endpointDataReference = endpointDataReference("assetId"); - when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(eq(edc1Url), any(), any(), any())).thenReturn( - List.of(CompletableFuture.completedFuture(endpointDataReference))); - when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(eq(edc2Url), any(), any(), any())).thenReturn( - endpointDataReferenceForAssetFutures); + when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(eq(edc1Url), any(), any(), + any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference))); + when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(eq(edc2Url), any(), any(), + any())).thenReturn(endpointDataReferenceForAssetFutures); // Act final Collection digitalTwinRegistryKeys = decentralDigitalTwinRegistryService.lookupShellIdentifiers( @@ -317,10 +311,10 @@ void lookupShellIdentifiers_multipleEDCs_multipleDTRs() throws RegistryServiceEx // simulate endpoint data reference final var endpointDataReference1 = endpointDataReference("dtr1-assetId"); final var endpointDataReference2 = endpointDataReference("dtr2-assetId"); - when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(eq(edc1Url), any(), any(), any())).thenReturn( - List.of(CompletableFuture.completedFuture(endpointDataReference1))); - when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(eq(edc2Url), any(), any(), any())).thenReturn( - List.of(CompletableFuture.completedFuture(endpointDataReference2))); + when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(eq(edc1Url), any(), any(), + any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference1))); + when(edcEndpointReferenceRetrieverMock.getEndpointReferencesForAsset(eq(edc2Url), any(), any(), + any())).thenReturn(List.of(CompletableFuture.completedFuture(endpointDataReference2))); // Act & Assert final Collection digitalTwinRegistryKeys = decentralDigitalTwinRegistryService.lookupShellIdentifiers( @@ -336,26 +330,4 @@ void lookupShellIdentifiers_multipleEDCs_multipleDTRs() throws RegistryServiceEx verify(exactly(edcUrls.size()), getRequestedFor(urlPathEqualTo(LOOKUP_SHELLS_PATH))); } } - - private EndpointDataReference endpointDataReference(final String contractAgreementId) { - return EndpointDataReference.Builder.newInstance() - .authKey("X-API-KEY") - .authCode(edrAuthCode(contractAgreementId)) - .properties( - Map.of(JsonLdConfiguration.NAMESPACE_EDC_CID, contractAgreementId)) - .endpoint(DATAPLANE_URL) - .build(); - } - - private String edrAuthCode(final String contractAgreementId) { - final EDRAuthCode edrAuthCode = EDRAuthCode.builder() - .cid(contractAgreementId) - .dad("test") - .exp(9999999999L) - .build(); - final String b64EncodedAuthCode = Base64.getUrlEncoder() - .encodeToString(StringMapper.mapToString(edrAuthCode) - .getBytes(StandardCharsets.UTF_8)); - return "eyJhbGciOiJSUzI1NiJ9." + b64EncodedAuthCode + ".test"; - } } diff --git a/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/EndpointDataForConnectorsServiceTest.java b/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/EndpointDataForConnectorsServiceTest.java index 3181ef0310..ffee494aaf 100644 --- a/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/EndpointDataForConnectorsServiceTest.java +++ b/irs-registry-client/src/test/java/org/eclipse/tractusx/irs/registryclient/decentral/EndpointDataForConnectorsServiceTest.java @@ -39,6 +39,7 @@ import org.eclipse.edc.spi.types.domain.edr.EndpointDataReference; import org.eclipse.tractusx.irs.edc.client.exceptions.EdcClientException; import org.junit.jupiter.api.Test; +import org.springframework.http.HttpHeaders; class EndpointDataForConnectorsServiceTest { @@ -47,13 +48,26 @@ class EndpointDataForConnectorsServiceTest { private static final String CONNECTION_ONE_ADDRESS = "connectionOneAddress"; private static final String CONNECTION_TWO_ADDRESS = "connectionTwoAddress"; + private static final String CONNECTION_ONE_CONTRACT_ID = "id1"; + private static final String CONNECTION_TWO_CONTRACT_ID = "id2"; private static final String BPN = "bpn"; private static final EndpointDataReference CONNECTION_ONE_DATA_REF = // - EndpointDataReference.Builder.newInstance().endpoint(CONNECTION_ONE_ADDRESS).build(); + EndpointDataReference.Builder.newInstance() + .endpoint(CONNECTION_ONE_ADDRESS) + .contractId(CONNECTION_ONE_CONTRACT_ID) + .id("test1") + .authKey(HttpHeaders.AUTHORIZATION) + .authCode("authCode") + .build(); private static final EndpointDataReference CONNECTION_TWO_DATA_REF = // - EndpointDataReference.Builder.newInstance().endpoint(CONNECTION_TWO_ADDRESS).build(); + EndpointDataReference.Builder.newInstance().endpoint(CONNECTION_TWO_ADDRESS) + .contractId(CONNECTION_TWO_CONTRACT_ID) + .id("test1") + .authKey(HttpHeaders.AUTHORIZATION) + .authCode("authCode") + .build(); private final EdcEndpointReferenceRetriever edcSubmodelFacade = mock(EdcEndpointReferenceRetriever.class); diff --git a/irs-testing/src/main/java/org/eclipse/tractusx/irs/testing/wiremock/SubmodelFacadeWiremockSupport.java b/irs-testing/src/main/java/org/eclipse/tractusx/irs/testing/wiremock/SubmodelFacadeWiremockSupport.java index 10fe132070..c2539e4b1f 100644 --- a/irs-testing/src/main/java/org/eclipse/tractusx/irs/testing/wiremock/SubmodelFacadeWiremockSupport.java +++ b/irs-testing/src/main/java/org/eclipse/tractusx/irs/testing/wiremock/SubmodelFacadeWiremockSupport.java @@ -38,11 +38,14 @@ public final class SubmodelFacadeWiremockSupport { public static final String DATAPLANE_HOST = "http://provider.dataplane"; public static final String CONTEXT = """ { - "dct": "https://purl.org/dc/terms/", + "@vocab": "https://w3id.org/edc/v0.0.1/ns/", + "dct": "http://purl.org/dc/terms/", "tx": "https://w3id.org/tractusx/v0.0.1/ns/", "edc": "https://w3id.org/edc/v0.0.1/ns/", - "dcat": "https://www.w3.org/ns/dcat/", "odrl": "http://www.w3.org/ns/odrl/2/", + "dcat": "http://www.w3.org/ns/dcat#", + "tx-auth": "https://w3id.org/tractusx/auth/", + "cx-policy": "https://w3id.org/catenax/policy/", "dspace": "https://w3id.org/dspace/v0.8/" }"""; public static final String EDC_PROVIDER_DUMMY_URL = "https://edc.io/api/v1/dsp"; @@ -66,7 +69,8 @@ public static void prepareNegotiation(final String negotiationId, final String t stubFor(post(urlPathEqualTo(PATH_CATALOG)).willReturn(WireMockConfig.responseWithStatus(STATUS_CODE_OK) .withBody(getCatalogResponse(edcAssetId, - "USE", EDC_PROVIDER_BPN)))); + contractAgreementId, "USE", + EDC_PROVIDER_BPN)))); stubFor(post(urlPathEqualTo(PATH_NEGOTIATE)).willReturn( WireMockConfig.responseWithStatus(STATUS_CODE_OK).withBody(startNegotiationResponse(negotiationId)))); @@ -104,27 +108,27 @@ private static String startTransferProcessResponse(final String transferProcessI private static String startNegotiationResponse(final String negotiationId) { return """ { - "@type": "edc:IdResponseDto", + "@type": "IdResponse", "@id": "%s", - "edc:createdAt": 1686830151573, + "createdAt": 1686830151573, "@context": %s } """.formatted(negotiationId, CONTEXT); } private static String getNegotiationStateResponse(final String negotiationState) { - return stateResponseTemplate("edc:NegotiationState", negotiationState); + return stateResponseTemplate("NegotiationState", negotiationState); } private static String getTransferProcessStateResponse(final String transferProcessState) { - return stateResponseTemplate("edc:TransferState", transferProcessState); + return stateResponseTemplate("TransferState", transferProcessState); } private static String stateResponseTemplate(final String responseType, final String negotiationState) { return """ { "@type": "%s", - "edc:state": "%s", + "state": "%s", "@context": %s } """.formatted(responseType, negotiationState, CONTEXT); @@ -134,17 +138,18 @@ private static String getNegotiationConfirmedResponse(final String negotiationId final String contractAgreementId) { return """ { - "@type": "edc:ContractNegotiationDto", + "@type": "ContractNegotiation", "@id": "%s", - "edc:type": "CONSUMER", - "edc:protocol": "dataspace-protocol-http", - "edc:state": "%s", - "edc:counterPartyAddress": "%s", - "edc:callbackAddresses": [], - "edc:contractAgreementId": "%s", + "type": "CONSUMER", + "protocol": "dataspace-protocol-http", + "state": "%s", + "counterPartyAddress": "%s", + "counterPartyId": "%s", + "callbackAddresses": [], + "contractAgreementId": "%s", "@context": %s } - """.formatted(negotiationId, negotiationState, EDC_PROVIDER_DUMMY_URL, contractAgreementId, CONTEXT); + """.formatted(negotiationId, negotiationState, EDC_PROVIDER_DUMMY_URL, "BPNL00000001TEST", contractAgreementId, CONTEXT); } private static String getTransferConfirmedResponse(final String transferProcessId, final String transferState, @@ -152,62 +157,68 @@ private static String getTransferConfirmedResponse(final String transferProcessI return """ { "@id": "%s", - "@type": "edc:TransferProcessDto", - "edc:state": "%s", - "edc:stateTimestamp": 1688024335567, - "edc:type": "CONSUMER", - "edc:callbackAddresses": [], - "edc:dataDestination": { - "edc:type": "HttpProxy" + "@type": "TransferProcess", + "state": "%s", + "stateTimestamp": 1688024335567, + "type": "CONSUMER", + "callbackAddresses": { + "@type": "CallbackAddress", + "transactional": false, + "uri": "%s", + "events": "transfer.process.started" }, - "edc:dataRequest": { - "@type": "edc:DataRequestDto", - "@id": "%s", - "edc:assetId": "%s", - "edc:contractId": "%s", - "edc:connectorId": "%s" + "correlationId": "%s", + "assetId": "%s", + "contractId": "%s", + "transferType": "HttpData-PULL", + "dataDestination": { + "@type": "DataAddress", + "type": "HttpProxy" }, - "edc:receiverHttpEndpoint": "%s", "@context": %s } - """.formatted(transferProcessId, transferState, transferProcessId, edcAssetId, contractAgreementId, - EDC_PROVIDER_BPN, IRS_INTERNAL_CALLBACK_URL, CONTEXT); + """.formatted(transferProcessId, transferState, IRS_INTERNAL_CALLBACK_URL, transferProcessId, edcAssetId, contractAgreementId, + CONTEXT); } - public static String getCatalogResponse(final String edcAssetId, final String permissionType, + @SuppressWarnings("PMD.UseObjectForClearerAPI") // used only for testing + public static String getCatalogResponse(final String edcAssetId, final String offerId, final String permissionType, final String edcProviderBpn) { return """ { "@id": "78ff625c-0c05-4014-965c-bd3d0a6a0de0", "@type": "dcat:Catalog", "dcat:dataset": { - "@id": "58505404-4da1-427a-82aa-b79482bcd1f0", + "@id": "%s", "@type": "dcat:Dataset", "odrl:hasPolicy": { - "@id": "7681f966-36ea-4542-b5ea-0d0db81967de:5a7ab616-989f-46ae-bdf2-32027b9f6ee6-31b614f5-ec14-4ed2-a509-e7b7780083e7:66131c58-32af-4df0-825d-77f7df6017c1", - "@type": "odrl:Set", + "@id": "%s", + "@type": "odrl:Offer", "odrl:permission": { - "odrl:target": "%s", "odrl:action": { "odrl:type": "%s" }, "odrl:constraint": %s }, "odrl:prohibition": [], - "odrl:obligation": [], - "odrl:target": "%s" + "odrl:obligation": [] }, "dcat:distribution": [ { "@type": "dcat:Distribution", "dct:format": { - "@id": "HttpProxy" + "@id": "HttpData-PULL" }, - "dcat:accessService": "4ba1faa1-7f1a-4fb7-a41c-317f450e7443" + "dcat:accessService": { + "@id": "4ba1faa1-7f1a-4fb7-a41c-317f450e7443", + "@type": "dcat:DataService", + "dct:terms": "connector", + "dct:endpointUrl": "%s" + } } ], - "edc:description": "IRS EDC Test Asset", - "edc:id": "%s" + "description": "IRS EDC Test Asset", + "id": "%s" }, "dcat:service": { "@id": "4ba1faa1-7f1a-4fb7-a41c-317f450e7443", @@ -215,11 +226,12 @@ public static String getCatalogResponse(final String edcAssetId, final String pe "dct:terms": "connector", "dct:endpointUrl": "%s" }, - "edc:participantId": "%s", + "participantId": "%s", + "dspace:participantId": "%s", "@context": %s } - """.formatted(edcAssetId, permissionType, createConstraints(), edcAssetId, edcAssetId, - EDC_PROVIDER_DUMMY_URL, edcProviderBpn, CONTEXT); + """.formatted(edcAssetId, offerId, permissionType, createConstraints(), EDC_PROVIDER_DUMMY_URL, + edcAssetId, EDC_PROVIDER_DUMMY_URL, edcProviderBpn, edcProviderBpn, CONTEXT); } private static String createConstraints() { diff --git a/local/testing/testdata/CX_Testdata_v.1.7.0_PartType.json b/local/testing/testdata/CX_Testdata_v.1.7.0_PartType.json index eafb522c61..a636a89e86 100644 --- a/local/testing/testdata/CX_Testdata_v.1.7.0_PartType.json +++ b/local/testing/testdata/CX_Testdata_v.1.7.0_PartType.json @@ -7,7 +7,7 @@ "@type": "PolicyDefinitionRequestDto", "@id": "id-3.1-trace", "policy": { - "@type": "Policy", + "@type": "odrl:Set", "odrl:permission": [ { "odrl:action": "USE", diff --git a/local/testing/testdata/CX_Testdata_v1.7.0_PartInstance-not-accepted-policy.json b/local/testing/testdata/CX_Testdata_v1.7.0_PartInstance-not-accepted-policy.json index bacd2ac20e..2106d4d0ac 100644 --- a/local/testing/testdata/CX_Testdata_v1.7.0_PartInstance-not-accepted-policy.json +++ b/local/testing/testdata/CX_Testdata_v1.7.0_PartInstance-not-accepted-policy.json @@ -7,15 +7,13 @@ "@type": "PolicyDefinitionRequestDto", "@id": "id-3.0-not-accepted", "policy": { - "@type": "Policy", + "@type": "odrl:Set", "odrl:permission": [ { "odrl:action": "USE", "odrl:constraint": { - "@type": "AtomicConstraint", "odrl:or": [ { - "@type": "Constraint", "odrl:leftOperand": "PURPOSE", "odrl:operator": { "@id": "odrl:eq" diff --git a/local/testing/testdata/CX_Testdata_v1.7.0_PartInstance-reduced.json b/local/testing/testdata/CX_Testdata_v1.7.0_PartInstance-reduced.json index b90817355b..60fe498505 100644 --- a/local/testing/testdata/CX_Testdata_v1.7.0_PartInstance-reduced.json +++ b/local/testing/testdata/CX_Testdata_v1.7.0_PartInstance-reduced.json @@ -7,7 +7,7 @@ "@type": "PolicyDefinitionRequestDto", "@id": "id-3.1-trace", "policy": { - "@type": "Policy", + "@type": "odrl:Set", "odrl:permission": [ { "odrl:action": "USE", diff --git a/local/testing/testdata/ESS_Testdata_v2.0.0-AsPlanned.json b/local/testing/testdata/ESS_Testdata_v2.0.0-AsPlanned.json index dd05561bff..9160a066bf 100644 --- a/local/testing/testdata/ESS_Testdata_v2.0.0-AsPlanned.json +++ b/local/testing/testdata/ESS_Testdata_v2.0.0-AsPlanned.json @@ -7,7 +7,7 @@ "@type": "PolicyDefinitionRequestDto", "@id": "id-3.1-trace", "policy": { - "@type": "Policy", + "@type": "odrl:Set", "odrl:permission": [ { "odrl:action": "USE", diff --git a/local/testing/testdata/transform-and-upload.py b/local/testing/testdata/transform-and-upload.py index 9e532abb05..4719cc5359 100644 --- a/local/testing/testdata/transform-and-upload.py +++ b/local/testing/testdata/transform-and-upload.py @@ -1,5 +1,25 @@ #!/usr/bin/python +# ############################################################################# +# Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# Copyright (c) 2021,2024 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# 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. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################# + import argparse import json import math @@ -16,93 +36,98 @@ def create_submodel_payload(json_payload): def create_edc_asset_payload(submodel_url_, asset_id_): return json.dumps({ - "@context": {}, - "asset": { - "@type": "Asset", - "@id": f"{asset_id_}", - "properties": { - "description": "IRS EDC Test Asset" - } + "@context": edc_context(), + "@id": f"{asset_id_}", + "edc:properties": { + "edc:description": "IRS EDC Test Asset", + "edc:id": f"{asset_id_}", }, - "dataAddress": { - "@type": "DataAddress", - "type": "HttpData", - "baseUrl": f"{submodel_url_}", - "proxyPath": "true", - "proxyBody": "false", - "proxyMethod": "false", - "proxyQueryParams": "false" + "edc:dataAddress": { + "@type": "edc:DataAddress", + "edc:type": "HttpData", + "edc:baseUrl": f"{submodel_url_}", + "edc:proxyPath": "true", + "edc:proxyBody": "false", + "edc:proxyMethod": "false", + "edc:proxyQueryParams": "false" } }) def create_edc_registry_asset_payload(registry_url_, asset_prop_id_): return json.dumps({ - "@context": {}, - "asset": { - "@type": "Asset", - "@id": f"{asset_prop_id_}", # DTR-EDC-instance-unique-ID - "properties": { - "type": "data.core.digitalTwinRegistry", - "description": "Digital Twin Registry Endpoint of IRS DEV" - } + "@context": edc_context(), + "@id": f"{asset_prop_id_}", # DTR-EDC-instance-unique-ID + "edc:properties": { + "edc:description": "Digital Twin Registry Endpoint of IRS DEV", + "edc:id": f"{asset_prop_id_}", # DTR-EDC-instance-unique-ID + "edc:type": "data.core.digitalTwinRegistry" }, - "dataAddress": { - "@type": "DataAddress", - "type": "HttpData", - "baseUrl": f"{registry_url_}", - "proxyPath": "true", - "proxyBody": "true", - "proxyMethod": "true", - "proxyQueryParams": "true" + "edc:dataAddress": { + "@type": "edc:DataAddress", + "edc:type": "HttpData", + "edc:baseUrl": f"{registry_url_}", + "edc:proxyPath": "true", + "edc:proxyMethod": "true", + "edc:proxyQueryParams": "true", + "edc:proxyBody": "true", + "edc:contentType": "application-json" } }) +def edc_context(): + return { + "dct": "https://purl.org/dc/terms/", + "tx": "https://w3id.org/tractusx/v0.0.1/ns/", + "edc": "https://w3id.org/edc/v0.0.1/ns/", + "dcat": "https://www.w3.org/ns/dcat/", + "odrl": "http://www.w3.org/ns/odrl/2/", + "dspace": "https://w3id.org/dspace/v0.8/" + } + + def create_edc_notification_asset_payload(ess_url_, asset_id_, notification_type_): return json.dumps({ - "@context": {}, - "asset": { - "@id": f"{asset_id_}", - "properties": { - "description": "ESS notification endpoint", - "contenttype": "application/json", - "notificationtype": f"{notification_type_}", - "notificationmethod": "receive" - } + "@context": edc_context(), + "@id": f"{asset_id_}", + "edc:properties": { + "edc:description": "ESS notification endpoint", + "edc:id": f"{asset_id_}", + "edc:notificationtype": f"{notification_type_}", + "edc:notificationmethod": "receive" }, - "dataAddress": { - "baseUrl": f"{ess_url_}", - "type": "HttpData", - "proxyBody": "true", - "proxyMethod": "true" + "edc:dataAddress": { + "@type": "edc:DataAddress", + "edc:type": "HttpData", + "edc:baseUrl": f"{ess_url_}", + "edc:proxyBody": "true", + "edc:proxyMethod": "true", } }) def create_esr_edc_asset_payload(esr_url_, asset_prop_id_, digital_twin_id_): return json.dumps({ - "asset": { - "properties": { - "asset:prop:id": asset_prop_id_, - "asset:prop:description": "product description", - "asset:prop:contenttype": "application/json" - } + "@context": edc_context(), + "@id": f"{asset_prop_id_}", + "edc:properties": { + "edc:description": "product description", + "edc:id": f"{asset_prop_id_}", }, - "dataAddress": { - "properties": { - "baseUrl": f"{esr_url_}/{digital_twin_id_}/asBuilt/ISO14001/submodel", - "type": "HttpData", - "proxyBody": True, - "proxyMethod": True - } + "edc:dataAddress": { + "@type": "edc:DataAddress", + "edc:type": "HttpData", + "edc:baseUrl": f"{esr_url_}/{digital_twin_id_}/asBuilt/ISO14001/submodel", + "edc:proxyBody": "true", + "edc:proxyMethod": "true", } }) def create_edc_contract_definition_payload(edc_policy_id_, asset_prop_id_): return json.dumps({ - "@context": {}, + "@context": edc_context(), "@type": "ContractDefinition", "accessPolicyId": f"{edc_policy_id_}", "contractPolicyId": f"{edc_policy_id_}", @@ -214,6 +239,8 @@ def print_response(response_): print(response_) if response_.status_code > 205: print(response_.text) + if response_.status_code in [404, 401] or response_.status_code >= 500: + raise Exception("Failed to call service") def check_url_args(submodel_server_upload_urls_, submodel_server_urls_, edc_upload_urls_, edc_urls_, dataplane_urls_): @@ -277,7 +304,8 @@ def create_registry_asset(edc_upload_urls_, edc_asset_path_, edc_contract_defini payload_ = { "@context": edc_context(), "edc:protocol": "dataspace-protocol-http", - "edc:providerUrl": f"{edc_url_}/api/v1/dsp", + "edc:counterPartyAddress": f"{edc_url_}/api/v1/dsp", + "edc:counterPartyId": "BPNL00000001CRHK", "edc:querySpec": { "edc:filterExpression": { "@type": "edc:Criterion", @@ -289,7 +317,7 @@ def create_registry_asset(edc_upload_urls_, edc_asset_path_, edc_contract_defini } print(f"Query Catalog for registry asset {catalog_url_}") response_ = session_.request(method="POST", url=catalog_url_, headers=header_, data=json.dumps(payload_)) - + print_response(response_) asset_url_ = edc_upload_url_ + edc_asset_path_ print(response_.status_code) catalog_response_ = response_.json() @@ -316,16 +344,6 @@ def create_registry_asset(edc_upload_urls_, edc_asset_path_, edc_contract_defini print_response(response_) -def edc_context(): - return { - "dct": "https://purl.org/dc/terms/", - "tx": "https://w3id.org/tractusx/v0.0.1/ns/", - "edc": "https://w3id.org/edc/v0.0.1/ns/", - "odrl": "http://www.w3.org/ns/odrl/2/", - "dcat": "https://www.w3.org/ns/dcat/", - "dspace": "https://w3id.org/dspace/v0.8/"} - - def create_notification_assets(edc_upload_urls_, edc_asset_path_, edc_contract_definition_path_, edc_catalog_path_, edc_public_path_, header_, session_, edc_urls_, policy_, ess_base_url_): for edc_upload_url_ in edc_upload_urls_: @@ -476,7 +494,7 @@ def search_for_asset_in_catalog(edc_catalog_path_, edc_upload_url_, edc_url_, he check_url_args(submodel_server_upload_urls, submodel_server_urls, edc_upload_urls, edc_urls, dataplane_urls) - edc_asset_path = "/management/v2/assets" + edc_asset_path = "/management/v3/assets" edc_policy_path = "/management/v2/policydefinitions" edc_contract_definition_path = "/management/v2/contractdefinitions" edc_catalog_path = "/management/v2/catalog/request" @@ -499,7 +517,7 @@ def search_for_asset_in_catalog(edc_catalog_path_, edc_upload_url_, edc_url_, he "@context": { "odrl": "http://www.w3.org/ns/odrl/2/" }, - "@type": "PolicyDefinitionRequestDto", + "@type": "odrl:Set", "@id": "default-policy", "policy": { "@type": "Policy", @@ -634,7 +652,7 @@ def search_for_asset_in_catalog(edc_catalog_path_, edc_upload_url_, edc_url_, he endpoint_address = f"{edc_url}/{catenax_id}-{submodel_identification}/submodel?content=value&extent=withBlobValue" if is_aas3: - endpoint_address = f"{dataplane_url}{dataplane_public_path}/data/{submodel_identification}" + endpoint_address = f"{dataplane_url}{dataplane_public_path}/{submodel_identification}" if is_ess and tmp_data["bpnl"] in bpnl_fail: endpoint_address = f"http://idonotexist/{dataplane_public_path}/data/{submodel_identification}" descriptor = create_submodel_descriptor_3_0(submodel_name, submodel_identification, semantic_id, @@ -656,7 +674,7 @@ def search_for_asset_in_catalog(edc_catalog_path_, edc_upload_url_, edc_url_, he if tmp_data[tmp_key] != "": payload = create_submodel_payload(tmp_data[tmp_key][0]) response = session.request(method="POST", - url=f"{submodel_upload_url}/data/{submodel_identification}", + url=f"{submodel_upload_url}/{submodel_identification}", headers=headers, data=payload) print_response(response) diff --git a/pom.xml b/pom.xml index cb7cdab98f..a7691e9979 100644 --- a/pom.xml +++ b/pom.xml @@ -73,7 +73,7 @@ - 1.10.0-SNAPSHOT + 1.11.0-SNAPSHOT 3.1.11 @@ -92,7 +92,7 @@ 2.0 1.8.0 2.2.18 - 0.2.1 + 0.6.0 3.5.0 1.78 3.5.2 @@ -124,6 +124,7 @@ 1.1.0 1.1.10.5 1.26.1 + 4.4