diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml index 21285fe7..3c3d2110 100644 --- a/.github/workflows/trivy.yml +++ b/.github/workflows/trivy.yml @@ -74,7 +74,7 @@ jobs: uses: aquasecurity/trivy-action@master with: # Path to Docker image - image-ref: "ghcr.io/catenax-ng/tx-autosetup-backend/autosetup:latest" + image-ref: "ghcr.io/catenax-ng/tx-managed-service-orchestrator/autosetup:latest" format: "sarif" output: "trivy-results.sarif" exit-code: "1" diff --git a/CHANGELOG.md b/CHANGELOG.md index b81e74b5..d3ac5a6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] - NA +## [1.4.1] - 2023-08-21 + +### Fixed + - Corrected image for Trviy workflow + - Email notification only on successful component connetcivity test + - Corrected email template + ## [1.4.0] - 2023-08-17 ### Fixed diff --git a/README.md b/README.md index bcc7fcbb..d81c9514 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.4.0 -Helm release version: 1.4.0 +Application version: 1.4.1 +Helm release version: 1.4.1 ``` ### Container images diff --git a/charts/chart-testing-config.yaml b/charts/chart-testing-config.yaml index 0e182b74..5631e807 100644 --- a/charts/chart-testing-config.yaml +++ b/charts/chart-testing-config.yaml @@ -1,3 +1,23 @@ +################################################################################# +# Copyright (c) 2022,2023 T-Systems International GmbH +# Copyright (c) 2022,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 +################################################################################ + validate-maintainers: false chart-repos: - bitnami=https://charts.bitnami.com/bitnami \ No newline at end of file diff --git a/charts/orchestrator/Chart.yaml b/charts/orchestrator/Chart.yaml index f0746311..7ef3ab55 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.4.0 +version: 1.4.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.4.0" +appVersion: "1.4.1" dependencies: - condition: postgresql.enabled diff --git a/charts/orchestrator/README.md b/charts/orchestrator/README.md index b6874f44..5fbd3ebc 100644 --- a/charts/orchestrator/README.md +++ b/charts/orchestrator/README.md @@ -1,6 +1,6 @@ # autosetup -![Version: 1.4.0](https://img.shields.io/badge/Version-1.4.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.4.0](https://img.shields.io/badge/AppVersion-1.4.0-informational?style=flat-square) +![Version: 1.4.1](https://img.shields.io/badge/Version-1.4.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.4.1](https://img.shields.io/badge/AppVersion-1.4.1-informational?style=flat-square) This service will help service provider to set up DFT/SDE with EDC and EDC as service in service provider environment. diff --git a/pom.xml b/pom.xml index d87a7978..8fc63e4b 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ org.eclipse.tractusx auto-setup - 1.4.0 + 1.4.1 auto-setup auto-setup diff --git a/src/main/java/org/eclipse/tractusx/autosetup/config/EclipseLinkJpaConfiguration.java b/src/main/java/org/eclipse/tractusx/autosetup/config/EclipseLinkJpaConfiguration.java index 88de01ca..ef29d875 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/config/EclipseLinkJpaConfiguration.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/config/EclipseLinkJpaConfiguration.java @@ -51,7 +51,7 @@ protected AbstractJpaVendorAdapter createJpaVendorAdapter() { protected Map getVendorProperties() { HashMap map = new HashMap<>(); map.put(PersistenceUnitProperties.WEAVING, detectWeavingMode()); - map.put(PersistenceUnitProperties.DDL_GENERATION, PersistenceUnitProperties.CREATE_ONLY); + map.put(PersistenceUnitProperties.DDL_GENERATION, PersistenceUnitProperties.CREATE_OR_EXTEND); return map; } diff --git a/src/main/java/org/eclipse/tractusx/autosetup/entity/AutoSetupTriggerEntry.java b/src/main/java/org/eclipse/tractusx/autosetup/entity/AutoSetupTriggerEntry.java index f8dee3e0..fdbad90b 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/entity/AutoSetupTriggerEntry.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/entity/AutoSetupTriggerEntry.java @@ -90,6 +90,9 @@ public class AutoSetupTriggerEntry { @Column(name = "remark", columnDefinition = "TEXT") private String remark; + + @Column(name = "input_configuration", columnDefinition = "TEXT") + private String inputConfiguration; public void addTriggerDetails(AutoSetupTriggerDetails autoSetupTriggerDetails) { if (autosetupTriggerDetails == null) 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 e5160961..311ce45c 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java @@ -28,6 +28,7 @@ import java.util.Map; import java.util.UUID; +import org.apache.commons.lang3.StringUtils; import org.eclipse.tractusx.autosetup.constant.TriggerStatusEnum; import org.eclipse.tractusx.autosetup.entity.AutoSetupTriggerDetails; import org.eclipse.tractusx.autosetup.entity.AutoSetupTriggerEntry; @@ -158,17 +159,17 @@ public Map deleteConnector(SelectedTools tool, Map header = new HashMap<>(); header.put("Authorization", "Bearer " + getKeycloakToken()); - log.info(LogUtil.encode(orgName) + "-" + LogUtil.encode(packageName) + "-CONNECTOR-DELETE deleted"); autoSetupTriggerDetails.setStatus(TriggerStatusEnum.SUCCESS.name()); portalIntegrationProxy.deleteConnector(connectorRegistrationUrl, header, connectorId); + + log.info(LogUtil.encode(orgName) + "-" + LogUtil.encode(packageName) + "-CONNECTOR-DELETE deleted"); } else log.error("Connector Id not found in autosetup result to delete connector from portal"); 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 18b9864b..ba855748 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorService.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorService.java @@ -59,6 +59,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; @Service @@ -66,6 +67,7 @@ @RequiredArgsConstructor public class AutoSetupOrchitestratorService { + private static final String CCEMAIL = "ccemail"; private static final String TEST_SERVICE_URL = "testServiceURL"; private static final String CONNECTOR_TEST_RESULT = "connectorTestResult"; private static final String EMAIL_SENT_SUCCESSFULLY = "Email sent successfully"; @@ -101,7 +103,10 @@ public class AutoSetupOrchitestratorService { @Value("${portal.email.address}") private String portalEmail; - + + @Value("${mail.replyto.address}") + private String mailReplytoAddress; + @Value("${manual.update}") private boolean manualUpdate; @@ -323,14 +328,17 @@ private void proceessTrigger(AutoSetupRequest autoSetupRequest, AppActions actio log.error("Error in package creation " + e.getMessage()); trigger.setStatus(TriggerStatusEnum.FAILED.name()); trigger.setRemark(e.getMessage()); + generateNotification(autoSetupRequest.getCustomer(), "Error in autosetup execution - "+trigger.getTriggerId()); } LocalDateTime now = LocalDateTime.now(); trigger.setModifiedTimestamp(now.toString()); + trigger.setInputConfiguration(autoSetupTriggerMapper.fromMaptoStr(List.of(inputConfiguration))); autoSetupTriggerManager.saveTriggerUpdate(trigger); } + private void executeEDCTractus(AutoSetupRequest autoSetupRequest, AppActions action, AutoSetupTriggerEntry trigger, Map inputConfiguration, SelectedTools selectedTool) { @@ -357,11 +365,22 @@ private void edcDeployemnt(AutoSetupRequest autoSetupRequest, AutoSetupTriggerEn Map emailContent = new HashMap<>(); emailContent.put(ORGNAME, customer.getOrganizationName()); emailContent.putAll(edcOutput); - emailContent.put(TOEMAIL, customer.getEmail()); - emailContent.put("ccemail", portalEmail); - - emailManager.sendEmail(emailContent, "EDC Application Activited Successfully", "edc_success_activate.html"); - log.info(EMAIL_SENT_SUCCESSFULLY); + + + String connectivityTestStr= edcOutput.get(CONNECTOR_TEST_RESULT); + + boolean isTestConnectivityTestSuccess = connectivityTestStr!=null && connectivityTestStr.contains("consumer and provider"); + + if (isTestConnectivityTestSuccess) { + emailContent.put(TOEMAIL, customer.getEmail()); + emailContent.put(CCEMAIL, portalEmail); + emailManager.sendEmail(emailContent, "EDC Application Activited Successfully", "edc_success_activate.html"); + log.info(EMAIL_SENT_SUCCESSFULLY); + }else { + generateNotification(customer, "EDC Application Deployed Successfully"); + } + + } private void executeSDEWithEDCTractus(AutoSetupRequest autoSetupRequest, AppActions action, @@ -400,7 +419,7 @@ private void dtDeployment(Customer customer, AppActions action, AutoSetupTrigger emailContent.put(ORGNAME, customer.getOrganizationName()); emailContent.putAll(inputConfiguration); emailContent.put(TOEMAIL, customer.getEmail()); - emailContent.put("ccemail", portalEmail); + emailContent.put(CCEMAIL, portalEmail); emailManager.sendEmail(emailContent, "DT registry Application Activited Successfully", "dt_success_template.html"); @@ -430,15 +449,12 @@ private void sdeDeployment(AutoSetupRequest autoSetupRequest, AppActions action, emailContent.put(TEST_SERVICE_URL, map.get(TEST_SERVICE_URL)); emailContent.putAll(map); - if (manualUpdate) { - // Send an email - emailContent.put("helloto", "Team"); - emailContent.put(ORGNAME, customer.getOrganizationName()); - emailContent.put(TOEMAIL, portalEmail); - - // End of email sending code - emailManager.sendEmail(emailContent, "SDE Application Deployed Successfully", "success.html"); - log.info(EMAIL_SENT_SUCCESSFULLY); + String connectivityTestStr= inputConfiguration.get(CONNECTOR_TEST_RESULT); + boolean isTestConnectivityTestSuccess = connectivityTestStr!=null && connectivityTestStr.contains("consumer and provider"); + + if (manualUpdate || !isTestConnectivityTestSuccess) { + + generateNotification(customer, "SDE Application Deployed Successfully"); trigger.setStatus(TriggerStatusEnum.MANUAL_UPDATE_PENDING.name()); } else { @@ -448,7 +464,7 @@ private void sdeDeployment(AutoSetupRequest autoSetupRequest, AppActions action, // Send an email emailContent.put(ORGNAME, customer.getOrganizationName()); emailContent.put(TOEMAIL, customer.getEmail()); - emailContent.put("ccemail", portalEmail); + emailContent.put(CCEMAIL, portalEmail); emailManager.sendEmail(emailContent, "SDE Application Activited Successfully", "success_activate.html"); log.info(EMAIL_SENT_SUCCESSFULLY); @@ -460,7 +476,19 @@ private void sdeDeployment(AutoSetupRequest autoSetupRequest, AppActions action, trigger.setAutosetupResult(json); } + + @SneakyThrows + private void generateNotification(Customer customer, String emailSubject) { + + Map emailContent = new HashMap<>(); + emailContent.put(ORGNAME, customer.getOrganizationName()); + emailContent.put(TOEMAIL, mailReplytoAddress); + emailContent.put(CCEMAIL, portalEmail); + emailManager.sendEmail(emailContent, emailSubject, "success.html"); + log.info(EMAIL_SENT_SUCCESSFULLY); + } + private void processDeleteTrigger(AutoSetupTriggerEntry trigger, Map inputConfiguration) { if (trigger != null && trigger.getAutosetupRequest() != null) { diff --git a/src/main/java/org/eclipse/tractusx/autosetup/service/DTAppWorkFlow.java b/src/main/java/org/eclipse/tractusx/autosetup/service/DTAppWorkFlow.java index 0a2864fd..4e2d3a0d 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/service/DTAppWorkFlow.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/service/DTAppWorkFlow.java @@ -52,10 +52,8 @@ public Map getWorkFlow(Customer customerDetails, SelectedTools t dtregistryManager.managePackage(customerDetails, workflowAction, tool, inputConfiguration, triger)); if (!manualUpdate) { - Runnable runnable = () -> dtregistryManager.dtRegistryRegistrationInEDC(customerDetails, tool, + dtregistryManager.dtRegistryRegistrationInEDC(customerDetails, tool, inputConfiguration, triger); - - new Thread(runnable).start(); } return inputConfiguration; diff --git a/src/main/resources/templates/success.html b/src/main/resources/templates/success.html index 9ee9caec..93eb24c1 100644 --- a/src/main/resources/templates/success.html +++ b/src/main/resources/templates/success.html @@ -24,17 +24,15 @@ - SDE template + Deployment template

Hello Team,

-

The SDE application deployed successfully for ${orgname}.

-

Frontend URL : ${sdeFrontEndUrl}

-

Backend URL : ${sdeBackEndUrl}

-

Please send the Digital Twin and Keycloak details to configure SDE tool for ${orgname} use.

+

The Subcribe application deployed successfully for ${orgname}.

+

please perform manually verification to activate application for customer use.

Kind Regards
Catina-X