From 74495fe3a344b5929be3766a5fd533701203b1ce Mon Sep 17 00:00:00 2001 From: "Krzysztof Massalski (Extern)" Date: Wed, 1 May 2024 09:55:24 +0200 Subject: [PATCH 1/2] feat(impl):[#568] remove bpdm lookup --- .../configmap-spring-app-config.yaml | 9 - .../templates/deployment.yaml | 10 - .../templates/secrets.yaml | 2 - charts/item-relationship-service/values.yaml | 10 - docs/src/api/irs-api.yaml | 4 +- .../docs/administration/configuration.adoc | 9 - .../building-block-view/whitebox-overall.adoc | 20 +- .../arc42/cross-cutting/under-the-hood.adoc | 4 - docs/src/docs/security/security-assessment.md | 2 - .../whitebox_overall_decentral.puml | 21 +- .../irs/aaswrapper/job/RequestMetric.java | 1 - .../aaswrapper/job/delegate/BpdmDelegate.java | 117 ----------- .../BpdmDelegateProcessingException.java | 39 ---- .../eclipse/tractusx/irs/bpdm/BpdmClient.java | 120 ----------- .../eclipse/tractusx/irs/bpdm/BpdmFacade.java | 72 ------- .../irs/bpdm/BusinessPartnerResponse.java | 43 ---- .../tractusx/irs/bpdm/NameResponse.java | 40 ---- .../irs/configuration/JobConfiguration.java | 11 +- .../irs/configuration/RestTemplateConfig.java | 9 - .../services/IrsItemGraphQueryService.java | 47 +---- irs-api/src/main/resources/application.yml | 13 -- .../tractusx/irs/IrsFunctionalTest.java | 61 +----- .../irs/IrsWireMockIntegrationTest.java | 8 - .../tractusx/irs/WireMockTestConfig.java | 8 - .../job/delegate/BpdmDelegateTest.java | 195 ------------------ .../tractusx/irs/bpdm/BpdmClientImplTest.java | 55 ----- .../tractusx/irs/bpdm/BpdmFacadeTest.java | 46 ----- .../irs/bpdm/BpdmWireMockSupport.java | 110 ---------- .../tractusx/irs/bpdm/BpdmWiremockTest.java | 75 ------- .../IrsItemGraphQueryServiceTest.java | 8 - .../eclipse/tractusx/irs/util/TestMother.java | 5 - .../test/resources/__files/jobResponse.json | 10 - .../irs/component/RegisterBatchOrder.java | 2 +- .../tractusx/irs/component/RegisterJob.java | 2 +- .../irs/component/enums/ProcessStep.java | 2 - .../DigitalTwinRegistryClientImpl.java | 10 +- local/deployment/irs-local/README.md | 2 +- local/deployment/irs-local/values.yaml | 2 - .../api-tests/irs-api-tests.tavern.yaml | 16 +- local/testing/api-tests/tavern_helpers.py | 4 +- 40 files changed, 50 insertions(+), 1174 deletions(-) delete mode 100644 irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/BpdmDelegate.java delete mode 100644 irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/BpdmDelegateProcessingException.java delete mode 100644 irs-api/src/main/java/org/eclipse/tractusx/irs/bpdm/BpdmClient.java delete mode 100644 irs-api/src/main/java/org/eclipse/tractusx/irs/bpdm/BpdmFacade.java delete mode 100644 irs-api/src/main/java/org/eclipse/tractusx/irs/bpdm/BusinessPartnerResponse.java delete mode 100644 irs-api/src/main/java/org/eclipse/tractusx/irs/bpdm/NameResponse.java delete mode 100644 irs-api/src/test/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/BpdmDelegateTest.java delete mode 100644 irs-api/src/test/java/org/eclipse/tractusx/irs/bpdm/BpdmClientImplTest.java delete mode 100644 irs-api/src/test/java/org/eclipse/tractusx/irs/bpdm/BpdmFacadeTest.java delete mode 100644 irs-api/src/test/java/org/eclipse/tractusx/irs/bpdm/BpdmWireMockSupport.java delete mode 100644 irs-api/src/test/java/org/eclipse/tractusx/irs/bpdm/BpdmWiremockTest.java diff --git a/charts/item-relationship-service/templates/configmap-spring-app-config.yaml b/charts/item-relationship-service/templates/configmap-spring-app-config.yaml index 32bd73b6ec..3b20ef49e3 100644 --- a/charts/item-relationship-service/templates/configmap-spring-app-config.yaml +++ b/charts/item-relationship-service/templates/configmap-spring-app-config.yaml @@ -62,16 +62,11 @@ data: discovery: client-id: ${DISCOVERY_OAUTH2_CLIENT_ID} # taken from secret ENV client-secret: ${DISCOVERY_OAUTH2_CLIENT_SECRET} # taken from secret ENV - bpdm: - client-id: ${BPDM_OAUTH2_CLIENT_ID} # taken from secret ENV - client-secret: ${BPDM_OAUTH2_CLIENT_SECRET} # taken from secret ENV provider: semantics: token-uri: {{ tpl (.Values.oauth2.clientTokenUri | default "http://localhost") . | quote }} discovery: token-uri: {{ tpl (.Values.oauth2.clientTokenUri | default "http://localhost") . | quote }} - bpdm: - token-uri: {{ tpl (.Values.oauth2.clientTokenUri | default "http://localhost") . | quote }} digitalTwinRegistry: descriptorEndpoint: {{ tpl (.Values.digitalTwinRegistry.descriptorEndpoint | default "") . | quote }} @@ -94,10 +89,6 @@ data: localModelDirectory: /app/semantic-models {{- end }} - bpdm: - oAuthClientId: {{ .Values.bpdm.oAuthClientId | default "bpdm" }} - bpnEndpoint: {{ tpl (.Values.bpdm.bpnEndpoint | default "") . | quote }} - irs-edc-client: callback: mapping: {{ .Values.edc.callbackMapping | default "/internal/endpoint-data-reference" | quote }} diff --git a/charts/item-relationship-service/templates/deployment.yaml b/charts/item-relationship-service/templates/deployment.yaml index e30f10c7e8..f766400710 100644 --- a/charts/item-relationship-service/templates/deployment.yaml +++ b/charts/item-relationship-service/templates/deployment.yaml @@ -101,16 +101,6 @@ spec: secretKeyRef: name: {{ template "irs.secretName" . }} key: discoveryClientSecret - - name: BPDM_OAUTH2_CLIENT_ID - valueFrom: - secretKeyRef: - name: {{ template "irs.secretName" . }} - key: bpdmClientId - - name: BPDM_OAUTH2_CLIENT_SECRET - valueFrom: - secretKeyRef: - name: {{ template "irs.secretName" . }} - key: bpdmClientSecret - name: EDC_API_KEY_SECRET valueFrom: secretKeyRef: diff --git a/charts/item-relationship-service/templates/secrets.yaml b/charts/item-relationship-service/templates/secrets.yaml index d9488ae665..4434287573 100644 --- a/charts/item-relationship-service/templates/secrets.yaml +++ b/charts/item-relationship-service/templates/secrets.yaml @@ -39,8 +39,6 @@ data: semanticsSecret: {{ .Values.oauth2.semantics.clientSecret | default "semanticsSecret" | b64enc | quote }} discoveryClientId: {{ .Values.oauth2.discovery.clientId | default "discoveryClientId" | b64enc | quote }} discoveryClientSecret: {{ .Values.oauth2.discovery.clientSecret | default "discoveryClientSecret" | b64enc | quote }} - bpdmClientId: {{ .Values.oauth2.bpdm.clientId | default "bpdmClientId" | b64enc | quote }} - bpdmClientSecret: {{ .Values.oauth2.bpdm.clientSecret | default "bpdmClientSecret" | b64enc | quote }} edcApiSecret: {{ .Values.edc.controlplane.apikey.secret | toString | default "" | b64enc | quote }} {{- if .Values.grafana.enabled }} grafanaUser: {{ .Values.grafana.user | default "grafana" | b64enc | quote }} diff --git a/charts/item-relationship-service/values.yaml b/charts/item-relationship-service/values.yaml index 2f60e73eb3..6a8ad59602 100644 --- a/charts/item-relationship-service/values.yaml +++ b/charts/item-relationship-service/values.yaml @@ -148,13 +148,6 @@ semanticshub: # Map of Base64 encoded strings of semantic models. The key must be the Base64 encoded full URN of the model. # Example for urn:bamm:io.catenax.serial_part:1.0.0#SerialPart: # dXJuOmJhbW06aW8uY2F0ZW5heC5zZXJpYWxfcGFydDoxLjAuMCNTZXJpYWxQYXJ0: ewoJIiRzY2hlbWEiOiAiaHR0cDovL2pzb24tc2NoZW1hLm9yZy9kcmFmdC0wNC9zY2hlbWEiLAoJImRlc2NyaXB0aW9uIjogIkEgc2VyaWFsaXplZCBwYXJ0IGlzIGFuIGluc3RhbnRpYXRpb24gb2YgYSAoZGVzaWduLSkgcGFydCwgd2hlcmUgdGhlIHBhcnRpY3VsYXIgaW5zdGFudGlhdGlvbiBjYW4gYmUgdW5pcXVlbHkgaWRlbnRpZmllZCBieSBtZWFucyBvZiBhIHNlcmlhbCBudW1iZXIgb3IgYSBzaW1pbGFyIGlkZW50aWZpZXIgKGUuZy4gVkFOKSBvciBhIGNvbWJpbmF0aW9uIG9mIG11bHRpcGxlIGlkZW50aWZpZXJzIChlLmcuIGNvbWJpbmF0aW9uIG9mIG1hbnVmYWN0dXJlciwgZGF0ZSBhbmQgbnVtYmVyKSIsCgkidHlwZSI6ICJvYmplY3QiLAoJImNvbXBvbmVudHMiOiB7CgkJInNjaGVtY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ybWF0aW9uIjogewoJCQkiZGVzY3JpcHRpb24iOiAiVGhlIHBhcnQgdHlwZSBmcm9tIHdoaWNoIHRoZSBzZXJpYWxpemVkIHBhcnQgaGFzIGJlZW4gaW5zdGFudGlhdGVkIiwKCQkJIiRyZWYiOiAiIy9jb21wb25lbnRzL3NjaGVtYXMvdXJuX2JhbW1faW8uY2F0ZW5heC5zZXJpYWxfcGFydF8xLjAuMF9QYXJ0VHlwZUluZm9ybWF0aW9uQ2hhcmFjdGVyaXN0aWMiCgkJfQoJfSwKCSJyZXF1aXJlZCI6IFsKCQkiY2F0ZW5hWElkIiwKCQkibG9jYWxJZGVudGlmaWVycyIsCgkJIm1hbnVmYWN0dXJpbmdJbmZvcm1hdGlvbiIsCgkJInBhcnRUeXBlSW5mb3JtYXRpb24iCgldCn0= -bpdm: - url: # https:// - oAuthClientId: bpdm - bpnEndpoint: >- - {{- if .Values.bpdm.url }} - {{- tpl (.Values.bpdm.url | default "") . }}/api/catena/legal-entities/{partnerId}?idType={idType} - {{- end }} minioUser: "minio" # minioPassword: # minioUrl: "http://{{ .Release.Name }}-minio:9000" @@ -166,9 +159,6 @@ oauth2: discovery: clientId: # clientSecret: # - bpdm: - clientId: # - clientSecret: # edc: controlplane: endpoint: diff --git a/docs/src/api/irs-api.yaml b/docs/src/api/irs-api.yaml index 52094f769b..99d729841f 100644 --- a/docs/src/api/irs-api.yaml +++ b/docs/src/api/irs-api.yaml @@ -2344,8 +2344,6 @@ components: - DigitalTwinRequest - SchemaValidation - SchemaRequest - - BpdmRequest - - BpdmValidation - UsagePolicyValidation - EssValidation retryCounter: @@ -2481,6 +2479,7 @@ components: maxItems: 2147483647 lookupBPNs: type: boolean + deprecated: true description: Flag to specify whether BPNs should be collected and resolved via the configured BPDM URL. Default is false. timeout: @@ -2646,6 +2645,7 @@ components: $ref: '#/components/schemas/PartChainIdentificationKey' lookupBPNs: type: boolean + deprecated: true description: Flag to specify whether BPNs should be collected and resolved via the configured BPDM URL. Default is false. required: diff --git a/docs/src/docs/administration/configuration.adoc b/docs/src/docs/administration/configuration.adoc index 6607b75911..5921895f1f 100644 --- a/docs/src/docs/administration/configuration.adoc +++ b/docs/src/docs/administration/configuration.adoc @@ -64,9 +64,6 @@ The URL of the Discovery Finder. The IRS uses this service to discover EDC to a ==== The URL of the SemanticsHub. The IRS uses this service to fetch aspect schemas for payload validation. -==== -The URL of the BPDM service. The IRS uses this service to fetch business partner information based on BPNs. - ==== The URL of the OAuth2 token API. Used by the IRS for token creation to authenticate with other services. @@ -168,12 +165,6 @@ Dataspace Discovery client ID for OAuth2 provider. Request this from your OAuth === Dataspace Discovery client secret for OAuth2 provider. Request this from your OAuth2 operator. -=== -BPDM client ID for OAuth2 provider. Request this from your OAuth2 operator. - -=== -BPDM client secret for OAuth2 provider. Request this from your OAuth2 operator. - === Login username for Minio. To be defined by you. diff --git a/docs/src/docs/arc42/building-block-view/whitebox-overall.adoc b/docs/src/docs/arc42/building-block-view/whitebox-overall.adoc index 847049863b..17058ee455 100644 --- a/docs/src/docs/arc42/building-block-view/whitebox-overall.adoc +++ b/docs/src/docs/arc42/building-block-view/whitebox-overall.adoc @@ -43,9 +43,6 @@ include::../../../uml-diagrams/building-block-view/whitebox_overall_decentral.pu |Semantic Hub |Semantic Hub provides information about semantic models in a specific version. This also includes JSON schemas, which IRS uses to validate the payload received by data providers. - -|BPDM -|The Business Partner Data Management (BPDM) Service is used by the IRS to access shared business partner data for BPNs of Data Providers along the supply chain. |=== @@ -83,30 +80,27 @@ include::../../../uml-diagrams/building-block-view/whitebox_overall_decentral.pu | IRS uses *Semantic Hub* to validate of *SubmodelAspects* payloads agains the schema provided in *Semantic Hub* | 11 -| In case "lookupBPNs" is active IRS provides a lookup of company for given BPN - -| 12 | *EDC* is connected to *Managed Identity Wallet* for access policy check for data offers -| 13 +| 12 | *EDC* communication covering negotiation and data consumption -| 14 +| 13 | *EDC* is connected to *Managed Identity Wallet* for access policy check for data offers -| 15 +| 14 | *IRS* accessing to *SubmodelServer* on Tier Level using the *EDC* -| 16 +| 15 | *IRS* accessing the *decentral DigitalTwinRegistry* on Tier Level using the *EDC* -| 17 +| 16 | In case of the use-case Environmental and Social Standards, *IRS* sends notifications to the *IRS-ESS* instance running at the data provider using the *EDC*. -| 18 +| 17 | *IRS* uses the Policy Store to load the usage policies stored for BPNLs in order to check the usage policies during the consumption of the data assets. -| 19 +| 18 | IrsApiConsumer calls the IRS public /policy *API* |=== diff --git a/docs/src/docs/arc42/cross-cutting/under-the-hood.adoc b/docs/src/docs/arc42/cross-cutting/under-the-hood.adoc index 38419e28cc..ac7328c6bb 100644 --- a/docs/src/docs/arc42/cross-cutting/under-the-hood.adoc +++ b/docs/src/docs/arc42/cross-cutting/under-the-hood.adoc @@ -121,10 +121,6 @@ The IRS caches data provided externally to avoid unnecessary requests and reduce Caching is implemented for the following services: -=== BPDM - -Whenever a BPN is resolved via BPDM, the partner name is cached on IRS side, as this data does not change. - === Semantics Hub Whenever a semantic model schema is requested from the Semantic Hub, it is stored locally until the cache is evicted (configurable). diff --git a/docs/src/docs/security/security-assessment.md b/docs/src/docs/security/security-assessment.md index cd83d1f730..59dbe0fb30 100644 --- a/docs/src/docs/security/security-assessment.md +++ b/docs/src/docs/security/security-assessment.md @@ -14,7 +14,6 @@ System_Ext(EDC-DS, "EDC Discovery Service") System_Ext(DF, "Discovery Finder") System_Ext(DTR, "Digital Twin Registry") System_Ext(OAuth2, "OAuth2") -System_Ext(BPDM, "BPDM") System_Ext(SH, "Semantic Hub") System_Ext(V, "Vault") @@ -47,7 +46,6 @@ Rel(IRS-App, EDC-DS, "Find decentral DTs, https, access token") Rel(IRS-App, DF, "Get EDC Discovery Service URL, https, access token") Rel(IRS-App, DTR, "https, access token") Rel(IRS-App, OAuth2, "https, clientID, clientSecret, Get tokens to access DTR") -Rel(IRS-App, BPDM, "https, access token, Get BPN") Rel(IRS-App, SH, "Get schemas to validate response from EDC, https, access token") Rel(DAPS, EDC, "") diff --git a/docs/src/uml-diagrams/building-block-view/whitebox_overall_decentral.puml b/docs/src/uml-diagrams/building-block-view/whitebox_overall_decentral.puml index 353914a6c2..c3b763ffd9 100644 --- a/docs/src/uml-diagrams/building-block-view/whitebox_overall_decentral.puml +++ b/docs/src/uml-diagrams/building-block-view/whitebox_overall_decentral.puml @@ -33,7 +33,6 @@ package [**CatenaX-Network**] as network { component [**EDC Discovery Service**] <> as edc_discovery component [**Discovery Finder**] <> as discovery_finder component [**Semantic Hub**] <> as semantic_hub - component [**BPDM**] <> as bpdm } package [**N-Tier**] <> as provider { @@ -59,22 +58,20 @@ IRS <..> edc_discovery : **[08]** IRS <..> discovery_finder : **[09]** IRS <..> semantic_hub : **[10]** -IRS <..> bpdm : **[11]** -EDC <..> miw : **[12]** -EDC <..> EDCProvider : **[13]** -EDC <..> EDCProviderOEM : **[13]** +EDC <..> miw : **[11]** +EDC <..> EDCProvider : **[12]** +EDC <..> EDCProviderOEM : **[12]** -miw <..> EDCProvider : **[14]** -EDCProvider <--> SubmodelServer : **[15]** -EDCProvider <--> DT_REG : **[16]** -EDCProvider <-> EssProvider : **[17]** +miw <..> EDCProvider : **[13]** +EDCProvider <--> SubmodelServer : **[14]** +EDCProvider <--> DT_REG : **[15]** +EDCProvider <-> EssProvider : **[16]** -IRS <...> policy_store : **[18]** -IrsApiConsumer -r(0- policy_store : **[19]** +IRS <...> policy_store : **[17]** +IrsApiConsumer -r(0- policy_store : **[18]** miw -[hidden]d- IAM_IRS miw -[hidden]r- discovery_finder discovery_finder -[hidden]d- edc_discovery -bpdm -[hidden]d- semantic_hub @enduml \ No newline at end of file diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/RequestMetric.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/RequestMetric.java index e67439b46a..86750f73b1 100644 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/RequestMetric.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/RequestMetric.java @@ -72,7 +72,6 @@ public void incrementFailed() { * Type of tracked request. Can be used to filter for the different metrics. */ public enum RequestType { - BPDM, DITIGAL_TWIN, RELATIONSHIP, SUBMODEL diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/BpdmDelegate.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/BpdmDelegate.java deleted file mode 100644 index 2817ad9157..0000000000 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/BpdmDelegate.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022,2024 - * 2022: ZF Friedrichshafen AG - * 2022: ISTOS GmbH - * 2022,2024: Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * 2022,2023: BOSCH AG - * Copyright (c) 2021,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.irs.aaswrapper.job.delegate; - -import java.util.function.Consumer; -import java.util.regex.Pattern; - -import lombok.extern.slf4j.Slf4j; -import org.eclipse.tractusx.irs.aaswrapper.job.AASTransferProcess; -import org.eclipse.tractusx.irs.aaswrapper.job.ItemContainer; -import org.eclipse.tractusx.irs.aaswrapper.job.RequestMetric; -import org.eclipse.tractusx.irs.bpdm.BpdmFacade; -import org.eclipse.tractusx.irs.component.Bpn; -import org.eclipse.tractusx.irs.component.JobParameter; -import org.eclipse.tractusx.irs.component.PartChainIdentificationKey; -import org.eclipse.tractusx.irs.component.Tombstone; -import org.eclipse.tractusx.irs.component.enums.ProcessStep; -import org.springframework.web.client.RestClientException; - -/** - * Builds bpns array for AAShell from previous steps. - * To build bpns Business Partner service is called. - */ -@Slf4j -public class BpdmDelegate extends AbstractDelegate { - - private static final Pattern BPN_RGX = Pattern.compile("(BPN)[LSA][\\w\\d]{10}[\\w\\d]{2}"); - - private final BpdmFacade bpdmFacade; - - public BpdmDelegate(final AbstractDelegate nextStep, final BpdmFacade bpdmFacade) { - super(nextStep); - this.bpdmFacade = bpdmFacade; - } - - @Override - public ItemContainer process(final ItemContainer.ItemContainerBuilder itemContainerBuilder, - final JobParameter jobData, final AASTransferProcess aasTransferProcess, - final PartChainIdentificationKey itemId) { - - if (jobData.isLookupBPNs()) { - log.debug("BPN Lookup enabled, collecting BPN information"); - - final RequestMetric requestMetric = new RequestMetric(); - requestMetric.setType(RequestMetric.RequestType.BPDM); - itemContainerBuilder.metric(requestMetric); - - try { - itemContainerBuilder.build() - .getBpns() - .forEach(bpn -> lookupBPN(itemContainerBuilder, itemId.getGlobalAssetId(), bpn, - requestMetric)); - } catch (final RestClientException e) { - log.info("Business Partner endpoint could not be retrieved for Item: {}. Creating Tombstone.", itemId); - requestMetric.incrementFailed(); - itemContainerBuilder.tombstone( - Tombstone.from(itemId.getGlobalAssetId(), null, e, retryCount, ProcessStep.BPDM_REQUEST)); - } - } else { - log.debug("BPN lookup disabled, no BPN information will be collected."); - } - - return next(itemContainerBuilder, jobData, aasTransferProcess, itemId); - } - - private void lookupBPN(final ItemContainer.ItemContainerBuilder itemContainerBuilder, final String itemId, - final Bpn bpn, final RequestMetric metric) { - - final Consumer action = name -> { - if (BPN_RGX.matcher(bpn.getManufacturerId() + bpn.getManufacturerName()).find()) { - bpn.updateManufacturerName(name); - metric.incrementCompleted(); - } else { - final String message = String.format("BPN: \"%s\" for CatenaXId: %s is not valid.", - bpn.getManufacturerId() + bpn.getManufacturerName(), itemId); - log.warn(message); - metric.incrementFailed(); - itemContainerBuilder.tombstone( - Tombstone.from(itemId, null, new BpdmDelegateProcessingException(message), 0, - ProcessStep.BPDM_VALIDATION)); - } - }; - - final Runnable fallbackOnEmptyManufacturedId = () -> { - final String message = String.format("BPN not exist for given ManufacturerId: %s and for CatenaXId: %s.", - bpn.getManufacturerId(), itemId); - log.warn(message); - metric.incrementFailed(); - itemContainerBuilder.tombstone(Tombstone.from(itemId, null, new BpdmDelegateProcessingException(message), 0, - ProcessStep.BPDM_REQUEST)); - }; - - bpdmFacade.findManufacturerName(bpn.getManufacturerId()).ifPresentOrElse(action, fallbackOnEmptyManufacturedId); - } - -} diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/BpdmDelegateProcessingException.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/BpdmDelegateProcessingException.java deleted file mode 100644 index 5021dd6759..0000000000 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/BpdmDelegateProcessingException.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022,2024 - * 2022: ZF Friedrichshafen AG - * 2022: ISTOS GmbH - * 2022,2024: Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * 2022,2023: BOSCH AG - * Copyright (c) 2021,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.irs.aaswrapper.job.delegate; - -/** - * Bpdm Delegate processing exception. - */ -public class BpdmDelegateProcessingException extends RuntimeException { - - /** - * Generate a new instance of a {@link BpdmDelegateProcessingException} - * - * @param message Exception message. - */ - public BpdmDelegateProcessingException(final String message) { - super(message); - } -} diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/bpdm/BpdmClient.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/bpdm/BpdmClient.java deleted file mode 100644 index 1b7423b604..0000000000 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/bpdm/BpdmClient.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022,2024 - * 2022: ZF Friedrichshafen AG - * 2022: ISTOS GmbH - * 2022,2024: Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * 2022,2023: BOSCH AG - * Copyright (c) 2021,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.irs.bpdm; - -import static org.eclipse.tractusx.irs.configuration.RestTemplateConfig.BPDM_REST_TEMPLATE; - -import java.util.Collections; -import java.util.Map; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Profile; -import org.springframework.stereotype.Service; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponentsBuilder; - -/** - * Business Partner Data Management Rest Client - */ -interface BpdmClient { - - /** - * Find a business partner by the specified identifier. - * - * @param idValue identifier value - * @param idType type of identifier - * @return - */ - BusinessPartnerResponse getBusinessPartner(String idValue, String idType); - -} - -/** - * Business Partner Data Management Rest Client Stub used in local environment - */ -@Service -@Profile({ "local", - "test" -}) -class BpdmClientLocalStub implements BpdmClient { - - @Override - public BusinessPartnerResponse getBusinessPartner(final String idValue, final String idType) { - return BusinessPartnerResponse.builder() - .bpn(idValue) - .names(Collections.singletonList(NameResponse.of("OEM A"))) - .build(); - } -} - -/** - * Business Partner Data Management Rest Client Implementation - */ -@Service -@Profile({ "!local && !test" }) -class BpdmClientImpl implements BpdmClient { - - private static final String PLACEHOLDER_BPID = "partnerId"; - private static final String PLACEHOLDER_ID_TYPE = "idType"; - - private final RestTemplate restTemplate; - private final String bpdmUrl; - - /* package */ BpdmClientImpl(@Qualifier(BPDM_REST_TEMPLATE) final RestTemplate restTemplate, - @Value("${bpdm.bpnEndpoint:}") final String bpdmUrl) { - this.restTemplate = restTemplate; - this.bpdmUrl = bpdmUrl; - - if (StringUtils.isNotBlank(bpdmUrl)) { - ensureUrlContainsPlaceholders(bpdmUrl); - } - } - - private void ensureUrlContainsPlaceholders(final String bpdmUrl) { - require(bpdmUrl, PLACEHOLDER_ID_TYPE); - require(bpdmUrl, PLACEHOLDER_BPID); - } - - private static void require(final String bpdmUrl, final String placeholder) { - if (!bpdmUrl.contains(wrap(placeholder))) { - throw new IllegalStateException( - "Configuration value for 'bpdm.bpnEndpoint' must contain the URL placeholder '" + placeholder - + "'!"); - } - } - - private static String wrap(final String placeholderIdType) { - return "{" + placeholderIdType + "}"; - } - - @Override - public BusinessPartnerResponse getBusinessPartner(final String idValue, final String idType) { - final UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromUriString(bpdmUrl); - final Map values = Map.of(PLACEHOLDER_BPID, idValue, PLACEHOLDER_ID_TYPE, idType); - - return restTemplate.getForObject(uriBuilder.build(values), BusinessPartnerResponse.class); - } -} diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/bpdm/BpdmFacade.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/bpdm/BpdmFacade.java deleted file mode 100644 index 34da82c843..0000000000 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/bpdm/BpdmFacade.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022,2024 - * 2022: ZF Friedrichshafen AG - * 2022: ISTOS GmbH - * 2022,2024: Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * 2022,2023: BOSCH AG - * Copyright (c) 2021,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.irs.bpdm; - -import java.util.List; -import java.util.Optional; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.stereotype.Service; -import org.springframework.web.client.RestClientException; - -/** - * Public API Facade for bpdm domain - */ -@Service -@RequiredArgsConstructor -@Slf4j -public class BpdmFacade { - - private static final String BPDM_CACHE_NAME = "bpdm_cache"; - private static final String BPN_TYPE = "BPN"; - - private final BpdmClient bpdmClient; - - @Cacheable(value = BPDM_CACHE_NAME, key = "#manufacturerId") - public Optional findManufacturerName(final String manufacturerId) { - - final List names; - try { - final BusinessPartnerResponse businessPartner = bpdmClient.getBusinessPartner(manufacturerId, BPN_TYPE); - names = businessPartner.getNames(); - } catch (final RestClientException e) { - log.warn(e.getMessage(), e); - return Optional.empty(); - } - - if (names.isEmpty()) { - log.warn("Names not found for {} BPN", manufacturerId); - return Optional.empty(); - } - - return names.stream() - .filter(it -> StringUtils.isNotBlank(it.getValue())) - .findFirst() - .map(NameResponse::getValue); - } - -} diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/bpdm/BusinessPartnerResponse.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/bpdm/BusinessPartnerResponse.java deleted file mode 100644 index 123ceaa1f4..0000000000 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/bpdm/BusinessPartnerResponse.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022,2024 - * 2022: ZF Friedrichshafen AG - * 2022: ISTOS GmbH - * 2022,2024: Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * 2022,2023: BOSCH AG - * Copyright (c) 2021,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.irs.bpdm; - -import java.util.List; - -import lombok.Builder; -import lombok.Value; -import lombok.extern.jackson.Jacksonized; - -/** - * Bpn Response - */ -@Value -@Builder -@Jacksonized -class BusinessPartnerResponse { - - private String bpn; - private List names; - -} diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/bpdm/NameResponse.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/bpdm/NameResponse.java deleted file mode 100644 index 2e19c8ba23..0000000000 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/bpdm/NameResponse.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022,2024 - * 2022: ZF Friedrichshafen AG - * 2022: ISTOS GmbH - * 2022,2024: Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * 2022,2023: BOSCH AG - * Copyright (c) 2021,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.irs.bpdm; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -/** - * Name response - */ -@Getter -@AllArgsConstructor(staticName = "of") -@NoArgsConstructor -class NameResponse { - - private String value; - -} diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/configuration/JobConfiguration.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/configuration/JobConfiguration.java index 8857e26c5c..7430f7c7a2 100644 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/configuration/JobConfiguration.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/configuration/JobConfiguration.java @@ -37,11 +37,9 @@ import org.eclipse.tractusx.irs.aaswrapper.job.ItemDataRequest; import org.eclipse.tractusx.irs.aaswrapper.job.ItemTreesAssembler; import org.eclipse.tractusx.irs.aaswrapper.job.TreeRecursiveLogic; -import org.eclipse.tractusx.irs.aaswrapper.job.delegate.BpdmDelegate; import org.eclipse.tractusx.irs.aaswrapper.job.delegate.DigitalTwinDelegate; import org.eclipse.tractusx.irs.aaswrapper.job.delegate.RelationshipDelegate; import org.eclipse.tractusx.irs.aaswrapper.job.delegate.SubmodelDelegate; -import org.eclipse.tractusx.irs.bpdm.BpdmFacade; import org.eclipse.tractusx.irs.common.OutboundMeterRegistryService; import org.eclipse.tractusx.irs.common.persistence.BlobPersistence; import org.eclipse.tractusx.irs.common.persistence.BlobPersistenceException; @@ -144,15 +142,10 @@ public DigitalTwinDelegate digitalTwinDelegate(final RelationshipDelegate relati } @Bean - public RelationshipDelegate relationshipDelegate(final BpdmDelegate bpdmDelegate, + public RelationshipDelegate relationshipDelegate(final SubmodelDelegate submodelDelegate, final EdcSubmodelFacade submodelFacade, final ConnectorEndpointsService connectorEndpointsService, final JsonUtil jsonUtil) { - return new RelationshipDelegate(bpdmDelegate, submodelFacade, connectorEndpointsService, jsonUtil); - } - - @Bean - public BpdmDelegate bpdmDelegate(final SubmodelDelegate submodelDelegate, final BpdmFacade bpdmFacade) { - return new BpdmDelegate(submodelDelegate, bpdmFacade); + return new RelationshipDelegate(submodelDelegate, submodelFacade, connectorEndpointsService, jsonUtil); } @Bean diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/configuration/RestTemplateConfig.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/configuration/RestTemplateConfig.java index d8b50542aa..1d31045efb 100644 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/configuration/RestTemplateConfig.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/configuration/RestTemplateConfig.java @@ -70,7 +70,6 @@ public class RestTemplateConfig { public static final String DTR_REST_TEMPLATE = "dtrRestTemplate"; - public static final String BPDM_REST_TEMPLATE = "bpdmRestTemplate"; public static final String SEMHUB_REST_TEMPLATE = "semhubRestTemplate"; public static final String NO_ERROR_REST_TEMPLATE = "noErrorRestTemplate"; public static final String DISCOVERY_REST_TEMPLATE = "discoveryRestTemplate"; @@ -121,14 +120,6 @@ private static ClientHttpRequestInterceptor getRegistryInterceptor( return oAuthRestTemplate(restTemplateBuilder, readTimeout, connectTimeout, clientRegistrationId).build(); } - @Bean(BPDM_REST_TEMPLATE) - /* package */ RestTemplate bpdmRestTemplate(final RestTemplateBuilder restTemplateBuilder, - @Value("${bpdm.timeout.read}") final Duration readTimeout, - @Value("${bpdm.timeout.connect}") final Duration connectTimeout, - @Value("${bpdm.oAuthClientId}") final String clientRegistrationId) { - return oAuthRestTemplate(restTemplateBuilder, readTimeout, connectTimeout, clientRegistrationId).build(); - } - @Bean(DISCOVERY_REST_TEMPLATE) /* package */ RestTemplate discoveryRestTemplate(final RestTemplateBuilder restTemplateBuilder, @Value("${digitalTwinRegistry.discovery.timeout.read}") final Duration readTimeout, diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/services/IrsItemGraphQueryService.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/services/IrsItemGraphQueryService.java index 498d3f09eb..6f27f65a40 100644 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/services/IrsItemGraphQueryService.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/services/IrsItemGraphQueryService.java @@ -38,7 +38,6 @@ import lombok.NonNull; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.eclipse.tractusx.irs.aaswrapper.job.AASTransferProcess; import org.eclipse.tractusx.irs.aaswrapper.job.ItemContainer; import org.eclipse.tractusx.irs.aaswrapper.job.ItemDataRequest; @@ -76,7 +75,6 @@ import org.eclipse.tractusx.irs.util.JsonUtil; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.support.MutableSortDefinition; import org.springframework.beans.support.PagedListHolder; import org.springframework.context.ApplicationEventPublisher; @@ -109,20 +107,16 @@ public class IrsItemGraphQueryService implements IIrsItemGraphQueryService { private final ApplicationEventPublisher applicationEventPublisher; - private final String bpdmUrl; - public IrsItemGraphQueryService(final JobOrchestrator orchestrator, final JobStore jobStore, @Qualifier(JOB_BLOB_PERSISTENCE) final BlobPersistence blobStore, final MeterRegistryService meterRegistryService, final SemanticsHubFacade semanticsHubFacade, - final ApplicationEventPublisher applicationEventPublisher, - @Value("${bpdm.bpnEndpoint:}") final String bpdmUrl) { + final ApplicationEventPublisher applicationEventPublisher) { this.orchestrator = orchestrator; this.jobStore = jobStore; this.blobStore = blobStore; this.meterRegistryService = meterRegistryService; this.semanticsHubFacade = semanticsHubFacade; this.applicationEventPublisher = applicationEventPublisher; - this.bpdmUrl = bpdmUrl; } @Override @@ -172,11 +166,8 @@ public JobHandle registerItemJob(final @NonNull RegisterJob request, final UUID final var params = JobParameter.create(request); if (params.getDirection().equals(Direction.UPWARD) && !params.getBomLifecycle().equals(BomLifecycle.AS_BUILT)) { // Currently not supported variant - throw new IllegalArgumentException("Upward direction is supported only for asBuilt bomLifecycle parameter!"); - } - if (params.isLookupBPNs() && StringUtils.isBlank(bpdmUrl)) { - throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, - "Can't start job with BPN lookup - configured bpdm endpoint is empty!"); + throw new IllegalArgumentException( + "Upward direction is supported only for asBuilt bomLifecycle parameter!"); } validateAspectTypeValues(params.getAspects()); @@ -245,7 +236,6 @@ public Jobs getJobForJobId(final MultiTransferJob multiJob, final boolean includ final var tombstones = new ArrayList(); final var shells = new ArrayList(); final var submodels = new ArrayList(); - final var bpns = new ArrayList(); if (multiJob.jobIsCompleted()) { final var container = retrieveJobResultRelationships(multiJob.getJob().getId()); @@ -253,31 +243,29 @@ public Jobs getJobForJobId(final MultiTransferJob multiJob, final boolean includ tombstones.addAll(container.getTombstones()); shells.addAll(container.getShells()); submodels.addAll(container.getSubmodels()); - bpns.addAll(container.getBpns()); } else if (includePartialResults) { final var container = retrievePartialResults(multiJob); relationships.addAll(container.getRelationships()); tombstones.addAll(container.getTombstones()); shells.addAll(container.getShells()); submodels.addAll(container.getSubmodels()); - bpns.addAll(container.getBpns()); } - log.info("Found job with id {} in status {} with {} relationships, {} tombstones and {} submodels", multiJob.getJob().getId(), - multiJob.getJob().getState(), relationships.size(), tombstones.size(), submodels.size()); + log.info("Found job with id {} in status {} with {} relationships, {} tombstones and {} submodels", + multiJob.getJob().getId(), multiJob.getJob().getState(), relationships.size(), tombstones.size(), + submodels.size()); return Jobs.builder() .job(multiJob.getJob() .toBuilder() .summary(buildSummary(multiJob.getCompletedTransfers().size(), - multiJob.getTransferProcessIds().size(), tombstones.size(), - retrievePartialResults(multiJob))) + multiJob.getTransferProcessIds().size(), tombstones.size())) .build()) .relationships(relationships) .tombstones(tombstones) .shells(shells) .submodels(submodels) - .bpns(bpns) + .bpns(List.of()) .build(); } @@ -300,30 +288,17 @@ public void updateJobsInJobStoreMetrics() { } - private Summary buildSummary(final int completedTransfersSize, final int runningSize, final int tombstonesSize, - final ItemContainer itemContainer) { - final Integer bpnLookupCompleted = getBpnLookupMetric(itemContainer, RequestMetric::getCompleted); - final Integer bpnLookupFailed = getBpnLookupMetric(itemContainer, RequestMetric::getFailed); + private Summary buildSummary(final int completedTransfersSize, final int runningSize, final int tombstonesSize) { return Summary.builder() .asyncFetchedItems(AsyncFetchedItems.builder() .completed(completedTransfersSize) .running(runningSize) - .failed(tombstonesSize - bpnLookupFailed) + .failed(tombstonesSize) .build()) - .bpnLookups(FetchedItems.builder().completed(bpnLookupCompleted).failed(bpnLookupFailed).build()) + .bpnLookups(FetchedItems.builder().completed(0).failed(0).build()) .build(); } - private Integer getBpnLookupMetric(final ItemContainer itemContainer, - final Function requestMetricIntegerFunction) { - return itemContainer.getMetrics() - .stream() - .filter(metric -> metric.getType().equals(RequestMetric.RequestType.BPDM)) - .map(requestMetricIntegerFunction) - .reduce(Integer::sum) - .orElse(0); - } - private ItemContainer retrievePartialResults(final MultiTransferJob multiJob) { final List completedTransfers = multiJob.getCompletedTransfers(); final List transferIds = completedTransfers.stream().map(TransferProcess::getId).toList(); diff --git a/irs-api/src/main/resources/application.yml b/irs-api/src/main/resources/application.yml index 2e1268a00c..f315165d93 100644 --- a/irs-api/src/main/resources/application.yml +++ b/irs-api/src/main/resources/application.yml @@ -17,17 +17,11 @@ spring: authorization-grant-type: client_credentials client-id: ${DISCOVERY_OAUTH2_CLIENT_ID} # Dataspace Discovery OAuth2 client ID used to authenticate with the IAM client-secret: ${DISCOVERY_OAUTH2_CLIENT_SECRET} # Dataspace Discovery OAuth2 client secret used to authenticate with the IAM - bpdm: - authorization-grant-type: client_credentials - client-id: ${BPDM_OAUTH2_CLIENT_ID} # BPDM Pool OAuth2 client ID used to authenticate with the IAM - client-secret: ${BPDM_OAUTH2_CLIENT_SECRET} # BPDM Pool OAuth2 client secret used to authenticate with the IAM provider: semantics: token-uri: ${SEMANTICS_OAUTH2_CLIENT_TOKEN_URI:https://default} # OAuth2 endpoint to request tokens using the client credentials discovery: token-uri: ${DISCOVERY_OAUTH2_CLIENT_TOKEN_URI:https://default} # OAuth2 endpoint to request tokens using the client credentials - bpdm: - token-uri: ${BPDM_OAUTH2_CLIENT_TOKEN_URI:https://default} # OAuth2 endpoint to request tokens using the client credentials management: # Spring management API config, see https://spring.io/guides/gs/centralized-configuration/ endpoints: @@ -218,13 +212,6 @@ semanticshub: connect: PT90S # HTTP connect timeout for the semantic hub client pageSize: "${SEMANTICSHUB_PAGE_SIZE:100}" -bpdm: - bpnEndpoint: "${BPDM_URL:}" # Endpoint to resolve BPNs, must contain the placeholders {partnerId} and {idType} - oAuthClientId: bpdm # ID of the OAuth2 client registration to use, see config spring.security.oauth2.client - timeout: - read: PT90S # HTTP read timeout for the bpdm client - connect: PT90S # HTTP connect timeout for the bpdm client - # ESS Module specific properties ess: localBpn: ${ESS_LOCAL_BPN:} # BPN value of product - used during EDC notification communication diff --git a/irs-api/src/test/java/org/eclipse/tractusx/irs/IrsFunctionalTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/IrsFunctionalTest.java index 04d6bddfc3..a419c65829 100644 --- a/irs-api/src/test/java/org/eclipse/tractusx/irs/IrsFunctionalTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/IrsFunctionalTest.java @@ -26,11 +26,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; -import static org.springframework.security.oauth2.jwt.JwtClaimNames.SUB; -import java.time.Instant; import java.util.List; -import java.util.Map; import java.util.Optional; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; @@ -59,7 +56,6 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.oauth2.jwt.Jwt; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.support.TestPropertySourceUtils; @@ -68,9 +64,7 @@ @Testcontainers @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - properties = { "bpdm.bpnEndpoint=http://localbpdm.com", - "digitalTwinRegistry.type=central" - }) + properties = { "digitalTwinRegistry.type=central" }) @ContextConfiguration(initializers = IrsFunctionalTest.MinioConfigInitializer.class) @ActiveProfiles(profiles = { "local" }) class IrsFunctionalTest { @@ -125,59 +119,6 @@ void shouldStartJobAndRetrieveResult() { assertThat(finishedJob.get().getJob().getParameter()).isNotNull(); } - @Test - void shouldFillSummaryWithoutBPNLookup() { - final RegisterJob registerJob = TestMother.registerJobWithoutDepth(); - when(connectorEndpointsService.fetchConnectorEndpoints(any())).thenReturn( - List.of("http://localhost/discovery")); - - thereIsAuthentication(); - - final JobHandle jobHandle = controller.registerJobForGlobalAssetId(registerJob); - final Optional finishedJob = Awaitility.await() - .pollDelay(500, TimeUnit.MILLISECONDS) - .pollInterval(500, TimeUnit.MILLISECONDS) - .atMost(15, TimeUnit.SECONDS) - .until(getJobDetails(jobHandle), - jobs -> jobs.isPresent() && jobs.get() - .getJob() - .getState() - .equals(JobState.COMPLETED)); - - assertThat(finishedJob).isPresent(); - assertThat(finishedJob.get().getJob().getSummary().getAsyncFetchedItems().getCompleted()).isPositive(); - assertThat(finishedJob.get().getJob().getSummary().getAsyncFetchedItems().getFailed()).isZero(); - assertThat(finishedJob.get().getJob().getSummary().getAsyncFetchedItems().getRunning()).isZero(); - assertThat(finishedJob.get().getJob().getSummary().getBpnLookups().getCompleted()).isZero(); - assertThat(finishedJob.get().getJob().getSummary().getBpnLookups().getFailed()).isZero(); - } - - @Test - void shouldFillSummaryWithBPNLookup() { - final RegisterJob registerJob = TestMother.registerJobWithLookupBPNs(); - when(connectorEndpointsService.fetchConnectorEndpoints(any())).thenReturn( - List.of("http://localhost/discovery")); - thereIsAuthentication(); - - final JobHandle jobHandle = controller.registerJobForGlobalAssetId(registerJob); - final Optional finishedJob = Awaitility.await() - .pollDelay(500, TimeUnit.MILLISECONDS) - .pollInterval(500, TimeUnit.MILLISECONDS) - .atMost(15, TimeUnit.SECONDS) - .until(getJobDetails(jobHandle), - jobs -> jobs.isPresent() && jobs.get() - .getJob() - .getState() - .equals(JobState.COMPLETED)); - - assertThat(finishedJob).isPresent(); - assertThat(finishedJob.get().getJob().getSummary().getAsyncFetchedItems().getCompleted()).isPositive(); - assertThat(finishedJob.get().getJob().getSummary().getAsyncFetchedItems().getFailed()).isZero(); - assertThat(finishedJob.get().getJob().getSummary().getAsyncFetchedItems().getRunning()).isZero(); - assertThat(finishedJob.get().getJob().getSummary().getBpnLookups().getCompleted()).isPositive(); - assertThat(finishedJob.get().getJob().getSummary().getBpnLookups().getFailed()).isZero(); - } - private void thereIsAuthentication() { final ApiKeyAuthentication jwtAuthenticationToken = new ApiKeyAuthentication(new ApiKeyAuthority("apiKey", List.of(new SimpleGrantedAuthority(IrsRoles.VIEW_IRS)))); diff --git a/irs-api/src/test/java/org/eclipse/tractusx/irs/IrsWireMockIntegrationTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/IrsWireMockIntegrationTest.java index efadf045c0..af019fd55b 100644 --- a/irs-api/src/test/java/org/eclipse/tractusx/irs/IrsWireMockIntegrationTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/IrsWireMockIntegrationTest.java @@ -19,7 +19,6 @@ ********************************************************************************/ package org.eclipse.tractusx.irs; -import static com.github.tomakehurst.wiremock.client.WireMock.containing; import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; @@ -55,7 +54,6 @@ import com.github.tomakehurst.wiremock.junit5.WireMockTest; import org.awaitility.Awaitility; -import org.eclipse.tractusx.irs.bpdm.BpdmWireMockSupport; import org.eclipse.tractusx.irs.component.JobHandle; import org.eclipse.tractusx.irs.component.Jobs; import org.eclipse.tractusx.irs.component.RegisterJob; @@ -68,7 +66,6 @@ import org.eclipse.tractusx.irs.services.SemanticHubService; import org.eclipse.tractusx.irs.services.validation.SchemaNotFoundException; import org.eclipse.tractusx.irs.testing.containers.MinioContainer; -import org.eclipse.tractusx.irs.testing.wiremock.DiscoveryServiceWiremockSupport; import org.eclipse.tractusx.irs.testing.wiremock.SubmodelFacadeWiremockSupport; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; @@ -127,7 +124,6 @@ static void stopContainer() { @DynamicPropertySource static void configureProperties(DynamicPropertyRegistry registry) { - registry.add("bpdm.bpnEndpoint", () -> BpdmWireMockSupport.BPDM_URL_TEMPLATE); registry.add("digitalTwinRegistry.discovery.discoveryFinderUrl", () -> DISCOVERY_FINDER_URL); registry.add("digitalTwinRegistry.shellDescriptorTemplate", () -> SHELL_DESCRIPTORS_TEMPLATE); registry.add("digitalTwinRegistry.lookupShellsTemplate", () -> LOOKUP_SHELLS_TEMPLATE); @@ -172,8 +168,6 @@ void shouldStopJobAfterDepthIsReached() { successfulRegistryAndDataRequest(globalAssetIdLevel2, "Polyamid", TEST_BPN, "integrationtesting/batch-2.json", "integrationtesting/singleLevelBomAsBuilt-2.json"); - BpdmWireMockSupport.bpdmWillReturnCompanyName(DiscoveryServiceWiremockSupport.TEST_BPN, "Company Name"); - final RegisterJob request = WiremockSupport.jobRequest(globalAssetIdLevel1, TEST_BPN, 1); // Act @@ -261,8 +255,6 @@ void shouldStartRecursiveProcesses() { successfulRegistryAndDataRequest(globalAssetIdLevel3, "GenericChemical", TEST_BPN, "integrationtesting/batch-3.json", "integrationtesting/singleLevelBomAsBuilt-3.json"); - BpdmWireMockSupport.bpdmWillReturnCompanyName(DiscoveryServiceWiremockSupport.TEST_BPN, "Company Name"); - final RegisterJob request = WiremockSupport.jobRequest(globalAssetIdLevel1, TEST_BPN, 4); // Act diff --git a/irs-api/src/test/java/org/eclipse/tractusx/irs/WireMockTestConfig.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/WireMockTestConfig.java index 8c41604857..b3f20374e6 100644 --- a/irs-api/src/test/java/org/eclipse/tractusx/irs/WireMockTestConfig.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/WireMockTestConfig.java @@ -19,7 +19,6 @@ ********************************************************************************/ package org.eclipse.tractusx.irs; -import static org.eclipse.tractusx.irs.configuration.RestTemplateConfig.BPDM_REST_TEMPLATE; import static org.eclipse.tractusx.irs.configuration.RestTemplateConfig.DISCOVERY_REST_TEMPLATE; import static org.eclipse.tractusx.irs.configuration.RestTemplateConfig.DTR_REST_TEMPLATE; import static org.eclipse.tractusx.irs.configuration.RestTemplateConfig.EDC_REST_TEMPLATE; @@ -82,13 +81,6 @@ RestTemplate discoveryRestTemplate() { return restTemplateProxy(PROXY_SERVER_HOST, HTTP_PORT); } - @Primary - @Profile("integrationtest") - @Bean(BPDM_REST_TEMPLATE) - RestTemplate bpdmRestTemplate() { - return restTemplateProxy(PROXY_SERVER_HOST, HTTP_PORT); - } - @Primary @Profile("integrationtest") @Bean(SEMHUB_REST_TEMPLATE) diff --git a/irs-api/src/test/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/BpdmDelegateTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/BpdmDelegateTest.java deleted file mode 100644 index b27955ab8e..0000000000 --- a/irs-api/src/test/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/BpdmDelegateTest.java +++ /dev/null @@ -1,195 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022,2024 - * 2022: ZF Friedrichshafen AG - * 2022: ISTOS GmbH - * 2022,2024: Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * 2022,2023: BOSCH AG - * Copyright (c) 2021,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.irs.aaswrapper.job.delegate; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.tractusx.irs.util.TestMother.jobParameter; -import static org.eclipse.tractusx.irs.util.TestMother.jobParameterCollectBpns; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.Optional; - -import org.eclipse.tractusx.irs.aaswrapper.job.AASTransferProcess; -import org.eclipse.tractusx.irs.aaswrapper.job.ItemContainer; -import org.eclipse.tractusx.irs.bpdm.BpdmFacade; -import org.eclipse.tractusx.irs.component.Bpn; -import org.eclipse.tractusx.irs.component.PartChainIdentificationKey; -import org.eclipse.tractusx.irs.component.enums.ProcessStep; -import org.junit.jupiter.api.Test; -import org.springframework.web.client.RestClientException; - -class BpdmDelegateTest { - - final BpdmFacade bpdmFacade = mock(BpdmFacade.class); - final BpdmDelegate bpdmDelegate = new BpdmDelegate(null, bpdmFacade); - - @Test - void shouldFillItemContainerWithBpn() { - // given - given(bpdmFacade.findManufacturerName(any())).willReturn(Optional.of("Tier A")); - final ItemContainer.ItemContainerBuilder itemContainer = ItemContainer.builder().bpn(Bpn.withManufacturerId("BPNL00000003AYRE")); - - // when - final ItemContainer result = bpdmDelegate.process(itemContainer, jobParameterCollectBpns(), - new AASTransferProcess("id", 0), createKey()); - - // then - assertThat(result).isNotNull(); - assertThat(result.getBpns()).isNotEmpty(); - assertThat(result.getBpns().stream().findFirst().get().getManufacturerName()).isEqualTo("Tier A"); - } - - private static PartChainIdentificationKey createKey() { - return PartChainIdentificationKey.builder().globalAssetId("itemId").build(); - } - - @Test - void shouldCreateTombstoneForNotValidBpn() { - // given - given(bpdmFacade.findManufacturerName(any())).willReturn(Optional.of("Tier A")); - final ItemContainer.ItemContainerBuilder itemContainer = ItemContainer.builder().bpn(Bpn.withManufacturerId("dsfvzsdfvzsvdszvzdsvdszvdszvds")); - - // when - final ItemContainer result = bpdmDelegate.process(itemContainer, jobParameterCollectBpns(), - new AASTransferProcess("id", 0), createKey()); - - // then - assertThat(result).isNotNull(); - assertThat(result.getBpns()).isNotEmpty(); - assertThat(result.getTombstones()).hasSize(1); - assertThat(result.getTombstones().get(0).getCatenaXId()).isEqualTo("itemId"); - assertThat(result.getTombstones().get(0).getProcessingError().getProcessStep()).isEqualTo( - ProcessStep.BPDM_VALIDATION); - } - - @Test - void shouldCatchRestClientExceptionAndPutTombstone() { - // given - when(bpdmFacade.findManufacturerName(any())).thenThrow(RestClientException.class); - final ItemContainer.ItemContainerBuilder itemContainerWithShell = ItemContainer.builder().bpn(Bpn.withManufacturerId("BPNL00000003AYRE")); - - // when - final ItemContainer result = bpdmDelegate.process(itemContainerWithShell, jobParameterCollectBpns(), - new AASTransferProcess("id", 0), createKey()); - - // then - assertThat(result).isNotNull(); - assertThat(result.getBpns()).isNotEmpty(); - assertThat(result.getTombstones()).hasSize(1); - assertThat(result.getTombstones().get(0).getCatenaXId()).isEqualTo("itemId"); - assertThat(result.getTombstones().get(0).getProcessingError().getProcessStep()).isEqualTo( - ProcessStep.BPDM_REQUEST); - } - - @Test - void shouldCreateTombstoneForMissingBpnForGivenManufacturerId() { - // given - final ItemContainer.ItemContainerBuilder itemContainer = ItemContainer.builder().bpn(Bpn.withManufacturerId("BPNL00000003AYRE")); - - // when - final ItemContainer result = bpdmDelegate.process(itemContainer, jobParameterCollectBpns(), - new AASTransferProcess("id", 0), createKey()); - - // then - assertThat(result).isNotNull(); - assertThat(result.getBpns()).isNotEmpty(); - assertThat(result.getTombstones()).hasSize(1); - assertThat(result.getTombstones().get(0).getCatenaXId()).isEqualTo("itemId"); - assertThat(result.getTombstones().get(0).getProcessingError().getProcessStep()).isEqualTo( - ProcessStep.BPDM_REQUEST); - } - - @Test - void shouldNotResolveBPNsWithoutFlag() { - // given - given(bpdmFacade.findManufacturerName(any())).willReturn(Optional.of("Tier A")); - final ItemContainer.ItemContainerBuilder itemContainer = ItemContainer.builder().bpn(Bpn.withManufacturerId("BPNL00000003AYRE")); - - // when - final ItemContainer result = bpdmDelegate.process(itemContainer, jobParameter(), - new AASTransferProcess("id", 0), createKey()); - - // then - assertThat(result).isNotNull(); - assertThat(result.getBpns()).isNotEmpty(); - assertThat(result.getMetrics()).isEmpty(); - } - - @Test - void shouldResolveBPNsWhenFlagIsTrue() { - // given - given(bpdmFacade.findManufacturerName(any())).willReturn(Optional.of("Tier A")); - final ItemContainer.ItemContainerBuilder itemContainer = ItemContainer.builder().bpn(Bpn.withManufacturerId("BPNL00000003AYRE")); - - // when - final ItemContainer result = bpdmDelegate.process(itemContainer, jobParameterCollectBpns(), - new AASTransferProcess("id", 0), createKey()); - - // then - assertThat(result).isNotNull(); - assertThat(result.getBpns()).isNotEmpty(); - assertThat(result.getBpns().stream().findFirst().get().getManufacturerName()).isEqualTo("Tier A"); - assertThat(result.getMetrics()).isNotEmpty(); - assertThat(result.getMetrics().stream().findFirst().get().getCompleted()).isOne(); - } - - @Test - void shouldIncrementFailedMetricWhenFacadeResultIsEmpty() { - // given - given(bpdmFacade.findManufacturerName(any())).willReturn(Optional.empty()); - final ItemContainer.ItemContainerBuilder itemContainer = ItemContainer.builder().bpn(Bpn.withManufacturerId("BPNL00000003AYRE")); - - // when - final ItemContainer result = bpdmDelegate.process(itemContainer, jobParameterCollectBpns(), - new AASTransferProcess("id", 0), createKey()); - - // then - assertThat(result).isNotNull(); - assertThat(result.getBpns()).isNotEmpty(); - assertThat(result.getMetrics()).isNotEmpty(); - assertThat(result.getMetrics().stream().findFirst().get().getFailed()).isOne(); - assertThat(result.getMetrics().stream().findFirst().get().getCompleted()).isZero(); - } - - @Test - void shouldIncrementFailedMetricWhenExceptionIsThrown() { - // given - given(bpdmFacade.findManufacturerName(any())).willThrow(new RestClientException("test")); - final ItemContainer.ItemContainerBuilder itemContainer = ItemContainer.builder().bpn(Bpn.withManufacturerId("BPNL00000003AYRE")); - - // when - final ItemContainer result = bpdmDelegate.process(itemContainer, jobParameterCollectBpns(), - new AASTransferProcess("id", 0), createKey()); - - // then - assertThat(result).isNotNull(); - assertThat(result.getBpns()).isNotEmpty(); - assertThat(result.getMetrics()).isNotEmpty(); - assertThat(result.getMetrics().stream().findFirst().get().getFailed()).isOne(); - assertThat(result.getMetrics().stream().findFirst().get().getCompleted()).isZero(); - } -} diff --git a/irs-api/src/test/java/org/eclipse/tractusx/irs/bpdm/BpdmClientImplTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/bpdm/BpdmClientImplTest.java deleted file mode 100644 index 012a13799d..0000000000 --- a/irs-api/src/test/java/org/eclipse/tractusx/irs/bpdm/BpdmClientImplTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022,2024 - * 2022: ZF Friedrichshafen AG - * 2022: ISTOS GmbH - * 2022,2024: Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * 2022,2023: BOSCH AG - * Copyright (c) 2021,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.irs.bpdm; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import org.junit.jupiter.api.Test; -import org.springframework.web.client.RestTemplate; - -class BpdmClientImplTest { - - private final RestTemplate restTemplate = mock(RestTemplate.class); - private final BpdmClient bpdmClient = new BpdmClientImpl(restTemplate, "url/{idType}/{partnerId}"); - - @Test - void shouldCallExternalServiceOnceAndGetBusinessPartnerResponse() { - final String bpn = "BPNL00000003AYRE"; - final BusinessPartnerResponse mockResponse = BusinessPartnerResponse.builder().bpn(bpn).build(); - doReturn(mockResponse).when(restTemplate).getForObject(any(), eq(BusinessPartnerResponse.class)); - - final BusinessPartnerResponse businessPartner = bpdmClient.getBusinessPartner(bpn, "BPN"); - - assertThat(businessPartner).isNotNull(); - assertThat(businessPartner.getBpn()).isEqualTo(bpn); - verify(this.restTemplate, times(1)).getForObject(any(), eq(BusinessPartnerResponse.class)); - } - -} diff --git a/irs-api/src/test/java/org/eclipse/tractusx/irs/bpdm/BpdmFacadeTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/bpdm/BpdmFacadeTest.java deleted file mode 100644 index 01b4bfa04b..0000000000 --- a/irs-api/src/test/java/org/eclipse/tractusx/irs/bpdm/BpdmFacadeTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022,2024 - * 2022: ZF Friedrichshafen AG - * 2022: ISTOS GmbH - * 2022,2024: Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * 2022,2023: BOSCH AG - * Copyright (c) 2021,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.irs.bpdm; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Optional; - -import org.junit.jupiter.api.Test; - -class BpdmFacadeTest { - - private final BpdmFacade bpdmFacade = new BpdmFacade(new BpdmClientLocalStub()); - - @Test - void shouldReturnManufacturerNameWhenManufacturerIdExists() { - final String manufacturerId = "BPNL00000003AYRE"; - - final Optional manufacturerName = bpdmFacade.findManufacturerName(manufacturerId); - - assertThat(manufacturerName).isNotEmpty(); - assertThat(manufacturerName.get()).contains("OEM A"); - } - -} diff --git a/irs-api/src/test/java/org/eclipse/tractusx/irs/bpdm/BpdmWireMockSupport.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/bpdm/BpdmWireMockSupport.java deleted file mode 100644 index d7af399fcc..0000000000 --- a/irs-api/src/test/java/org/eclipse/tractusx/irs/bpdm/BpdmWireMockSupport.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2021,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.irs.bpdm; - -import static com.github.tomakehurst.wiremock.client.WireMock.exactly; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.verify; -import static org.eclipse.tractusx.irs.testing.wiremock.WireMockConfig.responseWithStatus; - -/** - * WireMock configurations and requests used for testing BPDM flow. - */ -public final class BpdmWireMockSupport { - - public static final String BPN_PATH = "/legal-entities/"; - public static final String BPDM_URL_TEMPLATE = "http://bpdm.test" + BPN_PATH + "{partnerId}?idType={idType}"; - - private BpdmWireMockSupport() { - } - - public static void bpdmWillReturnCompanyName(final String bpn, final String companyName) { - stubFor(get(urlPathEqualTo(BPN_PATH + bpn)).willReturn( - responseWithStatus(200).withBody(bpdmResponse(bpn, companyName)))); - } - - public static void bpdmWillNotFindCompanyName(final String bpn) { - stubFor(get(urlPathEqualTo(BPN_PATH + bpn)).willReturn(responseWithStatus(404))); - } - - public static void verifyBpdmWasCalledWithBPN(final String bpn, final int times) { - verify(exactly(times), getRequestedFor(urlPathEqualTo(BPN_PATH + bpn))); - } - - public static String bpdmResponse(final String bpn, final String companyName) { - return """ - { - "bpn": "%s", - "identifiers": [ - { - "value": "%s", - "type": { - "technicalKey": "BPN", - "name": "Business Partner Number", - "url": "" - }, - "issuingBody": { - "technicalKey": "CATENAX", - "name": "Catena-X", - "url": "" - }, - "status": { - "technicalKey": "UNKNOWN", - "name": "Unknown" - } - } - ], - "names": [ - { - "value": "%s", - "shortName": null, - "type": { - "technicalKey": "OTHER", - "name": "Any other alternative name used for a company, such as a specific language variant.", - "url": "" - }, - "language": { - "technicalKey": "undefined", - "name": "Undefined" - } - } - ], - "legalForm": null, - "status": null, - "profileClassifications": [], - "types": [ - { - "technicalKey": "UNKNOWN", - "name": "Unknown", - "url": "" - } - ], - "bankAccounts": [], - "roles": [], - "relations": [], - "currentness": "2022-07-26T08:17:38.737578Z" - } - """.formatted(bpn, bpn, companyName); - } - -} \ No newline at end of file diff --git a/irs-api/src/test/java/org/eclipse/tractusx/irs/bpdm/BpdmWiremockTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/bpdm/BpdmWiremockTest.java deleted file mode 100644 index a1e272fca4..0000000000 --- a/irs-api/src/test/java/org/eclipse/tractusx/irs/bpdm/BpdmWiremockTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2021,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.irs.bpdm; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.tractusx.irs.bpdm.BpdmWireMockSupport.BPDM_URL_TEMPLATE; -import static org.eclipse.tractusx.irs.bpdm.BpdmWireMockSupport.bpdmWillNotFindCompanyName; -import static org.eclipse.tractusx.irs.bpdm.BpdmWireMockSupport.bpdmWillReturnCompanyName; -import static org.eclipse.tractusx.irs.bpdm.BpdmWireMockSupport.verifyBpdmWasCalledWithBPN; -import static org.eclipse.tractusx.irs.testing.wiremock.WireMockConfig.restTemplateProxy; - -import java.util.Optional; - -import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; -import com.github.tomakehurst.wiremock.junit5.WireMockTest; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.web.client.RestTemplate; - -@WireMockTest -class BpdmWiremockTest { - private static final String PROXY_SERVER_HOST = "127.0.0.1"; - private BpdmFacade bpdmFacade; - - @BeforeEach - void setUp(WireMockRuntimeInfo wireMockRuntimeInfo) { - final RestTemplate restTemplate = restTemplateProxy(PROXY_SERVER_HOST, wireMockRuntimeInfo.getHttpPort()); - - bpdmFacade = new BpdmFacade(new BpdmClientImpl(restTemplate, BPDM_URL_TEMPLATE)); - } - - @Test - void shouldResolveManufacturerName() { - // Arrange - final String bpn = "BPNL00000000TEST"; - bpdmWillReturnCompanyName(bpn, "TEST_BPN_DFT_1"); - - // Act - final Optional manufacturerName = bpdmFacade.findManufacturerName(bpn); - - // Assert - assertThat(manufacturerName).isPresent().contains("TEST_BPN_DFT_1"); - verifyBpdmWasCalledWithBPN(bpn, 1); - } - - @Test - void shouldReturnEmptyOnNotFound() { - // Arrange - final String bpn = "BPNL00000000TEST"; - bpdmWillNotFindCompanyName(bpn); - - // Act & Assert - final Optional manufacturerName = bpdmFacade.findManufacturerName(bpn); - verifyBpdmWasCalledWithBPN(bpn, 1); - assertThat(manufacturerName).isEmpty(); - } - -} diff --git a/irs-api/src/test/java/org/eclipse/tractusx/irs/services/IrsItemGraphQueryServiceTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/services/IrsItemGraphQueryServiceTest.java index f8eb2b3ab6..ad22381aa7 100644 --- a/irs-api/src/test/java/org/eclipse/tractusx/irs/services/IrsItemGraphQueryServiceTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/services/IrsItemGraphQueryServiceTest.java @@ -25,7 +25,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.eclipse.tractusx.irs.util.TestMother.registerJobWithDepthAndAspect; -import static org.eclipse.tractusx.irs.util.TestMother.registerJobWithLookupBPNs; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -201,11 +200,4 @@ void shouldThrowExceptionForUnknownAspectTypes() throws SchemaNotFoundException assertThrows(IllegalArgumentException.class, executable); } - @Test - void shouldThrowExceptionWhenLookupBpnAndBpdmEndpointUrlIsMissing() { - final Executable executable = () -> testee.registerItemJob(registerJobWithLookupBPNs()); - - assertThrows(ResponseStatusException.class, executable); - } - } \ No newline at end of file diff --git a/irs-api/src/test/java/org/eclipse/tractusx/irs/util/TestMother.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/util/TestMother.java index 52a3c479ac..d289a8b01c 100644 --- a/irs-api/src/test/java/org/eclipse/tractusx/irs/util/TestMother.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/util/TestMother.java @@ -112,11 +112,6 @@ public static RegisterJob registerJobWithDepthAndAspectAndCollectAspects(final I Direction.DOWNWARD); } - public static RegisterJob registerJobWithLookupBPNs() { - return registerJob(EXISTING_GLOBAL_ASSET_ID, null, - List.of(singleLevelBomAsBuiltAspectName), false, true, Direction.DOWNWARD); - } - public static RegisterJob registerJob(final String globalAssetId, final Integer depth, final List aspectTypes, final boolean collectAspects, final boolean lookupBPNs, final Direction direction) { diff --git a/irs-edc-client/src/test/resources/__files/jobResponse.json b/irs-edc-client/src/test/resources/__files/jobResponse.json index 1f0855e04c..3a346dbd47 100644 --- a/irs-edc-client/src/test/resources/__files/jobResponse.json +++ b/irs-edc-client/src/test/resources/__files/jobResponse.json @@ -2749,16 +2749,6 @@ "retryCounter": 3 } }, - { - "catenaXId": "urn:uuid:68c9b1bf-b2c1-456a-883c-2aac5f5cb5f4", - "endpointURL": null, - "processingError": { - "processStep": "BpdmRequest", - "errorDetail": "Cannot find ManufacturerId for CatenaXId: urn:uuid:68c9b1bf-b2c1-456a-883c-2aac5f5cb5f4", - "lastAttempt": "2022-11-08T08:37:18.724609316Z", - "retryCounter": 0 - } - }, { "catenaXId": "urn:uuid:68766b51-f794-4033-bcb1-f635ed309cd4", "endpointURL": "https://subtier-a-edc-ocp0900009.apps.c7von4sy.westeurope.aroapp.io/BPNL00000003B3NX/urn:uuid:68766b51-f794-4033-bcb1-f635ed309cd4-urn:uuid:f6f15bca-c901-4dca-bdb0-6abea6fae5fd/submodel?content=value&extent=withBlobValue", diff --git a/irs-models/src/main/java/org/eclipse/tractusx/irs/component/RegisterBatchOrder.java b/irs-models/src/main/java/org/eclipse/tractusx/irs/component/RegisterBatchOrder.java index 3ba59f7da0..aaa70ab534 100644 --- a/irs-models/src/main/java/org/eclipse/tractusx/irs/component/RegisterBatchOrder.java +++ b/irs-models/src/main/java/org/eclipse/tractusx/irs/component/RegisterBatchOrder.java @@ -107,7 +107,7 @@ public class RegisterBatchOrder { @Schema(description = "Flag to specify whether aspects should be requested and collected. Default is false.") private boolean collectAspects; - @Schema(description = "Flag to specify whether BPNs should be collected and resolved via the configured BPDM URL. Default is false.") + @Schema(description = "Flag to specify whether BPNs should be collected and resolved via the configured BPDM URL. Default is false.", deprecated = true) private boolean lookupBPNs; @URL diff --git a/irs-models/src/main/java/org/eclipse/tractusx/irs/component/RegisterJob.java b/irs-models/src/main/java/org/eclipse/tractusx/irs/component/RegisterJob.java index f7b0d562de..1113ad1de2 100644 --- a/irs-models/src/main/java/org/eclipse/tractusx/irs/component/RegisterJob.java +++ b/irs-models/src/main/java/org/eclipse/tractusx/irs/component/RegisterJob.java @@ -81,7 +81,7 @@ public class RegisterJob { @Schema(description = "Flag to specify whether aspects should be requested and collected. Default is false.") private boolean collectAspects; - @Schema(description = "Flag to specify whether BPNs should be collected and resolved via the configured BPDM URL. Default is false.") + @Schema(description = "Flag to specify whether BPNs should be collected and resolved via the configured BPDM URL. Default is false.", deprecated = true) private boolean lookupBPNs; @Schema(description = "Flag enables and disables auditing, including provisioning of ContractAgreementId inside submodels and shells objects. Default is true.") diff --git a/irs-models/src/main/java/org/eclipse/tractusx/irs/component/enums/ProcessStep.java b/irs-models/src/main/java/org/eclipse/tractusx/irs/component/enums/ProcessStep.java index 94d3d0ae16..81078cddc1 100644 --- a/irs-models/src/main/java/org/eclipse/tractusx/irs/component/enums/ProcessStep.java +++ b/irs-models/src/main/java/org/eclipse/tractusx/irs/component/enums/ProcessStep.java @@ -37,8 +37,6 @@ public enum ProcessStep { DIGITAL_TWIN_REQUEST("DigitalTwinRequest"), SCHEMA_VALIDATION("SchemaValidation"), SCHEMA_REQUEST("SchemaRequest"), - BPDM_REQUEST("BpdmRequest"), - BPDM_VALIDATION("BpdmValidation"), USAGE_POLICY_VALIDATION("UsagePolicyValidation"), ESS_VALIDATION("EssValidation"); diff --git a/irs-registry-client/src/main/java/org/eclipse/tractusx/irs/registryclient/central/DigitalTwinRegistryClientImpl.java b/irs-registry-client/src/main/java/org/eclipse/tractusx/irs/registryclient/central/DigitalTwinRegistryClientImpl.java index 66a484a742..d99c7eda02 100644 --- a/irs-registry-client/src/main/java/org/eclipse/tractusx/irs/registryclient/central/DigitalTwinRegistryClientImpl.java +++ b/irs-registry-client/src/main/java/org/eclipse/tractusx/irs/registryclient/central/DigitalTwinRegistryClientImpl.java @@ -61,8 +61,8 @@ public DigitalTwinRegistryClientImpl(final RestTemplate restTemplate, PLACEHOLDER_AAS_IDENTIFIER); } - private static void require(final String bpdmUrl, final String configPath, final String placeholder) { - if (!bpdmUrl.contains(wrap(placeholder))) { + private static void require(final String descriptorEndpoint, final String configPath, final String placeholder) { + if (!descriptorEndpoint.contains(wrap(placeholder))) { throw new IllegalStateException( "Configuration value for '" + configPath + "' must contain the URL placeholder '" + placeholder + "'!"); @@ -77,11 +77,11 @@ private static String encodeWithBase64(final String aasIdentifier) { return Base64.getEncoder().encodeToString(aasIdentifier.getBytes(StandardCharsets.UTF_8)); } - private void ensureUrlContainsPlaceholders(final String bpdmUrl, final String configPath, + private void ensureUrlContainsPlaceholders(final String descriptorEndpoint, final String configPath, final String... placeholders) { - if (StringUtils.isNotBlank(bpdmUrl)) { + if (StringUtils.isNotBlank(descriptorEndpoint)) { for (final var placeholder : placeholders) { - require(bpdmUrl, configPath, placeholder); + require(descriptorEndpoint, configPath, placeholder); } } } diff --git a/local/deployment/irs-local/README.md b/local/deployment/irs-local/README.md index 8623d1e351..1c9740243c 100644 --- a/local/deployment/irs-local/README.md +++ b/local/deployment/irs-local/README.md @@ -88,7 +88,7 @@ You can use these snippets for testing purposes. ```json { "bomLifecycle": "asBuilt", - "lookupBPNs": true, + "lookupBPNs": false, "direction": "downward", "depth": 10, "auditContractNegotiation": false, diff --git a/local/deployment/irs-local/values.yaml b/local/deployment/irs-local/values.yaml index 1efcafc82f..f57dd4d868 100644 --- a/local/deployment/irs-local/values.yaml +++ b/local/deployment/irs-local/values.yaml @@ -33,8 +33,6 @@ irs-helm: discoveryFinderUrl: https://localhost semanticshub: url: https://localhost - bpdm: - url: https://localhost minioUser: "testtest" minioPassword: "testtest" diff --git a/local/testing/api-tests/irs-api-tests.tavern.yaml b/local/testing/api-tests/irs-api-tests.tavern.yaml index c84b21c3ea..48501679ab 100644 --- a/local/testing/api-tests/irs-api-tests.tavern.yaml +++ b/local/testing/api-tests/irs-api-tests.tavern.yaml @@ -2468,7 +2468,7 @@ stages: depth: 2 direction: "downward" bomLifecycle: "asPlanned" - lookupBPNs: true + lookupBPNs: false callbackUrl: "https://www.check123.com" aspects: #- urn:samm:io.catenax.serial_part:3.0.0#SerialPart @@ -2568,7 +2568,7 @@ strict: - json:off stages: - - name: create a job with lookupBPNs = true and wait + - name: create a job and wait request: url: "{tavern.env_vars.IRS_HOST}/irs/jobs" json: @@ -2576,7 +2576,7 @@ stages: globalAssetId: "{tavern.env_vars.GLOBAL_ASSET_ID_AS_BUILT}" bpn: "{tavern.env_vars.BPN_AS_BUILT}" collectAspects: false - lookupBPNs: true + lookupBPNs: false depth: 1 direction: "downward" method: POST @@ -2622,7 +2622,7 @@ strict: - json:off stages: - - name: create a job with lookupBPNs = true and wait + - name: create a job and wait request: url: "{tavern.env_vars.IRS_HOST}/irs/jobs" json: @@ -2630,7 +2630,7 @@ stages: globalAssetId: "{tavern.env_vars.GLOBAL_ASSET_ID_AS_BUILT}" bpn: "{tavern.env_vars.BPN_AS_BUILT}" collectAspects: false - lookupBPNs: true + lookupBPNs: false depth: 1 direction: "downward" method: POST @@ -2731,7 +2731,7 @@ stages: - urn:samm:io.catenax.single_level_bom_as_built:3.0.0#SingeLevelBomAsBuilt - urn:samm:io.catenax.serial_part:3.0.0#SerialPart collectAspects: true - lookupBPNs: true + lookupBPNs: false batchSize: 10 batchStrategy: "PRESERVE_BATCH_JOB_ORDER" depth: 1 @@ -2791,7 +2791,7 @@ stages: - urn:samm:io.catenax.single_level_bom_as_built:3.0.0#SingeLevelBomAsBuilt - urn:samm:io.catenax.serial_part:3.0.0#SerialPart collectAspects: true - lookupBPNs: true + lookupBPNs: false batchSize: 2 batchStrategy: "PRESERVE_BATCH_JOB_ORDER" depth: 1 @@ -2843,7 +2843,7 @@ stages: - urn:samm:io.catenax.single_level_bom_as_built:3.0.0#SingeLevelBomAsBuilt - urn:samm:io.catenax.serial_part:3.0.0#SerialPart collectAspects: true - lookupBPNs: true + lookupBPNs: false batchSize: 10 batchStrategy: "PRESERVE_BATCH_JOB_ORDER" depth: 1 diff --git a/local/testing/api-tests/tavern_helpers.py b/local/testing/api-tests/tavern_helpers.py index e1c8f35348..60bf733b22 100644 --- a/local/testing/api-tests/tavern_helpers.py +++ b/local/testing/api-tests/tavern_helpers.py @@ -285,7 +285,7 @@ def summary_for_bpns_is_given(response): bpnLookups = response.json().get('job').get('summary').get('bpnLookups') print(bpnLookups) print("completed: ", bpnLookups.get('completed')) - assert bpnLookups.get('completed') != 0 + assert bpnLookups.get('completed') == 0 assert bpnLookups.get('failed') == 0 @@ -336,7 +336,7 @@ def job_parameter_are_as_requested(response): assert parameter.get('collectAspects') is True assert parameter.get('depth') == 2 assert parameter.get('direction') == 'downward' - assert parameter.get('lookupBPNs') is True + assert parameter.get('lookupBPNs') is False assert parameter.get('callbackUrl') == 'https://www.check123.com' aspects_list = parameter.get("aspects") assert 'urn:samm:io.catenax.part_as_planned:2.0.0#PartAsPlanned' in aspects_list From 72f4971f4075d42bc338d279aa670724183d7b81 Mon Sep 17 00:00:00 2001 From: "Krzysztof Massalski (Extern)" Date: Wed, 1 May 2024 10:19:04 +0200 Subject: [PATCH 2/2] feat(impl):[#568] remove bpdm lookup --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9358ba02c0..6c892e2672 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ _**For better traceability add the corresponding GitHub issue number in each cha ## [Unreleased] +### Changed + +- BPN lookup feature was removed #568 + ## [5.1.0] - 2024-04-30 ### Changed