From 7c21e6fed0d2d075ba69e5df6651bb64b9f2ddc2 Mon Sep 17 00:00:00 2001 From: Martin Maul Date: Mon, 17 Jun 2024 13:41:21 +0200 Subject: [PATCH 01/12] chore(actions): #1033 remove jira publish release action --- .github/workflows/jira-publish-release.yaml | 91 --------------------- .github/workflows/release.yaml | 8 -- 2 files changed, 99 deletions(-) delete mode 100644 .github/workflows/jira-publish-release.yaml diff --git a/.github/workflows/jira-publish-release.yaml b/.github/workflows/jira-publish-release.yaml deleted file mode 100644 index 39ce1b68eb..0000000000 --- a/.github/workflows/jira-publish-release.yaml +++ /dev/null @@ -1,91 +0,0 @@ -# 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 -name: "[BE][FE][RELEASE] Jira release publishing" - -on: - workflow_dispatch: # Trigger manually - inputs: - version: - required: true - type: string - description: Version that will be released in Jira, eg. 2.0.0 - workflow_call: - inputs: - version: - required: true - type: string - description: Version that will be released in Jira, eg. 2.0.0 -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Set current date as env variable - run: echo "NOW=$(date +'%Y-%m-%d')" >> $GITHUB_ENV - - name: Echo current date - run: echo $NOW - - - name: Get Version Id Of Release - env: - JIRA_USERNAME: ${{ secrets.RELEASE_IRS_JIRA_USERNAME }} - JIRA_PASSWORD: ${{ secrets.RELEASE_IRS_JIRA_PASSWORD }} - run: | - echo "versionId=$(curl --request GET --url 'https://jira.catena-x.net/rest/api/latest/project/10211/versions' \ - --user $JIRA_USERNAME:$JIRA_PASSWORD --header 'Accept: application/json' | jq -r '.[] | select(.name == "NEXT_RELEASE").id')" >> $GITHUB_ENV - - name: Echo versionId to release - run: echo Exported $versionId as version id to release - - - name: Release Version in Jira - env: - JIRA_USERNAME: ${{ secrets.RELEASE_IRS_JIRA_USERNAME }} - JIRA_PASSWORD: ${{ secrets.RELEASE_IRS_JIRA_PASSWORD }} - VERSION: ${{ github.event.inputs.version }} - VERSION_ID: ${{ env.versionId }} - RELEASE_DATE: ${{ env.NOW }} - run: | - curl --request PUT --url "https://jira.catena-x.net/rest/api/latest/version/$VERSION_ID" \ - --user $JIRA_USERNAME:$JIRA_PASSWORD \ - --header 'Accept: application/json' \ - --header 'Content-Type: application/json' \ - --data "{ - \"archived\": false, - \"description\": \"$VERSION\", - \"id\": $VERSION_ID, - \"name\": \"$VERSION\", - \"releaseDate\": \"$RELEASE_DATE\", - \"released\": true, - \"overdue\": false, - \"projectId\": 10211 - }" - - - name: Create NEXT_RELEASE Version in Jira - env: - JIRA_USERNAME: ${{ secrets.RELEASE_IRS_JIRA_USERNAME }} - JIRA_PASSWORD: ${{ secrets.RELEASE_IRS_JIRA_PASSWORD }} - run: | - curl --request POST --url 'https://jira.catena-x.net/rest/api/latest/version' \ - --user $JIRA_USERNAME:$JIRA_PASSWORD \ - --header 'Accept: application/json' \ - --header 'Content-Type: application/json' \ - --data '{ - "archived": false, - "name": "NEXT_RELEASE", - "projectId": 10211, - "released": false - }' diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f58afde5f8..644533953b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -91,14 +91,6 @@ jobs: with: body: ${{ env.CHANGELOG }} - trigger-jira: - needs: - - release - uses: ./.github/workflows/jira-publish-release.yaml - with: - version: ${{ github.ref_name }} - secrets: inherit - publish-to-swaggerhub: name: "Publish OpenAPI spec to Swaggerhub" permissions: From 486f5d3734800db430987c4cc67cd1912e7994a9 Mon Sep 17 00:00:00 2001 From: Martin Maul Date: Mon, 17 Jun 2024 13:43:28 +0200 Subject: [PATCH 02/12] chore(actions): #1033 remove jira publish release action --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f0cf3f7bf..8c7a301f9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ _**For better traceability add the corresponding GitHub issue number in each cha ### Removed - XXX Removed EdcNotifiactionMockServiceImpl class and replaced with mocks +- #1033 removed action jira-publish-release workflow ### Changed From 7a72e52f90d75e91a4f2da4ecdbb7908d69bfa45 Mon Sep 17 00:00:00 2001 From: Maximilian Wesener Date: Mon, 17 Jun 2024 16:04:00 +0200 Subject: [PATCH 03/12] feature(refactoring):xxx removed message coverters --- .../traceability/common/config/PolicyStartUpConfig.java | 1 - .../traceability/common/config/RestTemplateConfiguration.java | 2 -- 2 files changed, 3 deletions(-) diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/PolicyStartUpConfig.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/PolicyStartUpConfig.java index fb92971ea1..b945569866 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/PolicyStartUpConfig.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/PolicyStartUpConfig.java @@ -74,7 +74,6 @@ public class PolicyStartUpConfig { @ConditionalOnProperty(name = "applicationConfig.registerDecentralRegistryPermissions.enabled", havingValue = "true") public void registerDecentralRegistryPermissions() throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); - mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); mapper.registerModule(new JavaTimeModule()); List acceptedPolicy = buildAcceptedPolicies(); defaultAcceptedPoliciesProvider.addAcceptedPolicies(acceptedPolicy); diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/RestTemplateConfiguration.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/RestTemplateConfiguration.java index ff9cfb7701..524d79ba88 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/RestTemplateConfiguration.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/RestTemplateConfiguration.java @@ -143,7 +143,6 @@ public RestTemplate irsAdminTemplate(@Autowired TraceabilityProperties traceabil .rootUri(traceabilityProperties.getIrsBase()) .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) // Set Content-Type header .defaultHeader(IRS_API_KEY_HEADER_NAME, traceabilityProperties.getAdminApiKey()) - .messageConverters(customMessageConverters()) .build(); } @@ -225,7 +224,6 @@ private List> customMessageConverters() { .configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true) .configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) - .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) .build() .registerModules(javaTimeModule)); From a052fe39519a60029d5a0dff62ebc92e4f34df05 Mon Sep 17 00:00:00 2001 From: Maximilian Wesener Date: Tue, 18 Jun 2024 08:09:28 +0200 Subject: [PATCH 04/12] feature(refactoring):xxx removed message coverters --- .github/workflows/pull-request_backend.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request_backend.yml b/.github/workflows/pull-request_backend.yml index f340361a75..5614645fd4 100644 --- a/.github/workflows/pull-request_backend.yml +++ b/.github/workflows/pull-request_backend.yml @@ -120,7 +120,7 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_BACKEND }} SONAR_ORGANIZATION: ${{ vars.SONAR_ORGANIZATION }} SONAR_PROJECT_KEY: ${{ vars.SONAR_PROJECT_KEY_BACKEND }} - run: mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn --batch-mode sonar:sonar -Dsonar.coverage.jacoco.xmlReportPaths=/home/runner/work/tx-traceability-foss/tx-traceability-foss/tx-coverage/target/site/jacoco-aggregate/jacoco.xml -Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY_BACKEND }} -Dsonar.organization=${{ vars.SONAR_ORGANIZATION }} + run: mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn --batch-mode sonar:sonar -Dsonar.coverage.jacoco.xmlReportPaths=/home/runner/work/traceability-foss/traceability-foss/tx-coverage/target/site/jacoco-aggregate/jacoco.xml -Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY_BACKEND }} -Dsonar.organization=${{ vars.SONAR_ORGANIZATION }} Publish-docker-image: needs: [ "Test-and-Sonar" ] From 4de015e363d852cf92df742ff34e5b976eedb578 Mon Sep 17 00:00:00 2001 From: Maximilian Wesener Date: Tue, 18 Jun 2024 08:28:30 +0200 Subject: [PATCH 05/12] feature(refactoring):xxx removed message coverters --- .github/workflows/pull-request_backend.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request_backend.yml b/.github/workflows/pull-request_backend.yml index 5614645fd4..cdffe57426 100644 --- a/.github/workflows/pull-request_backend.yml +++ b/.github/workflows/pull-request_backend.yml @@ -120,7 +120,7 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_BACKEND }} SONAR_ORGANIZATION: ${{ vars.SONAR_ORGANIZATION }} SONAR_PROJECT_KEY: ${{ vars.SONAR_PROJECT_KEY_BACKEND }} - run: mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn --batch-mode sonar:sonar -Dsonar.coverage.jacoco.xmlReportPaths=/home/runner/work/traceability-foss/traceability-foss/tx-coverage/target/site/jacoco-aggregate/jacoco.xml -Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY_BACKEND }} -Dsonar.organization=${{ vars.SONAR_ORGANIZATION }} + run: mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn --batch-mode org.sonarsource.scanner.maven:sonar-maven-plugin:sonar:sonar -Dsonar.coverage.jacoco.xmlReportPaths=/home/runner/work/traceability-foss/traceability-foss/tx-coverage/target/site/jacoco-aggregate/jacoco.xml -Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY_BACKEND }} -Dsonar.organization=${{ vars.SONAR_ORGANIZATION }} Publish-docker-image: needs: [ "Test-and-Sonar" ] From be474a6cbe950572251485de56cea9ad7b5b8d88 Mon Sep 17 00:00:00 2001 From: Maximilian Wesener Date: Tue, 18 Jun 2024 08:34:54 +0200 Subject: [PATCH 06/12] feature(refactoring):xxx removed message coverters --- .github/workflows/pull-request_backend.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request_backend.yml b/.github/workflows/pull-request_backend.yml index cdffe57426..4cb647931e 100644 --- a/.github/workflows/pull-request_backend.yml +++ b/.github/workflows/pull-request_backend.yml @@ -120,7 +120,7 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_BACKEND }} SONAR_ORGANIZATION: ${{ vars.SONAR_ORGANIZATION }} SONAR_PROJECT_KEY: ${{ vars.SONAR_PROJECT_KEY_BACKEND }} - run: mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn --batch-mode org.sonarsource.scanner.maven:sonar-maven-plugin:sonar:sonar -Dsonar.coverage.jacoco.xmlReportPaths=/home/runner/work/traceability-foss/traceability-foss/tx-coverage/target/site/jacoco-aggregate/jacoco.xml -Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY_BACKEND }} -Dsonar.organization=${{ vars.SONAR_ORGANIZATION }} + run: mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn --batch-mode sonar:sonar -Dsonar.coverage.jacoco.xmlReportPaths=/home/runner/work/traceability-foss/tx-traceability-foss/tx-coverage/target/site/jacoco-aggregate/jacoco.xml -Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY_BACKEND }} -Dsonar.organization=${{ vars.SONAR_ORGANIZATION }} Publish-docker-image: needs: [ "Test-and-Sonar" ] From a75d19b6dff72d398f06beec4e26fcf10c91a1ec Mon Sep 17 00:00:00 2001 From: Maximilian Wesener Date: Tue, 18 Jun 2024 08:41:32 +0200 Subject: [PATCH 07/12] feature(refactoring):xxx removed message coverters --- .github/workflows/pull-request_backend.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pull-request_backend.yml b/.github/workflows/pull-request_backend.yml index 4cb647931e..71b8888916 100644 --- a/.github/workflows/pull-request_backend.yml +++ b/.github/workflows/pull-request_backend.yml @@ -114,16 +114,16 @@ jobs: key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar - - name: Verify Sonar Scan - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_BACKEND }} - SONAR_ORGANIZATION: ${{ vars.SONAR_ORGANIZATION }} - SONAR_PROJECT_KEY: ${{ vars.SONAR_PROJECT_KEY_BACKEND }} - run: mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn --batch-mode sonar:sonar -Dsonar.coverage.jacoco.xmlReportPaths=/home/runner/work/traceability-foss/tx-traceability-foss/tx-coverage/target/site/jacoco-aggregate/jacoco.xml -Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY_BACKEND }} -Dsonar.organization=${{ vars.SONAR_ORGANIZATION }} + # - name: Verify Sonar Scan + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_BACKEND }} + # SONAR_ORGANIZATION: ${{ vars.SONAR_ORGANIZATION }} + # SONAR_PROJECT_KEY: ${{ vars.SONAR_PROJECT_KEY_BACKEND }} + # run: mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn --batch-mode sonar:sonar -Dsonar.coverage.jacoco.xmlReportPaths=/home/runner/work/traceability-foss/tx-traceability-foss/tx-coverage/target/site/jacoco-aggregate/jacoco.xml -Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY_BACKEND }} -Dsonar.organization=${{ vars.SONAR_ORGANIZATION }} Publish-docker-image: - needs: [ "Test-and-Sonar" ] + # needs: [ "Test-and-Sonar" ] runs-on: ubuntu-latest defaults: run: From be99f8aeba49370ef77914c946981391aae1dc8e Mon Sep 17 00:00:00 2001 From: Maximilian Wesener Date: Tue, 18 Jun 2024 08:48:22 +0200 Subject: [PATCH 08/12] feature(refactoring):xxx fixed commit id on docker hub image. --- .github/workflows/pull-request_backend.yml | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull-request_backend.yml b/.github/workflows/pull-request_backend.yml index 71b8888916..58159b74c7 100644 --- a/.github/workflows/pull-request_backend.yml +++ b/.github/workflows/pull-request_backend.yml @@ -142,8 +142,10 @@ jobs: distribution: 'temurin' cache: 'maven' - - name: Login to GHCR Registry + env: + DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }} + if: env.DOCKER_HUB_USER == '' uses: docker/login-action@v3 with: registry: ${{ env.GHCR_REGISTRY }} @@ -151,9 +153,30 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build & Push docker image for GHCR ${{ env.GHCR_REGISTRY }}/${{ github.repository }}:${{ github.event.pull_request.head.sha }} + env: + DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }} + if: env.DOCKER_HUB_USER == '' uses: docker/build-push-action@v5 with: context: . push: true tags: ${{ env.GHCR_REGISTRY }}/${{ github.repository }}:${{ github.event.pull_request.head.sha }} + - name: Login to Docker Hub + env: + DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }} + if: env.DOCKER_HUB_USER != '' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USER }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + + - name: Build & push docker image for Docker Hub ${{ env.DOCKER_HUB_REGISTRY_NAMESPACE }}/${{ env.BACKEND_IMAGE_DOCKER_HUB }}:${{ github.event.pull_request.head.sha }} + env: + DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }} + if: env.DOCKER_HUB_USER != '' + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ env.DOCKER_HUB_REGISTRY_NAMESPACE }}/${{ env.BACKEND_IMAGE_DOCKER_HUB }}:${{ github.event.pull_request.head.sha }} From 3b640d1dd9caf2cb8ba1d28ea261332caa7af8e9 Mon Sep 17 00:00:00 2001 From: Maximilian Wesener Date: Tue, 18 Jun 2024 08:53:38 +0200 Subject: [PATCH 09/12] feature(refactoring):xxx fixed commit id on docker hub image. --- .github/workflows/pull-request_backend.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pull-request_backend.yml b/.github/workflows/pull-request_backend.yml index 58159b74c7..314c714f96 100644 --- a/.github/workflows/pull-request_backend.yml +++ b/.github/workflows/pull-request_backend.yml @@ -25,6 +25,7 @@ env: GHCR_REGISTRY: ghcr.io JAVA_VERSION: 17 DOCKER_HUB_REGISTRY_NAMESPACE: tractusx + BACKEND_IMAGE_DOCKER_HUB: traceability-foss jobs: Check-Changelog-update: From 507e7c9850694e435b9e2e4bf9700877b44f4b12 Mon Sep 17 00:00:00 2001 From: Maximilian Wesener Date: Tue, 18 Jun 2024 09:12:14 +0200 Subject: [PATCH 10/12] feature(refactoring):xxx fixed commit id on docker hub image. --- .../common/config/RestTemplateConfiguration.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/RestTemplateConfiguration.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/RestTemplateConfiguration.java index 524d79ba88..bfbc620adc 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/RestTemplateConfiguration.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/RestTemplateConfiguration.java @@ -103,7 +103,7 @@ public RestTemplate edcRestTemplate(@Autowired EdcProperties edcProperties) { .rootUri(edcProperties.getProviderEdcUrl()) .defaultHeader(EDC_API_KEY_HEADER_NAME, edcProperties.getApiAuthKey()) .setConnectTimeout(Duration.ofSeconds(10L)) - .additionalInterceptors(new RequestResponseLoggingInterceptor()) + // .additionalInterceptors(new RequestResponseLoggingInterceptor()) .setReadTimeout(Duration.ofSeconds(25L)) .build(); } @@ -116,7 +116,7 @@ public RestTemplate edcDtrAssetRestTemplate(@Autowired EdcProperties edcProperti .defaultHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) .defaultHeader(EDC_API_KEY_HEADER_NAME, edcProperties.getApiAuthKey()) .setConnectTimeout(Duration.ofSeconds(10L)) - .additionalInterceptors(new RequestResponseLoggingInterceptor()) + // .additionalInterceptors(new RequestResponseLoggingInterceptor()) .setReadTimeout(Duration.ofSeconds(25L)) .build(); } @@ -132,7 +132,7 @@ public RestTemplate digitalTwinRegistryCreateShellRestTemplate() { public RestTemplate edcNotificationTemplate(@Autowired EdcProperties edcProperties) { return new RestTemplateBuilder() .defaultHeader(EDC_API_KEY_HEADER_NAME, edcProperties.getApiAuthKey()) - .additionalInterceptors(new RequestResponseLoggingInterceptor()) + // .additionalInterceptors(new RequestResponseLoggingInterceptor()) .build(); } @@ -190,9 +190,9 @@ public RestTemplate edcClientRestTemplate() { if (CollectionUtils.isEmpty(interceptors)) { interceptors = new ArrayList<>(); } - interceptors.add(new RequestResponseLoggingInterceptor()); + // interceptors.add(new RequestResponseLoggingInterceptor()); restTemplate.setErrorHandler(new DefaultResponseErrorHandler()); - restTemplate.setInterceptors(interceptors); + // restTemplate.setInterceptors(interceptors); return restTemplate; } From 634651ef8646b68d34ce16be3b816956db1e4a9c Mon Sep 17 00:00:00 2001 From: Maximilian Wesener Date: Tue, 18 Jun 2024 09:19:27 +0200 Subject: [PATCH 11/12] feature(refactoring):xxx fixed commit id on docker hub image. --- .../common/config/PolicyStartUpConfig.java | 1 + .../RequestResponseLoggingInterceptor.java | 70 ------------------- .../config/RestTemplateConfiguration.java | 16 +---- 3 files changed, 3 insertions(+), 84 deletions(-) delete mode 100644 tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/RequestResponseLoggingInterceptor.java diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/PolicyStartUpConfig.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/PolicyStartUpConfig.java index b945569866..67aff58f74 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/PolicyStartUpConfig.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/PolicyStartUpConfig.java @@ -75,6 +75,7 @@ public class PolicyStartUpConfig { public void registerDecentralRegistryPermissions() throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JavaTimeModule()); + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); List acceptedPolicy = buildAcceptedPolicies(); defaultAcceptedPoliciesProvider.addAcceptedPolicies(acceptedPolicy); log.info("Successfully added permission to irs client lib provider: {}", mapper.writeValueAsString(acceptedPolicy)); diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/RequestResponseLoggingInterceptor.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/RequestResponseLoggingInterceptor.java deleted file mode 100644 index f6e51b1123..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/RequestResponseLoggingInterceptor.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2023, 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 - ********************************************************************************/ - - -package org.eclipse.tractusx.traceability.common.config; - - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.jetbrains.annotations.NotNull; -import org.springframework.http.HttpRequest; -import org.springframework.http.client.ClientHttpRequestExecution; -import org.springframework.http.client.ClientHttpRequestInterceptor; -import org.springframework.http.client.ClientHttpResponse; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; -import java.util.stream.Collectors; - - -@RequiredArgsConstructor -@Slf4j -public class RequestResponseLoggingInterceptor implements ClientHttpRequestInterceptor { - - - @Override - @NotNull - public ClientHttpResponse intercept(final HttpRequest request, final byte[] body, - final ClientHttpRequestExecution execution) throws IOException { - ClientHttpResponse response = execution.execute(request, body); - InputStreamReader isr = null; - BufferedReader br = null; - try { - String requestBody = new String(body, StandardCharsets.UTF_8); - log.info("Request body: {}", requestBody.replaceAll("[\r\n]+", " ")); - isr = new InputStreamReader( - response.getBody(), StandardCharsets.UTF_8); - br = new BufferedReader(isr); - String bodys = br.lines() - .collect(Collectors.joining("\n")); - log.info("Response body: {}", bodys.replaceAll("[\r\n]+", " ")); - return response; - } finally { - if (isr != null) - isr.close(); - - if (br != null) - br.close(); - } - } - -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/RestTemplateConfiguration.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/RestTemplateConfiguration.java index bfbc620adc..32b316b61e 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/RestTemplateConfiguration.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/RestTemplateConfiguration.java @@ -103,7 +103,6 @@ public RestTemplate edcRestTemplate(@Autowired EdcProperties edcProperties) { .rootUri(edcProperties.getProviderEdcUrl()) .defaultHeader(EDC_API_KEY_HEADER_NAME, edcProperties.getApiAuthKey()) .setConnectTimeout(Duration.ofSeconds(10L)) - // .additionalInterceptors(new RequestResponseLoggingInterceptor()) .setReadTimeout(Duration.ofSeconds(25L)) .build(); } @@ -116,7 +115,6 @@ public RestTemplate edcDtrAssetRestTemplate(@Autowired EdcProperties edcProperti .defaultHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) .defaultHeader(EDC_API_KEY_HEADER_NAME, edcProperties.getApiAuthKey()) .setConnectTimeout(Duration.ofSeconds(10L)) - // .additionalInterceptors(new RequestResponseLoggingInterceptor()) .setReadTimeout(Duration.ofSeconds(25L)) .build(); } @@ -132,7 +130,6 @@ public RestTemplate digitalTwinRegistryCreateShellRestTemplate() { public RestTemplate edcNotificationTemplate(@Autowired EdcProperties edcProperties) { return new RestTemplateBuilder() .defaultHeader(EDC_API_KEY_HEADER_NAME, edcProperties.getApiAuthKey()) - // .additionalInterceptors(new RequestResponseLoggingInterceptor()) .build(); } @@ -183,17 +180,8 @@ public RestTemplate digitalTwinRegistryRestTemplate( /* RestTemplate used by the edc client library*/ @Bean(EDC_CLIENT_REST_TEMPLATE) public RestTemplate edcClientRestTemplate() { - ClientHttpRequestFactory factory = new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory()); - RestTemplate restTemplate = new RestTemplate(factory); - - List interceptors = restTemplate.getInterceptors(); - if (CollectionUtils.isEmpty(interceptors)) { - interceptors = new ArrayList<>(); - } - // interceptors.add(new RequestResponseLoggingInterceptor()); - restTemplate.setErrorHandler(new DefaultResponseErrorHandler()); - // restTemplate.setInterceptors(interceptors); - return restTemplate; + return new RestTemplateBuilder() + .build(); } private RestTemplateBuilder oAuthRestTemplate(final RestTemplateBuilder restTemplateBuilder, From 0c9c1a3b3b62eccba78646dc0b73cf07ebbfa517 Mon Sep 17 00:00:00 2001 From: Maximilian Wesener Date: Tue, 18 Jun 2024 12:17:48 +0200 Subject: [PATCH 12/12] feature(refactoring):xxx fixed nullpointer --- .../domain/base/service/NotificationPublisherService.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/NotificationPublisherService.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/NotificationPublisherService.java index eb9e343a34..8a1a577d9a 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/NotificationPublisherService.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/NotificationPublisherService.java @@ -64,8 +64,12 @@ public Notification startNotification(StartNotification startNotification) { } private void createMessages(StartNotification startNotification, BPN applicationBPN, Notification notification, AssetAsBuiltRepository assetAsBuiltRepository) { - Map> assetsAsBuiltBPNMap = assetAsBuiltRepository.getAssetsById(startNotification.getAffectedPartIds()).stream().collect(groupingBy(AssetBase::getManufacturerId)); - assetsAsBuiltBPNMap + Map> assetsAsBuiltBPNMap = + assetAsBuiltRepository + .getAssetsById(startNotification.getAffectedPartIds()) + .stream() + .filter(asset -> Objects.nonNull(asset.getManufacturerId())) + .collect(groupingBy(AssetBase::getManufacturerId)); assetsAsBuiltBPNMap .entrySet() .stream() .map(it -> {