From 798462fea7c0d77d26cee263721cadc740689ae2 Mon Sep 17 00:00:00 2001 From: Muhammad Saud Khan Date: Thu, 31 Aug 2023 11:52:25 +0200 Subject: [PATCH 1/6] chore: update lookup/shells registry api --- .../productpass/services/AasService.java | 23 +++++++++---------- .../src/main/resources/application.yml | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/services/AasService.java b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/services/AasService.java index 736f7c691..c05aea8c2 100644 --- a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/services/AasService.java +++ b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/services/AasService.java @@ -100,7 +100,7 @@ public void init(Environment env) { Object decentralApis = dtrConfig.getDecentralApis(); if (decentralApis == null) { // If the configuration is null use the default variables decentralApis = Map.of( - "search", "/lookup/shells/query", + "search", "/lookup/shells", "digitalTwin", "/shell-descriptors", "subModel", "/submodel-descriptors" ); @@ -519,22 +519,21 @@ public ArrayList queryDigitalTwin(String assetType, String assetId, Stri ResponseEntity response = null; if (!this.central && registryUrl != null && edr != null) { // Set request body as post if the central query is disabled - Object body = Map.of( - "query", Map.of( - "assetIds", List.of( - Map.of( - "name", assetType, - "value", assetId - ) - ) - ) + // Query as GET if the central query is enabled + Map assetIds = Map.of( + "name", assetType, + "value", assetId ); + + String jsonString = jsonUtil.toJson(assetIds, false); HttpHeaders headers = this.getTokenHeader(edr); - response = httpUtil.doPost(url, ArrayList.class, headers, httpUtil.getParams(), body, false, false); + params.put("assetIds", jsonString); + response = httpUtil.doGet(url, ArrayList.class, headers, params, true, false); + } else { // Query as GET if the central query is enabled Map assetIds = Map.of( - "key", assetType, + "name", assetType, "value", assetId ); diff --git a/consumer-backend/productpass/src/main/resources/application.yml b/consumer-backend/productpass/src/main/resources/application.yml index ae67f1211..43a0a3721 100644 --- a/consumer-backend/productpass/src/main/resources/application.yml +++ b/consumer-backend/productpass/src/main/resources/application.yml @@ -68,7 +68,7 @@ configuration: dspEndpointKey: 'dspEndpoint' internalDtr: "https://materialpass.int.demo.catena-x.net/BPNL000000000000" # -- If there is an internal DTR available it can be referenced here and will be injected in the list of DTRs decentralApis: - search: "/lookup/shells/query" + search: "/lookup/shells" digitalTwin: "/shell-descriptors" subModel: "/submodel-descriptors" timeouts: From 8801f12016b305ffc35486432931662d8aa1bffd Mon Sep 17 00:00:00 2001 From: Muhammad Saud Khan Date: Thu, 31 Aug 2023 11:52:25 +0200 Subject: [PATCH 2/6] chore: update lookup/shells registry api --- charts/digital-product-pass/values-int.yaml | 2 +- charts/digital-product-pass/values.yaml | 2 +- .../productpass/services/AasService.java | 23 +++++++++---------- .../src/main/resources/application.yml | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/charts/digital-product-pass/values-int.yaml b/charts/digital-product-pass/values-int.yaml index 2997c5c3b..a06a4b030 100644 --- a/charts/digital-product-pass/values-int.yaml +++ b/charts/digital-product-pass/values-int.yaml @@ -131,7 +131,7 @@ backend: endpointInterface: 'SUBMODEL-3.0' internalDtr: "https://materialpass.int.demo.catena-x.net/BPNL000000000000" # -- If there is an internal DTR available it can be referenced here and will be injected in the list of DTRs decentralApis: - search: "/lookup/shells/query" + search: "/lookup/shells" digitalTwin: "/shell-descriptors" subModel: "/submodel-descriptors" timeouts: diff --git a/charts/digital-product-pass/values.yaml b/charts/digital-product-pass/values.yaml index 0830bf34b..377de0444 100644 --- a/charts/digital-product-pass/values.yaml +++ b/charts/digital-product-pass/values.yaml @@ -157,7 +157,7 @@ backend: internalDtr: "" # -- ff there is an internal DTR available it can be referenced here and will be injected in the list of DTRs # -- decentral digital twin apis decentralApis: - search: "/lookup/shells/query" + search: "/lookup/shells" digitalTwin: "/shell-descriptors" subModel: "/submodel-descriptors" # -- timeouts for the digital twin registry async negotiation diff --git a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/services/AasService.java b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/services/AasService.java index 736f7c691..c05aea8c2 100644 --- a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/services/AasService.java +++ b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/services/AasService.java @@ -100,7 +100,7 @@ public void init(Environment env) { Object decentralApis = dtrConfig.getDecentralApis(); if (decentralApis == null) { // If the configuration is null use the default variables decentralApis = Map.of( - "search", "/lookup/shells/query", + "search", "/lookup/shells", "digitalTwin", "/shell-descriptors", "subModel", "/submodel-descriptors" ); @@ -519,22 +519,21 @@ public ArrayList queryDigitalTwin(String assetType, String assetId, Stri ResponseEntity response = null; if (!this.central && registryUrl != null && edr != null) { // Set request body as post if the central query is disabled - Object body = Map.of( - "query", Map.of( - "assetIds", List.of( - Map.of( - "name", assetType, - "value", assetId - ) - ) - ) + // Query as GET if the central query is enabled + Map assetIds = Map.of( + "name", assetType, + "value", assetId ); + + String jsonString = jsonUtil.toJson(assetIds, false); HttpHeaders headers = this.getTokenHeader(edr); - response = httpUtil.doPost(url, ArrayList.class, headers, httpUtil.getParams(), body, false, false); + params.put("assetIds", jsonString); + response = httpUtil.doGet(url, ArrayList.class, headers, params, true, false); + } else { // Query as GET if the central query is enabled Map assetIds = Map.of( - "key", assetType, + "name", assetType, "value", assetId ); diff --git a/consumer-backend/productpass/src/main/resources/application.yml b/consumer-backend/productpass/src/main/resources/application.yml index ae67f1211..43a0a3721 100644 --- a/consumer-backend/productpass/src/main/resources/application.yml +++ b/consumer-backend/productpass/src/main/resources/application.yml @@ -68,7 +68,7 @@ configuration: dspEndpointKey: 'dspEndpoint' internalDtr: "https://materialpass.int.demo.catena-x.net/BPNL000000000000" # -- If there is an internal DTR available it can be referenced here and will be injected in the list of DTRs decentralApis: - search: "/lookup/shells/query" + search: "/lookup/shells" digitalTwin: "/shell-descriptors" subModel: "/submodel-descriptors" timeouts: From bc66fdaa4a78280b0569f0cb8f3aef07abf7ccdf Mon Sep 17 00:00:00 2001 From: Saud Khan <98085363+saudkhan116@users.noreply.github.com> Date: Thu, 31 Aug 2023 12:49:00 +0200 Subject: [PATCH 3/6] chore: update /lookup/shells registry endpoint --- charts/digital-product-pass/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/digital-product-pass/values.yaml b/charts/digital-product-pass/values.yaml index 0830bf34b..377de0444 100644 --- a/charts/digital-product-pass/values.yaml +++ b/charts/digital-product-pass/values.yaml @@ -157,7 +157,7 @@ backend: internalDtr: "" # -- ff there is an internal DTR available it can be referenced here and will be injected in the list of DTRs # -- decentral digital twin apis decentralApis: - search: "/lookup/shells/query" + search: "/lookup/shells" digitalTwin: "/shell-descriptors" subModel: "/submodel-descriptors" # -- timeouts for the digital twin registry async negotiation From fd17cbc96f9915601b63140ff42dcea09cbeab95 Mon Sep 17 00:00:00 2001 From: Saud Khan <98085363+saudkhan116@users.noreply.github.com> Date: Thu, 31 Aug 2023 12:49:29 +0200 Subject: [PATCH 4/6] chore: update /lookup/shells registry endpoint --- charts/digital-product-pass/values-int.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/digital-product-pass/values-int.yaml b/charts/digital-product-pass/values-int.yaml index 2997c5c3b..a06a4b030 100644 --- a/charts/digital-product-pass/values-int.yaml +++ b/charts/digital-product-pass/values-int.yaml @@ -131,7 +131,7 @@ backend: endpointInterface: 'SUBMODEL-3.0' internalDtr: "https://materialpass.int.demo.catena-x.net/BPNL000000000000" # -- If there is an internal DTR available it can be referenced here and will be injected in the list of DTRs decentralApis: - search: "/lookup/shells/query" + search: "/lookup/shells" digitalTwin: "/shell-descriptors" subModel: "/submodel-descriptors" timeouts: From 67579ed2888104a1dec632d5b1ad4d06b5ad1af9 Mon Sep 17 00:00:00 2001 From: Muhammad Saud Khan Date: Fri, 1 Sep 2023 11:32:50 +0200 Subject: [PATCH 5/6] chore: update request headers and response for /lookup/shells api --- .../productpass/services/AasService.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/services/AasService.java b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/services/AasService.java index c05aea8c2..07506c674 100644 --- a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/services/AasService.java +++ b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/services/AasService.java @@ -527,8 +527,14 @@ public ArrayList queryDigitalTwin(String assetType, String assetId, Stri String jsonString = jsonUtil.toJson(assetIds, false); HttpHeaders headers = this.getTokenHeader(edr); + headers.remove("Content-Type"); // This should be fixed by the dtr team to allow content-type as application/json params.put("assetIds", jsonString); - response = httpUtil.doGet(url, ArrayList.class, headers, params, true, false); + response = httpUtil.doGet(url, Map.class, headers, params, true, false); + if(response == null){ + return null; + } + Map responseBody = (Map) response.getBody(); + return (ArrayList) responseBody.get("result"); } else { // Query as GET if the central query is enabled @@ -538,16 +544,15 @@ public ArrayList queryDigitalTwin(String assetType, String assetId, Stri ); String jsonString = jsonUtil.toJson(assetIds, false); - HttpHeaders headers = httpUtil.getHeadersWithToken(this.authService.getToken().getAccessToken());; + HttpHeaders headers = httpUtil.getHeadersWithToken(this.authService.getToken().getAccessToken()); params.put("assetIds", jsonString); response = httpUtil.doGet(url, ArrayList.class, headers, params, true, false); + if(response == null){ + return null; + } + ArrayList responseBody = (ArrayList) response.getBody(); + return responseBody; } - if(response == null){ - return null; - } - ArrayList responseBody = (ArrayList) response.getBody(); - return responseBody; - } catch (Exception e) { throw new ServiceException(this.getClass().getName() + "." + "queryDigitalTwin", e, From e779dc837c6a7343f04048eb9cfabae17c14ef28 Mon Sep 17 00:00:00 2001 From: Muhammad Saud Khan Date: Fri, 1 Sep 2023 12:12:25 +0200 Subject: [PATCH 6/6] chore: sync changes from Mathias: add json ignore properties annotations to v3 models --- .../models/dtregistry/DigitalTwin3.java | 37 ++++++++++++++++++- .../models/dtregistry/EndPoint3.java | 2 + .../models/dtregistry/SubModel3.java | 25 +++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/models/dtregistry/DigitalTwin3.java b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/models/dtregistry/DigitalTwin3.java index 8d940c609..dd2348e16 100644 --- a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/models/dtregistry/DigitalTwin3.java +++ b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/models/dtregistry/DigitalTwin3.java @@ -23,12 +23,14 @@ package org.eclipse.tractusx.productpass.models.dtregistry; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import java.util.ArrayList; +@JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_NULL) public class DigitalTwin3 { @JsonProperty("description") @@ -36,6 +38,12 @@ public class DigitalTwin3 { @JsonProperty("idShort") String idShort; + @JsonProperty("assetKind") + String assetKind; + + @JsonProperty("assetType") + String assetType; + @JsonProperty("globalAssetId") String globalAssetId; @JsonProperty("displayName") @@ -79,6 +87,18 @@ public DigitalTwin3(ArrayList description, String idShort, String glob this.submodelDescriptors = submodelDescriptors; } + public DigitalTwin3(ArrayList description, String idShort, String assetKind, String assetType, String globalAssetId, Object displayName, String identification, ArrayList specificAssetIds, ArrayList submodelDescriptors) { + this.description = description; + this.idShort = idShort; + this.assetKind = assetKind; + this.assetType = assetType; + this.globalAssetId = globalAssetId; + this.displayName = displayName; + this.identification = identification; + this.specificAssetIds = specificAssetIds; + this.submodelDescriptors = submodelDescriptors; + } + public ArrayList getDescription() { return description; @@ -135,5 +155,20 @@ public String getGlobalAssetId() { public void setGlobalAssetId(String globalAssetId) { this.globalAssetId = globalAssetId; } -} + public String getAssetKind() { + return assetKind; + } + + public void setAssetKind(String assetKind) { + this.assetKind = assetKind; + } + + public String getAssetType() { + return assetType; + } + + public void setAssetType(String assetType) { + this.assetType = assetType; + } +} diff --git a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/models/dtregistry/EndPoint3.java b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/models/dtregistry/EndPoint3.java index b2c065f93..3d6c8056c 100644 --- a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/models/dtregistry/EndPoint3.java +++ b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/models/dtregistry/EndPoint3.java @@ -23,6 +23,7 @@ package org.eclipse.tractusx.productpass.models.dtregistry; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Splitter; @@ -31,6 +32,7 @@ import java.util.List; import java.util.Map; +@JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_NULL) public class EndPoint3 { @JsonProperty("interface") diff --git a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/models/dtregistry/SubModel3.java b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/models/dtregistry/SubModel3.java index 76f566e4f..1264cf45f 100644 --- a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/models/dtregistry/SubModel3.java +++ b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/models/dtregistry/SubModel3.java @@ -23,16 +23,24 @@ package org.eclipse.tractusx.productpass.models.dtregistry; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import java.util.ArrayList; +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) public class SubModel3 { @JsonProperty("description") ArrayList description; @JsonProperty("idShort") String idShort; + + @JsonProperty("supplementalSemanticId") + Object supplementalSemanticId; + @JsonProperty("id") String identification; @JsonProperty("semanticId") @@ -52,6 +60,15 @@ public SubModel3(ArrayList description, String idShort, String identif public SubModel3() { } + public SubModel3(ArrayList description, String idShort, Object supplementalSemanticId, String identification, JsonNode semanticId, ArrayList endpoints) { + this.description = description; + this.idShort = idShort; + this.supplementalSemanticId = supplementalSemanticId; + this.identification = identification; + this.semanticId = semanticId; + this.endpoints = endpoints; + } + public ArrayList getDescription() { return description; } @@ -91,4 +108,12 @@ public ArrayList getEndpoints() { public void setEndpoints(ArrayList endpoints) { this.endpoints = endpoints; } + + public Object getSupplementalSemanticId() { + return supplementalSemanticId; + } + + public void setSupplementalSemanticId(Object supplementalSemanticId) { + this.supplementalSemanticId = supplementalSemanticId; + } }