Skip to content

Commit

Permalink
Merge branch 'main' into feat/803-get-policy-by-id
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
dsmf committed Jul 15, 2024
2 parents f92340c + 5ca63e5 commit 4a0ad32
Show file tree
Hide file tree
Showing 18 changed files with 330 additions and 40 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ _**For better traceability add the corresponding GitHub issue number in each cha
### Added

- Added endpoint: `GET /irs/policies/{policyId}`. #803

## [5.3.0] - 2024-07-15

### Added

- Added filtering by "createdOn", "validUntil" to paging endpoint for Policy Store API: `GET /irs/policies/paged`. #750
- Added autocomplete endpoint Policy Store API: `GET /irs/policies/attributes/{attribute}`. #750
- Added get and delete functionality for contract definitions eclipse-tractusx/traceability-foss#1190

Expand Down Expand Up @@ -728,7 +734,8 @@ _**For better traceability add the corresponding GitHub issue number in each cha
- **Select Aspects you need** You are able to select the needed aspects for which you want to collect the correct endpoint information.


[Unreleased]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.2.0...HEAD
[Unreleased]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.3.0...HEAD
[5.3.0]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.2.0...5.3.0
[5.2.0]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.1.4...5.2.0
[5.1.4]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.1.3...5.1.4
[5.1.3]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.1.2...5.1.3
Expand Down
19 changes: 18 additions & 1 deletion COMPATIBILITY_MATRIX.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,24 @@ Full changelog of IRS: [changelog](CHANGELOG.md)
| Discovery Finder | 0.2.5 | - | REST connection |
| Minio | RELEASE.2022-11-11T03-44-20Z | 5.0.1 | |
| Helm | 3.9.3 | - | - |
| Kubernetes | 1.29 | - | - |
| Kubernetes | [ 1.28; 1.29; 1.30 ] | - | - |
| [SingleLevelBomAsBuilt](https://github.com/eclipse-tractusx/sldt-semantic-models/tree/main/io.catenax.single_level_bom_as_built) | [ 2.0.0; 3.0.0 ] | - | Model version |
| [SingleLevelBomAsPlanned](https://github.com/eclipse-tractusx/sldt-semantic-models/tree/main/io.catenax.single_level_bom_as_planned) | [ 2.0.0; 3.0.0 ] | - | Model version |
| [SingleLevelBomAsSpecified](https://github.com/eclipse-tractusx/sldt-semantic-models/tree/main/io.catenax.single_level_bom_as_specified) | 2.0.0 | - | Model version |
| [SingleLevelUsageAsBuilt](https://github.com/eclipse-tractusx/sldt-semantic-models/tree/main/io.catenax.single_level_usage_as_built) | 3.0.0 | - | Model version |
| [SingleLevelUsageAsPlanned](https://github.com/eclipse-tractusx/sldt-semantic-models/tree/main/io.catenax.single_level_usage_as_planned) | 2.0.0 | - | Model version |

## [CATENA-X Release 24.08](https://eclipse-tractusx.github.io/CHANGELOG/) - [5.3.0](https://github.com/eclipse-tractusx/item-relationship-service/releases/tag/5.3.0) - 2024-07-15

| Dependency | Version | Helm | Comments |
|------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|-------|-----------------|
| EDC | 0.7.1 | 0.7.1 | |
| Semantics Hub | 0.3.1 | 0.2.1 | REST connection |
| DTR | 0.4.1 | 0.4.9 | REST connection |
| Discovery Finder | 0.2.5 | - | REST connection |
| Minio | RELEASE.2022-11-11T03-44-20Z | 5.0.1 | |
| Helm | 3.9.3 | - | - |
| Kubernetes | [ 1.28; 1.29; 1.30 ] | - | - |
| [SingleLevelBomAsBuilt](https://github.com/eclipse-tractusx/sldt-semantic-models/tree/main/io.catenax.single_level_bom_as_built) | [ 2.0.0; 3.0.0 ] | - | Model version |
| [SingleLevelBomAsPlanned](https://github.com/eclipse-tractusx/sldt-semantic-models/tree/main/io.catenax.single_level_bom_as_planned) | [ 2.0.0; 3.0.0 ] | - | Model version |
| [SingleLevelBomAsSpecified](https://github.com/eclipse-tractusx/sldt-semantic-models/tree/main/io.catenax.single_level_bom_as_specified) | 2.0.0 | - | Model version |
Expand Down
10 changes: 5 additions & 5 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,12 @@ maven/mavencentral/org.eclipse.tractusx.edc/core-spi/0.6.0, Apache-2.0, approved
maven/mavencentral/org.eclipse.tractusx.edc/edr-api/0.6.0, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.edc/edr-spi/0.6.0, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-api/0.0.2-SNAPSHOT, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-common/2.1.6, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-edc-client/2.1.6, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-models/2.1.6, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-common/2.1.7, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-edc-client/2.1.7, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-models/2.1.7, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-policy-store/0.0.2-SNAPSHOT, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-registry-client/2.1.6, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-testing/2.1.6, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-registry-client/2.1.7, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-testing/2.1.7, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.glassfish/jakarta.json/2.0.1, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jsonp
maven/mavencentral/org.hamcrest/hamcrest-core/2.2, BSD-3-Clause, approved, clearlydefined
maven/mavencentral/org.hamcrest/hamcrest/2.2, BSD-3-Clause, approved, clearlydefined
Expand Down
6 changes: 6 additions & 0 deletions charts/item-relationship-service/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [7.3.0] - 2024-07-15

### Changed

- Update IRS version to 5.3.0

## [7.2.1] - 2024-07-10
- Update bitnami/common to 2.x.x

Expand Down
4 changes: 2 additions & 2 deletions charts/item-relationship-service/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 7.2.1
version: 7.3.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "5.2.0"
appVersion: "5.3.0"
dependencies:
- name: common
repository: https://charts.bitnami.com/bitnami
Expand Down
2 changes: 1 addition & 1 deletion docs/src/api/irs-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ info:
description: The API of the Item Relationship Service (IRS) for retrieving item
graphs along the value chain of CATENA-X partners.
title: IRS API
version: 5.2.0
version: 5.3.0
servers:
- url: http://localhost:8080
security:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class IrsApplication {
/**
* The IRS API version.
*/
public static final String API_VERSION = "5.2.0";
public static final String API_VERSION = "5.3.0";

/**
* The URL prefix for IRS API URLs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ void shouldCreateDetailedTombstoneForMissmatchPolicy() {
final Tombstone actualTombstone = jobForJobId.getTombstones().get(0);
assertThat(actualTombstone.getProcessingError().getRootCauses()).hasSize(1);
assertThat(actualTombstone.getProcessingError().getRootCauses().get(0)).contains(
"Asset could not be negotiated for providerWithSuffix 'https://test.edc.io/api/v1/dsp', BPN 'BPNL00000000TEST', catalogItem");
"UsagePolicyPermissionException: Policies [default-policy] did not match with policy from BPNL00000000TEST.");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void shouldUseSuppressedExceptionWhenPresent() {

// assert
assertThat(from.getProcessingError().getErrorDetail()).isEqualTo(exception.getMessage());
assertThat(from.getProcessingError().getRootCauses()).contains(suppressedExceptionMessage);
assertThat(from.getProcessingError().getRootCauses()).contains("Exception: " + suppressedExceptionMessage);
}

@Test
Expand All @@ -93,7 +93,8 @@ void shouldUseDeepSuppressedExceptionWhenPresent() {
final Exception exception = new Exception("Exception occurred.");

final Exception rootCause = new Exception("Wrapper exception to the root cause");
rootCause.addSuppressed(new Exception("Root cause of the exception"));
final String suppressedRootCause = "Root cause of the exception";
rootCause.addSuppressed(new Exception(suppressedRootCause));

final Exception suppressedWrapperException = new Exception(
"Suppressed Exception which was added through Futures.", rootCause);
Expand All @@ -107,7 +108,7 @@ void shouldUseDeepSuppressedExceptionWhenPresent() {

// assert
assertThat(from.getProcessingError().getErrorDetail()).isEqualTo(exception.getMessage());
assertThat(from.getProcessingError().getRootCauses()).contains("Root cause of the exception");
assertThat(from.getProcessingError().getRootCauses()).contains("Exception: " + suppressedRootCause);
}

@Test
Expand Down
5 changes: 5 additions & 0 deletions irs-models/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;
import lombok.extern.jackson.Jacksonized;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.eclipse.tractusx.irs.component.enums.NodeType;
import org.eclipse.tractusx.irs.component.enums.ProcessStep;

Expand Down Expand Up @@ -88,8 +88,8 @@ public static Tombstone from(final String catenaXId, final String endpointURL, f

public static Tombstone from(final String globalAssetId, final String endpointURL, final Throwable exception,
final Throwable[] suppressed, final int retryCount, final ProcessStep processStep) {
final ProcessingError processingError =
withProcessingError(processStep, retryCount, exception.getMessage(), suppressed);
final ProcessingError processingError = withProcessingError(processStep, retryCount, exception.getMessage(),
suppressed);
return Tombstone.builder()
.endpointURL(endpointURL)
.catenaXId(globalAssetId)
Expand All @@ -99,7 +99,7 @@ public static Tombstone from(final String globalAssetId, final String endpointUR

private static ProcessingError withProcessingError(final ProcessStep processStep, final int retryCount,
final String message, final Throwable... suppressed) {
final List<String> rootCauses = Arrays.stream(suppressed).flatMap(Tombstone::getErrorMessages).toList();
final List<String> rootCauses = Arrays.stream(suppressed).map(Tombstone::getRootErrorMessages).toList();

return ProcessingError.builder()
.withProcessStep(processStep)
Expand All @@ -110,12 +110,31 @@ private static ProcessingError withProcessingError(final ProcessStep processStep
.build();
}

private static Stream<String> getErrorMessages(final Throwable throwable) {
/**
* Search for the root cause or suppressed exception as long as there is a cause or suppressed exception.
* Stop after a depth of 10 to prevent endless loop.
*
* @param throwable the exception with a nested or suppressed exception
* @return the root cause, eiter suppressed or nested
*/
private static String getRootErrorMessages(final Throwable throwable) {
final Throwable cause = throwable.getCause();
if (cause != null && hasSuppressedExceptions(cause)) {
return Arrays.stream(throwable.getCause().getSuppressed()).map(Throwable::getMessage);

if (cause != null) {
Throwable rootCause = cause;
int depth = 0;
final int maxDepth = 10;
while ((rootCause.getCause() != null || hasSuppressedExceptions(rootCause)) && depth < maxDepth) {
if (hasSuppressedExceptions(rootCause)) {
rootCause = rootCause.getSuppressed()[0];
} else {
rootCause = rootCause.getCause();
}
depth++;
}
return ExceptionUtils.getRootCauseMessage(rootCause);
}
return Stream.of(throwable.getMessage());
return ExceptionUtils.getRootCauseMessage(throwable);
}

private static ProcessingError withProcessingError(final ProcessStep processStep, final int retryCount,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/********************************************************************************
* 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.policystore.common;

import java.time.LocalDate;
import java.time.LocalTime;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;

/**
* Date utilities.
*/
public final class DateUtils {

private DateUtils() {
// private constructor (utility class)
}

public static boolean isDateBefore(final OffsetDateTime dateTime, final String referenceDateString) {
return dateTime.isBefore(toOffsetDateTimeAtStartOfDay(referenceDateString));
}

public static boolean isDateAfter(final OffsetDateTime dateTime, final String referenceDateString) {
return dateTime.isAfter(toOffsetDateTimeAtEndOfDay(referenceDateString));
}

public static OffsetDateTime toOffsetDateTimeAtStartOfDay(final String dateString) {
return LocalDate.parse(dateString).atStartOfDay().atOffset(ZoneOffset.UTC);
}

public static OffsetDateTime toOffsetDateTimeAtEndOfDay(final String dateString) {
return LocalDate.parse(dateString).atTime(LocalTime.MAX).atOffset(ZoneOffset.UTC);
}
}
Loading

0 comments on commit 4a0ad32

Please sign in to comment.