-
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/436844_get_all_vocabularies' into 'develop'
feature/436844_get_all_vocabularies See merge request upm-inesdata/inesdata-connector!31
- Loading branch information
Showing
45 changed files
with
1,087 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM eclipse-temurin:17-jre | ||
FROM eclipse-temurin:17-jre-jammy | ||
ARG CONNECTOR_JAR | ||
|
||
# System env vars | ||
|
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
31 changes: 31 additions & 0 deletions
31
...rom-registration-service/src/main/java/org/upm/inesdata/catalog/SharedUrlParticipant.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,31 @@ | ||
package org.upm.inesdata.catalog; | ||
|
||
public class SharedUrlParticipant { | ||
private String participantId; | ||
private String url; | ||
private String sharedUrl; | ||
|
||
public String getParticipantId() { | ||
return participantId; | ||
} | ||
|
||
public void setParticipantId(String participantId) { | ||
this.participantId = participantId; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
|
||
public String getSharedUrl() { | ||
return sharedUrl; | ||
} | ||
|
||
public void setSharedUrl(String sharedUrl) { | ||
this.sharedUrl = sharedUrl; | ||
} | ||
} |
Empty file.
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,12 @@ | ||
plugins { | ||
`java-library` | ||
id("com.gmv.inesdata.edc-application") | ||
} | ||
|
||
dependencies { | ||
api(libs.edc.web.spi) | ||
api(libs.edc.auth.spi) | ||
api(libs.edc.iam.oauth2.service) | ||
api(libs.edc.spi.jsonld) | ||
api(libs.edc.jersey.providers.lib) | ||
} |
111 changes: 111 additions & 0 deletions
111
.../main/java/org/upm/inesdata/api/shared/configuration/SharedApiConfigurationExtension.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,111 @@ | ||
package org.upm.inesdata.api.shared.configuration; | ||
|
||
import org.eclipse.edc.api.auth.spi.AuthenticationRequestFilter; | ||
import org.eclipse.edc.api.auth.spi.registry.ApiAuthenticationRegistry; | ||
import org.eclipse.edc.jsonld.spi.JsonLd; | ||
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.runtime.metamodel.annotation.SettingContext; | ||
import org.eclipse.edc.spi.EdcException; | ||
import org.eclipse.edc.spi.iam.IdentityService; | ||
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.spi.types.TypeManager; | ||
import org.eclipse.edc.web.jersey.providers.jsonld.JerseyJsonLdInterceptor; | ||
import org.eclipse.edc.web.jersey.providers.jsonld.ObjectMapperProvider; | ||
import org.eclipse.edc.web.spi.WebServer; | ||
import org.eclipse.edc.web.spi.WebService; | ||
import org.eclipse.edc.web.spi.configuration.WebServiceConfiguration; | ||
import org.eclipse.edc.web.spi.configuration.WebServiceConfigurer; | ||
import org.eclipse.edc.web.spi.configuration.WebServiceSettings; | ||
|
||
import java.net.URI; | ||
|
||
import static java.lang.String.format; | ||
import static org.eclipse.edc.policy.model.OdrlNamespace.ODRL_PREFIX; | ||
import static org.eclipse.edc.policy.model.OdrlNamespace.ODRL_SCHEMA; | ||
import static org.eclipse.edc.spi.constants.CoreConstants.JSON_LD; | ||
|
||
/** | ||
* This extension provides generic endpoints which are open to all connectors. | ||
*/ | ||
@Provides(SharedApiUrl.class) | ||
@Extension(value = SharedApiConfigurationExtension.NAME) | ||
public class SharedApiConfigurationExtension implements ServiceExtension { | ||
public static final String NAME = "Shared Public API"; | ||
|
||
private static final int DEFAULT_SHARED_PORT = 8186; | ||
private static final String SHARED_CONTEXT_PATH = "/api/v1/shared"; | ||
|
||
@SettingContext("Shared API context setting key") | ||
private static final String SHARED_CONFIG_KEY = "web.http.shared"; | ||
|
||
@Setting(value = "Base url of the shared API endpoint without the trailing slash. This should correspond to the values configured " + | ||
"in '" + DEFAULT_SHARED_PORT + "' and '" + SHARED_CONTEXT_PATH + "'.", defaultValue = "http://<HOST>:" + DEFAULT_SHARED_PORT + SHARED_CONTEXT_PATH) | ||
private static final String SHARED_ENDPOINT = "edc.shared.endpoint"; | ||
|
||
private static final WebServiceSettings SHARED_SETTINGS = WebServiceSettings.Builder.newInstance() | ||
.apiConfigKey(SHARED_CONFIG_KEY) | ||
.contextAlias("shared") | ||
.defaultPath(SHARED_CONTEXT_PATH) | ||
.defaultPort(DEFAULT_SHARED_PORT) | ||
.name(NAME) | ||
.build(); | ||
|
||
private static final String SHARED_SCOPE = "SHARED_API"; | ||
|
||
@Inject | ||
private WebServer webServer; | ||
@Inject | ||
private ApiAuthenticationRegistry authenticationRegistry; | ||
@Inject | ||
private WebServiceConfigurer webServiceConfigurer; | ||
@Inject | ||
private WebService webService; | ||
@Inject | ||
private ExecutorInstrumentation executorInstrumentation; | ||
@Inject | ||
private Hostname hostname; | ||
@Inject | ||
private IdentityService identityService; | ||
@Inject | ||
private JsonLd jsonLd; | ||
@Inject | ||
private TypeManager typeManager; | ||
|
||
@Override | ||
public String name() { | ||
return NAME; | ||
} | ||
|
||
@Override | ||
public void initialize(ServiceExtensionContext context) { | ||
var config = context.getConfig(SHARED_CONFIG_KEY); | ||
var configuration = webServiceConfigurer.configure(config, webServer, SHARED_SETTINGS); | ||
|
||
context.registerService(SharedApiUrl.class, sharedApiUrl(context, configuration)); | ||
|
||
var authenticationFilter = new AuthenticationRequestFilter(authenticationRegistry, "shared-api"); | ||
webService.registerResource("shared", authenticationFilter); | ||
|
||
jsonLd.registerNamespace(ODRL_PREFIX, ODRL_SCHEMA, SHARED_SCOPE); | ||
var jsonLdMapper = typeManager.getMapper(JSON_LD); | ||
webService.registerResource("shared", new ObjectMapperProvider(jsonLdMapper)); | ||
webService.registerResource("shared", new JerseyJsonLdInterceptor(jsonLd, jsonLdMapper, SHARED_SCOPE)); | ||
} | ||
|
||
private SharedApiUrl sharedApiUrl(ServiceExtensionContext context, WebServiceConfiguration config) { | ||
var callbackAddress = context.getSetting(SHARED_ENDPOINT, format("http://%s:%s%s", hostname.get(), config.getPort(), config.getPath())); | ||
try { | ||
var url = URI.create(callbackAddress); | ||
return () -> url; | ||
} catch (IllegalArgumentException e) { | ||
context.getMonitor().severe("Error creating shared endpoint url", e); | ||
throw new EdcException(e); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...i-configuration/src/main/java/org/upm/inesdata/api/shared/configuration/SharedApiUrl.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,17 @@ | ||
package org.upm.inesdata.api.shared.configuration; | ||
|
||
import java.net.URI; | ||
|
||
/** | ||
* Provides the Shared Api URL exposed, useful for setting callbacks. | ||
*/ | ||
@FunctionalInterface | ||
public interface SharedApiUrl { | ||
|
||
/** | ||
* URI on which the Shared API is exposed | ||
* | ||
* @return Shared API URI. | ||
*/ | ||
URI get(); | ||
} |
Oops, something went wrong.