Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/sovity/edc-extensions into …
Browse files Browse the repository at this point in the history
…410-backend-ui-api-wrapper-get-policies-endpoint-with-02x

# Conflicts:
#	CHANGELOG.md
#	connector/.env
#	docker-compose-dev.yaml
#	docs/postman_collection.json
#	e2e-test/src/test/java/de/sovity/edc/extension/e2e/PostgresFlywayExtensionTest.java
#	e2e-test/src/test/java/de/sovity/edc/extension/e2e/connector/Connector.java
#	e2e-test/src/test/java/de/sovity/edc/extension/e2e/connector/TestConnector.java
#	e2e-test/src/test/java/de/sovity/edc/extension/e2e/connector/factory/TestConnectorFactory.java
#	extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtension.java
#	extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/WrapperExtensionContextBuilder.java
#	extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/UiResource.java
  • Loading branch information
SaadEGI committed Aug 8, 2023
2 parents 919c968 + c344797 commit e70472e
Show file tree
Hide file tree
Showing 20 changed files with 294 additions and 98 deletions.
12 changes: 6 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
8 changes: 3 additions & 5 deletions connector/.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions connector/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
12 changes: 4 additions & 8 deletions docker-compose-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ 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:
image: ${DEV_EDC_IMAGE}
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"
Expand Down Expand Up @@ -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
Expand All @@ -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'
Expand Down Expand Up @@ -81,15 +79,15 @@ 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:
image: ${DEV_EDC_IMAGE}
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"
Expand Down Expand Up @@ -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
Expand All @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions docs/postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
{
Expand All @@ -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"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -45,7 +45,7 @@ String negotiateContract(

Map<String, String> getConfig();

URI getUriForApi(EdcApiType apiType);
URI getUriForApi(EdcApiGroup edcApiGroup);

String getParticipantId();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -69,7 +69,7 @@ public class TestConnector implements Connector {
private final List<SimpleConfig> simpleConfigs;

private final String baseUrl;
private final Map<EdcApiType, ApiConfig> apiConfigMap;
private final Map<EdcApiGroup, EdcApiGroupConfig> apiGroupConfigMap;

@Override
public void createAsset(String assetId, Map<String, Object> dataAddressProperties) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -341,15 +341,24 @@ public String getTransferProcessState(String id) {

@Override
public Map<String, String> 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;
}
}

}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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<String, String> 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));
}
}
}
Loading

0 comments on commit e70472e

Please sign in to comment.