Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(edc 0.7.0): integrated the latest edc in the backend + e2e bugs solved #314

Merged
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
219aeee
feat(edc7): enabled the new edc configuration and updates
May 7, 2024
2a3e2da
feat(edc7): enabled negotiation and transfer in edc, with new catalog…
May 8, 2024
8028331
fix: added condition to not add edc data endpoint if already exists
May 9, 2024
6ab4824
fix: startup copyright updated
May 9, 2024
0cb0122
feat: fixed bug with the destribution parsing
May 9, 2024
c556637
chore(tmp): disabled dash license plugin
May 9, 2024
c4cd844
fix: propagate error related to no policy available
May 9, 2024
bc89c1f
chore(err): updated digital twin registry search error messages
May 9, 2024
ac5c99c
chore(err): updated digital twin registry search error messages
May 9, 2024
defe3b4
Merge branch 'develop' of https://github.com/catenax-ng/tx-digital-pr…
May 10, 2024
5cfa457
feat(dependency): fixed bug bug adding lombok library, ip checks exec…
May 10, 2024
4607204
feat: added jacksonized annotation
May 10, 2024
ac5a7f6
chore: updated bug from lombok
May 10, 2024
2b4ac70
fix(policy-bug): fixed policy parsing bug
May 10, 2024
a79c945
fix(policy-bug): fixed unit tests
May 10, 2024
9686b7d
chore: removed debug messages
May 11, 2024
4bc51c6
fix: solved issue with policy selection
May 11, 2024
c86b2b8
chore: update create function
May 11, 2024
acc3a57
chore(charts): updated chart version
May 11, 2024
90dc9e5
Merge pull request #256 from catenax-ng/feature/edc7-integration
matbmoser May 11, 2024
d35eadb
chore(bug): added debuggers
May 11, 2024
6ca6b26
Âfix: updated chart
May 11, 2024
050b8e0
fix(bug): fixed action type bug
May 11, 2024
833dc47
fix(bug): fixed bug related to invalid policy
May 11, 2024
a9d2f0b
feat(edc7-edr): added new edr structure from edc7
May 11, 2024
3014820
feat: added edr default authorization key configurationç
May 11, 2024
a1beda0
feat(callbackaddress): implemented lombok builder in callback address
May 11, 2024
9000e7a
chore(debug): added debug on policy parsing
May 12, 2024
a34cc1e
fix(contract-check): fixed bug with contract filter
May 12, 2024
8d28ae9
chore(charts): fixed policy configuration
May 12, 2024
5cce456
fix(bug): fixed bug related to auto-negotiation and adding logging
May 13, 2024
3b39068
Merge branch 'eclipse-tractusx:main' into release/v3.0.0-edc7-integra…
matbmoser May 13, 2024
ff45344
fix(debugs): removed all debugs and fixed logs
May 13, 2024
9410383
fix(transfer): fixed bug related to transfer process selection
May 13, 2024
3c9c40d
fix(frontend): fixed bug from selection of multiple policies
May 13, 2024
92d4288
fix(frontend): backend availability error fixed
May 13, 2024
8a3ffa9
fix(transfer): fixed bug in single api
May 13, 2024
ed565a7
fix(frontend): backend availability error fixed
May 13, 2024
74dc733
chore: updated user guide + removed debugs
May 13, 2024
6381b7d
chore: updated chart version
May 13, 2024
f97db88
chore(charts): updated values from charts)
May 13, 2024
983ce41
fix(frontend): fixed frontned error messages
May 13, 2024
82f4467
fix(frontend): added space in between error messages
May 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DEPENDENCIES_BACKEND
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ maven/mavencentral/org.bouncycastle/bcutil-jdk15on/1.69, MIT, approved, clearlyd
maven/mavencentral/org.checkerframework/checker-qual/3.33.0, MIT, approved, clearlydefined
maven/mavencentral/org.codehaus.plexus/plexus-utils/3.2.1, , approved, CQ20774
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
maven/mavencentral/org.reactivestreams/reactive-streams/1.0.4, CC0-1.0, approved, CQ16332
maven/mavencentral/org.slf4j/jul-to-slf4j/2.0.13, MIT, approved, #7698
maven/mavencentral/org.slf4j/slf4j-api/2.0.13, MIT, approved, #5915
Expand Down
2 changes: 1 addition & 1 deletion charts/digital-product-pass/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type: application
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)

