diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fcb46c0a9..03c16255fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Change logo of irs +- Added 'businessPartnerNumber' field to Tombstone model. This will be filled only when UsagePolicyValidation tombstone is being created. + +### Fixed +- Update to Spring Boot 3.1.9 to fix CVE's. ## [4.6.0] - 2024-02-20 ### Added diff --git a/docs/src/api/irs-api.yaml b/docs/src/api/irs-api.yaml index 9afa2c32f3..bd6c56e6a7 100644 --- a/docs/src/api/irs-api.yaml +++ b/docs/src/api/irs-api.yaml @@ -2700,6 +2700,8 @@ components: additionalProperties: false description: Tombstone with information about request failure properties: + businessPartnerNumber: + type: string catenaXId: type: string description: CATENA-X global asset id in the format urn:uuid:uuid4. diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/RelationshipDelegate.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/RelationshipDelegate.java index 231b6d5b31..14dd51dbef 100644 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/RelationshipDelegate.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/RelationshipDelegate.java @@ -117,7 +117,7 @@ private void processEndpoint(final Endpoint endpoint, final RelationshipAspect r log.info("Encountered usage policy exception: {}. Creating Tombstone.", e.getMessage()); itemContainerBuilder.tombstone( Tombstone.from(itemId.getGlobalAssetId(), endpoint.getProtocolInformation().getHref(), e, - 0, ProcessStep.USAGE_POLICY_VALIDATION, jsonUtil.asMap(e.getPolicy()))); + 0, ProcessStep.USAGE_POLICY_VALIDATION, e.getBusinessPartnerNumber(), jsonUtil.asMap(e.getPolicy()))); } catch (final EdcClientException e) { log.info("Submodel Endpoint could not be retrieved for Endpoint: {}. Creating Tombstone.", endpoint.getProtocolInformation().getHref()); diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/SubmodelDelegate.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/SubmodelDelegate.java index a75fcb400a..f586c3c03b 100644 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/SubmodelDelegate.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/SubmodelDelegate.java @@ -147,7 +147,7 @@ private List getSubmodels(final SubmodelDescriptor submodelDescriptor, } catch (final UsagePolicyException e) { log.info("Encountered usage policy exception: {}. Creating Tombstone.", e.getMessage()); itemContainerBuilder.tombstone(Tombstone.from(itemId, endpoint.getProtocolInformation().getHref(), e, 0, - ProcessStep.USAGE_POLICY_VALIDATION, jsonUtil.asMap(e.getPolicy()))); + ProcessStep.USAGE_POLICY_VALIDATION, e.getBusinessPartnerNumber(), jsonUtil.asMap(e.getPolicy()))); } catch (final EdcClientException e) { log.info("Submodel Endpoint could not be retrieved for Item: {}. Creating Tombstone.", itemId); itemContainerBuilder.tombstone(Tombstone.from(itemId, endpoint.getProtocolInformation().getHref(), e, 0, diff --git a/irs-api/src/test/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/RelationshipDelegateTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/RelationshipDelegateTest.java index 3b060bd29e..7d446883d4 100644 --- a/irs-api/src/test/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/RelationshipDelegateTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/RelationshipDelegateTest.java @@ -191,6 +191,7 @@ void shouldCatchJsonParseExceptionAndPutTombstone() throws EdcClientException { @Test void shouldCatchUsagePolicyExceptionAndPutTombstone() throws EdcClientException { // given + final String businessPartnerNumber = "BPNL000000011111"; final ItemContainer.ItemContainerBuilder itemContainerWithShell = ItemContainer.builder() .shell(shell("", shellDescriptor( List.of(submodelDescriptorWithDspEndpoint( @@ -198,7 +199,7 @@ void shouldCatchUsagePolicyExceptionAndPutTombstone() throws EdcClientException "address"))))); // when - when(submodelFacade.getSubmodelPayload(any(), any(), any())).thenThrow(new UsagePolicyException("itemId", null)); + when(submodelFacade.getSubmodelPayload(any(), any(), any())).thenThrow(new UsagePolicyException("itemId", null, businessPartnerNumber)); when(connectorEndpointsService.fetchConnectorEndpoints(any())).thenReturn(List.of("connector.endpoint.nl")); final ItemContainer result = relationshipDelegate.process(itemContainerWithShell, jobParameter(), new AASTransferProcess(), createKey()); @@ -207,6 +208,7 @@ void shouldCatchUsagePolicyExceptionAndPutTombstone() throws EdcClientException assertThat(result).isNotNull(); assertThat(result.getTombstones()).hasSize(1); assertThat(result.getTombstones().get(0).getCatenaXId()).isEqualTo("itemId"); + assertThat(result.getTombstones().get(0).getBusinessPartnerNumber()).isEqualTo(businessPartnerNumber); assertThat(result.getTombstones().get(0).getProcessingError().getProcessStep()).isEqualTo( ProcessStep.USAGE_POLICY_VALIDATION); } diff --git a/irs-api/src/test/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/SubmodelDelegateTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/SubmodelDelegateTest.java index 312113d974..e80ecdf3b1 100644 --- a/irs-api/src/test/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/SubmodelDelegateTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/SubmodelDelegateTest.java @@ -139,6 +139,7 @@ void shouldPutTombstoneForMissingBpn() { @Test void shouldCatchUsagePolicyExceptionAndPutTombstone() throws EdcClientException { // given + final String businessPartnerNumber = "BPNL000000011111"; final ItemContainer.ItemContainerBuilder itemContainerShellWithTwoSubmodels = ItemContainer.builder() .shell(shell("", shellDescriptor( List.of(submodelDescriptorWithDspEndpoint( @@ -149,7 +150,7 @@ void shouldCatchUsagePolicyExceptionAndPutTombstone() throws EdcClientException "testSingleLevelBomAsBuiltEndpoint"))))); // when - when(submodelFacade.getSubmodelPayload(any(), any(), any())).thenThrow(new UsagePolicyException("itemId", null)); + when(submodelFacade.getSubmodelPayload(any(), any(), any())).thenThrow(new UsagePolicyException("itemId", null, businessPartnerNumber)); when(connectorEndpointsService.fetchConnectorEndpoints(any())).thenReturn(List.of("connector.endpoint.nl")); final ItemContainer result = submodelDelegate.process(itemContainerShellWithTwoSubmodels, jobParameterCollectAspects(), new AASTransferProcess(), createKey()); @@ -158,6 +159,7 @@ void shouldCatchUsagePolicyExceptionAndPutTombstone() throws EdcClientException assertThat(result).isNotNull(); assertThat(result.getTombstones()).hasSize(2); assertThat(result.getTombstones().get(0).getCatenaXId()).isEqualTo("itemId"); + assertThat(result.getTombstones().get(0).getBusinessPartnerNumber()).isEqualTo(businessPartnerNumber); assertThat(result.getTombstones().get(0).getProcessingError().getProcessStep()).isEqualTo( ProcessStep.USAGE_POLICY_VALIDATION); } diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/ContractNegotiationService.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/ContractNegotiationService.java index 63def1d591..ebe0689cc3 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/ContractNegotiationService.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/ContractNegotiationService.java @@ -124,7 +124,7 @@ private CompletableFuture startNewNegotiation(final String if (!policyCheckerService.isValid(catalogItem.getPolicy())) { log.info("Policy was not allowed, canceling negotiation."); - throw new UsagePolicyException(catalogItem.getItemId(), catalogItem.getPolicy()); + throw new UsagePolicyException(catalogItem.getItemId(), catalogItem.getPolicy(), catalogItem.getConnectorId()); } final NegotiationRequest negotiationRequest = createNegotiationRequestFromCatalogItem(providerConnectorUrl, diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/exceptions/UsagePolicyException.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/exceptions/UsagePolicyException.java index dcf419790b..5956b37c94 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/exceptions/UsagePolicyException.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/exceptions/UsagePolicyException.java @@ -33,10 +33,12 @@ public class UsagePolicyException extends EdcClientException { private final transient Policy policy; + private final String businessPartnerNumber; - public UsagePolicyException(final String itemId, final Policy policy) { + public UsagePolicyException(final String itemId, final Policy policy, final String businessPartnerNumber) { super("Consumption of asset '" + itemId + "' is not permitted as the required catalog offer policies do not comply with defined IRS policies."); this.policy = policy; + this.businessPartnerNumber = businessPartnerNumber; } } diff --git a/irs-models/src/main/java/org/eclipse/tractusx/irs/component/Tombstone.java b/irs-models/src/main/java/org/eclipse/tractusx/irs/component/Tombstone.java index 268a33c8c4..0822260099 100644 --- a/irs-models/src/main/java/org/eclipse/tractusx/irs/component/Tombstone.java +++ b/irs-models/src/main/java/org/eclipse/tractusx/irs/component/Tombstone.java @@ -51,39 +51,45 @@ public class Tombstone { pattern = "^urn:uuid:[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$") private final String catenaXId; private final String endpointURL; + private final String businessPartnerNumber; private final ProcessingError processingError; private final Map policy; public static Tombstone from(final String catenaXId, final String endpointURL, final Exception exception, final int retryCount, final ProcessStep processStep) { - return from(catenaXId, endpointURL, exception.getMessage(), retryCount, processStep, null); - } - - public static Tombstone from(final String catenaXId, final String endpointURL, final String errorDetails, - final int retryCount, final ProcessStep processStep) { - return from(catenaXId, endpointURL, errorDetails, retryCount, processStep, null); + return from(catenaXId, endpointURL, exception.getMessage(), retryCount, processStep); } public static Tombstone from(final String catenaXId, final String endpointURL, final Exception exception, - final int retryCount, final ProcessStep processStep, final Map policy) { - return from(catenaXId, endpointURL, exception.getMessage(), retryCount, processStep, policy); + final int retryCount, final ProcessStep processStep, final String businessPartnerNumber, final Map policy) { + + return Tombstone.builder() + .endpointURL(endpointURL) + .catenaXId(catenaXId) + .processingError(withProcessingError(processStep, retryCount, exception.getMessage())) + .businessPartnerNumber(businessPartnerNumber) + .policy(policy) + .build(); } public static Tombstone from(final String catenaXId, final String endpointURL, final String errorDetails, - final int retryCount, final ProcessStep processStep, final Map policy) { + final int retryCount, final ProcessStep processStep) { - final ProcessingError processingError = ProcessingError.builder() - .withProcessStep(processStep) - .withRetryCounter(retryCount) - .withLastAttempt(ZonedDateTime.now(ZoneOffset.UTC)) - .withErrorDetail(errorDetails) - .build(); return Tombstone.builder() .endpointURL(endpointURL) .catenaXId(catenaXId) - .processingError(processingError) - .policy(policy) + .processingError(withProcessingError(processStep, retryCount, errorDetails)) .build(); } + private static ProcessingError withProcessingError(final ProcessStep processStep, final int retryCount, + final String exception) { + return ProcessingError.builder() + .withProcessStep(processStep) + .withRetryCounter(retryCount) + .withLastAttempt(ZonedDateTime.now(ZoneOffset.UTC)) + .withErrorDetail(exception) + .build(); + } + }