Skip to content

Commit

Permalink
Merge pull request #914 from catenax-ng/feature/#358-update-edc-0.7.0
Browse files Browse the repository at this point in the history
Feature/#358 update edc 0.7.0
  • Loading branch information
ds-mwesener authored May 6, 2024
2 parents f6c9812 + b1d3920 commit 36a46a8
Show file tree
Hide file tree
Showing 70 changed files with 2,343 additions and 768 deletions.
2 changes: 1 addition & 1 deletion .config/pmd-rules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<rule ref="category/java/documentation.xml/CommentSize">
<properties>
<property name="maxLines" value="23"/>
<property name="maxLineLength" value="100"/>
<property name="maxLineLength" value="120"/>
</properties>
</rule>
<rule ref="category/java/documentation.xml/CommentRequired">
Expand Down
9 changes: 2 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,13 @@ _**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

- Removed obsolete entries from acceptedPolicies configuration. #530
- Support of building relationships based on SingleLevelUsageAsBuilt v3.0.0 #558
- Support of building relationships based on SingleLevelBomAsPlanned v3.0.0 #558
- BPN lookup feature was removed #568
- Update IRS EDC client to use EDC 0.7.0 #358

### Fixed

Expand Down
219 changes: 82 additions & 137 deletions DEPENDENCIES

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion charts/item-relationship-service/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fix for incomplete renaming of Helm chart (see #489)

- Fixed missing Spring attribute #358


## [7.0.1] - 2024-04-17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ data:
client:
registration:
semantics:
authorization-grant-type: client_credentials
client-id: "${SEMANTICS_OAUTH2_CLIENT_ID}" # taken from secret ENV
client-secret: "${SEMANTICS_OAUTH2_CLIENT_SECRET}" # taken from secret ENV
discovery:
authorization-grant-type: client_credentials
client-id: ${DISCOVERY_OAUTH2_CLIENT_ID} # taken from secret ENV
client-secret: ${DISCOVERY_OAUTH2_CLIENT_SECRET} # taken from secret ENV
provider:
Expand Down
2 changes: 1 addition & 1 deletion irs-api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spring:
oauth2:
client:
registration:
semantics :
semantics:
authorization-grant-type: client_credentials
client-id: ${SEMANTICS_OAUTH2_CLIENT_ID} # Semantic Hub OAuth2 client ID used to authenticate with the IAM
client-secret: ${SEMANTICS_OAUTH2_CLIENT_SECRET} # Semantic Hub OAuth2 client secret used to authenticate with the IAM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import static org.eclipse.tractusx.irs.WiremockSupport.createEndpointDataReference;
import static org.eclipse.tractusx.irs.WiremockSupport.encodedAssetIds;
import static org.eclipse.tractusx.irs.WiremockSupport.randomUUID;
import static org.eclipse.tractusx.irs.component.enums.AspectType.AspectTypesConstants.BATCH;
import static org.eclipse.tractusx.irs.component.enums.AspectType.AspectTypesConstants.SINGLE_LEVEL_BOM_AS_BUILT;
import static org.eclipse.tractusx.irs.testing.wiremock.DiscoveryServiceWiremockSupport.DISCOVERY_FINDER_PATH;
import static org.eclipse.tractusx.irs.testing.wiremock.DiscoveryServiceWiremockSupport.DISCOVERY_FINDER_URL;
import static org.eclipse.tractusx.irs.testing.wiremock.DiscoveryServiceWiremockSupport.EDC_DISCOVERY_PATH;
Expand Down Expand Up @@ -58,7 +60,6 @@
import org.eclipse.tractusx.irs.component.Jobs;
import org.eclipse.tractusx.irs.component.RegisterJob;
import org.eclipse.tractusx.irs.component.enums.JobState;
import org.eclipse.tractusx.irs.data.StringMapper;
import org.eclipse.tractusx.irs.edc.client.EndpointDataReferenceStorage;
import org.eclipse.tractusx.irs.semanticshub.AspectModels;
import org.eclipse.tractusx.irs.semanticshub.SemanticHubWireMockSupport;
Expand Down Expand Up @@ -111,12 +112,6 @@ static void startContainer() {
WiremockSupport.successfulSemanticModelRequest();
}

@AfterEach
void tearDown() {
cacheManager.getCacheNames()
.forEach(cacheName -> Objects.requireNonNull(cacheManager.getCache(cacheName)).clear());
}

@AfterAll
static void stopContainer() {
minioContainer.stop();
Expand All @@ -141,6 +136,12 @@ static void configureProperties(DynamicPropertyRegistry registry) {
registry.add("resilience4j.retry.configs.default.waitDuration", () -> "1s");
}

@AfterEach
void tearDown() {
cacheManager.getCacheNames()
.forEach(cacheName -> Objects.requireNonNull(cacheManager.getCache(cacheName)).clear());
}

@Test
void shouldStartApplicationAndCollectSemanticModels() throws SchemaNotFoundException {
// Arrange
Expand Down Expand Up @@ -264,7 +265,6 @@ void shouldStartRecursiveProcesses() {
assertThat(jobHandle.getId()).isNotNull();
waitForCompletion(jobHandle);
final Jobs jobForJobId = irsService.getJobForJobId(jobHandle.getId(), false);
System.out.println(StringMapper.mapToString(jobForJobId));

assertThat(jobForJobId.getJob().getState()).isEqualTo(JobState.COMPLETED);
assertThat(jobForJobId.getShells()).hasSize(3);
Expand All @@ -280,10 +280,9 @@ private void successfulRegistryAndDataRequest(final String globalAssetId, final
final String batchFileName, final String sbomFileName) {

final String edcAssetId = WiremockSupport.randomUUIDwithPrefix();
final String batch = WiremockSupport.submodelRequest(edcAssetId, "Batch",
batchAspectName, batchFileName);
final String batch = WiremockSupport.submodelRequest(edcAssetId, BATCH, batchAspectName, batchFileName);

final String singleLevelBomAsBuilt = WiremockSupport.submodelRequest(edcAssetId, "SingleLevelBomAsBuilt",
final String singleLevelBomAsBuilt = WiremockSupport.submodelRequest(edcAssetId, SINGLE_LEVEL_BOM_AS_BUILT,
singleLevelBomAsBuiltAspectName, sbomFileName);

final List<String> submodelDescriptors = List.of(batch, singleLevelBomAsBuilt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public static EndpointDataReference createEndpointDataReference(final String con
.getBytes(StandardCharsets.UTF_8));
final String jwtToken = "eyJhbGciOiJSUzI1NiJ9." + b64EncodedAuthCode + ".test";
return EndpointDataReference.Builder.newInstance()
.authKey("testkey")
.contractId(contractAgreementId)
.authKey("Authorization")
.id("test")
.authCode(jwtToken)
.properties(
Map.of(JsonLdConfiguration.NAMESPACE_EDC_CID, contractAgreementId))
Expand Down
83 changes: 45 additions & 38 deletions irs-edc-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
<artifactId>commons-validator</artifactId>
<version>${commons-validator.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>${commons-collections4.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand Down Expand Up @@ -96,78 +101,80 @@
<artifactId>swagger-annotations</artifactId>
<version>${swagger-annotations.version}</version>
</dependency>

<!-- EDC Client -->
<dependency>
<groupId>org.eclipse.edc</groupId>
<artifactId>connector-core</artifactId>
<artifactId>management-api</artifactId>
<version>${edc.version}</version>
<exclusions>
<exclusion>
<artifactId>runtime-metamodel</artifactId>
<groupId>org.eclipse.edc</groupId>
</exclusion>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
</exclusion>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk18on</artifactId>
<artifactId>swagger-jaxrs2-jakarta</artifactId>
<groupId>io.swagger.core.v3</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- Below overrides the one provided with above EDC Client -->
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio-jvm</artifactId>
<version>${okio-jvm.version}</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk18on</artifactId>
<version>${bc-jdk18on.version}</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
<version>${bc-jdk18on.version}</version>
<groupId>org.eclipse.edc</groupId>
<artifactId>policy-engine-lib</artifactId>
<version>${edc.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.edc</groupId>
<artifactId>dsp</artifactId>
<artifactId>connector-core</artifactId>
<version>${edc.version}</version>
<exclusions>
<exclusion>
<artifactId>runtime-metamodel</artifactId>
<artifactId>bcpkix-jdk18on</artifactId>
<groupId>org.bouncycastle</groupId>
</exclusion>
<exclusion>
<artifactId>policy-engine-lib</artifactId>
<groupId>org.eclipse.edc</groupId>
</exclusion>
<exclusion>
<artifactId>websocket-jakarta-server</artifactId>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>policy-engine-spi</artifactId>
<groupId>org.eclipse.edc</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-jakarta-server</artifactId>
<version>11.0.17</version>
</dependency>
<dependency>
<groupId>org.eclipse.edc</groupId>
<artifactId>json-ld</artifactId>
<artifactId>dsp</artifactId>
<version>${edc.version}</version>
<exclusions>
<exclusion>
<artifactId>runtime-metamodel</artifactId>
<groupId>org.eclipse.edc</groupId>
<artifactId>swagger-jaxrs2-jakarta</artifactId>
<groupId>io.swagger.core.v3</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<artifactId>runtime-metamodel</artifactId>
<groupId>org.eclipse.edc</groupId>
<artifactId>json-ld-lib</artifactId>
<version>${edc.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.tractusx.edc</groupId>
<artifactId>edr-api</artifactId>
<version>${edc.version}</version>
<exclusions>
<exclusion>
<artifactId>management-api</artifactId>
<groupId>org.eclipse.edc</groupId>
</exclusion>
<exclusion>
<artifactId>validator-core</artifactId>
<groupId>org.eclipse.edc</groupId>
</exclusion>
<exclusion>
<artifactId>swagger-jaxrs2-jakarta</artifactId>
<groupId>io.swagger.core.v3</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- EDC Client -->

<dependency>
<groupId>org.eclipse.tractusx.irs</groupId>
<artifactId>irs-common</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
********************************************************************************/
package org.eclipse.tractusx.irs.edc.client;

import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
Expand All @@ -34,12 +36,13 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.edc.spi.types.domain.DataAddress;
import org.eclipse.edc.spi.types.domain.callback.CallbackAddress;
import org.eclipse.tractusx.irs.edc.client.cache.endpointdatareference.EndpointDataReferenceStatus;
import org.eclipse.tractusx.irs.edc.client.exceptions.ContractNegotiationException;
import org.eclipse.tractusx.irs.edc.client.exceptions.TransferProcessException;
import org.eclipse.tractusx.irs.edc.client.exceptions.UsagePolicyException;
import org.eclipse.tractusx.irs.edc.client.model.CatalogItem;
import org.eclipse.tractusx.irs.edc.client.model.ContractOfferDescription;
import org.eclipse.tractusx.irs.edc.client.model.ContractOffer;
import org.eclipse.tractusx.irs.edc.client.model.EDRAuthCode;
import org.eclipse.tractusx.irs.edc.client.model.NegotiationRequest;
import org.eclipse.tractusx.irs.edc.client.model.NegotiationResponse;
Expand All @@ -60,6 +63,8 @@
public class ContractNegotiationService {

public static final String EDC_PROTOCOL = "dataspace-protocol-http";
public static final String EVENT_TRANSFER_PROCESS_STARTED = "transfer.process.started";
public static final String HTTP_DATA_PULL = "HttpData-PULL";
private final EdcControlPlaneClient edcControlPlaneClient;
private final PolicyCheckerService policyCheckerService;
private final EdcConfiguration config;
Expand Down Expand Up @@ -94,7 +99,7 @@ public NegotiationResponse negotiate(final String providerConnectorUrl, final Ca
if (authCode == null) {
throw new IllegalStateException("Missing information about AuthKey.");
}
log.error("AuthCode to be parsed: " + authCode);
log.error("AuthCode to be parsed: {}", authCode);
contractAgreementId = EDRAuthCode.fromAuthCodeToken(authCode).getCid();
log.info(
"Cached endpoint data reference has expired token. Refreshing token without new contract negotiation for contractAgreementId: {}",
Expand Down Expand Up @@ -148,30 +153,34 @@ private TransferProcessRequest createTransferProcessRequest(final String provide
.managedResources(
TransferProcessRequest.DEFAULT_MANAGED_RESOURCES)
.connectorId(catalogItem.getConnectorId())
.connectorAddress(providerConnectorUrl)
.counterPartyAddress(providerConnectorUrl)
.transferType(HTTP_DATA_PULL)
.contractId(agreementId)
.assetId(catalogItem.getAssetPropId())
.dataDestination(destination);
if (StringUtils.isNotBlank(config.getCallbackUrl())) {
log.info("Setting EDR callback to {}", config.getCallbackUrl());
transferProcessRequestBuilder.privateProperties(Map.of("receiverHttpEndpoint", config.getCallbackUrl()));
final CallbackAddress callbackAddress = CallbackAddress.Builder.newInstance()
.uri(config.getCallbackUrl())
.events(Set.of(
EVENT_TRANSFER_PROCESS_STARTED))
.build();
transferProcessRequestBuilder.callbackAddresses(List.of(callbackAddress));
}
return transferProcessRequestBuilder.build();
}

private NegotiationRequest createNegotiationRequestFromCatalogItem(final String providerConnectorUrl,
final CatalogItem catalogItem) {
final var contractOfferDescription = ContractOfferDescription.builder()
.offerId(catalogItem.getOfferId())
.assetId(catalogItem.getPolicy().getTarget())
.policy(catalogItem.getPolicy())
.build();

return NegotiationRequest.builder()
.connectorId(catalogItem.getConnectorId())
.connectorAddress(providerConnectorUrl)
.counterPartyAddress(providerConnectorUrl)
.counterPartyId(catalogItem.getConnectorId())
.protocol(EDC_PROTOCOL)
.offer(contractOfferDescription)
.contractOffer(
ContractOffer.fromPolicy(catalogItem.getPolicy(), catalogItem.getOfferId(),
catalogItem.getAssetPropId(), catalogItem.getConnectorId()))
.build();
}

Expand Down
Loading

0 comments on commit 36a46a8

Please sign in to comment.