From 3ccdd36dbb28a34c007a4331b8bfe0d39357150c Mon Sep 17 00:00:00 2001 From: "Amol.Dashwant" Date: Fri, 26 Jul 2024 15:51:32 +0530 Subject: [PATCH 1/3] Changes for 24_08 release --- DEPENDENCIES | 64 +-- pom.xml | 2 +- .../autosetup/apiproxy/EDCApiProxy.java | 60 --- .../autosetup/apiproxy/EDCProxyService.java | 140 ----- .../constant/SDEConfigurationProperty.java | 23 +- .../GlobalDefaultExceptionHandler.java | 2 +- .../manager/ConnectorRegistrationManager.java | 45 +- .../autosetup/manager/DTRegistryManager.java | 4 +- .../manager/PortalIntegrationManager.java | 239 ++++++--- .../autosetup/manager/SDEManager.java | 39 +- .../portal/model/TechnicalUsers.java | 4 +- .../portal/proxy/PortalIntegrationProxy.java | 12 +- .../AutoSetupOrchitestratorService.java | 7 +- .../service/EDCConnectorWorkFlow.java | 9 + .../autosetup/service/SDEAppWorkFlow.java | 7 +- .../utility/JsonObjectProcessingUtility.java | 4 +- .../utility/KeyCloakTokenProxyUtitlity.java | 4 +- .../asset-request-filter.json | 17 - .../resources/edc-request-template/asset.json | 39 -- .../contract-defination.json | 13 - .../edc-request-template/policy.json | 11 - .../V11__update_sde_edc_app_version.sql | 503 ++++++++++++++++++ .../flyway/V9__update_app_version.sql | 4 +- .../autosetup/manager/SDEManagerTest.java | 2 +- 24 files changed, 789 insertions(+), 465 deletions(-) delete mode 100644 src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCApiProxy.java delete mode 100644 src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCProxyService.java delete mode 100644 src/main/resources/edc-request-template/asset-request-filter.json delete mode 100644 src/main/resources/edc-request-template/asset.json delete mode 100644 src/main/resources/edc-request-template/contract-defination.json delete mode 100644 src/main/resources/edc-request-template/policy.json create mode 100644 src/main/resources/flyway/V11__update_sde_edc_app_version.sql diff --git a/DEPENDENCIES b/DEPENDENCIES index 6ed4829d..bfbb027b 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -1,13 +1,13 @@ -maven/mavencentral/ch.qos.logback/logback-classic/1.4.14, EPL-1.0 OR LGPL-2.1-only, approved, #3435 -maven/mavencentral/ch.qos.logback/logback-core/1.4.14, EPL-1.0 OR LGPL-2.1-only, approved, #3373 -maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.15.4, Apache-2.0, approved, #7947 -maven/mavencentral/com.fasterxml.jackson.core/jackson-core/2.15.4, MIT AND Apache-2.0, approved, #7932 -maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.15.4, Apache-2.0, approved, #7934 -maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-toml/2.15.4, Apache-2.0, approved, #9160 -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-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-parameter-names/2.15.4, Apache-2.0, approved, #8803 +maven/mavencentral/ch.qos.logback/logback-classic/1.4.14, EPL-1.0 AND LGPL-2.1-only, approved, #15230 +maven/mavencentral/ch.qos.logback/logback-core/1.4.14, EPL-1.0 AND LGPL-2.1-only, approved, #15209 +maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.15.4, Apache-2.0, approved, #15260 +maven/mavencentral/com.fasterxml.jackson.core/jackson-core/2.15.4, , approved, #15194 +maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.15.4, Apache-2.0, approved, #15199 +maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-toml/2.15.4, Apache-2.0, approved, #15242 +maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.15.4, Apache-2.0, approved, #15207 +maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jdk8/2.15.4, Apache-2.0, approved, #15281 +maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.15.4, Apache-2.0, approved, #15189 +maven/mavencentral/com.fasterxml.jackson.module/jackson-module-parameter-names/2.15.4, Apache-2.0, approved, #15219 maven/mavencentral/com.fasterxml/classmate/1.6.0, Apache-2.0, approved, clearlydefined maven/mavencentral/com.github.stephenc.jcip/jcip-annotations/1.0-1, Apache-2.0, approved, CQ21949 maven/mavencentral/com.google.code.gson/gson/2.10.1, Apache-2.0, approved, #6159 @@ -17,7 +17,7 @@ maven/mavencentral/com.nimbusds/content-type/2.2, Apache-2.0, approved, clearlyd maven/mavencentral/com.nimbusds/lang-tag/1.7, Apache-2.0, approved, clearlydefined maven/mavencentral/com.nimbusds/nimbus-jose-jwt/9.24.4, Apache-2.0, approved, clearlydefined maven/mavencentral/com.nimbusds/oauth2-oidc-sdk/9.43.3, Apache-2.0, approved, clearlydefined -maven/mavencentral/com.sun.istack/istack-commons-runtime/4.1.2, BSD-3-Clause, approved, #2590 +maven/mavencentral/com.sun.istack/istack-commons-runtime/4.1.2, BSD-3-Clause, approved, #15290 maven/mavencentral/com.sun.mail/javax.mail/1.6.2, CDDL-1.0 AND Apache-2.0, approved, CQ18739 maven/mavencentral/com.sun.xml.bind/jaxb-core/4.0.5, BSD-3-Clause, approved, ee4j.jaxb-impl maven/mavencentral/com.sun.xml.bind/jaxb-xjc/4.0.5, BSD-3-Clause, approved, ee4j.jaxb-impl @@ -53,11 +53,11 @@ maven/mavencentral/org.apache.commons/commons-lang3/3.13.0, Apache-2.0, approved maven/mavencentral/org.apache.commons/commons-text/1.12.0, Apache-2.0, approved, #14414 maven/mavencentral/org.apache.logging.log4j/log4j-api/2.17.1, Apache-2.0, approved, clearlydefined maven/mavencentral/org.apache.logging.log4j/log4j-to-slf4j/2.17.1, Apache-2.0, approved, #2163 -maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-core/10.1.20, Apache-2.0 AND (EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0) AND (CDDL-1.0 OR GPL-2.0-only WITH Classpath-exception-2.0) AND W3C AND CC0-1.0, approved, #5949 +maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-core/10.1.20, Apache-2.0 AND (EPL-2.0 OR (GPL-2.0 WITH Classpath-exception-2.0)) AND CDDL-1.0 AND (CDDL-1.1 OR (GPL-2.0-only WITH Classpath-exception-2.0)) AND EPL-2.0, approved, #15195 maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-el/10.1.20, Apache-2.0, approved, #6997 maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-websocket/10.1.20, Apache-2.0, approved, #7920 maven/mavencentral/org.apiguardian/apiguardian-api/1.1.2, Apache-2.0, approved, clearlydefined -maven/mavencentral/org.aspectj/aspectjweaver/1.9.22, Apache-2.0 AND BSD-3-Clause AND EPL-1.0 AND BSD-3-Clause AND Apache-1.1, approved, #7695 +maven/mavencentral/org.aspectj/aspectjweaver/1.9.22, Apache-2.0 AND BSD-3-Clause AND EPL-1.0 AND BSD-3-Clause AND Apache-1.1, approved, #15252 maven/mavencentral/org.assertj/assertj-core/3.24.2, Apache-2.0, approved, #6161 maven/mavencentral/org.awaitility/awaitility/4.2.1, Apache-2.0, approved, #14178 maven/mavencentral/org.bouncycastle/bcpkix-jdk18on/1.78.1, MIT, approved, #14434 @@ -66,7 +66,7 @@ maven/mavencentral/org.bouncycastle/bcutil-jdk18on/1.78.1, MIT, approved, #14435 maven/mavencentral/org.checkerframework/checker-qual/3.42.0, MIT, approved, clearlydefined maven/mavencentral/org.eclipse.angus/angus-activation/2.0.2, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.angus maven/mavencentral/org.eclipse.persistence/eclipselink/4.0.3, EPL-2.0 OR BSD-3-Clause, approved, ee4j.eclipselink -maven/mavencentral/org.flywaydb/flyway-core/9.22.3, Apache-2.0, approved, #10349 +maven/mavencentral/org.flywaydb/flyway-core/9.22.3, Apache-2.0, approved, #15215 maven/mavencentral/org.freemarker/freemarker/2.3.32, Apache-2.0, approved, #6764 maven/mavencentral/org.glassfish.jaxb/jaxb-core/4.0.5, BSD-3-Clause, approved, ee4j.jaxb-impl maven/mavencentral/org.glassfish.jaxb/jaxb-runtime/4.0.5, BSD-3-Clause, approved, ee4j.jaxb-impl @@ -78,8 +78,8 @@ maven/mavencentral/org.hibernate.validator/hibernate-validator/8.0.1.Final, Apac maven/mavencentral/org.jboss.logging/jboss-logging/3.5.3.Final, Apache-2.0, approved, #9471 maven/mavencentral/org.junit.jupiter/junit-jupiter-api/5.10.2, EPL-2.0, approved, #9714 maven/mavencentral/org.junit.jupiter/junit-jupiter-engine/5.10.2, EPL-2.0, approved, #9711 -maven/mavencentral/org.junit.jupiter/junit-jupiter-params/5.10.2, EPL-2.0, approved, #9708 -maven/mavencentral/org.junit.jupiter/junit-jupiter/5.10.2, EPL-2.0, approved, #13393 +maven/mavencentral/org.junit.jupiter/junit-jupiter-params/5.10.2, EPL-2.0, approved, #15250 +maven/mavencentral/org.junit.jupiter/junit-jupiter/5.10.2, EPL-2.0, approved, #15197 maven/mavencentral/org.junit.platform/junit-platform-commons/1.10.2, EPL-2.0, approved, #9715 maven/mavencentral/org.junit.platform/junit-platform-engine/1.10.2, EPL-2.0, approved, #9709 maven/mavencentral/org.mapstruct/mapstruct/1.5.5.Final, Apache-2.0, approved, #6277 @@ -89,7 +89,7 @@ maven/mavencentral/org.objenesis/objenesis/3.3, Apache-2.0, approved, clearlydef maven/mavencentral/org.opentest4j/opentest4j/1.3.0, Apache-2.0, approved, #9713 maven/mavencentral/org.ow2.asm/asm/9.6, BSD-3-Clause, approved, #10776 maven/mavencentral/org.postgresql/postgresql/42.7.3, BSD-2-Clause AND Apache-2.0, approved, #11681 -maven/mavencentral/org.projectlombok/lombok/1.18.32, MIT AND LicenseRef-Public-Domain, approved, CQ23907 +maven/mavencentral/org.projectlombok/lombok/1.18.32, MIT, approved, #15192 maven/mavencentral/org.skyscreamer/jsonassert/1.5.1, Apache-2.0, approved, clearlydefined 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 @@ -121,8 +121,8 @@ maven/mavencentral/org.springframework.cloud/spring-cloud-context/4.1.2, Apache- maven/mavencentral/org.springframework.cloud/spring-cloud-openfeign-core/4.1.1, Apache-2.0, approved, clearlydefined maven/mavencentral/org.springframework.cloud/spring-cloud-starter-openfeign/4.1.1, Apache-2.0, approved, clearlydefined maven/mavencentral/org.springframework.cloud/spring-cloud-starter/4.1.2, Apache-2.0, approved, clearlydefined -maven/mavencentral/org.springframework.data/spring-data-commons/3.2.5, Apache-2.0, approved, #11917 -maven/mavencentral/org.springframework.data/spring-data-jpa/3.2.5, Apache-2.0, approved, #11882 +maven/mavencentral/org.springframework.data/spring-data-commons/3.2.5, Apache-2.0, approved, #15202 +maven/mavencentral/org.springframework.data/spring-data-jpa/3.2.5, Apache-2.0, approved, #15183 maven/mavencentral/org.springframework.retry/spring-retry/2.0.5, Apache-2.0, approved, clearlydefined maven/mavencentral/org.springframework.security/spring-security-config/6.2.4, Apache-2.0, approved, #11896 maven/mavencentral/org.springframework.security/spring-security-core/6.2.3, Apache-2.0, approved, #11904 @@ -133,20 +133,20 @@ maven/mavencentral/org.springframework.security/spring-security-oauth2-jose/6.2. maven/mavencentral/org.springframework.security/spring-security-oauth2-resource-server/6.2.4, Apache-2.0, approved, #11920 maven/mavencentral/org.springframework.security/spring-security-rsa/1.1.2, Apache-2.0, approved, clearlydefined maven/mavencentral/org.springframework.security/spring-security-web/6.2.4, Apache-2.0, approved, #11911 -maven/mavencentral/org.springframework/spring-aop/6.1.6, Apache-2.0, approved, #11755 -maven/mavencentral/org.springframework/spring-aspects/6.1.6, Apache-2.0, approved, #11905 -maven/mavencentral/org.springframework/spring-beans/6.1.6, Apache-2.0, approved, #11754 +maven/mavencentral/org.springframework/spring-aop/6.1.6, Apache-2.0, approved, #15221 +maven/mavencentral/org.springframework/spring-aspects/6.1.6, Apache-2.0, approved, #15193 +maven/mavencentral/org.springframework/spring-beans/6.1.6, Apache-2.0, approved, #15213 maven/mavencentral/org.springframework/spring-context-support/6.0.14, Apache-2.0, approved, #6960 -maven/mavencentral/org.springframework/spring-context/6.1.6, Apache-2.0, approved, #11753 -maven/mavencentral/org.springframework/spring-core/6.1.6, Apache-2.0 AND BSD-3-Clause, approved, #11750 -maven/mavencentral/org.springframework/spring-expression/6.1.6, Apache-2.0, approved, #11747 -maven/mavencentral/org.springframework/spring-jcl/6.1.6, Apache-2.0, approved, #11749 -maven/mavencentral/org.springframework/spring-jdbc/6.1.6, Apache-2.0, approved, #11897 -maven/mavencentral/org.springframework/spring-orm/6.1.6, Apache-2.0, approved, #11924 -maven/mavencentral/org.springframework/spring-test/6.1.6, Apache-2.0, approved, #12919 -maven/mavencentral/org.springframework/spring-tx/6.1.6, Apache-2.0, approved, #11901 -maven/mavencentral/org.springframework/spring-web/6.1.6, Apache-2.0, approved, #11748 -maven/mavencentral/org.springframework/spring-webmvc/6.1.6, Apache-2.0, approved, #11879 +maven/mavencentral/org.springframework/spring-context/6.1.6, Apache-2.0, approved, #15261 +maven/mavencentral/org.springframework/spring-core/6.1.6, Apache-2.0 AND BSD-3-Clause, approved, #15206 +maven/mavencentral/org.springframework/spring-expression/6.1.6, Apache-2.0, approved, #15264 +maven/mavencentral/org.springframework/spring-jcl/6.1.6, Apache-2.0, approved, #15266 +maven/mavencentral/org.springframework/spring-jdbc/6.1.6, Apache-2.0, approved, #15191 +maven/mavencentral/org.springframework/spring-orm/6.1.6, Apache-2.0, approved, #15278 +maven/mavencentral/org.springframework/spring-test/6.1.6, Apache-2.0, approved, #15265 +maven/mavencentral/org.springframework/spring-tx/6.1.6, Apache-2.0, approved, #15229 +maven/mavencentral/org.springframework/spring-web/6.1.6, Apache-2.0, approved, #15188 +maven/mavencentral/org.springframework/spring-webmvc/6.1.6, Apache-2.0, approved, #15182 maven/mavencentral/org.webjars/swagger-ui/5.13.0, Apache-2.0, approved, #14547 maven/mavencentral/org.xmlunit/xmlunit-core/2.9.1, Apache-2.0, approved, #6272 maven/mavencentral/org.yaml/snakeyaml/2.2, Apache-2.0 AND (Apache-2.0 OR BSD-3-Clause OR EPL-1.0 OR GPL-2.0-or-later OR LGPL-2.1-or-later), approved, #10232 diff --git a/pom.xml b/pom.xml index 132c6311..6f8741d8 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ org.eclipse.tractusx managed-service-orchestrator - 1.5.6 + 1.5.9 managed-service-orchestrator managed-service-orchestrator diff --git a/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCApiProxy.java b/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCApiProxy.java deleted file mode 100644 index f7397a20..00000000 --- a/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCApiProxy.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2023 T-Systems International GmbH - * Copyright (c) 2023 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.autosetup.apiproxy; - -import java.net.URI; -import java.util.List; -import java.util.Map; - -import org.eclipse.tractusx.autosetup.portal.model.ServiceInstanceResultResponse; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -import feign.Headers; - -@FeignClient(name = "EDCApiProxy", url = "placeholder") -public interface EDCApiProxy { - - @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") - public ServiceInstanceResultResponse createAsset(URI url, @RequestHeader Map header, - @RequestBody ObjectNode requestBody); - - @PostMapping("/v2/policydefinitions") - @Headers("Content-Type: application/json") - public ServiceInstanceResultResponse createPolicy(URI url, @RequestHeader Map header, - @RequestBody ObjectNode requestBody); - - @PostMapping("/v2/contractdefinitions") - @Headers("Content-Type: application/json") - public ServiceInstanceResultResponse createContractDefination(URI url, @RequestHeader Map header, - @RequestBody ObjectNode requestBody); - -} diff --git a/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCProxyService.java b/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCProxyService.java deleted file mode 100644 index 24a2808d..00000000 --- a/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCProxyService.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2023 T-Systems International GmbH - * Copyright (c) 2023 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.autosetup.apiproxy; - -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; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.MappingJsonFactory; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; - -import lombok.RequiredArgsConstructor; -import lombok.SneakyThrows; - -@Component -@RequiredArgsConstructor -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; - - private Map requestHeader(Map inputData) { - Map header = new HashMap<>(); - header.put(inputData.get("edcApiKey"), inputData.get("edcApiKeyValue")); - return header; - } - - @SneakyThrows - public List getAssets(Customer customerDetails, Map inputData) { - String dataURL = inputData.get(CONTROL_PLANE_DATA_ENDPOINT); - 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 - public String createAsset(Customer customerDetails, Map inputData) { - - String dataURL = inputData.get(CONTROL_PLANE_DATA_ENDPOINT); - String uId = UUID.randomUUID().toString(); - 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 = valueReplacer(readValueAsTree, inputData); - ObjectNode json = (ObjectNode) new ObjectMapper().readTree(jsonString); - eDCApiProxy.createAsset(new URI(dataURL), requestHeader(inputData), json); - - return uId; - } - - @SneakyThrows - public String createPolicy(Customer customerDetails, Map inputData) { - String uId = UUID.randomUUID().toString(); - 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 uId = UUID.randomUUID().toString(); - inputData.put("contractPolicyId", uId); - String readValueAsTree = getSchemaFromFile("/edc-request-template/contract-defination.json"); - 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); - return uId; - } - - @SneakyThrows - private String getSchemaFromFile(String schemaFile) { - JsonParser createParser = null; - String schema = null; - try { - MappingJsonFactory jf = new MappingJsonFactory(); - InputStream jsonFile = this.getClass().getResourceAsStream(schemaFile); - - if (jsonFile == null) { - // this is how we load file within editor (eg eclipse) - jsonFile = this.getClass().getClassLoader().getResourceAsStream(schemaFile); - } - createParser = jf.createParser(jsonFile); - schema = createParser.readValueAsTree().toString(); - if (schema == null) { - throw new ServiceException("The schema for EDC asset creation is null " + schemaFile); - } - - return schema; - } finally { - if (createParser != null) - createParser.close(); - } - } - - 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/constant/SDEConfigurationProperty.java b/src/main/java/org/eclipse/tractusx/autosetup/constant/SDEConfigurationProperty.java index 5beac959..0dee9828 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/constant/SDEConfigurationProperty.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/constant/SDEConfigurationProperty.java @@ -34,32 +34,21 @@ public class SDEConfigurationProperty { private String keycloakAuth; private String keycloakRealm; private String keycloakTokenUrl; + private String keycloakTechnicalClientid; + private String keycloakTechnicalClientsecret; private String digitalTwinsHostname; - private String digitalTwinsAuthenticationUrl; - - private String partnerPoolHostname; - private String partnerPoolAuthenticationUrl; - private String partnerPoolClientId; - private String partnerPoolClientSecret; - - private String portalBackendHostname; - private String portalBackendAuthenticationUrl; - private String portalBackendClientId; - private String portalBackendClientSecret; - private String dtregistryidpClientId; private String dtregistrytenantId; private String dtregistryUrlPrefix; private String dtregistryApiUri; + private String partnerPoolHostname; + private String portalBackendHostname; + private String policyhubHostname; private String bpndiscoveryHostname; - private String discoveryAuthenticationUrl; - private String discoveryClientId; - private String discoveryClientSecret; - private String bpdmProviderEdcDataspaceApi; + private String bpdmProviderEdcDspApi; private String bpdmProviderBpnl; - private String bpdmProviderEdcPublicApi; } diff --git a/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java b/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java index 96ebc112..0767be6e 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java @@ -69,7 +69,7 @@ public ResponseEntity handleValidationException(ValidationException ex, } @ExceptionHandler(FeignException.class) - public ResponseEntity> handleFeignException(FeignException ex) { + public ResponseEntity> handleFeignException(FeignException ex, WebRequest request) { log.error("FeignException: " + ex.getMessage()); log.error("FeignException RequestBody: " + ex.request()); log.error("FeignException ResponseBody: " + ex.contentUTF8()); diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java index c63e1ca7..89a63cf9 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java @@ -98,10 +98,12 @@ public Map registerConnector(Customer customerDetails, SelectedT file = getTestFile(inputData.get("selfsigncertificate")); String subscriptionIdVal = inputData.get(SUBSCRIPTION_ID); + String connectorUrl = inputData.get("controlPlaneEndpoint"); + MultiValueMap body = new LinkedMultiValueMap<>(); String tenantNameNamespace = triger.getAutosetupTenantName(); body.add("name", tenantNameNamespace); - body.add("connectorUrl", inputData.get("controlPlaneEndpoint")); + body.add("connectorUrl", connectorUrl); body.add("location", customerDetails.getCountry()); body.add(SUBSCRIPTION_ID, subscriptionIdVal); Map header = new HashMap<>(); @@ -111,9 +113,11 @@ public Map registerConnector(Customer customerDetails, SelectedT String connectorId = checkSubcriptionHaveConnectorRegister(header, subscriptionIdVal); if (StringUtils.isNotBlank(connectorId)) { + Map updateBody = new HashMap<>(); - updateBody.put("connectorUrl", inputData.get("controlPlaneEndpoint")); - portalIntegrationProxy.updateRegisterConnectorUrl(connectorRegistrationUrl, header, updateBody); + updateBody.put("connectorUrl", connectorUrl); + portalIntegrationProxy.updateRegisterConnectorUrl(connectorRegistrationUrl, header, connectorId, + updateBody); } else { connectorId = portalIntegrationProxy.manageConnector(connectorRegistrationUrl, header, body); } @@ -133,15 +137,16 @@ public Map registerConnector(Customer customerDetails, SelectedT log.error("ConnectorregisterManager failed retry attempt: : {}", RetrySynchronizationManager.getContext().getRetryCount() + 1); log.error("RequestBody: " + e.request()); + log.error("ResponseStatus: " + e.status()); log.error("ResponseBody: " + e.contentUTF8()); autoSetupTriggerDetails.setStatus(TriggerStatusEnum.FAILED.name()); autoSetupTriggerDetails.setRemark(e.contentUTF8()); - if (e.toString().contains("FeignException$Conflict") || e.toString().contains("409 Conflict")) { + if (e.toString().contains("FeignException$Conflict") || e.toString().contains("409 Conflict") || e.status()== 403) { log.warn( - "Skipping connector registration process and also continue with remaining steps of autosetup process"); + "Skipping connector registration process and also continue with remaining steps of autosetup process because status for registration: "+e.status()); } else - throw new ServiceException("ConnectorregisterManager Oops! We have an exception - " + e.contentUTF8()); + throw new ServiceException("ConnectorregisterManager Oops! We have an FeignException - " + e.contentUTF8()); } catch (Exception ex) { @@ -168,10 +173,18 @@ public Map registerConnector(Customer customerDetails, SelectedT @SneakyThrows private String checkSubcriptionHaveConnectorRegister(Map header, String subscriptionId) { + String foundConnectorId = null; + try { JsonNode subcriptionWithConnectors = portalIntegrationProxy .getSubcriptionWithConnectors(connectorRegistrationUrl, header, true); + JsonNode allManageConnectorWithContent = portalIntegrationProxy + .getAllManageConnectors(connectorRegistrationUrl, header); + + JsonNode allManageConnectors = JsonObjectProcessingUtility + .getArrayNodeFromJsonNode(allManageConnectorWithContent, "content"); + if (subcriptionWithConnectors != null && subcriptionWithConnectors.isArray()) { for (JsonNode jsonNode : subcriptionWithConnectors) { @@ -182,9 +195,21 @@ private String checkSubcriptionHaveConnectorRegister(Map header, JsonNode connectorIds = JsonObjectProcessingUtility.getArrayNodeFromJsonNode(jsonNode, "connectorIds"); - - if (connectorIds != null && connectorIds.isArray() && connectorIds.size() > 0) - return connectorIds.get(0).asText(); + if (connectorIds != null && connectorIds.isArray()) + for (JsonNode connectorJsonValue : connectorIds) { + String connectorId = connectorJsonValue.asText(); + + if (allManageConnectors != null && allManageConnectors.isArray()) + for (JsonNode managedConnectorNode : allManageConnectors) { + + String managedConnectorId = JsonObjectProcessingUtility + .getValueFromJsonNode(managedConnectorNode, "id"); + if (managedConnectorId.equalsIgnoreCase(connectorId)) { + foundConnectorId = connectorId; + break; + } + } + } } } } @@ -193,7 +218,7 @@ private String checkSubcriptionHaveConnectorRegister(Map header, log.error("Error in checkSubcriptionHaveConnectorRegister or not " + e.getMessage()); } - return null; + return foundConnectorId; } @Retryable(retryFor = { 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 5fa10eb7..1136710f 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/DTRegistryManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/DTRegistryManager.java @@ -23,12 +23,10 @@ import static org.eclipse.tractusx.autosetup.constant.AppNameConstant.DT_REGISTRY; -import java.util.List; import java.util.Map; import java.util.UUID; import org.apache.commons.lang3.StringUtils; -import org.eclipse.tractusx.autosetup.apiproxy.EDCProxyService; import org.eclipse.tractusx.autosetup.constant.AppActions; import org.eclipse.tractusx.autosetup.constant.SDEConfigurationProperty; import org.eclipse.tractusx.autosetup.constant.TriggerStatusEnum; @@ -77,7 +75,7 @@ public Map managePackage(Customer customerDetails, AppActions ac dturi = StringUtils.isBlank(dturi) ? "/api/v3" : dturi; if (managedDTRegistryLocal) { String appName = DT_REGISTRY.name().replace("_", ""); - String localDTUrl = "http://cx-" + packageName + "-" + appName.toLowerCase() + "-registry-svc:8080"; + String localDTUrl = "http://" + packageName + "-" + appName.toLowerCase() + "-digital-twin-registry:8080"; inputData.put("dtregistryUrl", localDTUrl); inputData.put("dtregistryUrlWithURI", localDTUrl + dturi); } else { diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java index 3ce7c7fd..0b203f97 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java @@ -62,14 +62,12 @@ public class PortalIntegrationManager { private static final String BEARER = "Bearer "; - private static final String ACTIVE = "ACTIVE"; - private final PortalIntegrationProxy portalIntegrationProxy; private final AutoSetupTriggerManager autoSetupTriggerManager; private final KeyCloakTokenProxyUtitlity keyCloakTokenProxyUtitlity; - + @Value("${portal.url}") private URI portalUrl; @@ -113,14 +111,10 @@ public Map postServiceInstanceResultAndGetTenantSpecs(Customer c String applicationURL = dnsNameURLProtocol + "://" + dnsName; inputData.put("applicationURL", applicationURL); - Map header = new HashMap<>(); - header.put(AUTHORIZATION, - BEARER + keyCloakTokenProxyUtitlity.getKeycloakToken(clientId, clientSecret, tokenURI)); - ServiceInstanceResultRequest serviceInstanceResultRequest = ServiceInstanceResultRequest.builder() .requestId(subscriptionId).offerUrl(applicationURL).build(); - serviceInstanceResultResponse = processAppServiceGetResponse(subscriptionId, offerId, header, + serviceInstanceResultResponse = processAppServiceGetResponse(subscriptionId, offerId, serviceInstanceResultRequest, appServiceURIPath); handlePortalServiceExcutionResponse(inputData, autoSetupTriggerDetails, serviceInstanceResultResponse); @@ -164,6 +158,62 @@ public Map postServiceInstanceResultAndGetTenantSpecs(Customer c } return inputData; } + + + @Retryable(retryFor = { + ServiceException.class }, maxAttemptsExpression = "${retry.maxAttempts}", backoff = @Backoff(delayExpression = "#{${retry.backOffDelay}}")) + public Map activateAppAndServiceInstanceOnPortalEnd(Customer customerDetails, SelectedTools tool, + Map inputData, AutoSetupTriggerEntry triger) { + + AutoSetupTriggerDetails autoSetupTriggerDetails = AutoSetupTriggerDetails.builder() + .id(UUID.randomUUID().toString()).step("ActivateAppAndServiceInstanceOnPortalEnd").build(); + try { + String appServiceURIPath = "apps"; + + if (!"app".equalsIgnoreCase(tool.getType())) { + appServiceURIPath = "services"; + } + + String packageName = tool.getLabel(); + String tenantName = customerDetails.getOrganizationName(); + + log.info(LogUtil.encode(tenantName) + "-" + LogUtil.encode(packageName) + + "-ActivateAppAndServiceInstanceOnPortalEnd acivating"); + String subscriptionId = inputData.get("subscriptionId"); + + portalIntegrationProxy.activateAppServiceOnPortalSide( + portalUrl, getHeaderWithToken(), appServiceURIPath, subscriptionId); + + log.info(LogUtil.encode(tenantName) + "-" + LogUtil.encode(packageName) + + "-ActivateAppAndServiceInstanceOnPortalEnd acivated"); + + } catch (FeignException e) { + + log.error(LogUtil.encode("PortalIntegrationManager-activateAppAndServiceInstanceOnPortalEnd FeignException failed retry attempt: : " + + RetrySynchronizationManager.getContext().getRetryCount() + 1)); + log.error(LogUtil.encode("RequestBody: " + e.request())); + log.error(LogUtil.encode("ResponseBody: " + e.contentUTF8())); + + autoSetupTriggerDetails.setStatus(TriggerStatusEnum.FAILED.name()); + autoSetupTriggerDetails.setRemark(e.contentUTF8()); + throw new ServiceException("PortalIntegrationManager-activateAppAndServiceInstanceOnPortalEnd Oops! We have an FeignException - " + e.contentUTF8()); + + } catch (Exception ex) { + + log.error(LogUtil.encode("PortalIntegrationManager-activateAppAndServiceInstanceOnPortalEnd Exception failed retry attempt: : " + + RetrySynchronizationManager.getContext().getRetryCount() + 1)); + + autoSetupTriggerDetails.setStatus(TriggerStatusEnum.FAILED.name()); + + ex.getStackTrace(); + + throw new ServiceException("PortalIntegrationManager-activateAppAndServiceInstanceOnPortalEnd Oops! We have an exception - " + ex.getMessage()); + } finally { + autoSetupTriggerManager.saveTriggerDetails(autoSetupTriggerDetails, triger); + } + + return inputData; + } @SneakyThrows private void handlePortalServiceExcutionResponse(Map inputData, @@ -206,115 +256,132 @@ private void handlePortalServiceExcutionResponse(Map inputData, @SneakyThrows private ServiceInstanceResultResponse processAppServiceGetResponse(String subscriptionId, String offerId, - Map header, ServiceInstanceResultRequest serviceInstanceResultRequest, - String appServiceURIPath) { - - ServiceInstanceResultResponse serviceInstanceResultResponse = verifyIsAlreadySubcribedActivatedAndGetDetails( - subscriptionId, offerId, header, appServiceURIPath); + ServiceInstanceResultRequest serviceInstanceResultRequest, String appServiceURIPath) { - if (serviceInstanceResultResponse == null) { + ServiceInstanceResultResponse serviceInstanceResultResponse = readStatus(subscriptionId, offerId, appServiceURIPath); - portalIntegrationProxy.postAppServiceStartAutoSetup(portalUrl, header, appServiceURIPath, + if (serviceInstanceResultResponse == null || serviceInstanceResultResponse.getTenantUrl() == null) { + log.info("Posting app/service instanceURL becasue no tenant url preconfiguration found"); + portalIntegrationProxy.postAppServiceStartAutoSetup(portalUrl, getHeaderWithToken(), appServiceURIPath, serviceInstanceResultRequest); - log.info("Post App/Service instanceURL, going to read credentials asynchronously"); + } + + serviceInstanceResultResponse = verifyIsAlreadySubcribedActivatedAndGetDetails(subscriptionId, offerId, + appServiceURIPath); - serviceInstanceResultResponse = verifyIsAlreadySubcribedActivatedAndGetDetails(subscriptionId, offerId, - header, appServiceURIPath); - - } - - if (serviceInstanceResultResponse == null) { + if (serviceInstanceResultResponse == null || serviceInstanceResultResponse.getTechnicalUserData() == null + || serviceInstanceResultResponse.getTechnicalUserData().isEmpty()) { throw new ServiceException("Unable to read technical user detials from portal auto setup"); } - readTechnicalUserDetails(header, serviceInstanceResultResponse); + readTechnicalUserDetails(serviceInstanceResultResponse); return serviceInstanceResultResponse; } + @SneakyThrows private ServiceInstanceResultResponse verifyIsAlreadySubcribedActivatedAndGetDetails(String subscriptionId, - String offerId, Map header, String appServiceURIPath) { + String offerId, String appServiceURIPath) { int retry = 5; int counter = 1; ServiceInstanceResultResponse serviceInstanceResultResponse = null; - String offerSubscriptionStatus = null; + boolean continueCheckingifTenantUrlNotConfigureAndNotTechnicalUserCreated= true; do { - log.info("Waiting '" + requestTimeout + "'sec to portal /provider API call to get subcription status"); + log.info("Waiting '" + requestTimeout + + "'sec to portal /provider API call to get subcription status- retry => " + counter); Thread.sleep(requestTimeout); - try { - - header.put(AUTHORIZATION, - BEARER + keyCloakTokenProxyUtitlity.getKeycloakToken(clientId, clientSecret, tokenURI)); - - serviceInstanceResultResponse = portalIntegrationProxy.getAppServiceInstanceSubcriptionDetails( - portalUrl, header, appServiceURIPath, offerId, subscriptionId); - - offerSubscriptionStatus = serviceInstanceResultResponse.getOfferSubscriptionStatus(); + + serviceInstanceResultResponse = readStatus(subscriptionId, offerId, appServiceURIPath); + + if (serviceInstanceResultResponse!=null && serviceInstanceResultResponse.getTenantUrl() != null + && !serviceInstanceResultResponse.getTechnicalUserData().isEmpty()) { + continueCheckingifTenantUrlNotConfigureAndNotTechnicalUserCreated = false; + } + + counter++; - log.info(LogUtil.encode("VerifyIsAlreadySubcribedActivatedAndGetDetails: The subscription details found for " + offerId - + ", " + subscriptionId + ", status is " + offerSubscriptionStatus + ", result is " - + serviceInstanceResultResponse.toJsonString())); + } while (continueCheckingifTenantUrlNotConfigureAndNotTechnicalUserCreated && counter <= retry); - } catch (FeignException e) { - log.error(LogUtil.encode("VerifyIsAlreadySubcribedActivatedAndGetDetails FeignException request: " + e.request())); - log.error(LogUtil.encode("VerifyIsAlreadySubcribedActivatedAndGetDetails FeignException response Body: " - + e.responseBody())); - String error = e.contentUTF8(); - error = StringUtils.isAllEmpty(error) ? error : e.getMessage(); - - if (e.status() == 404) { - log.warn(LogUtil.encode("VerifyIsAlreadySubcribedActivatedAndGetDetails: The no app or subscription found for " - + offerId + ", " + subscriptionId + ", result is " + error)); - } else { - log.error(LogUtil.encode("VerifyIsAlreadySubcribedActivatedAndGetDetails FeignException Exception response: " - + error)); - } + return serviceInstanceResultResponse; + } - } catch (Exception e) { - log.error(LogUtil.encode("VerifyIsAlreadySubcribedActivatedAndGetDetails Exception processing portal call " - + e.getMessage())); + private ServiceInstanceResultResponse readStatus(String subscriptionId, String offerId, String appServiceURIPath) { + + ServiceInstanceResultResponse serviceInstanceResultResponse =null; + String offerSubscriptionStatus; + try { + serviceInstanceResultResponse = portalIntegrationProxy.getAppServiceInstanceSubcriptionDetails( + portalUrl, getHeaderWithToken(), appServiceURIPath, offerId, subscriptionId); + + offerSubscriptionStatus = serviceInstanceResultResponse.getOfferSubscriptionStatus(); + log.info(LogUtil + .encode("VerifyIsAlreadySubcribedActivatedAndGetDetails: The subscription details found for " + + offerId + ", " + subscriptionId + ", status is " + offerSubscriptionStatus + + ", result is " + serviceInstanceResultResponse.toJsonString())); + + } catch (FeignException e) { + log.error(LogUtil.encode( + "VerifyIsAlreadySubcribedActivatedAndGetDetails FeignException request: " + e.request())); + log.error(LogUtil.encode("VerifyIsAlreadySubcribedActivatedAndGetDetails FeignException response Body: " + + e.responseBody())); + String error = e.contentUTF8(); + error = StringUtils.isAllEmpty(error) ? error : e.getMessage(); + + if (e.status() == 404) { + log.warn(LogUtil.encode( + "VerifyIsAlreadySubcribedActivatedAndGetDetails: The no app or subscription found for " + + offerId + ", " + subscriptionId + ", result is " + error)); + } else { + log.error(LogUtil + .encode("VerifyIsAlreadySubcribedActivatedAndGetDetails FeignException Exception response: " + + error)); } - counter++; - - } while (!ACTIVE.equalsIgnoreCase(offerSubscriptionStatus) && counter <= retry); + } catch (Exception e) { + log.error(LogUtil + .encode("VerifyIsAlreadySubcribedActivatedAndGetDetails Exception processing portal call " + + e.getMessage())); + } return serviceInstanceResultResponse; } @SneakyThrows - private void readTechnicalUserDetails(Map header, - ServiceInstanceResultResponse serviceInstanceResultResponse) { + private void readTechnicalUserDetails(ServiceInstanceResultResponse serviceInstanceResultResponse) { + + Map header = getHeaderWithToken(); - if (serviceInstanceResultResponse.getTechnicalUserData() != null) { - - header.put(AUTHORIZATION, - BEARER + keyCloakTokenProxyUtitlity.getKeycloakToken(clientId, clientSecret, tokenURI)); - - serviceInstanceResultResponse.getTechnicalUserData().forEach(elel -> { - try { - TechnicalUserDetails technicalUserDetails = portalIntegrationProxy - .getTechnicalUserDetails(portalUrl, header, elel.getId()); - elel.setTechnicalUserDetails(technicalUserDetails); - } catch (FeignException e) { - log.error("ReadTechnicalUserDetails FeignException request: " + e.request()); - log.error("ReadTechnicalUserDetails FeignException response Body: " + e.responseBody()); - String error = e.contentUTF8(); - error = StringUtils.isNotBlank(error) ? error : e.getMessage(); - log.error("ReadTechnicalUserDetails FeignException Exception response: " + error); - if (e.status() == 409) - throw new NoDataFoundException(error); - else - throw new ServiceException(error); - } catch (Exception e) { - String error = "Error in read existing TechnicalUserDetails from portal " + e.getMessage(); - log.error(error); + serviceInstanceResultResponse.getTechnicalUserData().forEach(elel -> { + try { + TechnicalUserDetails technicalUserDetails = portalIntegrationProxy.getTechnicalUserDetails(portalUrl, + header, elel.getId()); + elel.setTechnicalUserDetails(technicalUserDetails); + } catch (FeignException e) { + log.error("ReadTechnicalUserDetails FeignException request: " + e.request()); + log.error("ReadTechnicalUserDetails FeignException response Body: " + e.responseBody()); + String error = e.contentUTF8(); + error = StringUtils.isNotBlank(error) ? error : e.getMessage(); + log.error("ReadTechnicalUserDetails FeignException Exception response: " + error); + if (e.status() == 409) + throw new NoDataFoundException(error); + else throw new ServiceException(error); - } - }); - } + } catch (Exception e) { + String error = "Error in read existing TechnicalUserDetails from portal " + e.getMessage(); + log.error(error); + throw new ServiceException(error); + } + }); + + } + + private Map getHeaderWithToken() { + Map header = new HashMap<>(); + header.put(AUTHORIZATION, + BEARER + keyCloakTokenProxyUtitlity.getKeycloakToken(clientId, clientSecret, tokenURI)); + return header; } } diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/SDEManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/SDEManager.java index 38264b54..100f8840 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/SDEManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/SDEManager.java @@ -85,13 +85,18 @@ public Map managePackage(Customer customerDetails, AppActions ac inputData.put("sdeFrontEndUrl", sdefrontend); inputData.put("database", "sde"); - inputData.put("sde.digital-twins.authentication.url", - sDEConfigurationProperty.getDigitalTwinsAuthenticationUrl()); + String keycloakAuthenticationClientId = sDEConfigurationProperty.getKeycloakTechnicalClientid(); + String keycloakAuthenticationClientSecret = sDEConfigurationProperty.getKeycloakTechnicalClientsecret(); + + inputData.put("sde.digital-twins.authentication.url", sDEConfigurationProperty.getKeycloakTokenUrl()); if (!manualUpdate) { - inputData.put("digital-twins.authentication.clientId", inputData.get("keycloakAuthenticationClientId")); - inputData.put("digital-twins.authentication.clientSecret", - inputData.get("keycloakAuthenticationClientSecret")); + + keycloakAuthenticationClientId = inputData.get("keycloakAuthenticationClientId"); + keycloakAuthenticationClientSecret = inputData.get("keycloakAuthenticationClientSecret"); + + inputData.put("digital-twins.authentication.clientId", keycloakAuthenticationClientId); + inputData.put("digital-twins.authentication.clientSecret", keycloakAuthenticationClientSecret); inputData.put("sdebackendkeycloakclientid", inputData.get("keycloakResourceClient")); inputData.put("sdefrontendkeycloakclientid", inputData.get("keycloakResourceClient")); @@ -103,27 +108,18 @@ public Map managePackage(Customer customerDetails, AppActions ac inputData.put("sde.digital-twins.hostname", sDEConfigurationProperty.getDigitalTwinsHostname()); } + inputData.put("sde.resourceServerIssuer", sDEConfigurationProperty.getResourceServerIssuer()); inputData.put("sde.keycloak.auth", sDEConfigurationProperty.getKeycloakAuth()); inputData.put("sde.keycloak.realm", sDEConfigurationProperty.getKeycloakRealm()); inputData.put("sde.keycloak.tokenUrl", sDEConfigurationProperty.getKeycloakTokenUrl()); + inputData.put("sde.keycloak.technical.clientid", keycloakAuthenticationClientId); + inputData.put("sde.keycloak.technical.clientsecret", keycloakAuthenticationClientSecret); inputData.put("sde.partner.pool.hostname", sDEConfigurationProperty.getPartnerPoolHostname()); - inputData.put("sde.partner.pool.authentication.url", - sDEConfigurationProperty.getPartnerPoolAuthenticationUrl()); - inputData.put("sde.partner.pool.clientId", sDEConfigurationProperty.getPartnerPoolClientId()); - inputData.put("sde.partner.pool.clientSecret", sDEConfigurationProperty.getPartnerPoolClientSecret()); - inputData.put("sde.portal.backend.hostname", sDEConfigurationProperty.getPortalBackendHostname()); - inputData.put("sde.portal.backend.authentication.url", - sDEConfigurationProperty.getPortalBackendAuthenticationUrl()); - inputData.put("sde.portal.backend.clientId", sDEConfigurationProperty.getPortalBackendClientId()); - inputData.put("sde.portal.backend.clientSecret", sDEConfigurationProperty.getPortalBackendClientSecret()); - inputData.put("sde.bpndiscovery.hostname", sDEConfigurationProperty.getBpndiscoveryHostname()); - inputData.put("sde.discovery.authentication.url", sDEConfigurationProperty.getDiscoveryAuthenticationUrl()); - inputData.put("sde.discovery.clientId", sDEConfigurationProperty.getDiscoveryClientId()); - inputData.put("sde.discovery.clientSecret", sDEConfigurationProperty.getDiscoveryClientSecret()); + inputData.put("sde.policy.hub.hostname", sDEConfigurationProperty.getPolicyhubHostname()); inputData.put("sftpHost", "defaulthost"); inputData.put("sftpPort", "22"); @@ -137,12 +133,11 @@ public Map managePackage(Customer customerDetails, AppActions ac inputData.put("emailPort", emailConfigurationProperty.getPort()); inputData.put("emailTo", customerDetails.getEmail()); inputData.put("emailCC", emailConfigurationProperty.getReplytoAddress()); - inputData.put("emailFrom", customerDetails.getOrganizationName() +" SDE notification"); + inputData.put("emailFrom", customerDetails.getOrganizationName() + " SDE notification"); inputData.put("emailReply", emailConfigurationProperty.getReplytoAddress()); - - inputData.put("bpdm.provider.edc.dataspace.api", sDEConfigurationProperty.getBpdmProviderEdcDataspaceApi()); + + inputData.put("bpdm.provider.edc.dsp.api", sDEConfigurationProperty.getBpdmProviderEdcDspApi()); inputData.put("bpdm.provider.bpnl", sDEConfigurationProperty.getBpdmProviderBpnl()); - inputData.put("bpdm.provider.edc.public.api", sDEConfigurationProperty.getBpdmProviderEdcPublicApi()); String packageName = tool.getLabel(); diff --git a/src/main/java/org/eclipse/tractusx/autosetup/portal/model/TechnicalUsers.java b/src/main/java/org/eclipse/tractusx/autosetup/portal/model/TechnicalUsers.java index 7f392962..64b23dd0 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/portal/model/TechnicalUsers.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/portal/model/TechnicalUsers.java @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2024 T-Systems International GmbH - * Copyright (c) 2024 Contributors to the Eclipse Foundation + * Copyright (c) 2022,2024 T-Systems International GmbH + * Copyright (c) 2022,2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/tractusx/autosetup/portal/proxy/PortalIntegrationProxy.java b/src/main/java/org/eclipse/tractusx/autosetup/portal/proxy/PortalIntegrationProxy.java index 19951fd5..30b03848 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/portal/proxy/PortalIntegrationProxy.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/portal/proxy/PortalIntegrationProxy.java @@ -55,6 +55,11 @@ public ServiceInstanceResultResponse postAppInstanceResultAndGetTenantSpecs(URI public JsonNode postAppServiceStartAutoSetup(URI url, @RequestHeader Map header, @PathVariable("appServiceURIPath") String appServiceURIPath, @RequestBody ServiceInstanceResultRequest serviceInstanceResultRequest); + + @PutMapping("/api/{appServiceURIPath}/subscription/{subscriptionId}/activate") + public JsonNode activateAppServiceOnPortalSide(URI url, @RequestHeader Map header, + @PathVariable("appServiceURIPath") String appServiceURIPath, + @PathVariable("subscriptionId") String subscriptionId); @GetMapping("/api/{appServiceURIPath}/{appId}/subscription/{subscriptionId}/provider") public ServiceInstanceResultResponse getAppServiceInstanceSubcriptionDetails(URI url, @@ -69,13 +74,16 @@ public TechnicalUserDetails getTechnicalUserDetails(URI url, @RequestHeader Map< @PostMapping("/api/administration/connectors/managed") public String manageConnector(URI url, @RequestHeader Map header, @RequestBody MultiValueMap body); + + @GetMapping("/api/administration/connectors/managed") + public JsonNode getAllManageConnectors(URI url, @RequestHeader Map header); @GetMapping("/api/administration/connectors/offerSubscriptions") public JsonNode getSubcriptionWithConnectors(URI url, @RequestHeader Map header, @RequestParam("connectorIdSet") boolean connectorIdSet); - @PutMapping("/api/administration/connectors/{offerSubscriptionId}/connectorUrl") - public String updateRegisterConnectorUrl(URI url, @RequestHeader Map header, + @PutMapping("/api/administration/connectors/{connectorId}/connectorUrl") + public String updateRegisterConnectorUrl(URI url, @RequestHeader Map header, @PathVariable String connectorId, @RequestBody Map body); @DeleteMapping("/api/administration/connectors/{connectorId}") diff --git a/src/main/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorService.java b/src/main/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorService.java index 947d36c8..1f0755b9 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorService.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorService.java @@ -546,7 +546,8 @@ private void executeInstallTool(AutoSetupTriggerEntry trigger, Map> extractResultMap(Map outputMap dft.put("name", "SDE"); dft.put(SDE_FRONTEND_URL, outputMap.get(SDE_FRONTEND_URL)); dft.put(SDE_BACKEND_URL, outputMap.get(SDE_BACKEND_URL)); + dft.put("storage.media.bucket", findValueInMap(outputMap, "storage.media.bucket")); + dft.put("storage.media.endpoint", findValueInMap(outputMap, "storage.media.endpoint")); + dft.put("storage.media.accessKey", findValueInMap(outputMap, "storage.media.accessKey")); + dft.put("storage.media.secretKey", findValueInMap(outputMap, "storage.media.secretKey")); processResult.add(dft); diff --git a/src/main/java/org/eclipse/tractusx/autosetup/service/EDCConnectorWorkFlow.java b/src/main/java/org/eclipse/tractusx/autosetup/service/EDCConnectorWorkFlow.java index 6d8137c0..dbc53f1f 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/service/EDCConnectorWorkFlow.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/service/EDCConnectorWorkFlow.java @@ -87,6 +87,15 @@ public Map getWorkFlow(Customer customerDetails, SelectedTools t } catch (ServiceException ex) { log.warn(ex.getMessage()); } + + try { + if (!manualUpdate) + portalIntegrationManager.activateAppAndServiceInstanceOnPortalEnd(customerDetails, tool, inputConfiguration, + triger); + } catch (ServiceException ex) { + log.warn(ex.getMessage()); + } + return inputConfiguration; } diff --git a/src/main/java/org/eclipse/tractusx/autosetup/service/SDEAppWorkFlow.java b/src/main/java/org/eclipse/tractusx/autosetup/service/SDEAppWorkFlow.java index 15a0223b..303d8cc1 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/service/SDEAppWorkFlow.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/service/SDEAppWorkFlow.java @@ -28,8 +28,10 @@ import org.eclipse.tractusx.autosetup.entity.AutoSetupTriggerEntry; import org.eclipse.tractusx.autosetup.manager.AppDeleteManager; import org.eclipse.tractusx.autosetup.manager.SDEManager; +import org.eclipse.tractusx.autosetup.model.AutoSetupRequest; import org.eclipse.tractusx.autosetup.model.Customer; import org.eclipse.tractusx.autosetup.model.SelectedTools; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import lombok.RequiredArgsConstructor; @@ -42,6 +44,9 @@ public class SDEAppWorkFlow { private final AppDeleteManager appDeleteManager; + @Value("${automatic.storage.media:true}") + private boolean manualStorageMedia; + public Map getWorkFlow(Customer customerDetails, SelectedTools tool, AppActions workflowAction, Map inputConfiguration, AutoSetupTriggerEntry triger) { @@ -52,7 +57,7 @@ public Map getWorkFlow(Customer customerDetails, SelectedTools t } public void deletePackageWorkFlow(SelectedTools tool, Map inputConfiguration, - AutoSetupTriggerEntry triger) { + AutoSetupTriggerEntry triger, AutoSetupRequest orgRequest) { appDeleteManager.deletePackage(SDE, tool, inputConfiguration, triger); diff --git a/src/main/java/org/eclipse/tractusx/autosetup/utility/JsonObjectProcessingUtility.java b/src/main/java/org/eclipse/tractusx/autosetup/utility/JsonObjectProcessingUtility.java index ec5ce8f1..d58db5f4 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/utility/JsonObjectProcessingUtility.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/utility/JsonObjectProcessingUtility.java @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2024 T-Systems International GmbH - * Copyright (c) 2024 Contributors to the Eclipse Foundation + * Copyright (c) 2023 T-Systems International GmbH + * Copyright (c) 2023 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/tractusx/autosetup/utility/KeyCloakTokenProxyUtitlity.java b/src/main/java/org/eclipse/tractusx/autosetup/utility/KeyCloakTokenProxyUtitlity.java index 65b5453a..c0855967 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/utility/KeyCloakTokenProxyUtitlity.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/utility/KeyCloakTokenProxyUtitlity.java @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2024 T-Systems International GmbH - * Copyright (c) 2024 Contributors to the Eclipse Foundation + * Copyright (c) 2023 T-Systems International GmbH + * Copyright (c) 2023 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/resources/edc-request-template/asset-request-filter.json b/src/main/resources/edc-request-template/asset-request-filter.json deleted file mode 100644 index e77fb954..00000000 --- a/src/main/resources/edc-request-template/asset-request-filter.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "@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 deleted file mode 100644 index 04b39933..00000000 --- a/src/main/resources/edc-request-template/asset.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "@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 deleted file mode 100644 index 7ebb3ff3..00000000 --- a/src/main/resources/edc-request-template/contract-defination.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "@context": {}, - "@id": "${contractPolicyId}", - "@type": "ContractDefinition", - "accessPolicyId": "${policyId}", - "contractPolicyId": "${policyId}", - "assetsSelector": { - "@type": "CriterionDto", - "operandLeft": "https://w3id.org/edc/v0.0.1/ns/id", - "operator": "=", - "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 deleted file mode 100644 index da30d85a..00000000 --- a/src/main/resources/edc-request-template/policy.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "@context": { - "odrl": "http://www.w3.org/ns/odrl/2/" - }, - "@type": "PolicyDefinitionRequestDto", - "@id": "${policyId}", - "policy": { - "@type": "Policy", - "odrl:permission": [] - } -} \ No newline at end of file diff --git a/src/main/resources/flyway/V11__update_sde_edc_app_version.sql b/src/main/resources/flyway/V11__update_sde_edc_app_version.sql new file mode 100644 index 00000000..43952e9a --- /dev/null +++ b/src/main/resources/flyway/V11__update_sde_edc_app_version.sql @@ -0,0 +1,503 @@ +/******************************************************************************** + * Copyright (c) 2024 T-Systems International GmbH + * Copyright (c) 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 + ********************************************************************************/ + +update app_tbl set expected_input_data='{ + "sdepostgresql":{ + "enabled":true, + "primary":{ + "persistence":{ + "size":"1Gi" + } + }, + "persistence":{ + "size":"1Gi" + }, + "auth":{ + "postgresPassword":"$\{postgresPassword\}", + "password":"$\{postgresPassword\}", + "username":"$\{username\}", + "database":"$\{database\}" + } + }, + "backend": { + "ingresses":[ + { + "enabled":true, + "hostname":"$\{dnsName\}", + "annotations":{ + + }, + "className":"nginx", + "endpoints":[ + "default" + ], + "tls":{ + "enabled":true, + "secretName":"sdebackend" + }, + "certManager":{ + "clusterIssuer":"letsencrypt-prod" + } + } + ], + "configuration":{ + "properties": "server.port=8080 + + spring.main.allow-bean-definition-overriding=true + + spring.servlet.multipart.enabled=true + + spring.servlet.multipart.file-size-threshold=2KB + + spring.servlet.multipart.max-file-size=200MB + + spring.servlet.multipart.max-request-size=215MB + + server.servlet.context-path=/backend/api + + spring.flyway.baseline-on-migrate=true + + spring.flyway.locations=classpath:/flyway + + file.upload-dir=./temp/ + + logging.level.org.apache.http=info + + logging.level.root=info + + spring.datasource.driver-class-name=org.postgresql.Driver + + spring.jpa.open-in-view=false + + dft.hostname=$\{sdeBackEndUrl\} + + dft.apiKeyHeader=$\{sdeBackEndApiKeyHeader\} + + dft.apiKey=$\{sdeBackEndApiKey\} + + manufacturerId=$\{manufacturerId\} + + edc.hostname=$\{controlPlaneEndpoint\} + + edc.managementpath=/data + + edc.managementpath.apiversion=/v2 + + edc.managementpath.apiversion.asset=/v3 + + edc.dsp.endpointpath=/api/v1/dsp + + edc.dataplane.endpointpath=/api/public + + edc.apiKeyHeader=$\{edcApiKey\} + + edc.apiKey=$\{edcApiKeyValue\} + + edc.consumer.hostname=$\{controlPlaneEndpoint\} + + edc.consumer.apikeyheader=$\{edcApiKey\} + + edc.consumer.apikey=$\{edcApiKeyValue\} + + edc.consumer.managementpath=/data + + edc.consumer.managementpath.apiversion=/v2 + + edc.consumer.protocol.path=/api/v1/dsp + + keycloak.clientid=$\{sdebackendkeycloakclientid\} + + spring.security.oauth2.resourceserver.jwt.issuer-uri=$\{sde.resourceServerIssuer\} + + springdoc.api-docs.path=/api-docs + + springdoc.swagger-ui.oauth.client-id=$\{sdebackendkeycloakclientid\} + + digital-twins.hostname=$\{dtregistryUrl\} + + digital-twins.registry.uri=$\{dtregistryURI\} + + digital-twins.registry.lookup.uri=$\{dtregistryURI\} + + digital-twins.authentication.url=$\{sde.keycloak.tokenUrl\} + + digital-twins.authentication.clientId=$\{sde.keycloak.technical.clientid\} + + digital-twins.authentication.clientSecret=$\{sde.keycloak.technical.clientsecret\} + + digital-twins.authentication.grantType=client_credentials + + partner.pool.hostname=$\{sde.partner.pool.hostname\} + + partner.pool.authentication.url=$\{sde.keycloak.tokenUrl\} + + partner.pool.clientId=$\{sde.keycloak.technical.clientid\} + + partner.pool.clientSecret=$\{sde.keycloak.technical.clientsecret\} + + partner.pool.grantType=client_credentials + + portal.backend.hostname=$\{sde.portal.backend.hostname\} + + portal.backend.authentication.url=$\{sde.keycloak.tokenUrl\} + + portal.backend.clientId=$\{sde.keycloak.technical.clientid\} + + portal.backend.clientSecret=$\{sde.keycloak.technical.clientsecret\} + + portal.backend.grantType=client_credentials + + bpndiscovery.hostname=$\{sde.bpndiscovery.hostname\} + + discovery.authentication.url=$\{sde.keycloak.tokenUrl\} + + discovery.clientId=$\{sde.keycloak.technical.clientid\} + + discovery.clientSecret=$\{sde.keycloak.technical.clientsecret\} + + discovery.grantType=client_credentials + + policy.hub.hostname=$\{sde.policy.hub.hostname\} + + policy.hub.authentication.url=$\{sde.keycloak.tokenUrl\} + + policy.hub.clientId=$\{sde.keycloak.technical.clientid\} + + policy.hub.clientSecret=$\{sde.keycloak.technical.clientsecret\} + + policy.hub.grantType=client_credentials + + bpdm.provider.edc.dsp.api=$\{bpdm.provider.edc.dsp.api\} + + bpdm.provider.bpnl=$\{bpdm.provider.bpnl\} + + mail.smtp.username=$\{emailUsername\} + + mail.smtp.password=$\{emailPassword\} + + mail.smtp.host=$\{emailHost\} + + mail.smtp.port=$\{emailPort\} + + mail.to.address=$\{emailTo\} + + mail.cc.address=$\{emailCC\} + + mail.from.address=$\{emailFrom\} + + mail.replyto.address=$\{emailReply\} + + mail.smtp.starttls.enable=true + + mail.smtp.auth=true + + sftp.host=$\{sftpHost\} + + sftp.port=$\{sftpPort\} + + sftp.username=$\{sftpUsername\} + + sftp.password=$\{sftpPassword\} + + sftp.accessKey=$\{sftpKey\} + + sftp.location.tobeprocessed=/ToBeProcessed + + sftp.location.inprogress=/InProgress + + sftp.location.success=/Success + + sftp.location.partialsucess=/PartialSuccess + + sftp.location.failed=/Failed + + retriever.name=minio + + minio.endpoint=$\{storage.media.endpoint\} + + minio.access-key=$\{storage.media.accessKey\} + + minio.secret-key=$\{storage.media.secretKey\} + + minio.bucket-name=$\{storage.media.bucket\} + + minio.location.tobeprocessed= + + minio.location.inprogress=/InProgress + + minio.location.success=/Success + + minio.location.partialsucess=/PartialSuccess + + minio.location.failed=/Failed" + } + }, + "frontend": { + "ingresses":[ + { + "enabled":true, + "hostname":"$\{dnsName\}", + "annotations":{ + "kubernetes.io/tls-acme": "true" + }, + "className":"nginx", + "endpoints":[ + "default" + ], + "tls":{ + "enabled":true, + "secretName":"sdefrontend" + }, + "certManager":{ + "clusterIssuer":"letsencrypt-prod" + } + } + ], + "configuration":{ + "properties":"REACT_APP_API_URL=$\{sdeBackEndUrl\} + + REACT_APP_KEYCLOAK_URL=$\{sde.keycloak.auth\} + + REACT_APP_KEYCLOAK_REALM=$\{sde.keycloak.realm\} + + REACT_APP_CLIENT_ID=$\{sdefrontendkeycloakclientid\} + + REACT_APP_DEFAULT_COMPANY_BPN=$\{bpnNumber\} + + REACT_APP_FILESIZE=268435456" + } + } +}', package_identifier='tx-sde-charts/sde' ,package_version='1.2.5' where app_name='SDE'; + + +update app_tbl set expected_input_data= '{ + "enablePostgres": true, + "enableKeycloak": false, + "postgresql": { + "auth": { + "password":"$\{rgdbpass\}", + "postgresPassword":"$\{rgdbpass\}", + "username":"$\{rgusername\}", + "database":"$\{rgdatabase\}" + }, + "primary": + { + "persistence":{ + "size" :"1Gi" + } + }, + "persistence": { + "size" :"1Gi" + } + }, + "registry": { + "host": "$\{dnsName\}", + "idpClientId" : "$\{idpClientId\}", + "idpIssuerUri": "$\{idpIssuerUri\}", + "tenantId" : "$\{bpnNumber\}", + "authentication": $\{dtNeedExternalAccess\}, + "granularAccessControlFetchSize": "500", + "useGranularAccessControl": "true", + "ingress": { + "enabled": $\{dtNeedExternalAccess\}, + "hostname": "$\{dnsName\}", + "annotations": { + "cert-manager.io/cluster-issuer": letsencrypt-prod, + "nginx.ingress.kubernetes.io/cors-allow-credentials": "true", + "nginx.ingress.kubernetes.io/enable-cors": "true", + "nginx.ingress.kubernetes.io/rewrite-target": /$2, + "nginx.ingress.kubernetes.io/use-regex": "true", + "nginx.ingress.kubernetes.io/x-forwarded-prefix": /$\{dtregistryUrlPrefix\} + }, + "urlPrefix": /$\{dtregistryUrlPrefix\}, + "className": "nginx", + "tls": $\{dtNeedExternalAccess\} + } + } +}', package_identifier='tx-all-repo/digital-twin-registry', package_version='0.5.1' where app_name='DT_REGISTRY'; + + +update app_tbl set expected_input_data= '{ + "install": { + "postgresql": true, + "vault": false + }, + "participant" : { + "id": "$\{bpnNumber\}" + }, + "backendService": { + "httpProxyTokenReceiverUrl": "$\{dftAddress\}" + }, + "postgresql": { + "enabled": true, + "fullnameOverride": "connectorpostgresqlhost", + "jdbcUrl":"jdbc:postgresql://connectorpostgresqlhost:5432/edc", + "username":"$\{username\}", + "password":"$\{appdbpass\}", + "database": "edc", + "auth":{ + "username":"$\{username\}", + "password":"$\{appdbpass\}", + "postgresPassword":"$\{postgresPassword\}" + }, + "primary":{ + "persistence":{ + "enabled": true, + "size":"1Gi" + } + }, + "persistence":{ + "enabled": true, + "size":"1Gi" + } + }, + "vault": { + "hashicorp": { + "enabled": true, + "url": "$\{vaulturl\}", + "token": "$\{vaulttoken\}", + "timeout": 30, + "healthCheck": { + "enabled": false, + "standbyOk": false + }, + "paths": { + "health": "/v1/sys/health", + "secret": "$\{valuttenantpath\}" + } + }, + "secretNames": { + "dapsPrivateKey": "$\{certificate-private-key\}", + "dapsPublicKey": "$\{daps-cert\}", + "transferProxyTokenEncryptionAesKey": "$\{encryptionkeys\}", + "transferProxyTokenSignerPrivateKey": "$\{certificate-data-plane-private-key\}", + "transferProxyTokenSignerPublicKey": "$\{certificate-data-plane-public-key\}" + } + }, + "iatp": { + "id": "$\{iatp.id\}", + "sts": { + "dim": { + "url": "$\{iatp.sts.dim.url\}" + }, + "oauth": { + "client": { + "id": "$\{dimClientId\}", + "secret_alias": "$\{dim-client-secret\}" + }, + "token_url": "$\{iatp.sts.oauth.token_url\}" + } + } + }, + "controlplane": { + "endpoints": { + "management": { + "authKey": "$\{edcApiKeyValue\}", + "path": "/data", + "port": "8081" + } + }, + "bdrs": { + "cache_validity_seconds": 600, + "server": { + "url": "$\{bdrs.server\}" + } + }, + "env": { + "EDC_IAM_TRUSTED-ISSUER_ISSUER1_ID": "$\{edc.iam.trusted-issuer\}" + }, + "service": { + "type": "NodePort" + }, + "securityContext": { + "readOnlyRootFilesystem": false + }, + "ssi" : { + "miw" :{ + "authorityId" : "$\{authorityId\}", + "url": "$\{edcMiwUrl\}" + }, + "oauth": { + "client" :{ + "id" :"$\{keycloakAuthenticationClientId\}", + "secretAlias": "client-secret" + }, + "tokenurl": "$\{keycloakAuthTokenURL\}" + } + }, + "ingresses": [ + { + "enabled": true, + "hostname": "$\{dnsName\}", + "annotations": {}, + "className": "nginx", + "endpoints": [ + "protocol", + "management", + "control", + "default" + ], + "tls": { + "enabled": true, + "secretName": "edctxcontrolplane" + }, + "certManager": { + "clusterIssuer": "letsencrypt-prod" + } + } + ] + }, + "dataplane": { + "token": { + "refresh": { + "expiry_seconds": 300, + "expiry_tolerance_seconds": 300, + "refresh_endpoint": "$\{dataplane.token.refresh.refresh_endpoint\}" + }, + "signer": { + "privatekey_alias": "$\{certificate-private-key\}" + }, + "verifier": { + "publickey_alias": "$\{daps-cert\}" + } + } + }, + "ingresses": [ + { + "enabled": true, + "hostname": "$\{dnsName\}", + "annotations": {}, + "className": "nginx", + "endpoints": [ + "public" + ], + "tls": { + "enabled": true, + "secretName": "edctxdataplane" + }, + "certManager": { + "clusterIssuer": "letsencrypt-prod" + } + } + ] + } +}', package_version='0.7.3', package_identifier='tx-all-repo/tractusx-connector' where app_name='EDC_CONNECTOR'; + +update app_tbl set expected_input_data= replace(replace(expected_input_data,'\{','{'),'\}','}'), required_yaml_configuration=replace(replace(required_yaml_configuration,'\{','{'),'\}','}'); \ No newline at end of file diff --git a/src/main/resources/flyway/V9__update_app_version.sql b/src/main/resources/flyway/V9__update_app_version.sql index 8f29610f..8b90c774 100644 --- a/src/main/resources/flyway/V9__update_app_version.sql +++ b/src/main/resources/flyway/V9__update_app_version.sql @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2024 T-Systems International GmbH - * Copyright (c) 2024 Contributors to the Eclipse Foundation + * Copyright (c) 2023 T-Systems International GmbH + * Copyright (c) 2023 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/test/java/org/eclipse/tractusx/autosetup/manager/SDEManagerTest.java b/src/test/java/org/eclipse/tractusx/autosetup/manager/SDEManagerTest.java index f629ae2c..483cd6bd 100644 --- a/src/test/java/org/eclipse/tractusx/autosetup/manager/SDEManagerTest.java +++ b/src/test/java/org/eclipse/tractusx/autosetup/manager/SDEManagerTest.java @@ -75,7 +75,7 @@ void managePackage() { mockInputMap.put("dnsNameURLProtocol", "https"); Map resultMap = sdeManager.managePackage(customerDetails, AppActions.CREATE, selectedTools, mockInputMap, null); - assertEquals(46, resultMap.size()); + assertEquals(39, resultMap.size()); assertEquals("test", mockInputMap.get("dnsName")); } } \ No newline at end of file From c1751093f52006dca4b387aa9d392952614945d3 Mon Sep 17 00:00:00 2001 From: "Amol.Dashwant" Date: Fri, 26 Jul 2024 16:25:11 +0530 Subject: [PATCH 2/3] Changelog and license year updated --- CHANGELOG.md | 5 +++++ .../autosetup/exception/GlobalDefaultExceptionHandler.java | 4 ++-- .../autosetup/manager/ConnectorRegistrationManager.java | 4 ++-- .../autosetup/portal/proxy/PortalIntegrationProxy.java | 4 ++-- .../autosetup/service/AutoSetupOrchitestratorService.java | 4 ++-- .../tractusx/autosetup/service/EDCConnectorWorkFlow.java | 4 ++-- .../eclipse/tractusx/autosetup/service/SDEAppWorkFlow.java | 4 ++-- .../autosetup/utility/JsonObjectProcessingUtility.java | 4 ++-- .../autosetup/utility/KeyCloakTokenProxyUtitlity.java | 4 ++-- src/main/resources/flyway/V9__update_app_version.sql | 4 ++-- .../eclipse/tractusx/autosetup/manager/SDEManagerTest.java | 4 ++-- 11 files changed, 25 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf2f1972..3e4ceba8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +## [Unreleased] +### Added +- Portal auto setup support for multiple credentials for dim and shared services for 24.08 +- Use portal callback url to activate subscription on portal side + ## [1.5.6] - 2024-05-27 ### Added diff --git a/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java b/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java index 0767be6e..ef448e7c 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2022, 2023 T-Systems International GmbH - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022,2024 T-Systems International GmbH + * Copyright (c) 2022,2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java index 89a63cf9..81363e8c 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2022, 2023 T-Systems International GmbH - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022,2024 T-Systems International GmbH + * Copyright (c) 2022,2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/tractusx/autosetup/portal/proxy/PortalIntegrationProxy.java b/src/main/java/org/eclipse/tractusx/autosetup/portal/proxy/PortalIntegrationProxy.java index 30b03848..83b942a8 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/portal/proxy/PortalIntegrationProxy.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/portal/proxy/PortalIntegrationProxy.java @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2022, 2023 T-Systems International GmbH - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022,2024 T-Systems International GmbH + * Copyright (c) 2022,2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorService.java b/src/main/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorService.java index 1f0755b9..b2993f28 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorService.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorService.java @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2022, 2023 T-Systems International GmbH - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022,2024 T-Systems International GmbH + * Copyright (c) 2022,2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/tractusx/autosetup/service/EDCConnectorWorkFlow.java b/src/main/java/org/eclipse/tractusx/autosetup/service/EDCConnectorWorkFlow.java index dbc53f1f..20408ce4 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/service/EDCConnectorWorkFlow.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/service/EDCConnectorWorkFlow.java @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2022, 2023 T-Systems International GmbH - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022,2024 T-Systems International GmbH + * Copyright (c) 2022,2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/tractusx/autosetup/service/SDEAppWorkFlow.java b/src/main/java/org/eclipse/tractusx/autosetup/service/SDEAppWorkFlow.java index 303d8cc1..64555342 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/service/SDEAppWorkFlow.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/service/SDEAppWorkFlow.java @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2022, 2023 T-Systems International GmbH - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022,2024 T-Systems International GmbH + * Copyright (c) 2022,2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/tractusx/autosetup/utility/JsonObjectProcessingUtility.java b/src/main/java/org/eclipse/tractusx/autosetup/utility/JsonObjectProcessingUtility.java index d58db5f4..9a9a5175 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/utility/JsonObjectProcessingUtility.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/utility/JsonObjectProcessingUtility.java @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2023 T-Systems International GmbH - * Copyright (c) 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2023,2024 T-Systems International GmbH + * Copyright (c) 2023,2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/java/org/eclipse/tractusx/autosetup/utility/KeyCloakTokenProxyUtitlity.java b/src/main/java/org/eclipse/tractusx/autosetup/utility/KeyCloakTokenProxyUtitlity.java index c0855967..f0a60421 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/utility/KeyCloakTokenProxyUtitlity.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/utility/KeyCloakTokenProxyUtitlity.java @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2023 T-Systems International GmbH - * Copyright (c) 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2023,2024 T-Systems International GmbH + * Copyright (c) 2023,2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/main/resources/flyway/V9__update_app_version.sql b/src/main/resources/flyway/V9__update_app_version.sql index 8b90c774..cc1de65a 100644 --- a/src/main/resources/flyway/V9__update_app_version.sql +++ b/src/main/resources/flyway/V9__update_app_version.sql @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2023 T-Systems International GmbH - * Copyright (c) 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2023,2024 T-Systems International GmbH + * Copyright (c) 2023,2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. diff --git a/src/test/java/org/eclipse/tractusx/autosetup/manager/SDEManagerTest.java b/src/test/java/org/eclipse/tractusx/autosetup/manager/SDEManagerTest.java index 483cd6bd..74e4359b 100644 --- a/src/test/java/org/eclipse/tractusx/autosetup/manager/SDEManagerTest.java +++ b/src/test/java/org/eclipse/tractusx/autosetup/manager/SDEManagerTest.java @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2022, 2023 T-Systems International GmbH - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022,2024 T-Systems International GmbH + * Copyright (c) 2022,2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. From 565a87f965dd093c913b0a472827ee27d7e20df7 Mon Sep 17 00:00:00 2001 From: "Amol.Dashwant" Date: Mon, 29 Jul 2024 10:15:48 +0530 Subject: [PATCH 3/3] Removed unnecessary license update --- src/main/resources/flyway/V9__update_app_version.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/flyway/V9__update_app_version.sql b/src/main/resources/flyway/V9__update_app_version.sql index cc1de65a..8f29610f 100644 --- a/src/main/resources/flyway/V9__update_app_version.sql +++ b/src/main/resources/flyway/V9__update_app_version.sql @@ -1,6 +1,6 @@ /******************************************************************************** - * Copyright (c) 2023,2024 T-Systems International GmbH - * Copyright (c) 2023,2024 Contributors to the Eclipse Foundation + * Copyright (c) 2024 T-Systems International GmbH + * Copyright (c) 2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership.