Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: dataspace protocol negotiation API #2709

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.eclipse.edc.jsonld.spi.transformer.JsonLdTransformerRegistry;
import org.eclipse.edc.protocol.dsp.catalog.transform.from.JsonObjectFromCatalogRequestMessageTransformer;
import org.eclipse.edc.protocol.dsp.catalog.transform.to.JsonObjectToCatalogRequestMessageTransformer;
import org.eclipse.edc.runtime.metamodel.annotation.Extension;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;
Expand All @@ -30,25 +31,26 @@
/**
* Provides the transformers for catalog message types via the {@link JsonLdTransformerRegistry}.
*/
@Extension(value = DspCatalogTransformExtension.NAME)
public class DspCatalogTransformExtension implements ServiceExtension {

public static final String NAME = "Dataspace Protocol Catalog Transform Extension";

@Inject
private TypeManager typeManager;
@Inject
private JsonLdTransformerRegistry registry;

@Override
public String name() {
return NAME;
}

@Override
public void initialize(ServiceExtensionContext context) {
var jsonFactory = Json.createBuilderFactory(Map.of());
var mapper = typeManager.getMapper(TYPE_MANAGER_CONTEXT_JSON_LD);

registry.register(new JsonObjectFromCatalogRequestMessageTransformer(jsonFactory, mapper));
registry.register(new JsonObjectToCatalogRequestMessageTransformer(mapper));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2023 Fraunhofer Institute for Software and Systems Engineering
*
* 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:
* Fraunhofer Institute for Software and Systems Engineering - initial API and implementation
*
*/

plugins {
`java-library`
id("io.swagger.core.v3.swagger-gradle-plugin")
}

dependencies {
api(project(":data-protocols:dsp:dsp-api-configuration"))
api(project(":data-protocols:dsp:dsp-negotiation:dsp-negotiation-spi"))
api(project(":data-protocols:dsp:dsp-negotiation:dsp-negotiation-transform"))
api(project(":data-protocols:dsp:dsp-transform"))

api(project(":spi:common:core-spi"))
api(project(":spi:control-plane:control-plane-spi"))
api(project(":extensions:common:http"))
api(project(":extensions:common:json-ld"))

implementation(libs.jakarta.rsApi)

testImplementation(project(":core:common:junit"))
testImplementation(testFixtures(project(":extensions:common:http:jersey-core")))
testImplementation(libs.restAssured)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright (c) 2023 Fraunhofer Institute for Software and Systems Engineering
*
* 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:
* Fraunhofer Institute for Software and Systems Engineering - initial API and implementation
*
*/

package org.eclipse.edc.protocol.dsp.negotiation.api;

import org.eclipse.edc.connector.spi.contractnegotiation.ContractNegotiationProtocolService;
import org.eclipse.edc.jsonld.spi.transformer.JsonLdTransformerRegistry;
import org.eclipse.edc.protocol.dsp.api.configuration.DspApiConfiguration;
import org.eclipse.edc.protocol.dsp.negotiation.api.controller.DspNegotiationController;
import org.eclipse.edc.runtime.metamodel.annotation.Extension;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.spi.iam.IdentityService;
import org.eclipse.edc.spi.monitor.Monitor;
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.spi.WebService;

import static org.eclipse.edc.jsonld.JsonLdExtension.TYPE_MANAGER_CONTEXT_JSON_LD;

/**
* Creates and registers the controller for dataspace protocol negotiation requests.
*/
@Extension(value = DspNegotiationApiExtension.NAME)
public class DspNegotiationApiExtension implements ServiceExtension {

public static final String NAME = "Dataspace Protocol Negotiation Api Extension";

@Inject
private WebService webService;

@Inject
private TypeManager typeManager;

@Inject
private IdentityService identityService;

@Inject
private DspApiConfiguration apiConfiguration;

@Inject
private JsonLdTransformerRegistry transformerRegistry;

@Inject
private Monitor monitor;

@Inject
private ContractNegotiationProtocolService protocolService;

@Override
public String name() {
return NAME;
}

@Override
public void initialize(ServiceExtensionContext context) {
var callbackAddress = apiConfiguration.getDspCallbackAddress();
var objectMapper = typeManager.getMapper(TYPE_MANAGER_CONTEXT_JSON_LD);

var controller = new DspNegotiationController(monitor, objectMapper, callbackAddress, identityService, transformerRegistry, protocolService);

webService.registerResource(apiConfiguration.getContextAlias(), controller);
}
}
Loading