From 84ceb5cc98f0a17ab6a12427d26213ae41335cf8 Mon Sep 17 00:00:00 2001 From: ReneSchroederLJ Date: Wed, 19 Jun 2024 08:31:36 +0200 Subject: [PATCH] feat: updated notification endpoint to use context path and removed semantic id from notification asset --- .../edc/logic/service/EdcAdapterService.java | 7 +++-- .../edc/logic/util/EdcRequestBodyBuilder.java | 6 +---- .../backend/common/util/VariablesService.java | 26 ++++++++++++++++--- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/service/EdcAdapterService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/service/EdcAdapterService.java index e67eebdb..a43eee60 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/service/EdcAdapterService.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/service/EdcAdapterService.java @@ -170,8 +170,7 @@ public boolean registerAssetsInitially() { result &= assetRegistration; log.info("Registration of Demand and Capacity Notification 2.0.0 asset successful {}", (assetRegistration = registerNotificationAsset( variablesService.getNotificationApiAssetId(), - variablesService.getNotificationEndpoint(), - AssetType.NOTIFICATION.URN_SEMANTIC_ID + variablesService.getNotificationEndpoint() ))); log.info("Registration of PartTypeInformation 1.0.0 submodel successful {}", (assetRegistration = registerPartTypeInfoSubmodelAsset())); result &= assetRegistration; @@ -291,8 +290,8 @@ private boolean registerSubmodelAsset(String assetId, String endpoint, String se return sendAssetRegistrationRequest(body, assetId); } - private boolean registerNotificationAsset(String assetId, String endpoint, String semanticId) { - var body = edcRequestBodyBuilder.buildNotificationRegistrationBody(assetId, endpoint, semanticId); + private boolean registerNotificationAsset(String assetId, String endpoint) { + var body = edcRequestBodyBuilder.buildNotificationRegistrationBody(assetId, endpoint); return sendAssetRegistrationRequest(body, assetId); } diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/util/EdcRequestBodyBuilder.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/util/EdcRequestBodyBuilder.java index e262649f..3969d159 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/util/EdcRequestBodyBuilder.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/util/EdcRequestBodyBuilder.java @@ -424,7 +424,7 @@ public JsonNode buildSubmodelRegistrationBody(String assetId, String endpoint, S return body; } - public JsonNode buildNotificationRegistrationBody(String assetId, String endpoint, String semanticId) { + public JsonNode buildNotificationRegistrationBody(String assetId, String endpoint) { var body = getAssetRegistrationContext(); body.put("@id", assetId); var propertiesObject = MAPPER.createObjectNode(); @@ -433,10 +433,6 @@ public JsonNode buildNotificationRegistrationBody(String assetId, String endpoin propertiesObject.set("dct:type", dctTypeObject); dctTypeObject.put("@id", "cx-taxo:DemandAndCapacityNotificationApi"); propertiesObject.put("cx-common:version", "1.0"); - var semanticIdObject = MAPPER.createObjectNode(); - propertiesObject.set("aas-semantics:semanticId", semanticIdObject); - semanticIdObject.put("@id", semanticId); - body.set("privateProperties", MAPPER.createObjectNode()); body.set("dataAddress", createDataAddressObject(endpoint, "true")); return body; } diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java index 1d5b7880..bb32ccad 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java @@ -42,6 +42,14 @@ public class VariablesService { @Value("${puris.baseurl}") private String purisBaseUrl; + /** + * The puris base url as defined in the property puris.baseurl, + * ending with a slash ('/'). + */ + public String getPurisBaseUrl() { + return purisBaseUrl.endsWith("/") ? purisBaseUrl : purisBaseUrl + "/"; + } + @Value("${puris.demonstrator.role}") /** * Must be set to "CUSTOMER" or "SUPPLIER" if @@ -50,6 +58,17 @@ public class VariablesService { */ private String demoRole; + @Value("${server.servlet.context-path}") + private String contextPath; + + /** + * The context path as defined in the property server.servlet.context-path, + * ending with a slash ('/'). + */ + public String getContextPath() { + return contextPath.replace("/", "") + "/"; + } + @Value("${puris.baseurl}" + "catena/edrendpoint") /** * The edrEndpoint to be used during consumer pull asset transfers. @@ -112,12 +131,13 @@ public class VariablesService { */ private String deliverySubmodelAssetId; - @Value("${puris.baseurl}" + "catena/demand-and-capacity-notification/request") /** - * The url under which this application's request endpoint can + * The url under which this application's demand and capacity notification request endpoint can * be reached by external machines. */ - private String notificationEndpoint; + public String getNotificationEndpoint() { + return getPurisBaseUrl() + getContextPath() + "demand-and-capacity-notification/request"; + } @Value("${puris.notification.apiassetid}") /**