version: 2.3.3
version: 2.3.4

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
2 changes: 1 addition & 1 deletion charts/digital-product-pass/values-int.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ backend:
discovery:
hostname: "semantics.int.demo.catena-x.net/discoveryfinder"

single-api:
singleApi:
maxRetries: 30
delay: 1000

Expand Down
2 changes: 1 addition & 1 deletion charts/digital-product-pass/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ backend:
- action: "USE"
logicalConstraint: "odrl:and"
constraints:
- leftOperand: "cx-policy:Membership"
- leftOperand: "Membership"
operator: "odrl:eq"
rightOperand: "active"
- leftOperand: "cx-policy:UsagePurpose"
Expand Down
28 changes: 28 additions & 0 deletions dpp-backend/digitalproductpass/lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#################################################################################
# Tractus-X - Digital Product Passport Application
#
# Copyright (c) 2022, 2024 BMW AG, Henkel AG & Co. KGaA
# Copyright (c) 2023, 2024 CGI Deutschland B.V. & Co. KG
# Copyright (c) 2022, 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 govern in permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
#################################################################################


config.stopBubbling = true

lombok.copyableAnnotations += com.fasterxml.jackson.annotation.JsonProperty
10 changes: 8 additions & 2 deletions dpp-backend/digitalproductpass/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
</parent>
<groupId>org.eclipse.tractusx</groupId>
<artifactId>digitalproductpass</artifactId>
<version>2.3.0</version>
<version>3.0.0</version>
<packaging>jar</packaging>
<name>Catena-X Digital Product Passport Backend</name>
<description>Digital Product Passport Consumer Backend Reference Implementation System for Product Passport Consumer Frontend Application
<description>
Digital Product Passport Consumer Backend is a reference implementation system for retrieving aspect models of digital twins in the Catena-X Network.
</description>
<properties>
<java.version>19</java.version>
Expand Down Expand Up @@ -156,6 +157,11 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ public void started() {
LogUtil.printMessage(
"[ EDC Connection Test ] EDC consumer is ready and accessible!");
if(bpnCheck) {
String bpnNumber = dataTransferService.getEdcConnectorBpn();
if (!participantId.equals(bpnNumber)) {
if (!dataTransferService.isApplicationEdc(participantId)) {
throw new Exception("[" + this.getClass().getName()
+ ".onStartUp] Incorrect BPN Number configuration, expected the same participant id as the EDC consumer!");
}
Expand Down Expand Up @@ -217,6 +216,7 @@ public void onStartUp() {
"**********************************************************************\n\n" +
" " + buildProperties.getName() + "\n" +
" Copyright (c) 2022, 2024: BMW AG, Henkel AG & Co. KGaA\n" +
" Copyright (c) 2023, 2024: CGI Deutschland B.V. & Co. KG\n" +
" Copyright (c) 2022, 2024: Contributors to the Eclipse Foundation.\n\n" +
"**********************************************************************\n\n";
System.out.print(serverStartUpMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@
import org.eclipse.tractusx.digitalproductpass.models.http.responses.IdResponse;
import org.eclipse.tractusx.digitalproductpass.models.negotiation.catalog.Catalog;
import org.eclipse.tractusx.digitalproductpass.models.negotiation.catalog.Dataset;
import org.eclipse.tractusx.digitalproductpass.models.negotiation.catalog.Offer;
import org.eclipse.tractusx.digitalproductpass.models.negotiation.catalog.Policy;
import org.eclipse.tractusx.digitalproductpass.models.negotiation.policy.Set;
import org.eclipse.tractusx.digitalproductpass.models.negotiation.response.Negotiation;
import org.eclipse.tractusx.digitalproductpass.services.DataTransferService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import utils.*;

import java.lang.reflect.Type;
import java.nio.file.Path;
import java.time.Duration;

Expand Down Expand Up @@ -157,7 +158,7 @@ public void run() {
state = State.Finished;
} catch (Exception e) {
state = State.Error;
throw new DataModelException(this.getClass().getName(), e, "Was not possible to process the DTRs");
throw new DataModelException(this.getClass().getName(), e, "It was not possible find any valid digital twin registry!");
}
}
};
Expand Down Expand Up @@ -206,7 +207,7 @@ public void run() {

public void searchEndpoint(String processId, String bpn, String endpoint) {
//Search Digital Twin Catalog for each connectionURL with a timeout time
SearchDtrCatalog searchDtrCatalog = new SearchDtrCatalog(endpoint);
SearchDtrCatalog searchDtrCatalog = new SearchDtrCatalog(endpoint, bpn);
Thread asyncThread = ThreadUtil.runThread(searchDtrCatalog, "SearchEndpoint-" + processId + "-" + bpn + "-" + endpoint);
Dtr dtr = new Dtr("", endpoint, "", bpn, DateTimeUtil.addHoursToCurrentTimestamp(dtrConfig.getTemporaryStorage().getLifetime()), true);
try {
Expand Down Expand Up @@ -249,13 +250,19 @@ public void searchEndpoint(String processId, String bpn, String endpoint) {
return;
}
if (contractOffers instanceof LinkedHashMap) {
Dataset dataset = (Dataset) jsonUtil.bindObject(contractOffers, Dataset.class);
Dataset dataset = jsonUtil.bind(contractOffers, new TypeReference<>() {});
if (dataset != null) {
// Store the dataset in the digital twin logs
Map<String, Dataset> datasets = new HashMap<>() {{
put(dataset.getId(), dataset);
}};
Thread singleOfferThread = ThreadUtil.runThread(createAndSaveDtr(datasets, bpn, providerBpn, endpoint, processId), "CreateAndSaveDtr-" + processId + "-" + bpn + "-" + endpoint);

Selection<Dataset,Set> contractAndPolicy = getDtrDataset(datasets);
if (contractAndPolicy == null) {
throw new ManagerException("DtrSearchManager.searchEndpoint", "There was no valid policy available for the digital twin registry found!");
}

Thread singleOfferThread = ThreadUtil.runThread(createAndSaveDtr(contractAndPolicy, datasets, bpn, providerBpn, endpoint, processId), "CreateAndSaveDtr-" + processId + "-" + bpn + "-" + endpoint);
try {
if (!singleOfferThread.join(Duration.ofSeconds(this.dtrRequestProcessTimeout))) {
singleOfferThread.interrupt();
Expand All @@ -268,14 +275,18 @@ public void searchEndpoint(String processId, String bpn, String endpoint) {
}
return;
}
List<Dataset> contractOfferList = (List<Dataset>) jsonUtil.bindObject(contractOffers, List.class);
if (contractOfferList.isEmpty()) {
List<Dataset> contractOfferList = jsonUtil.bind(contractOffers, new TypeReference<>() {});
if (contractOfferList == null || contractOfferList.isEmpty()) {
return;
}
Map<String, Dataset> datasets = edcUtil.mapDatasetsById(contractOfferList);
Selection<Dataset,Set> contractAndPolicy = getDtrDataset(datasets);
if (contractAndPolicy == null) {
throw new ManagerException("DtrSearchManager.searchEndpoint", "There was no valid policy available for the digital twin registry found!");
}
// Store datasets in the digital twin logs
contractOfferList.parallelStream().forEach(dataset -> {
Thread multipleOffersThread = ThreadUtil.runThread(createAndSaveDtr(datasets, bpn, providerBpn, endpoint, processId), "CreateAndSaveDtr-" + processId + "-" + bpn + "-" + endpoint);
Thread multipleOffersThread = ThreadUtil.runThread(createAndSaveDtr(contractAndPolicy, datasets, bpn, providerBpn, endpoint, processId), "CreateAndSaveDtr-" + processId + "-" + bpn + "-" + endpoint);
try {
if (!multipleOffersThread.join(Duration.ofSeconds(this.dtrRequestProcessTimeout))) {
multipleOffersThread.interrupt();
Expand Down Expand Up @@ -339,9 +350,11 @@ public String getDataModelDir() {
public class SearchDtrCatalog implements Runnable {
Boolean error = true;
String connectionUrl;
String bpn;

SearchDtrCatalog(String connectionUrl) {
public SearchDtrCatalog(String connectionUrl, String bpn) {
this.connectionUrl = connectionUrl;
this.bpn = bpn;
}

public Boolean isError() {
Expand All @@ -351,7 +364,7 @@ public Boolean isError() {
@Override
public void run() {
try {
Catalog catalog = dataTransferService.searchDigitalTwinCatalog(connectionUrl);
Catalog catalog = dataTransferService.searchDigitalTwinCatalog(connectionUrl, bpn);
if (catalog == null) {
return;
}
Expand Down Expand Up @@ -484,23 +497,19 @@ public Selection<Dataset, Set> getDtrDataset(Map<String, Dataset> datasets) {
* for a given BPN number and an URL connection into a process with the given process id.
* <p>
*
* @param datasets the {@code Map<String,Dataset>} data for the contract offer.
* @param contractAndPolicy the {@code Selection<Dataset,Set>} the selected contract and policy
* @param datasets the {@code Map<String, Dataset>} map of contracts available
* @param bpn the {@code String} bpn number.
* @param connectionUrl the {@code String} URL connection of the Digital Twin.
* @param processId the {@code String} id of the application's process.
* @return a {@code Runnable} object to be used by a calling thread.
* @throws ManagerException if unable to do the contract negotiation for the DTR.
*/
private Runnable createAndSaveDtr(Map<String, Dataset> datasets, String bpn, String providerBpn, String connectionUrl, String processId) {
private Runnable createAndSaveDtr(Selection<Dataset,Set> contractAndPolicy, Map<String, Dataset> datasets, String bpn, String providerBpn, String connectionUrl, String processId) {
return new Runnable() {
@Override
public void run() {
try {
Selection<Dataset,Set> contractAndPolicy = getDtrDataset(datasets);
if (contractAndPolicy == null) {
LogUtil.printError("It was not possible to get the dataset contract and policy!");
return;
}
Dataset dataset = contractAndPolicy.d(); // Get the contract element
if (dataset == null) {
LogUtil.printError("It was not possible to get the contract!");
Expand All @@ -512,9 +521,9 @@ public void run() {
return;
}

Offer offer = dataTransferService.buildOffer(dataset, set);
Policy policy = dataTransferService.buildOffer(dataset, set, providerBpn);
String builtDataEndpoint = CatenaXUtil.buildDataEndpoint(connectionUrl);
IdResponse negotiationResponse = dataTransferService.doContractNegotiation(offer, bpn, providerBpn, builtDataEndpoint);
IdResponse negotiationResponse = dataTransferService.doContractNegotiation(policy, builtDataEndpoint);
if (negotiationResponse == null) {
return;
}
Expand All @@ -537,9 +546,8 @@ public void run() {
}

processManager.addSearchStatusDtr(processId, dtr);

} catch (Exception e) {
throw new ManagerException(this.getClass().getName() + ".createAndSaveDtr", e, "Failed to save the dataModel for this connection url: " + connectionUrl);
throw new ManagerException(this.getClass().getName() + ".createAndSaveDtr", e, "Failed to create the digital twin registry for url: " + connectionUrl);
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public class AssetSearch {
/** ATTRIBUTES **/
@JsonProperty("assetId")
String assetId;

@JsonProperty("bpn")
String bpn;
@JsonProperty("connectorAddress")
String connectorAddress;

Expand All @@ -52,6 +55,12 @@ public AssetSearch(String assetId, String connectorAddress) {
this.connectorAddress = connectorAddress;
}

public AssetSearch(String assetId, String bpn, String connectorAddress) {
this.assetId = assetId;
this.bpn = bpn;
this.connectorAddress = connectorAddress;
}


/** GETTERS AND SETTERS **/
public String getAssetId() {
Expand All @@ -67,4 +76,11 @@ public void setConnectorAddress(String connectorAddress) {
this.connectorAddress = connectorAddress;
}

public String getBpn() {
return bpn;
}

public void setBpn(String bpn) {
this.bpn = bpn;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class DidDocument {
/** ATTRIBUTES **/
@JsonProperty("@id")
public String id;

@JsonProperty("@type")
public String type;

Expand Down Expand Up @@ -69,6 +70,10 @@ public DidDocument(String type) {
public DidDocument(JsonNode context) {
this.context = context;
}
public DidDocument(JsonNode context, String type) {
this.context = context;
this.type = type;
}

/** GETTERS AND SETTERS **/
public String getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class Catalog extends DidDocument {
@JsonProperty("dcat:service")
DataService service;
@JsonProperty("participantId")
@JsonAlias({"participantId", "edc:participantId"})
@JsonAlias({"participantId", "edc:participantId", "dspace:participantId"})
String participantId;
@JsonIgnore
protected Map<String, Integer> contractOffersMap = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class CatalogRequest extends DidDocument {
String protocol;
@JsonProperty("counterPartyAddress")
String counterPartyAddress;
@JsonProperty("counterPartyId")
String counterPartyId;
@JsonProperty("querySpec")
QuerySpec querySpec;

Expand All @@ -67,6 +69,52 @@ public CatalogRequest(JsonNode context, String protocol, String counterPartyAddr
public CatalogRequest() {
}

public CatalogRequest(String id, String type, String protocol, String counterPartyAddress, String counterPartyId, QuerySpec querySpec) {
super(id, type);
this.protocol = protocol;
this.counterPartyAddress = counterPartyAddress;
this.counterPartyId = counterPartyId;
this.querySpec = querySpec;
}

public CatalogRequest(String protocol, String counterPartyAddress, String counterPartyId, QuerySpec querySpec) {
this.protocol = protocol;
this.counterPartyAddress = counterPartyAddress;
this.counterPartyId = counterPartyId;
this.querySpec = querySpec;
}

public CatalogRequest(String id, String type, JsonNode context, String protocol, String counterPartyAddress, String counterPartyId, QuerySpec querySpec) {
super(id, type, context);
this.protocol = protocol;
this.counterPartyAddress = counterPartyAddress;
this.counterPartyId = counterPartyId;
this.querySpec = querySpec;
}

public CatalogRequest(String type, String protocol, String counterPartyAddress, String counterPartyId, QuerySpec querySpec) {
super(type);
this.protocol = protocol;
this.counterPartyAddress = counterPartyAddress;
this.counterPartyId = counterPartyId;
this.querySpec = querySpec;
}

public CatalogRequest(JsonNode context, String protocol, String counterPartyAddress, String counterPartyId, QuerySpec querySpec) {
super(context);
this.protocol = protocol;
this.counterPartyAddress = counterPartyAddress;
this.counterPartyId = counterPartyId;
this.querySpec = querySpec;
}
public CatalogRequest(JsonNode context, String protocol, String counterPartyAddress, String counterPartyId, QuerySpec querySpec, String type) {
super(context, type);
this.protocol = protocol;
this.counterPartyAddress = counterPartyAddress;
this.counterPartyId = counterPartyId;
this.querySpec = querySpec;
}

/** GETTERS AND SETTERS **/
public String getProtocol() {
return protocol;
Expand All @@ -91,6 +139,14 @@ public void setQuerySpec(QuerySpec querySpec) {
this.querySpec = querySpec;
}

public String getCounterPartyId() {
return counterPartyId;
}

public void setCounterPartyId(String counterPartyId) {
this.counterPartyId = counterPartyId;
}

/** INNER CLASSES **/
/**
* This class consists exclusively to define attributes related to the Query specification of the Catalog request.
Expand Down
Loading
Loading