From 9348855704b2d4d32c14ce8ad99e2ab4e0e11ee7 Mon Sep 17 00:00:00 2001 From: adkumar1 Date: Tue, 29 Aug 2023 13:22:12 +0530 Subject: [PATCH 1/4] Update values.yaml --- charts/orchestrator/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/orchestrator/values.yaml b/charts/orchestrator/values.yaml index eb862cbf..5231fd32 100644 --- a/charts/orchestrator/values.yaml +++ b/charts/orchestrator/values.yaml @@ -23,7 +23,7 @@ replicaCount: 1 image: # -- Image to use for deploying an application - repository: tractusx/managed-service-orchestrator + repository: ghcr.io/catenax-ng/tx-autosetup-backend/autosetup # -- Set the Image Pull Policy pullPolicy: Always # -- Image tage is defined in chart appVersion From 5a8812bddbdc60673d5c51daff0f705b15c63f6e Mon Sep 17 00:00:00 2001 From: Sachin Argade Date: Wed, 20 Sep 2023 19:34:00 +0530 Subject: [PATCH 2/4] Update dt asset creation for oauth secrete information --- .../autosetup/apiproxy/EDCApiProxy.java | 6 ++- .../autosetup/apiproxy/EDCProxyService.java | 43 +++++++++------ .../autosetup/manager/DTRegistryManager.java | 17 ++---- .../autosetup/manager/VaultManager.java | 1 + .../asset-request-filter.json | 17 ++++++ .../resources/edc-request-template/asset.json | 54 +++++++++++++------ .../contract-defination.json | 8 +-- .../edc-request-template/policy.json | 2 +- 8 files changed, 94 insertions(+), 54 deletions(-) create mode 100644 src/main/resources/edc-request-template/asset-request-filter.json diff --git a/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCApiProxy.java b/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCApiProxy.java index b40ddc21..f7397a20 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCApiProxy.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCApiProxy.java @@ -21,6 +21,7 @@ package org.eclipse.tractusx.autosetup.apiproxy; import java.net.URI; +import java.util.List; import java.util.Map; import org.eclipse.tractusx.autosetup.portal.model.ServiceInstanceResultResponse; @@ -37,8 +38,9 @@ @FeignClient(name = "EDCApiProxy", url = "placeholder") public interface EDCApiProxy { - @PostMapping(value ="/v2/assets/request", consumes = MediaType.APPLICATION_JSON_VALUE) - public String getAssets(URI url, @RequestHeader Map header); + @PostMapping(value = "/v2/assets/request", consumes = MediaType.APPLICATION_JSON_VALUE) + public List getAssets(URI url, @RequestHeader Map header, + @RequestBody ObjectNode requestBody); @PostMapping("/v2/assets") @Headers("Content-Type: application/json") diff --git a/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCProxyService.java b/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCProxyService.java index d7ec0868..8d7af93c 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCProxyService.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCProxyService.java @@ -22,10 +22,14 @@ import java.io.InputStream; import java.net.URI; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.UUID; +import org.apache.commons.text.StringSubstitutor; import org.eclipse.tractusx.autosetup.exception.ServiceException; import org.eclipse.tractusx.autosetup.model.Customer; import org.springframework.stereotype.Component; @@ -43,6 +47,7 @@ public class EDCProxyService { private static final String CONTROL_PLANE_DATA_ENDPOINT = "controlPlaneDataEndpoint"; + private static final String DATE_FORMATTER = "dd/MM/yyyy HH:mm:ss"; private final EDCApiProxy eDCApiProxy; @@ -53,9 +58,11 @@ private Map requestHeader(Map inputData) { } @SneakyThrows - public String getAssets(Customer customerDetails, Map inputData) { + public List getAssets(Customer customerDetails, Map inputData) { String dataURL = inputData.get(CONTROL_PLANE_DATA_ENDPOINT); - return eDCApiProxy.getAssets(new URI(dataURL), requestHeader(inputData)); + String readValueAsTree = getSchemaFromFile("/edc-request-template/asset-request-filter.json"); + ObjectNode requestBody = (ObjectNode) new ObjectMapper().readTree(readValueAsTree); + return eDCApiProxy.getAssets(new URI(dataURL), requestHeader(inputData), requestBody); } @SneakyThrows @@ -63,12 +70,13 @@ public String createAsset(Customer customerDetails, Map inputDat String dataURL = inputData.get(CONTROL_PLANE_DATA_ENDPOINT); String uId = UUID.randomUUID().toString(); - String orgName = customerDetails.getOrganizationName(); - String baseUrl = inputData.get("dtregistryUrl"); - + inputData.put("assetId", uId); + LocalDateTime localdate = LocalDateTime.now(); + String date = localdate.format(DateTimeFormatter.ofPattern(DATE_FORMATTER)); + inputData.put("createdDate", date); + inputData.put("updateDate", date); String readValueAsTree = getSchemaFromFile("/edc-request-template/asset.json"); - String jsonString = String.format(readValueAsTree, uId, uId, orgName, baseUrl, baseUrl); - + String jsonString = valueReplacer(readValueAsTree, inputData); ObjectNode json = (ObjectNode) new ObjectMapper().readTree(jsonString); eDCApiProxy.createAsset(new URI(dataURL), requestHeader(inputData), json); @@ -77,26 +85,22 @@ public String createAsset(Customer customerDetails, Map inputDat @SneakyThrows public String createPolicy(Customer customerDetails, Map inputData) { - String uId = UUID.randomUUID().toString(); - - String readValueAsTree = getSchemaFromFile("/edc-request-template/policy.json"); - String jsonString = String.format(readValueAsTree, uId); - + inputData.put("policyId", uId); String dataURL = inputData.get(CONTROL_PLANE_DATA_ENDPOINT); + String readValueAsTree = getSchemaFromFile("/edc-request-template/policy.json"); + String jsonString = valueReplacer(readValueAsTree, inputData); ObjectNode json = (ObjectNode) new ObjectMapper().readTree(jsonString); eDCApiProxy.createPolicy(new URI(dataURL), requestHeader(inputData), json); return uId; } @SneakyThrows - public String createContractDefination(Customer customerDetails, Map inputData, String assetId, - String policyId) { + public String createContractDefination(Customer customerDetails, Map inputData) { String uId = UUID.randomUUID().toString(); - + inputData.put("contractPolicyId", uId); String readValueAsTree = getSchemaFromFile("/edc-request-template/contract-defination.json"); - String jsonString = String.format(readValueAsTree, uId, policyId, policyId, assetId); - + String jsonString = valueReplacer(readValueAsTree, inputData); String dataURL = inputData.get(CONTROL_PLANE_DATA_ENDPOINT); ObjectNode json = (ObjectNode) new ObjectMapper().readTree(jsonString); eDCApiProxy.createContractDefination(new URI(dataURL), requestHeader(inputData), json); @@ -128,4 +132,9 @@ private String getSchemaFromFile(String schemaFile) { } } + private String valueReplacer(String requestTemplate, Map inputData) { + StringSubstitutor stringSubstitutor1 = new StringSubstitutor(inputData); + return stringSubstitutor1.replace(requestTemplate); + } + } diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/DTRegistryManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/DTRegistryManager.java index 374cbc43..8087824a 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/DTRegistryManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/DTRegistryManager.java @@ -23,6 +23,7 @@ import static org.eclipse.tractusx.autosetup.constant.AppNameConstant.DT_REGISTRY; +import java.util.List; import java.util.Map; import java.util.UUID; @@ -117,9 +118,9 @@ public void dtRegistryRegistrationInEDC(Customer customerDetails, SelectedTools WaitingTimeUtility.waitingTime( tenantName + ": Waiting for EDC asset creation after DT setup to get connector pod up"); - String asset = eDCProxyService.getAssets(customerDetails, inputData); + List asset = eDCProxyService.getAssets(customerDetails, inputData); - if (asset != null) { + if (asset != null && asset.isEmpty()) { createEDCDTAsset(customerDetails, tool, inputData, triger); } @@ -156,8 +157,6 @@ private void createEDCAsset(Customer customerDetails, SelectedTools tool, Map uploadKeyandValues(Customer customerDetails, Selected String encryptionkeysalias = openSSLClientManager.executeCommand("openssl rand -base64 16"); tenantVaultSecret = new HashMap<>(); + encryptionkeysalias = encryptionkeysalias.replace("\n", ""); tenantVaultSecret.put(CONTENT, encryptionkeysalias); uploadSecrete(tenantNameNamespace, ENCRYPTIONKEYS, tenantVaultSecret); diff --git a/src/main/resources/edc-request-template/asset-request-filter.json b/src/main/resources/edc-request-template/asset-request-filter.json new file mode 100644 index 00000000..e77fb954 --- /dev/null +++ b/src/main/resources/edc-request-template/asset-request-filter.json @@ -0,0 +1,17 @@ +{ + "@context": { + "edc": "https://w3id.org/edc/v0.0.1/ns/" + }, + "@type": "QuerySpec", + "offset": 0, + "limit": 10, + "sortOrder": "DESC", + "sortField": "id", + "filterExpression": [ + { + "edc:operandLeft": "https://w3id.org/edc/v0.0.1/ns/type", + "edc:operator": "=", + "edc:operandRight": "data.core.digitalTwinRegistry" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/edc-request-template/asset.json b/src/main/resources/edc-request-template/asset.json index fc7e37c9..04b39933 100644 --- a/src/main/resources/edc-request-template/asset.json +++ b/src/main/resources/edc-request-template/asset.json @@ -1,19 +1,39 @@ { - "@context": {}, - "asset": { - "@type": "Asset", - "@id": "%s", - "properties": { - "id": "%s", - "type": "data.core.digitalTwinRegistry", - "name": "Digital Twin Registry Endpoint of provider %s", - "contenttype": "application/json", - "policy-id": "use-eu", - "publisher": "%s" - } - }, - "dataAddress": { - "type": "HttpData", - "baseUrl": "%s" - } + "@context": { + "edc": "https://w3id.org/edc/v0.0.1/ns/", + "oauth2": "https://datatracker.ietf.org/doc/html/rfc6749", + "dcat": "https://www.w3.org/ns/dcat/", + "rdfs": "http://www.w3.org/2000/01/rdf-schema#", + "aas": "https://admin-shell.io/aas/API/3/0/", + "aas-registry": "aas:AssetAdministrationShellRegistryServiceSpecification/", + "aas-discovery": "aas:DiscoveryServiceSpecification/" + }, + "@type": "edc:AssetEntryDto", + "edc:asset": { + "@type": "Asset", + "@id": "${assetId}", + "edc:properties": { + "edc:description": "Digital twin registry information", + "edc:id": "${assetId}", + "edc:name": "Digital twin registry information", + "edc:contenttype": "application/json", + "edc:version": "1.0.0", + "edc:publisher": "${tenantId}:${controlPlaneEndpoint}", + "edc:type": "data.core.digitalTwinRegistry", + "edc:modified": "${createdDate}", + "edc:creationDate": "${updateDate}" + } + }, + "edc:dataAddress": { + "edc:type": "HttpData", + "edc:baseUrl": "${dtregistryUrl}", + "oauth2:tokenUrl": "${idpIssuerUri}", + "oauth2:clientId": "${keycloakAuthenticationClientId}", + "oauth2:clientSecretKey": "client-secret", + "edc:proxyMethod": "true", + "edc:proxyBody": "true", + "edc:proxyPath": "true", + "edc:proxyQueryParams": "true", + "edc:contentType": "application/json" + } } \ No newline at end of file diff --git a/src/main/resources/edc-request-template/contract-defination.json b/src/main/resources/edc-request-template/contract-defination.json index d3d32e9b..7ebb3ff3 100644 --- a/src/main/resources/edc-request-template/contract-defination.json +++ b/src/main/resources/edc-request-template/contract-defination.json @@ -1,13 +1,13 @@ { "@context": {}, - "@id": "%s", + "@id": "${contractPolicyId}", "@type": "ContractDefinition", - "accessPolicyId": "%s", - "contractPolicyId": "%s", + "accessPolicyId": "${policyId}", + "contractPolicyId": "${policyId}", "assetsSelector": { "@type": "CriterionDto", "operandLeft": "https://w3id.org/edc/v0.0.1/ns/id", "operator": "=", - "operandRight": "%s" + "operandRight": "${assetId}" } } \ No newline at end of file diff --git a/src/main/resources/edc-request-template/policy.json b/src/main/resources/edc-request-template/policy.json index 45a43524..da30d85a 100644 --- a/src/main/resources/edc-request-template/policy.json +++ b/src/main/resources/edc-request-template/policy.json @@ -3,7 +3,7 @@ "odrl": "http://www.w3.org/ns/odrl/2/" }, "@type": "PolicyDefinitionRequestDto", - "@id": "%s", + "@id": "${policyId}", "policy": { "@type": "Policy", "odrl:permission": [] From d9ec9c40ef98ee1aec9213753060e7941f6b0660 Mon Sep 17 00:00:00 2001 From: adkumar1 Date: Mon, 30 Oct 2023 19:15:24 +0530 Subject: [PATCH 3/4] bump version --- CHANGELOG.md | 4 ++++ README.md | 4 ++-- charts/orchestrator/Chart.yaml | 4 ++-- charts/orchestrator/values.yaml | 2 +- pom.xml | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 605167c6..4b3e33e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] - The customer already gets an email from Portal and the third-Party-provider after the successful deployment that the SDE-Service is ready to use. If the connector End2End test is unsuccessful (this might be based on the cloud communication issue), the customer will be informed about the failing connectivity. This behavior might need to be clarified for the customer. We will change this behavior in the next release. +## [1.5.1] - 2023-10-16 +### Changed + - Update DT asset creation for oauth secret information + ## [1.5.0] - 2023-09-04 ### Changed diff --git a/README.md b/README.md index 89528750..7ffd9fe1 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ This service will help service provider to set up DFT/SDE with EDC and EDC as se ### Software Version ```shell -Application version: 1.5.0 -Helm release version: 1.5.0 +Application version: 1.5.1 +Helm release version: 1.5.1 ``` # Container images diff --git a/charts/orchestrator/Chart.yaml b/charts/orchestrator/Chart.yaml index d89cb123..62801ea9 100644 --- a/charts/orchestrator/Chart.yaml +++ b/charts/orchestrator/Chart.yaml @@ -38,13 +38,13 @@ sources: # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.5.0 +version: 1.5.1 # 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 # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "1.5.0" +appVersion: "1.5.1" dependencies: - condition: postgresql.enabled diff --git a/charts/orchestrator/values.yaml b/charts/orchestrator/values.yaml index 2b2dd53c..1aa6135f 100644 --- a/charts/orchestrator/values.yaml +++ b/charts/orchestrator/values.yaml @@ -23,7 +23,7 @@ replicaCount: 1 image: # -- Image to use for deploying an application - repository: ghcr.io/catenax-ng/tx-autosetup-backend/autosetup + repository: tractusx/managed-service-orchestrator # -- Set the Image Pull Policy pullPolicy: Always # -- Image tage is defined in chart appVersion diff --git a/pom.xml b/pom.xml index 9c49af1e..1d3eb711 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ org.eclipse.tractusx managed-service-orchestrator - 1.5.0 + 1.5.1 managed-service-orchestrator managed-service-orchestrator From fc950a06f1664c67debd3d0a78119299d9571738 Mon Sep 17 00:00:00 2001 From: Sachin Argade Date: Mon, 13 Nov 2023 22:39:29 +0530 Subject: [PATCH 4/4] Correct indentation --- .../eclipse/tractusx/autosetup/apiproxy/EDCProxyService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCProxyService.java b/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCProxyService.java index 8d7af93c..24a2808d 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCProxyService.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCProxyService.java @@ -47,7 +47,7 @@ public class EDCProxyService { private static final String CONTROL_PLANE_DATA_ENDPOINT = "controlPlaneDataEndpoint"; - private static final String DATE_FORMATTER = "dd/MM/yyyy HH:mm:ss"; + private static final String DATE_FORMATTER = "dd/MM/yyyy HH:mm:ss"; private final EDCApiProxy eDCApiProxy;