Skip to content

Commit

Permalink
build: bump EDC to 0.6.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt committed May 13, 2024
1 parent 1af902d commit 209ac58
Show file tree
Hide file tree
Showing 23 changed files with 67 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@
"contractId": "{{contract-agreement-id}}",
"assetId": "assetId",
"protocol": "dataspace-protocol-http",
"dataDestination": {
"type": "HttpProxy"
}
"transferType": "HttpData-PULL"
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
import org.eclipse.edc.boot.system.DefaultServiceExtensionContext;
import org.eclipse.edc.boot.system.runtime.BaseRuntime;
import org.eclipse.edc.spi.monitor.Monitor;
import org.eclipse.edc.spi.system.ConfigurationExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;
import org.eclipse.edc.spi.system.configuration.Config;
import org.jetbrains.annotations.NotNull;

import java.util.List;

public class CustomRuntime extends BaseRuntime {

/**
Expand All @@ -34,27 +32,22 @@ public static void main(String[] args) {
}

@Override
protected String getRuntimeName(ServiceExtensionContext context) {
return "CUSTOM-RUNTIME";
}

@Override
protected @NotNull ServiceExtensionContext createContext(Monitor monitor) {
protected @NotNull ServiceExtensionContext createContext(Monitor monitor, Config config) {
//override the default service extension context with a super customized one
return new SuperCustomExtensionContext(monitor, loadConfigurationExtensions());
return new SuperCustomExtensionContext(monitor, config);
}

@Override
protected void shutdown() {
public void shutdown() {
super.shutdown();

//this is the custom part here:
monitor.info(" CUSTOM RUNTIME SHUTDOWN ! ");
}

private static class SuperCustomExtensionContext extends DefaultServiceExtensionContext {
SuperCustomExtensionContext(Monitor monitor, List<ConfigurationExtension> configurationExtensions) {
super(monitor, configurationExtensions);
SuperCustomExtensionContext(Monitor monitor, Config config) {
super(monitor, config);
}
}
}
7 changes: 0 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ allprojects {
configDirectory.set(rootProject.file("resources"))
}

// EdcRuntimeExtension uses this to determine the runtime classpath of the module to run.
tasks.register("printClasspath") {
doLast {
println(sourceSets["main"].runtimeClasspath.asPath)
}
}

tasks.test {
testLogging {
showStandardStreams = true
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ format.version = "1.1"
[versions]
assertj = "3.25.3"
awaitility = "4.2.1"
edc = "0.6.0"
edc = "0.6.4"
jakarta-json = "2.0.1"
junit-pioneer = "2.2.0"
jupiter = "5.10.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;

import static org.eclipse.edc.connector.contract.spi.validation.ContractValidationService.NEGOTIATION_SCOPE;
import static org.eclipse.edc.connector.controlplane.contract.spi.validation.ContractValidationService.NEGOTIATION_SCOPE;
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_USE_ACTION_ATTRIBUTE;
import static org.eclipse.edc.policy.engine.spi.PolicyEngine.ALL_SCOPES;
import static org.eclipse.edc.spi.CoreConstants.EDC_NAMESPACE;
import static org.eclipse.edc.spi.constants.CoreConstants.EDC_NAMESPACE;

public class PolicyFunctionsExtension implements ServiceExtension {
private static final String LOCATION_CONSTRAINT_KEY = EDC_NAMESPACE + "location";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package org.eclipse.edc.samples.advanced;

import org.apache.http.HttpStatus;
import org.eclipse.edc.connector.transfer.spi.types.TransferProcessStates;
import org.eclipse.edc.junit.annotations.EndToEndTest;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
Expand All @@ -31,6 +30,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcessStates.STARTED;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileContentFromRelativePath;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileFromRelativePath;
import static org.eclipse.edc.samples.common.NegotiationCommon.createAsset;
Expand Down Expand Up @@ -75,7 +75,7 @@ void runSampleSteps() {
var contractNegotiationId = negotiateContract(NEGOTIATE_CONTRACT_FILE_PATH, catalogDatasetId);
var contractAgreementId = getContractAgreementId(contractNegotiationId);
var transferProcessId = startTransfer(getFileContentFromRelativePath(START_TRANSFER_FILE_PATH), contractAgreementId);
checkTransferStatus(transferProcessId, TransferProcessStates.STARTED);
checkTransferStatus(transferProcessId, STARTED);
assertJaegerState();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package org.eclipse.edc.samples.transfer;

import org.apache.http.HttpStatus;
import org.eclipse.edc.connector.transfer.spi.types.TransferProcessStates;
import org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcessStates;
import org.eclipse.edc.junit.annotations.EndToEndTest;
import org.eclipse.edc.junit.extensions.EdcRuntimeExtension;
import org.eclipse.edc.samples.util.HttpRequestLoggerConsumer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

package org.eclipse.edc.samples.transfer;

import org.eclipse.edc.connector.transfer.spi.types.TransferProcessStates;
import org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcessStates;
import org.eclipse.edc.junit.annotations.EndToEndTest;
import org.eclipse.edc.junit.extensions.EdcRuntimeExtension;
import org.eclipse.edc.samples.util.HttpRequestLoggerConsumer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

package org.eclipse.edc.samples.transfer;

import org.eclipse.edc.connector.transfer.spi.types.TransferProcessStates;
import org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcessStates;
import org.eclipse.edc.junit.annotations.EndToEndTest;
import org.eclipse.edc.junit.extensions.EdcRuntimeExtension;
import org.eclipse.edc.samples.util.HttpRequestLoggerContainer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,17 @@
import static jakarta.json.Json.createObjectBuilder;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.eclipse.edc.connector.contract.spi.types.negotiation.ContractNegotiationStates.FINALIZED;
import static org.awaitility.Awaitility.setDefaultTimeout;
import static org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractNegotiationStates.FINALIZED;
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.CONTEXT;
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID;
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE;
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCAT_DATASET_ATTRIBUTE;
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_ASSIGNER_ATTRIBUTE;
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_POLICY_ATTRIBUTE;
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.ODRL_TARGET_ATTRIBUTE;
import static org.eclipse.edc.spi.CoreConstants.EDC_NAMESPACE;
import static org.eclipse.edc.spi.CoreConstants.EDC_PREFIX;
import static org.eclipse.edc.spi.constants.CoreConstants.EDC_NAMESPACE;
import static org.eclipse.edc.spi.constants.CoreConstants.EDC_PREFIX;

/**
* Essentially a wrapper around the management API enabling to test interactions with other participants, eg. catalog, transfer...
Expand All @@ -74,13 +75,14 @@ public String getName() {
return name;
}

public void registerDataPlane(List<String> sourceTypes, List<String> destinationTypes) {
public void registerDataPlane(List<String> sourceTypes, List<String> destinationTypes, List<Object> transferTypes) {
var jsonObject = Json.createObjectBuilder()
.add(CONTEXT, createObjectBuilder().add(EDC_PREFIX, EDC_NAMESPACE))
.add(ID, UUID.randomUUID().toString())
.add(EDC_NAMESPACE + "url", controlEndpoint.url + "/transfer")
.add(EDC_NAMESPACE + "allowedSourceTypes", createArrayBuilder(sourceTypes))
.add(EDC_NAMESPACE + "allowedDestTypes", createArrayBuilder(destinationTypes))
.add(EDC_NAMESPACE + "allowedTransferTypes", createArrayBuilder(transferTypes))
.build();

managementEndpoint.baseRequest()
Expand Down Expand Up @@ -247,20 +249,26 @@ public String negotiateContract(Participant provider, JsonObject offer) {
* @param assetId asset id
* @param privateProperties private properties
* @param destination data destination address
* @param transferType transfer type
* @return id of the transfer process.
*/
public String initiateTransfer(Participant provider, String contractAgreementId, String assetId, JsonObject privateProperties, JsonObject destination) {
var requestBody = createObjectBuilder()
public String initiateTransfer(Participant provider, String contractAgreementId, String assetId, JsonObject privateProperties, JsonObject destination, String transferType) {
var builder = createObjectBuilder()
.add(CONTEXT, createObjectBuilder().add(EDC_PREFIX, EDC_NAMESPACE))
.add(TYPE, "TransferRequest")
.add("dataDestination", destination)
.add("protocol", DSP_PROTOCOL)
.add("assetId", assetId)
.add("contractId", contractAgreementId)
.add("connectorId", provider.id)
.add("counterPartyAddress", provider.protocolEndpoint.url.toString())
.add("privateProperties", privateProperties)
.build();
.add("transferType", transferType);

if (destination != null) {
builder.add("dataDestination", destination);
}

var requestBody = builder.build();

return managementEndpoint.baseRequest()
.contentType(JSON)
Expand All @@ -283,13 +291,14 @@ public String initiateTransfer(Participant provider, String contractAgreementId,
* @param assetId asset id
* @param privateProperties private properties of the data request
* @param destination data destination
* @param transferType transfer type
* @return transfer process id.
*/
public String requestAsset(Participant provider, String assetId, JsonObject privateProperties, JsonObject destination) {
public String requestAsset(Participant provider, String assetId, JsonObject privateProperties, JsonObject destination, String transferType) {
var offer = getOfferForAsset(provider, assetId);

var contractAgreementId = negotiateContract(provider, offer);
var transferProcessId = initiateTransfer(provider, contractAgreementId, assetId, privateProperties, destination);
var transferProcessId = initiateTransfer(provider, contractAgreementId, assetId, privateProperties, destination, transferType);
assertThat(transferProcessId).isNotNull();
return transferProcessId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.UUID;
Expand All @@ -36,7 +37,7 @@
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcessStates.STARTED;
import static org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcessStates.STARTED;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileContentFromRelativePath;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileFromRelativePath;

Expand Down Expand Up @@ -90,7 +91,7 @@ void setUp() throws IOException {
@Test
void streamData() throws IOException {
var source = Files.createTempDirectory("source");
PROVIDER.registerDataPlane(List.of("HttpStreaming"), List.of("HttpData"));
PROVIDER.registerDataPlane(List.of("HttpStreaming"), List.of("HttpData"), List.of("HttpData-PUSH"));

PROVIDER.createAsset(getFileContentFromRelativePath(SAMPLE_FOLDER + "/asset.json")
.replace("{{sourceFolder}}", source.toString()));
Expand All @@ -101,7 +102,7 @@ void streamData() throws IOException {
.add("type", "HttpData")
.add("baseUrl", "http://localhost:" + httpReceiverPort)
.build();
var transferProcessId = CONSUMER.requestAsset(PROVIDER, "stream-asset", Json.createObjectBuilder().build(), destination);
var transferProcessId = CONSUMER.requestAsset(PROVIDER, "stream-asset", Json.createObjectBuilder().build(), destination, "HttpData-PUSH");

await().atMost(TIMEOUT).untilAsserted(() -> {
String state = CONSUMER.getTransferProcessState(transferProcessId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.io.IOException;
import java.net.URI;
import java.time.Duration;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Properties;
Expand All @@ -43,7 +44,7 @@
import static java.util.concurrent.TimeUnit.MICROSECONDS;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcessStates.STARTED;
import static org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcessStates.STARTED;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileContentFromRelativePath;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileFromRelativePath;

Expand Down Expand Up @@ -109,7 +110,7 @@ void setUp() throws IOException {
@Test
void streamData() {

PROVIDER.registerDataPlane(List.of("Kafka"), List.of("HttpData"));
PROVIDER.registerDataPlane(List.of("Kafka"), List.of("HttpData"), List.of("HttpData-PUSH"));

PROVIDER.createAsset(getFileContentFromRelativePath(SAMPLE_FOLDER + "/1-asset.json")
.replace("{{bootstrap.servers}}", kafkaContainer.getBootstrapServers())
Expand All @@ -125,7 +126,7 @@ void streamData() {
.build();

var transferProcessId = CONSUMER.requestAsset(PROVIDER, "kafka-stream-asset",
Json.createObjectBuilder().build(), destination);
Json.createObjectBuilder().build(), destination, "HttpData-PUSH");

await().atMost(TIMEOUT).untilAsserted(() -> {
var state = CONSUMER.getTransferProcessState(transferProcessId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcessStates.STARTED;
import static org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcessStates.STARTED;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileContentFromRelativePath;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileFromRelativePath;
import static org.eclipse.edc.spi.CoreConstants.EDC_NAMESPACE;
import static org.eclipse.edc.spi.constants.CoreConstants.EDC_NAMESPACE;

@Testcontainers
@EndToEndTest
Expand Down Expand Up @@ -155,7 +155,7 @@ void streamData() throws InterruptedException, JsonProcessingException {
var transferProcessPrivateProperties = Json.createObjectBuilder()
.add("receiverHttpEndpoint", "http://localhost:" + httpReceiverPort)
.build();
var transferProcessId = CONSUMER.requestAsset(PROVIDER, "kafka-stream-asset", transferProcessPrivateProperties, destination);
var transferProcessId = CONSUMER.requestAsset(PROVIDER, "kafka-stream-asset", transferProcessPrivateProperties, destination, "KafkaBroker-PULL");

await().atMost(TIMEOUT).untilAsserted(() -> {
var state = CONSUMER.getTransferProcessState(transferProcessId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import io.restassured.http.ContentType;
import org.apache.http.HttpStatus;
import org.eclipse.edc.connector.transfer.spi.types.TransferProcessStates;
import org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcessStates;

import java.time.Duration;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

package org.eclipse.edc.samples.transfer.streaming.http;

import org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcess;
import org.eclipse.edc.connector.dataplane.spi.pipeline.DataSource;
import org.eclipse.edc.connector.dataplane.spi.pipeline.DataSourceFactory;
import org.eclipse.edc.connector.transfer.spi.types.TransferProcess;
import org.eclipse.edc.spi.result.Result;
import org.eclipse.edc.spi.types.domain.transfer.DataFlowStartMessage;
import org.jetbrains.annotations.NotNull;
Expand All @@ -31,8 +31,8 @@
public class HttpStreamingDataSourceFactory implements DataSourceFactory {

@Override
public boolean canHandle(DataFlowStartMessage dataFlowStartMessage) {
return dataFlowStartMessage.getSourceDataAddress().getType().equals("HttpStreaming");
public String supportedType() {
return "HttpStreaming";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

package org.eclipse.edc.samples.streaming;

import org.eclipse.edc.connector.transfer.spi.flow.DataFlowManager;
import org.eclipse.edc.connector.controlplane.transfer.spi.flow.DataFlowManager;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

package org.eclipse.edc.samples.streaming;

import org.eclipse.edc.connector.transfer.spi.flow.DataFlowController;
import org.eclipse.edc.connector.transfer.spi.types.DataFlowResponse;
import org.eclipse.edc.connector.transfer.spi.types.TransferProcess;
import org.eclipse.edc.connector.controlplane.asset.spi.domain.Asset;
import org.eclipse.edc.connector.controlplane.transfer.spi.flow.DataFlowController;
import org.eclipse.edc.connector.controlplane.transfer.spi.types.DataFlowResponse;
import org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcess;
import org.eclipse.edc.dataaddress.kafka.spi.KafkaDataAddressSchema;
import org.eclipse.edc.policy.model.Policy;
import org.eclipse.edc.spi.response.StatusResult;
import org.eclipse.edc.spi.types.domain.DataAddress;
import org.eclipse.edc.spi.types.domain.asset.Asset;
import org.eclipse.edc.spi.types.domain.edr.EndpointDataReference;
import org.jetbrains.annotations.NotNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@
"contractId": "{{contract-agreement-id}}",
"assetId": "assetId",
"protocol": "dataspace-protocol-http",
"dataDestination": {
"type": "HttpProxy"
}
"transferType": "HttpData-PULL"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"contractId": "{{contract-agreement-id}}",
"assetId": "assetId",
"protocol": "dataspace-protocol-http",
"transferType": "HttpData-PUSH",
"dataDestination": {
"type": "HttpData",
"baseUrl": "http://localhost:4000/api/consumer/store"
Expand Down
Loading

0 comments on commit 209ac58

Please sign in to comment.