-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/upgrade-0-7-1' into 'develop'
Feature/upgrade 0 7 1 See merge request upm-inesdata/inesdata-connector!26
- Loading branch information
Showing
16 changed files
with
171 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Extended data plane public API | ||
|
||
Provides an extension of 'DataPlanePublicApiV2Extension' that allows performing HTTP-PULL from AmazonS3 destinations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
plugins { | ||
`java-library` | ||
id("com.gmv.inesdata.edc-application") | ||
} | ||
|
||
dependencies { | ||
api(libs.edc.spi.core) | ||
implementation(libs.edc.data.plane.public.api) | ||
} |
115 changes: 115 additions & 0 deletions
115
...in/java/org/upm/inesdata/extendeddataplanepublic/ExtendedDataPlanePublicApiExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* | ||
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* | ||
* 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: | ||
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation | ||
* | ||
*/ | ||
|
||
package org.upm.inesdata.extendeddataplanepublic; | ||
|
||
import org.eclipse.edc.connector.dataplane.api.controller.DataPlanePublicApiV2Controller; | ||
import org.eclipse.edc.connector.dataplane.spi.Endpoint; | ||
import org.eclipse.edc.connector.dataplane.spi.iam.DataPlaneAuthorizationService; | ||
import org.eclipse.edc.connector.dataplane.spi.iam.PublicEndpointGeneratorService; | ||
import org.eclipse.edc.connector.dataplane.spi.pipeline.PipelineService; | ||
import org.eclipse.edc.runtime.metamodel.annotation.Extension; | ||
import org.eclipse.edc.runtime.metamodel.annotation.Inject; | ||
import org.eclipse.edc.runtime.metamodel.annotation.Setting; | ||
import org.eclipse.edc.runtime.metamodel.annotation.SettingContext; | ||
import org.eclipse.edc.spi.system.ExecutorInstrumentation; | ||
import org.eclipse.edc.spi.system.Hostname; | ||
import org.eclipse.edc.spi.system.ServiceExtension; | ||
import org.eclipse.edc.spi.system.ServiceExtensionContext; | ||
import org.eclipse.edc.web.spi.WebServer; | ||
import org.eclipse.edc.web.spi.WebService; | ||
import org.eclipse.edc.web.spi.configuration.ApiContext; | ||
import org.eclipse.edc.web.spi.configuration.WebServiceConfigurer; | ||
import org.eclipse.edc.web.spi.configuration.WebServiceSettings; | ||
|
||
import java.util.concurrent.Executors; | ||
|
||
/** | ||
* This extension provides generic endpoints which are open to public participants of the Dataspace to execute | ||
* requests on the actual data source. | ||
*/ | ||
@Extension(value = ExtendedDataPlanePublicApiExtension.NAME) | ||
public class ExtendedDataPlanePublicApiExtension implements ServiceExtension { | ||
public static final String NAME = "Data Plane Public API"; | ||
|
||
private static final int DEFAULT_PUBLIC_PORT = 8185; | ||
private static final String PUBLIC_CONTEXT_PATH = "/api/v2/public"; | ||
|
||
@SettingContext("Public API context setting key") | ||
private static final String PUBLIC_CONFIG_KEY = "web.http." + ApiContext.PUBLIC; | ||
|
||
@Setting(value = "Base url of the public API endpoint without the trailing slash. This should correspond to the values configured " + | ||
"in '" + DEFAULT_PUBLIC_PORT + "' and '" + PUBLIC_CONTEXT_PATH + "'.", defaultValue = "http://<HOST>:" + DEFAULT_PUBLIC_PORT + PUBLIC_CONTEXT_PATH) | ||
private static final String PUBLIC_ENDPOINT = "edc.dataplane.api.public.baseurl"; | ||
|
||
private static final int DEFAULT_THREAD_POOL = 10; | ||
private static final WebServiceSettings PUBLIC_SETTINGS = WebServiceSettings.Builder.newInstance() | ||
.apiConfigKey(PUBLIC_CONFIG_KEY) | ||
.contextAlias(ApiContext.PUBLIC) | ||
.defaultPath(PUBLIC_CONTEXT_PATH) | ||
.defaultPort(DEFAULT_PUBLIC_PORT) | ||
.name(NAME) | ||
.build(); | ||
|
||
@Inject | ||
private WebServer webServer; | ||
|
||
@Inject | ||
private WebServiceConfigurer webServiceConfigurer; | ||
|
||
@Inject | ||
private PipelineService pipelineService; | ||
|
||
@Inject | ||
private WebService webService; | ||
|
||
@Inject | ||
private ExecutorInstrumentation executorInstrumentation; | ||
|
||
@Inject | ||
private DataPlaneAuthorizationService authorizationService; | ||
|
||
@Inject | ||
private PublicEndpointGeneratorService generatorService; | ||
|
||
@Inject | ||
private Hostname hostname; | ||
|
||
@Override | ||
public String name() { | ||
return NAME; | ||
} | ||
|
||
@Override | ||
public void initialize(ServiceExtensionContext context) { | ||
var config = context.getConfig(PUBLIC_CONFIG_KEY); | ||
var configuration = webServiceConfigurer.configure(config, webServer, PUBLIC_SETTINGS); | ||
var executorService = executorInstrumentation.instrument( | ||
Executors.newFixedThreadPool(DEFAULT_THREAD_POOL), | ||
"Data plane proxy transfers" | ||
); | ||
|
||
var publicEndpoint = context.getSetting(PUBLIC_ENDPOINT, null); | ||
if (publicEndpoint == null) { | ||
publicEndpoint = "http://%s:%d%s".formatted(hostname.get(), configuration.getPort(), configuration.getPath()); | ||
context.getMonitor().warning("Config property '%s' was not specified, the default '%s' will be used.".formatted(PUBLIC_ENDPOINT, publicEndpoint)); | ||
} | ||
var endpoint = Endpoint.url(publicEndpoint); | ||
generatorService.addGeneratorFunction("HttpData", dataAddress -> endpoint); | ||
generatorService.addGeneratorFunction("AmazonS3", dataAddress -> endpoint); | ||
|
||
var publicApiController = new DataPlanePublicApiV2Controller(pipelineService, executorService, authorizationService); | ||
webService.registerResource(ApiContext.PUBLIC, publicApiController); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...blic-api/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.upm.inesdata.extendeddataplanepublic.ExtendedDataPlanePublicApiExtension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.