diff --git a/CHANGELOG.md b/CHANGELOG.md index b2903b383..f9d43e8c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file. ### Major Changes -- Upgrade to core-EDC version `0.1.2` +- Upgrade to core-EDC version `0.2.0` - Now using the `Dataspace Protocol` - Major changes to the management API - Examples for the new requests are located in the postman collection in the `docs` folder @@ -15,11 +15,11 @@ All notable changes to this project will be documented in this file. ### Migration Notes 1. The `MY_EDC_IDS_BASE_URL` has been renamed to `MY_EDC_PROTOCOL_BASE_URL` -1. The default value of `WEB_HTTP_PROTOCOL_PATH` been changed from `${MY_EDC_BASE_PATH}/api/v1/ids` to `${MY_EDC_BASE_PATH}/api/v1/protocol` -1. New environment variable: `EDC_PARTICIPANT_ID`: `provider` -1. New environment variable: `EDC_JSONLD_HTTPS_ENABLED`: `true` -1. New environment variable: `EDC_DSP_CALLBACK_ADDRESS`: `http://edc:11003/api/v1/protocol` -1. `v1` Management API has been deprecated in favor of the `JSON-LD` `v2` Management API. All endpoints have a `v2` prefix now (example: `http://localhost:11002/api/v1/management/assets/request` is now available at `http://localhost:11002/api/v1/management/v2/assets/request`) +2. The default value of `WEB_HTTP_PROTOCOL_PATH` been changed from `${MY_EDC_BASE_PATH}/api/v1/ids` to `${MY_EDC_BASE_PATH}/api/v1/dsp` +3. New environment variable: `EDC_PARTICIPANT_ID`: `provider` +4. New environment variable: `EDC_JSONLD_HTTPS_ENABLED`: `true` +5. New environment variable: `EDC_DSP_CALLBACK_ADDRESS`: `http://edc:11003/api/v1/dsp` +6. `v1` Management API has been deprecated in favor of the `JSON-LD` `v2` Management API. All endpoints have a `v2` prefix now (example: `http://localhost:11002/api/v1/management/assets/request` is now available at `http://localhost:11002/api/management/v2/assets/request`) ## [4.1.0] - 2023-07-24 diff --git a/connector/.env b/connector/.env index e950077cb..a79c499da 100644 --- a/connector/.env +++ b/connector/.env @@ -24,19 +24,17 @@ WEB_HTTP_MANAGEMENT_PORT=11002 WEB_HTTP_PROTOCOL_PORT=11003 WEB_HTTP_CONTROL_PORT=11004 WEB_HTTP_PATH=${MY_EDC_BASE_PATH}/api -WEB_HTTP_MANAGEMENT_PATH=${MY_EDC_BASE_PATH}/api/v1/management +WEB_HTTP_MANAGEMENT_PATH=${MY_EDC_BASE_PATH}/api/management WEB_HTTP_PROTOCOL_PATH=${MY_EDC_BASE_PATH}/api/v1/dsp WEB_HTTP_CONTROL_PATH=${MY_EDC_BASE_PATH}/api/v1/control -MY_EDC_PARTICIPANT_ID=default-participant-id -EDC_PARTICIPANT_ID=${MY_EDC_PARTICIPANT_ID} +EDC_PARTICIPANT_ID=${MY_EDC_NAME_KEBAB_CASE} EDC_JSONLD_HTTPS_ENABLED=true EDC_HOSTNAME=${MY_EDC_FQDN} EDC_UI_CONNECTOR_ID=${MY_EDC_PROTOCOL}${MY_EDC_FQDN} -MY_EDC_PROTOCOL_BASE_URL=${MY_EDC_PROTOCOL}${MY_EDC_FQDN} -EDC_DSP_CALLBACK_ADDRESS=${MY_EDC_PROTOCOL_BASE_URL}${WEB_HTTP_PROTOCOL_PATH} +EDC_DSP_CALLBACK_ADDRESS=${MY_EDC_PROTOCOL}${MY_EDC_FQDN}${WEB_HTTP_PROTOCOL_PATH} # Flyway Extension: Required MY_EDC_JDBC_URL=jdbc:postgresql://missing-postgresql-url diff --git a/connector/build.gradle.kts b/connector/build.gradle.kts index cb2e32a14..d61de02c8 100644 --- a/connector/build.gradle.kts +++ b/connector/build.gradle.kts @@ -41,12 +41,6 @@ dependencies { implementation(project(":extensions:postgres-flyway")) } - // Optional: MDS Extensions - if (project.hasProperty("mds")) { - implementation(project(":extensions:ids-clearinghouse-client")) - implementation(project(":extensions:ids-broker-client")) - } - // Optional: Connector-To-Connector IAM if (project.hasProperty("oauth2")) { implementation("${edcGroup}:oauth2-core:${edcVersion}") diff --git a/docker-compose-dev.yaml b/docker-compose-dev.yaml index b786c01fc..b49ab2616 100644 --- a/docker-compose-dev.yaml +++ b/docker-compose-dev.yaml @@ -7,7 +7,7 @@ services: environment: - EDC_UI_ACTIVE_PROFILE=${EDC_UI_ACTIVE_PROFILE} - EDC_UI_CONFIG_URL=edc-ui-config - - EDC_UI_DATA_MANAGEMENT_API_URL=http://localhost:11002/api/v1/management/v2 + - EDC_UI_DATA_MANAGEMENT_API_URL=http://localhost:11002/api/management/v2 - EDC_UI_DATA_MANAGEMENT_API_KEY=ApiKeyDefaultValue - EDC_UI_CATALOG_URLS=http://edc2:11003/api/v1/dsp edc: @@ -15,7 +15,7 @@ services: depends_on: - postgresql environment: - MY_EDC_NAME_KEBAB_CASE: "example-connector" + MY_EDC_NAME_KEBAB_CASE: "provider" MY_EDC_TITLE: "EDC Connector" MY_EDC_DESCRIPTION: "sovity Community Edition EDC Connector" MY_EDC_CURATOR_URL: "https://example.com" @@ -43,7 +43,6 @@ services: MY_EDC_PROTOCOL: "http://" MY_EDC_FQDN: "edc" - MY_EDC_PROTOCOL_BASE_URL: "http://edc:11003" MY_EDC_JDBC_URL: jdbc:postgresql://postgresql:5432/edc MY_EDC_JDBC_USER: edc @@ -52,7 +51,6 @@ services: EDC_WEB_REST_CORS_HEADERS: 'origin,content-type,accept,authorization,x-api-key' EDC_WEB_REST_CORS_ORIGINS: '*' - MY_EDC_PARTICIPANT_ID: provider EDC_DSP_CALLBACK_ADDRESS: http://edc:11003/api/v1/dsp ports: - '11001:11001' @@ -81,7 +79,7 @@ services: environment: - EDC_UI_ACTIVE_PROFILE=${EDC_UI_ACTIVE_PROFILE} - EDC_UI_CONFIG_URL=edc-ui-config - - EDC_UI_DATA_MANAGEMENT_API_URL=http://localhost:22002/api/v1/management/v2 + - EDC_UI_DATA_MANAGEMENT_API_URL=http://localhost:22002/api/management/v2 - EDC_UI_DATA_MANAGEMENT_API_KEY=ApiKeyDefaultValue - EDC_UI_CATALOG_URLS=http://edc:11003/api/v1/dsp edc2: @@ -89,7 +87,7 @@ services: depends_on: - postgresql2 environment: - MY_EDC_NAME_KEBAB_CASE: "example-connector" + MY_EDC_NAME_KEBAB_CASE: "consumer" MY_EDC_TITLE: "EDC Connector" MY_EDC_DESCRIPTION: "sovity Community Edition EDC Connector" MY_EDC_CURATOR_URL: "https://example.com" @@ -117,7 +115,6 @@ services: MY_EDC_PROTOCOL: "http://" MY_EDC_FQDN: "edc2" - MY_EDC_PROTOCOL_BASE_URL: "http://edc2:11003" MY_EDC_JDBC_URL: jdbc:postgresql://postgresql2:5432/edc MY_EDC_JDBC_USER: edc @@ -126,7 +123,6 @@ services: EDC_WEB_REST_CORS_HEADERS: 'origin,content-type,accept,authorization,x-api-key' EDC_WEB_REST_CORS_ORIGINS: '*' - MY_EDC_PARTICIPANT_ID: consumer EDC_DSP_CALLBACK_ADDRESS: http://edc2:11003/api/v1/dsp ports: - '22001:11001' diff --git a/docs/postman_collection.json b/docs/postman_collection.json index 707ef2559..ff0d03d45 100644 --- a/docs/postman_collection.json +++ b/docs/postman_collection.json @@ -885,7 +885,7 @@ "variable": [ { "key": "PROVIDER_EDC_MANAGEMENT_URL", - "value": "http://localhost:11002/api/v1/management/v2", + "value": "http://localhost:11002/api/management/v2", "type": "default" }, { @@ -900,7 +900,7 @@ }, { "key": "CONSUMER_EDC_MANAGEMENT_URL", - "value": "http://localhost:22002/api/v1/management/v2", + "value": "http://localhost:22002/api/management/v2", "type": "default" }, { diff --git a/e2e-test/src/test/java/de/sovity/edc/extension/e2e/PostgresFlywayExtensionTest.java b/e2e-test/src/test/java/de/sovity/edc/extension/e2e/PostgresFlywayExtensionTest.java index c9414c35d..45ae5ecc9 100644 --- a/e2e-test/src/test/java/de/sovity/edc/extension/e2e/PostgresFlywayExtensionTest.java +++ b/e2e-test/src/test/java/de/sovity/edc/extension/e2e/PostgresFlywayExtensionTest.java @@ -30,7 +30,7 @@ import java.util.Map; import java.util.UUID; -import static de.sovity.edc.extension.e2e.connector.config.EdcApiType.PROTOCOL; +import static de.sovity.edc.extension.e2e.connector.config.EdcApiGroup.PROTOCOL; import static jakarta.json.Json.createObjectBuilder; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; diff --git a/e2e-test/src/test/java/de/sovity/edc/extension/e2e/connector/Connector.java b/e2e-test/src/test/java/de/sovity/edc/extension/e2e/connector/Connector.java index bba06d448..29b4519c5 100644 --- a/e2e-test/src/test/java/de/sovity/edc/extension/e2e/connector/Connector.java +++ b/e2e-test/src/test/java/de/sovity/edc/extension/e2e/connector/Connector.java @@ -13,7 +13,7 @@ package de.sovity.edc.extension.e2e.connector; -import de.sovity.edc.extension.e2e.connector.config.EdcApiType; +import de.sovity.edc.extension.e2e.connector.config.EdcApiGroup; import jakarta.json.JsonObject; import java.net.URI; @@ -45,7 +45,7 @@ String negotiateContract( Map getConfig(); - URI getUriForApi(EdcApiType apiType); + URI getUriForApi(EdcApiGroup edcApiGroup); String getParticipantId(); diff --git a/e2e-test/src/test/java/de/sovity/edc/extension/e2e/connector/TestConnector.java b/e2e-test/src/test/java/de/sovity/edc/extension/e2e/connector/TestConnector.java index 1fd048076..e960a256e 100644 --- a/e2e-test/src/test/java/de/sovity/edc/extension/e2e/connector/TestConnector.java +++ b/e2e-test/src/test/java/de/sovity/edc/extension/e2e/connector/TestConnector.java @@ -14,9 +14,9 @@ package de.sovity.edc.extension.e2e.connector; import com.fasterxml.jackson.databind.ObjectMapper; -import de.sovity.edc.extension.e2e.connector.config.ApiConfig; import de.sovity.edc.extension.e2e.connector.config.DatasourceConfig; -import de.sovity.edc.extension.e2e.connector.config.EdcApiType; +import de.sovity.edc.extension.e2e.connector.config.EdcApiGroup; +import de.sovity.edc.extension.e2e.connector.config.EdcApiGroupConfig; import de.sovity.edc.extension.e2e.connector.config.EdcConfig; import de.sovity.edc.extension.e2e.connector.config.SimpleConfig; import jakarta.json.Json; @@ -39,7 +39,7 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Stream; -import static de.sovity.edc.extension.e2e.connector.config.EdcApiType.MANAGEMENT; +import static de.sovity.edc.extension.e2e.connector.config.EdcApiGroup.MANAGEMENT; import static io.restassured.RestAssured.given; import static io.restassured.http.ContentType.JSON; import static jakarta.json.Json.createObjectBuilder; @@ -69,7 +69,7 @@ public class TestConnector implements Connector { private final List simpleConfigs; private final String baseUrl; - private final Map apiConfigMap; + private final Map apiGroupConfigMap; @Override public void createAsset(String assetId, Map dataAddressProperties) { @@ -288,8 +288,8 @@ public String getContractNegotiationState(String id) { @Override - public URI getUriForApi(EdcApiType edcApiType) { - return apiConfigMap.get(edcApiType).getUri(); + public URI getUriForApi(EdcApiGroup edcApiGroup) { + return apiGroupConfigMap.get(edcApiGroup).getUri(); } @Override @@ -341,15 +341,24 @@ public String getTransferProcessState(String id) { @Override public Map getConfig() { + var configStream = Stream.of( + apiGroupConfigMap.values().stream().toList(), + datasourceConfigs, + simpleConfigs); return new HashMap<>() { { - Stream.of(apiConfigMap.values().stream().toList(), datasourceConfigs, - simpleConfigs) - .flatMap(List::stream) + configStream.flatMap(List::stream) .map(EdcConfig::toMap) .forEach(this::putAll); } }; } + public static class TestConnectorBuilder { + public TestConnectorBuilder configProperty(String key, String value) { + this.simpleConfig(new SimpleConfig(key, value)); + return this; + } + } + } diff --git a/e2e-test/src/test/java/de/sovity/edc/extension/e2e/connector/config/EdcApiGroup.java b/e2e-test/src/test/java/de/sovity/edc/extension/e2e/connector/config/EdcApiGroup.java new file mode 100644 index 000000000..1795b60ee --- /dev/null +++ b/e2e-test/src/test/java/de/sovity/edc/extension/e2e/connector/config/EdcApiGroup.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 sovity GmbH + * + * 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 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * sovity GmbH - init + */ + +package de.sovity.edc.extension.e2e.connector.config; + +public enum EdcApiGroup { + DEFAULT(""), + PROTOCOL("protocol"), + MANAGEMENT("management"), + CONTROL("control"); + + private final String dataSourcePropertyName; + + EdcApiGroup(String dataSourcePropertyName) { + this.dataSourcePropertyName = dataSourcePropertyName; + } + + public String getDataSourcePropertyName() { + return dataSourcePropertyName; + } +} \ No newline at end of file diff --git a/e2e-test/src/test/java/de/sovity/edc/extension/e2e/connector/config/EdcApiGroupConfig.java b/e2e-test/src/test/java/de/sovity/edc/extension/e2e/connector/config/EdcApiGroupConfig.java new file mode 100644 index 000000000..1ad3de619 --- /dev/null +++ b/e2e-test/src/test/java/de/sovity/edc/extension/e2e/connector/config/EdcApiGroupConfig.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023 sovity GmbH + * + * 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 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * sovity GmbH - init + */ + +package de.sovity.edc.extension.e2e.connector.config; + +import java.net.URI; +import java.util.Map; + +public record EdcApiGroupConfig( + EdcApiGroup edcApiGroup, + String baseUrl, + int port, + String path) implements EdcConfig { + + private static final String SETTING_WEB_HTTP_PATH = "web.http.%s.path"; + private static final String SETTING_WEB_HTTP_PORT = "web.http.%s.port"; + private static final String SETTING_WEB_HTTP_DEFAULT_PATH = "web.http.path"; + private static final String SETTING_WEB_HTTP_DEFAULT_PORT = "web.http.port"; + + public URI getUri() { + return URI.create(String.format("%s:%s%s", baseUrl, port, path)); + } + + @Override + public Map toMap() { + if ("".equals(edcApiGroup.getDataSourcePropertyName())) { + return Map.of( + SETTING_WEB_HTTP_DEFAULT_PATH, path, + SETTING_WEB_HTTP_DEFAULT_PORT, String.valueOf(port) + ); + } else { + var webHttpPathProperty = String.format( + SETTING_WEB_HTTP_PATH, + edcApiGroup.getDataSourcePropertyName()); + var webHttpPortProperty = String.format( + SETTING_WEB_HTTP_PORT, + edcApiGroup.getDataSourcePropertyName()); + return Map.of( + webHttpPathProperty, path, + webHttpPortProperty, String.valueOf(port)); + } + } +} diff --git a/e2e-test/src/test/java/de/sovity/edc/extension/e2e/connector/factory/TestConnectorFactory.java b/e2e-test/src/test/java/de/sovity/edc/extension/e2e/connector/factory/TestConnectorFactory.java index 6bd8b9567..85bfcbb45 100644 --- a/e2e-test/src/test/java/de/sovity/edc/extension/e2e/connector/factory/TestConnectorFactory.java +++ b/e2e-test/src/test/java/de/sovity/edc/extension/e2e/connector/factory/TestConnectorFactory.java @@ -15,10 +15,9 @@ import de.sovity.edc.extension.e2e.connector.Connector; import de.sovity.edc.extension.e2e.connector.TestConnector; -import de.sovity.edc.extension.e2e.connector.config.ApiConfig; import de.sovity.edc.extension.e2e.connector.config.DatasourceConfig; -import de.sovity.edc.extension.e2e.connector.config.EdcApiType; -import de.sovity.edc.extension.e2e.connector.config.SimpleConfig; +import de.sovity.edc.extension.e2e.connector.config.EdcApiGroup; +import de.sovity.edc.extension.e2e.connector.config.EdcApiGroupConfig; import de.sovity.edc.extension.e2e.db.TestDatabase; import lombok.RequiredArgsConstructor; import org.eclipse.edc.junit.extensions.EdcExtension; @@ -27,10 +26,10 @@ import java.util.Map; import java.util.UUID; -import static de.sovity.edc.extension.e2e.connector.config.EdcApiType.CONTROL; -import static de.sovity.edc.extension.e2e.connector.config.EdcApiType.DEFAULT; -import static de.sovity.edc.extension.e2e.connector.config.EdcApiType.MANAGEMENT; -import static de.sovity.edc.extension.e2e.connector.config.EdcApiType.PROTOCOL; +import static de.sovity.edc.extension.e2e.connector.config.EdcApiGroup.CONTROL; +import static de.sovity.edc.extension.e2e.connector.config.EdcApiGroup.DEFAULT; +import static de.sovity.edc.extension.e2e.connector.config.EdcApiGroup.MANAGEMENT; +import static de.sovity.edc.extension.e2e.connector.config.EdcApiGroup.PROTOCOL; import static org.eclipse.edc.junit.testfixtures.TestUtils.getFreePort; @RequiredArgsConstructor @@ -46,6 +45,10 @@ public class TestConnectorFactory implements ConnectorFactory { "dataplaneinstance", "default" ); + private static final String DEFAULT_API_GROUP_PATH = "/api"; + private static final String PROTOCOL_API_GROUP_PATH = "/dsp"; + private static final String MANAGEMENT_API_GROUP_PATH = "/api/management"; + private static final String CONTROL_API_GROUP_PATH = "/control"; private final String participantId; private final EdcExtension edcContext; @@ -53,36 +56,37 @@ public class TestConnectorFactory implements ConnectorFactory { @Override public Connector createConnector() { - var apiConfigMap = createApiConfigMap(); - var dspCallbackAddress = apiConfigMap.get(PROTOCOL).getUri(); + var apiGroupConfigMap = createApiGroupConfigMap(); + var dspCallbackAddress = apiGroupConfigMap.get(PROTOCOL).getUri(); var datasourceConfigs = getDatasourceConfigs(testDatabase); + var migrationLocation = "classpath:migration/" + participantId; var connector = TestConnector.builder() .participantId(participantId) - .apiConfigMap(apiConfigMap) + .apiGroupConfigMap(apiGroupConfigMap) .datasourceConfigs(datasourceConfigs) - .simpleConfig(new SimpleConfig("edc.participant.id", participantId)) - .simpleConfig(new SimpleConfig("edc.api.auth.key", UUID.randomUUID().toString())) - .simpleConfig(new SimpleConfig("edc.last.commit.info", "test env commit message")) - .simpleConfig(new SimpleConfig("edc.build.date", "2023-05-08T15:30:00Z")) - .simpleConfig(new SimpleConfig("edc.jsonld.https.enabled", "true")) - .simpleConfig(new SimpleConfig("edc.dsp.callback.address", - dspCallbackAddress.toString())) - .simpleConfig(new SimpleConfig( - "edc.flyway.additional.migration.locations", - "classpath:migration/" + participantId)) + .configProperty("edc.participant.id", participantId) + .configProperty("edc.api.auth.key", UUID.randomUUID().toString()) + .configProperty("edc.last.commit.info", "test env commit message") + .configProperty("edc.build.date", "2023-05-08T15:30:00Z") + .configProperty("edc.jsonld.https.enabled", "true") + .configProperty("edc.dsp.callback.address", dspCallbackAddress.toString()) + .configProperty("edc.flyway.additional.migration.locations", migrationLocation) .build(); System.out.println(connector.getConfig()); edcContext.setConfiguration(connector.getConfig()); return connector; } - private Map createApiConfigMap() { + private Map createApiGroupConfigMap() { return Map.of( - DEFAULT, new ApiConfig(BASE_URL, "", "/api", getFreePort()), - PROTOCOL, new ApiConfig(BASE_URL, "protocol", "/protocol", getFreePort()), - MANAGEMENT, new ApiConfig(BASE_URL, "management", "/api/management", getFreePort()), - CONTROL, new ApiConfig(BASE_URL, "control", "/control", getFreePort()) - ); + DEFAULT, createApiGroupConfig(DEFAULT, DEFAULT_API_GROUP_PATH), + PROTOCOL, createApiGroupConfig(PROTOCOL, PROTOCOL_API_GROUP_PATH), + MANAGEMENT, createApiGroupConfig(MANAGEMENT, MANAGEMENT_API_GROUP_PATH), + CONTROL, createApiGroupConfig(CONTROL, CONTROL_API_GROUP_PATH)); + } + + private EdcApiGroupConfig createApiGroupConfig(EdcApiGroup edcApiGroup, String path) { + return new EdcApiGroupConfig(edcApiGroup, BASE_URL, getFreePort(), path); } private List getDatasourceConfigs(TestDatabase testDatabase) { diff --git a/extensions/wrapper/client-example/src/main/resources/application.properties b/extensions/wrapper/client-example/src/main/resources/application.properties index ce096eb34..f7abcc5bf 100644 --- a/extensions/wrapper/client-example/src/main/resources/application.properties +++ b/extensions/wrapper/client-example/src/main/resources/application.properties @@ -1,4 +1,17 @@ -client-example.management-api-url=http://localhost:11002/api/v1/management +# +# Copyright (c) 2023 sovity GmbH +# +# 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 +# +# SPDX-License-Identifier: Apache-2.0 +# +# Contributors: +# sovity GmbH - init +# + +client-example.management-api-url=http://localhost:11002/api/management/v2 client-example.management-api-key=ApiKeyDefaultValue client-example.test-connection=true %test.client-example.test-connection=false diff --git a/extensions/wrapper/client-ts/README.md b/extensions/wrapper/client-ts/README.md index 7da1b992f..2983c0be3 100644 --- a/extensions/wrapper/client-ts/README.md +++ b/extensions/wrapper/client-ts/README.md @@ -36,7 +36,7 @@ Configure your EDC Client and use endpoints of our API Wrapper Extension: ```typescript const edcClient: EdcClient = buildEdcClient({ - managementApiUrl: 'http://localhost:11002/api/v1/management', + managementApiUrl: 'http://localhost:11002/api/management/v2', managementApiKey: 'ApiKeyDefaultValue', }); diff --git a/extensions/wrapper/client/README.md b/extensions/wrapper/client/README.md index 0df315685..1ef187817 100644 --- a/extensions/wrapper/client/README.md +++ b/extensions/wrapper/client/README.md @@ -44,7 +44,7 @@ import de.sovity.edc.client.gen.model.KpiResult; */ public class WrapperClientExample { - public static final String CONNECTOR_ENDPOINT = "http://localhost:11002/api/v1/management"; + public static final String CONNECTOR_ENDPOINT = "http://localhost:11002/api/management/v2"; public static final String CONNECTOR_API_KEY = "..."; public static void main(String[] args) { diff --git a/extensions/wrapper/client/src/test/java/de/sovity/edc/client/PolicyDefinitionApiServiceTest.java b/extensions/wrapper/client/src/test/java/de/sovity/edc/client/PolicyDefinitionApiServiceTest.java index 6836a0ea5..8f527e5ce 100644 --- a/extensions/wrapper/client/src/test/java/de/sovity/edc/client/PolicyDefinitionApiServiceTest.java +++ b/extensions/wrapper/client/src/test/java/de/sovity/edc/client/PolicyDefinitionApiServiceTest.java @@ -15,11 +15,14 @@ package de.sovity.edc.client; import de.sovity.edc.client.gen.model.ContractAgreementTransferRequest; import de.sovity.edc.client.gen.model.ContractAgreementTransferRequestParams; +import de.sovity.edc.ext.wrapper.api.ui.pages.policy.PolicyDefinitionApiService; import org.eclipse.edc.connector.contract.spi.negotiation.store.ContractNegotiationStore; import org.eclipse.edc.connector.contract.spi.types.agreement.ContractAgreement; import org.eclipse.edc.connector.contract.spi.types.negotiation.ContractNegotiation; import org.eclipse.edc.connector.contract.spi.types.negotiation.ContractNegotiationStates; import org.eclipse.edc.connector.contract.spi.types.offer.ContractOffer; +import org.eclipse.edc.connector.policy.spi.PolicyDefinition; +import org.eclipse.edc.connector.policy.spi.store.PolicyDefinitionStore; import org.eclipse.edc.connector.transfer.spi.store.TransferProcessStore; import org.eclipse.edc.jsonld.spi.JsonLd; import org.eclipse.edc.junit.annotations.ApiTest; @@ -40,4 +43,36 @@ @ApiTest @ExtendWith(EdcExtension.class) public class PolicyDefinitionApiServiceTest { + private static final String DATA_SINK = "http://my-data-sink/api/stuff"; + private static final String COUNTER_PARTY_ADDRESS = + "http://some-other-connector/api/v1/ids/data"; + + @BeforeEach + void setUp(EdcExtension extension) { + extension.registerServiceMock(ProtocolWebhook.class, mock(ProtocolWebhook.class)); + extension.registerServiceMock(JsonLd.class, mock(JsonLd.class)); + extension.setConfiguration(TestUtils.createConfiguration(Map.of())); + } + + @Test + void startPolicyDefinition(){ + var client = TestUtils.edcClient(); + + // arrange + var policyDefinitionId = UUID.randomUUID().toString(); + + var policyDefinition = new Policy(); + policyDefinition.setPolicyId(UUID.randomUUID().toString()); + + } + + private createPolicydefinition( + PolicyDefinitionStore policyDefinitionStore + ) { + var policy = Policy.Builder.newInstance(). + var policyDefintion = PolicyDefinition.Builder.newInstance().id(UUID.randomUUID().toString()) + .policyName("My Policy").policyContentHashAlgorithm("My Policy Content Hash Algorithm") + .build(); + } + } diff --git a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtension.java b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtension.java index bfdaec22f..5e62a5b21 100644 --- a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtension.java +++ b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtension.java @@ -15,6 +15,7 @@ package de.sovity.edc.ext.wrapper; import com.fasterxml.jackson.databind.ObjectMapper; +import de.sovity.edc.ext.wrapper.api.common.mappers.PolicyMapper; import org.eclipse.edc.connector.api.management.configuration.ManagementApiConfiguration; import org.eclipse.edc.connector.contract.spi.negotiation.store.ContractNegotiationStore; import org.eclipse.edc.connector.contract.spi.offer.store.ContractDefinitionStore; @@ -63,6 +64,8 @@ public class WrapperExtension implements ServiceExtension { @Inject private ObjectMapper jsonLdObjectMapper; @Inject + private PolicyMapper policyMapper; + @Inject private TypeManager typeManager; @Inject private WebService webService; @@ -90,7 +93,7 @@ public void initialize(ServiceExtensionContext context) { transferProcessStore, transferProcessService, policyDefinitionService, - jsonLdObjectMapper + policyMapper ); wrapperExtensionContext.jaxRsResources().forEach(resource -> diff --git a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtensionContextBuilder.java b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtensionContextBuilder.java index 91a903f9e..9fdba6f14 100644 --- a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtensionContextBuilder.java +++ b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtensionContextBuilder.java @@ -26,7 +26,7 @@ import de.sovity.edc.ext.wrapper.api.ui.pages.contracts.services.TransferRequestBuilder; import de.sovity.edc.ext.wrapper.api.ui.pages.contracts.services.utils.ContractAgreementUtils; import de.sovity.edc.ext.wrapper.api.ui.pages.contracts.services.utils.ContractNegotiationUtils; -import de.sovity.edc.ext.wrapper.api.ui.pages.policy.PolicyApiService; +import de.sovity.edc.ext.wrapper.api.ui.pages.policy.PolicyDefinitionApiService; import de.sovity.edc.ext.wrapper.api.ui.pages.transferhistory.TransferHistoryPageApiService; import de.sovity.edc.ext.wrapper.api.ui.pages.transferhistory.TransferHistoryPageAssetFetcherService; import de.sovity.edc.ext.wrapper.api.usecase.UseCaseResource; @@ -63,33 +63,92 @@ @NoArgsConstructor(access = lombok.AccessLevel.PRIVATE) public class WrapperExtensionContextBuilder { - public static WrapperExtensionContext buildContext(ServiceExtensionContext serviceExtensionContext, AssetIndex assetIndex, AssetService assetService, ContractAgreementService contractAgreementService, ContractDefinitionStore contractDefinitionStore, ContractNegotiationService contractNegotiationService, ContractNegotiationStore contractNegotiationStore, ObjectMapper objectMapper, PolicyDefinitionStore policyDefinitionStore, PolicyEngine policyEngine, TransferProcessStore transferProcessStore, TransferProcessService transferProcessService, PolicyDefinitionService policyDefinitionService, ObjectMapper jsonLdObjectMapper) { + public static WrapperExtensionContext buildContext( + ServiceExtensionContext serviceExtensionContext, + AssetIndex assetIndex, + AssetService assetService, + ContractAgreementService contractAgreementService, + ContractDefinitionStore contractDefinitionStore, + ContractNegotiationService contractNegotiationService, + ContractNegotiationStore contractNegotiationStore, + ObjectMapper objectMapper, + PolicyDefinitionStore policyDefinitionStore, + PolicyEngine policyEngine, + TransferProcessStore transferProcessStore, + TransferProcessService transferProcessService, + PolicyDefinitionService policyDefinitionService, + PolicyMapper policyMapper + ) { // UI API var transferProcessStateService = new TransferProcessStateService(); - var contractAgreementPageCardBuilder = new ContractAgreementPageCardBuilder(transferProcessStateService); - var contractAgreementDataFetcher = new ContractAgreementDataFetcher(contractAgreementService, contractNegotiationStore, transferProcessService, assetIndex); - var contractAgreementApiService = new ContractAgreementPageApiService(contractAgreementDataFetcher, contractAgreementPageCardBuilder); - var transferHistoryPageApiService = new TransferHistoryPageApiService(assetService, contractAgreementService, contractNegotiationStore, transferProcessService, transferProcessStateService); - var transferHistoryPageAssetFetcherService = new TransferHistoryPageAssetFetcherService(assetService, transferProcessService); + var contractAgreementPageCardBuilder = + new ContractAgreementPageCardBuilder( + transferProcessStateService); + var contractAgreementDataFetcher = new ContractAgreementDataFetcher( + contractAgreementService, + contractNegotiationStore, + transferProcessService, + assetIndex + ); + var contractAgreementApiService = new ContractAgreementPageApiService( + contractAgreementDataFetcher, + contractAgreementPageCardBuilder + ); + var transferHistoryPageApiService = new TransferHistoryPageApiService( + assetService, + contractAgreementService, + contractNegotiationStore, + transferProcessService, + transferProcessStateService); + var transferHistoryPageAssetFetcherService = new TransferHistoryPageAssetFetcherService( + assetService, + transferProcessService); var contractNegotiationUtils = new ContractNegotiationUtils(contractNegotiationService); var contractAgreementUtils = new ContractAgreementUtils(contractAgreementService); - var policyMapper = new PolicyMapper(jsonLdObjectMapper); - var policyApiService = new PolicyApiService(policyDefinitionService, policyMapper); - var transferRequestBuilder = new TransferRequestBuilder(objectMapper, contractAgreementUtils, contractNegotiationUtils, serviceExtensionContext.getConnectorId()); - var contractAgreementTransferApiService = new ContractAgreementTransferApiService(transferRequestBuilder, transferProcessService); - var uiResource = new UiResource(contractAgreementApiService, contractAgreementTransferApiService, transferHistoryPageApiService, transferHistoryPageAssetFetcherService, policyApiService + var transferRequestBuilder = new TransferRequestBuilder( + objectMapper, + contractAgreementUtils, + contractNegotiationUtils, + serviceExtensionContext.getConnectorId() + ); + var contractAgreementTransferApiService = new ContractAgreementTransferApiService( + transferRequestBuilder, + transferProcessService + ); + var policyDefinitionApiService = new PolicyDefinitionApiService( + policyDefinitionService, + policyMapper + ); + var uiResource = new UiResource( + contractAgreementApiService, + contractAgreementTransferApiService, + transferHistoryPageApiService, + transferHistoryPageAssetFetcherService, + policyDefinitionApiService ); // Use Case API - var kpiApiService = new KpiApiService(assetIndex, policyDefinitionStore, contractDefinitionStore, transferProcessStore, contractAgreementService); + var kpiApiService = new KpiApiService( + assetIndex, + policyDefinitionStore, + contractDefinitionStore, + transferProcessStore, + contractAgreementService + ); var supportedPolicyApiService = new SupportedPolicyApiService(policyEngine); var policyMappingService = new PolicyMappingService(); - var offeringService = new OfferingService(assetIndex, policyDefinitionStore, contractDefinitionStore, policyMappingService); - var useCaseResource = new UseCaseResource(kpiApiService, supportedPolicyApiService, offeringService); + var offeringService = new OfferingService(assetIndex, policyDefinitionStore, + contractDefinitionStore, policyMappingService); + var useCaseResource = new UseCaseResource(kpiApiService, supportedPolicyApiService, + offeringService); // Collect all JAX-RS resources - return new WrapperExtensionContext(List.of(uiResource, useCaseResource, new EnterpriseEditionResourceImpl())); + return new WrapperExtensionContext(List.of( + uiResource, + useCaseResource, + new EnterpriseEditionResourceImpl() + )); } } diff --git a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/UiResource.java b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/UiResource.java index 6dc06c8a6..f14de1a75 100644 --- a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/UiResource.java +++ b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/UiResource.java @@ -18,11 +18,11 @@ import de.sovity.edc.ext.wrapper.api.common.model.PolicyDefinitionDto; import de.sovity.edc.ext.wrapper.api.ui.model.ContractAgreementPage; import de.sovity.edc.ext.wrapper.api.ui.model.ContractAgreementTransferRequest; -import de.sovity.edc.ext.wrapper.api.ui.model.PolicyPage; +import de.sovity.edc.ext.wrapper.api.ui.model.PolicyDefinitionPage; import de.sovity.edc.ext.wrapper.api.ui.model.TransferHistoryPage; import de.sovity.edc.ext.wrapper.api.ui.pages.contracts.ContractAgreementPageApiService; import de.sovity.edc.ext.wrapper.api.ui.pages.contracts.ContractAgreementTransferApiService; -import de.sovity.edc.ext.wrapper.api.ui.pages.policy.PolicyApiService; +import de.sovity.edc.ext.wrapper.api.ui.pages.policy.PolicyDefinitionApiService; import de.sovity.edc.ext.wrapper.api.ui.pages.transferhistory.TransferHistoryPageApiService; import de.sovity.edc.ext.wrapper.api.ui.pages.transferhistory.TransferHistoryPageAssetFetcherService; import io.swagger.v3.oas.annotations.Operation; @@ -46,7 +46,7 @@ public class UiResource { private final ContractAgreementTransferApiService contractAgreementTransferApiService; private final TransferHistoryPageApiService transferHistoryPageApiService; private final TransferHistoryPageAssetFetcherService transferHistoryPageAssetFetcherService; - private final PolicyApiService policyApiService; + private final PolicyDefinitionApiService policyDefinitionApiService; @GET @Path("pages/contract-agreement-page") @@ -61,8 +61,12 @@ public ContractAgreementPage contractAgreementEndpoint() { @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Operation(description = "Initiate a Transfer Process") - public IdResponse initiateTransfer(ContractAgreementTransferRequest contractAgreementTransferRequest) { - return contractAgreementTransferApiService.initiateTransfer(contractAgreementTransferRequest); + public IdResponse initiateTransfer( + ContractAgreementTransferRequest contractAgreementTransferRequest + ) { + return contractAgreementTransferApiService.initiateTransfer( + contractAgreementTransferRequest + ); } @GET @@ -82,15 +86,15 @@ public AssetDto getTransferProcessAsset(@PathParam("transferProcessId") String t @GET @Path("pages/policy/page/policies") @Produces(MediaType.APPLICATION_JSON) - public PolicyPage policyPage() { - return new PolicyPage(policyApiService.getPolicies()); + public PolicyDefinitionPage policyPage() { + return new PolicyDefinitionPage(policyDefinitionApiService.getPolicies()); } @POST @Path("pages/policy/page/policies") @Produces(MediaType.APPLICATION_JSON) public IdResponse createPolicyDefinition(PolicyDefinitionDto policyDefinitionDtoDto) { - return policyApiService.createPolicy(policyDefinitionDtoDto); + return policyDefinitionApiService.createPolicy(policyDefinitionDtoDto); } } diff --git a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/PolicyPage.java b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/PolicyDefinitionPage.java similarity index 83% rename from extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/PolicyPage.java rename to extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/PolicyDefinitionPage.java index 5b22794bf..b7a11b9ee 100644 --- a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/PolicyPage.java +++ b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/PolicyDefinitionPage.java @@ -14,8 +14,6 @@ package de.sovity.edc.ext.wrapper.api.ui.model; import de.sovity.edc.ext.wrapper.api.common.model.PolicyDefinitionDto; -import de.sovity.edc.ext.wrapper.api.common.model.PolicyDto; -import de.sovity.edc.ext.wrapper.api.common.model.UiPolicyDto; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; import lombok.Data; @@ -24,7 +22,7 @@ @Data @AllArgsConstructor -public class PolicyPage { +public class PolicyDefinitionPage { @Schema(description = "Policy Entries", requiredMode = Schema.RequiredMode.REQUIRED) private List policies; } diff --git a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/policy/PolicyApiService.java b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/policy/PolicyDefinitionApiService.java similarity index 95% rename from extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/policy/PolicyApiService.java rename to extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/policy/PolicyDefinitionApiService.java index b08d35bc4..af2237771 100644 --- a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/policy/PolicyApiService.java +++ b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/policy/PolicyDefinitionApiService.java @@ -17,7 +17,6 @@ import de.sovity.edc.ext.wrapper.api.common.mappers.PolicyMapper; import de.sovity.edc.ext.wrapper.api.common.model.PolicyDefinitionDto; -import de.sovity.edc.ext.wrapper.api.common.model.UiPolicyDto; import jakarta.validation.constraints.NotNull; import lombok.RequiredArgsConstructor; import org.eclipse.edc.api.model.IdResponse; @@ -29,7 +28,7 @@ @RequiredArgsConstructor -public class PolicyApiService { +public class PolicyDefinitionApiService { private final PolicyDefinitionService policyDefinitionService; private final PolicyMapper policyMapper;