-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1687477
commit 890fdf1
Showing
27 changed files
with
453 additions
and
29 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
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,73 @@ | ||
<!-- PROJECT LOGO --> | ||
<br /> | ||
<div align="center"> | ||
<a href="https://github.com/sovity/edc-ce"> | ||
<img src="https://raw.githubusercontent.com/sovity/edc-ui/main/src/assets/images/sovity_logo.svg" alt="Logo" width="300"> | ||
</a> | ||
|
||
<h3 align="center">EDC-Connector Extension:<br />Sovity Messenger</h3> | ||
|
||
<p align="center"> | ||
<a href="https://github.com/sovity/edc-ce/issues/new?template=bug_report.md">Report Bug</a> | ||
· | ||
<a href="https://github.com/sovity/edc-ce/issues/new?template=feature_request.md">Request Feature</a> | ||
</p> | ||
</div> | ||
|
||
## About this Extension | ||
|
||
Provides a placeholder endpoint for on-request offers. | ||
|
||
## Why does this extension exist? | ||
|
||
This extension exists to inform the asset's consumer upon data retrieval that they should contact the provider and take extra steps to access the data. | ||
|
||
## Configuration | ||
|
||
`MY_EDC_DATASOURCE_PLACEHOLDER_BASEURL` / `my.edc.datasource.placeholder.baseurl` must be set to point to the placeholder endpoint's base URL. | ||
`/data-source/placeholder/asset/` will be appended to this base URL to make it the placeholder data source endpoint. This will be the address as seen by the consumer. | ||
|
||
--- | ||
|
||
On a production system, the base URL it could be: | ||
|
||
`https://mycompany.com/path/to/backend` | ||
|
||
with a placeholder value: | ||
|
||
`https://mycompany.com/path/to/backend/data-source/placeholder/asset/` | ||
|
||
and a full path to the asset's data: | ||
|
||
`https://mycompany.com/path/to/backend/data-source/placeholder/asset?email=foo%40example.com&subject=Contact+us+now`. | ||
|
||
--- | ||
|
||
On a system started with docker-compose, it will be pointing to the DSP port on the provider's EDC | ||
|
||
`http://edc:11003/` | ||
|
||
`http://edc:11003/data-source/placeholder/asset/` | ||
|
||
`http://edc:11003/data-source/placeholder/asset?email=foo%40example.com&subject=Contact+us+now` | ||
|
||
--- | ||
|
||
During local/dev/unit test execution, it will be pointing to the DSP port on the provider's EDC | ||
|
||
`http://localhost:12345/` | ||
|
||
where `12345` would be chosen at random | ||
|
||
`http://localhost:12345/data-source/placeholder/asset/` | ||
|
||
`http://localhost:12345/data-source/placeholder/asset?email=foo%40example.com&subject=Contact+us+now` | ||
|
||
## License | ||
|
||
Apache License 2.0 - see [LICENSE](../../LICENSE) | ||
|
||
## Contact | ||
|
||
sovity GmbH - [email protected] | ||
|
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,30 @@ | ||
|
||
plugins { | ||
`java-library` | ||
`maven-publish` | ||
} | ||
|
||
dependencies { | ||
annotationProcessor(libs.lombok) | ||
compileOnly(libs.lombok) | ||
|
||
api(libs.edc.coreSpi) | ||
api(libs.edc.controlPlaneSpi) | ||
implementation(libs.edc.apiCore) | ||
implementation(libs.edc.dspApiConfiguration) | ||
implementation(libs.okhttp.okhttp) | ||
|
||
testImplementation(libs.mockito.core) | ||
testImplementation(libs.junit.api) | ||
testRuntimeOnly(libs.junit.engine) | ||
} | ||
|
||
group = libs.versions.sovityEdcExtensionGroup.get() | ||
|
||
publishing { | ||
publications { | ||
create<MavenPublication>(project.name) { | ||
from(components["java"]) | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...in/java/de/sovity/edc/extension/placeholderdatasource/PlaceholderDataSourceExtension.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,52 @@ | ||
/* | ||
* Copyright (c) 2024 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 - initial API and implementation | ||
* | ||
*/ | ||
|
||
package de.sovity.edc.extension.placeholderdatasource; | ||
|
||
import lombok.val; | ||
import org.eclipse.edc.protocol.dsp.api.configuration.DspApiConfiguration; | ||
import org.eclipse.edc.runtime.metamodel.annotation.Extension; | ||
import org.eclipse.edc.runtime.metamodel.annotation.Inject; | ||
import org.eclipse.edc.runtime.metamodel.annotation.Provides; | ||
import org.eclipse.edc.runtime.metamodel.annotation.Setting; | ||
import org.eclipse.edc.spi.system.ServiceExtension; | ||
import org.eclipse.edc.spi.system.ServiceExtensionContext; | ||
import org.eclipse.edc.web.spi.WebService; | ||
|
||
import static de.sovity.edc.extension.placeholderdatasource.PlaceholderDataSourceExtension.NAME; | ||
|
||
@Extension(value = NAME) | ||
@Provides(PlaceholderEndpointService.class) | ||
public class PlaceholderDataSourceExtension implements ServiceExtension { | ||
|
||
public static final String NAME = "Placeholder Data Source"; | ||
|
||
@Setting(required = true) | ||
public static final String MY_EDC_DATASOURCE_PLACEHOLDER_BASEURL = "my.edc.datasource.placeholder.baseurl"; | ||
|
||
@Inject | ||
private DspApiConfiguration dspApiConfiguration; | ||
|
||
@Inject | ||
private WebService webService; | ||
|
||
@Override | ||
public void initialize(ServiceExtensionContext context) { | ||
val controller = new PlaceholderEndpointController(); | ||
webService.registerResource(dspApiConfiguration.getContextAlias(), controller); | ||
|
||
val baseUrl = context.getConfig().getString(MY_EDC_DATASOURCE_PLACEHOLDER_BASEURL); | ||
context.registerService(PlaceholderEndpointService.class, new PlaceholderEndpointService(baseUrl)); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...ain/java/de/sovity/edc/extension/placeholderdatasource/PlaceholderEndpointController.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,45 @@ | ||
/* | ||
* Copyright (c) 2024 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 - initial API and implementation | ||
* | ||
*/ | ||
|
||
package de.sovity.edc.extension.placeholderdatasource; | ||
|
||
import jakarta.ws.rs.Consumes; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.QueryParam; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.Response; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
@Produces({MediaType.APPLICATION_JSON}) | ||
@Path("/data-source/placeholder") | ||
public class PlaceholderEndpointController { | ||
|
||
@GET | ||
@Path("/{path:.*}") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
@Consumes("*/*") | ||
public Response get(@QueryParam("email") String email, @QueryParam("subject") String subject) { | ||
return Response.ok(""" | ||
This is not a real data offer. | ||
The offer you are trying to use only has this placeholder as a dummy endpoint and requires you top take extra actions to access it. | ||
Please contact the data provider for more information about how to access it. | ||
""" + "\n\n" + "Email: " + email + "\n" + "Subject: " + subject + "\n" | ||
).build(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...c/main/java/de/sovity/edc/extension/placeholderdatasource/PlaceholderEndpointService.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,36 @@ | ||
/* | ||
* Copyright (c) 2024 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 - initial API and implementation | ||
* | ||
*/ | ||
|
||
package de.sovity.edc.extension.placeholderdatasource; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import okhttp3.HttpUrl; | ||
|
||
@RequiredArgsConstructor | ||
public class PlaceholderEndpointService { | ||
|
||
private final String baseUrl; | ||
|
||
public static final String DUMMY_ENDPOINT_URL = "/data-source/placeholder/asset"; | ||
|
||
// TODO: maybe add String contactEmail, String contactPreferredEmailSubject and show them in the placeholder | ||
public String getPlaceholderEndpointForAsset(String email, String subject) { | ||
return HttpUrl.parse(baseUrl + DUMMY_ENDPOINT_URL) | ||
.newBuilder() | ||
.addQueryParameter("email", email) | ||
.addQueryParameter("subject", subject) | ||
.build() | ||
.toString(); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...a-source/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 @@ | ||
de.sovity.edc.extension.placeholderdatasource.PlaceholderDataSourceExtension |
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.