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: exposes protocol protoco version management api endpoint #4661

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 @@ -41,6 +41,7 @@
import org.eclipse.edc.connector.controlplane.services.policydefinition.PolicyDefinitionServiceImpl;
import org.eclipse.edc.connector.controlplane.services.protocol.ProtocolTokenValidatorImpl;
import org.eclipse.edc.connector.controlplane.services.protocol.VersionProtocolServiceImpl;
import org.eclipse.edc.connector.controlplane.services.protocol.VersionServiceImpl;
import org.eclipse.edc.connector.controlplane.services.query.QueryValidators;
import org.eclipse.edc.connector.controlplane.services.secret.SecretEventListener;
import org.eclipse.edc.connector.controlplane.services.secret.SecretServiceImpl;
Expand All @@ -55,6 +56,7 @@
import org.eclipse.edc.connector.controlplane.services.spi.protocol.ProtocolTokenValidator;
import org.eclipse.edc.connector.controlplane.services.spi.protocol.ProtocolVersionRegistry;
import org.eclipse.edc.connector.controlplane.services.spi.protocol.VersionProtocolService;
import org.eclipse.edc.connector.controlplane.services.spi.protocol.VersionService;
import org.eclipse.edc.connector.controlplane.services.spi.transferprocess.TransferProcessProtocolService;
import org.eclipse.edc.connector.controlplane.services.spi.transferprocess.TransferProcessService;
import org.eclipse.edc.connector.controlplane.services.transferprocess.TransferProcessProtocolServiceImpl;
Expand Down Expand Up @@ -287,4 +289,9 @@ public VersionProtocolService versionProtocolService() {
return new VersionProtocolServiceImpl(protocolVersionRegistry, protocolTokenValidator());
}

@Provider
public VersionService versionService() {
return new VersionServiceImpl(dispatcher);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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.eclipse.edc.connector.controlplane.services.protocol;

import org.eclipse.edc.connector.controlplane.protocolversion.spi.ProtocolVersionRequest;
import org.eclipse.edc.connector.controlplane.protocolversion.spi.ProtocolVersionRequestMessage;
import org.eclipse.edc.connector.controlplane.services.spi.protocol.VersionService;
import org.eclipse.edc.spi.message.RemoteMessageDispatcherRegistry;
import org.eclipse.edc.spi.response.StatusResult;

import java.util.concurrent.CompletableFuture;

public class VersionServiceImpl implements VersionService {

private final RemoteMessageDispatcherRegistry dispatcher;

public VersionServiceImpl(RemoteMessageDispatcherRegistry dispatcher) {
this.dispatcher = dispatcher;
}

@Override
public CompletableFuture<StatusResult<byte[]>> requestVersions(ProtocolVersionRequest request) {
var message = ProtocolVersionRequestMessage.Builder.newInstance()
.protocol(request.getProtocol())
.counterPartyId(request.getCounterPartyId())
.counterPartyAddress(request.getCounterPartyAddress())
.build();

return dispatcher.dispatch(byte[].class, message);
}
}
2 changes: 1 addition & 1 deletion data-protocols/dsp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ dependencies {
api(project(":data-protocols:dsp:dsp-http-spi"))
api(project(":data-protocols:dsp:dsp-negotiation"))
api(project(":data-protocols:dsp:dsp-transfer-process"))
api(project(":data-protocols:dsp:dsp-version:dsp-version-http-api"))
api(project(":data-protocols:dsp:dsp-version"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

import org.eclipse.edc.connector.controlplane.catalog.spi.CatalogRequestMessage;
import org.eclipse.edc.connector.controlplane.catalog.spi.DatasetRequestMessage;
import org.eclipse.edc.protocol.dsp.catalog.http.dispatcher.delegate.ByteArrayBodyExtractor;
import org.eclipse.edc.protocol.dsp.http.dispatcher.GetDspHttpRequestFactory;
import org.eclipse.edc.protocol.dsp.http.dispatcher.PostDspHttpRequestFactory;
import org.eclipse.edc.protocol.dsp.http.serialization.ByteArrayBodyExtractor;
import org.eclipse.edc.protocol.dsp.http.spi.DspProtocolParser;
import org.eclipse.edc.protocol.dsp.http.spi.dispatcher.DspHttpRemoteMessageDispatcher;
import org.eclipse.edc.protocol.dsp.http.spi.serialization.JsonLdRemoteMessageSerializer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractNegotiationTerminationMessage;
import org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractRequestMessage;
import org.eclipse.edc.connector.controlplane.contract.spi.types.protocol.ContractRemoteMessage;
import org.eclipse.edc.connector.controlplane.protocolversion.spi.ProtocolVersionRequestMessage;
import org.eclipse.edc.connector.controlplane.services.spi.protocol.ProtocolVersionRegistry;
import org.eclipse.edc.connector.controlplane.transfer.spi.types.protocol.TransferCompletionMessage;
import org.eclipse.edc.connector.controlplane.transfer.spi.types.protocol.TransferRemoteMessage;
Expand Down Expand Up @@ -136,6 +137,7 @@ public DspHttpRemoteMessageDispatcher dspHttpRemoteMessageDispatcher(ServiceExte
registerNegotiationPolicyScopes(dispatcher);
registerTransferProcessPolicyScopes(dispatcher);
registerCatalogPolicyScopes(dispatcher);
registerVersionPolicyScopes(dispatcher);
dispatcherRegistry.register(DATASPACE_PROTOCOL_HTTP, dispatcher);
dispatcherRegistry.register(DATASPACE_PROTOCOL_HTTP_V_2024_1, dispatcher);
return dispatcher;
Expand Down Expand Up @@ -187,4 +189,8 @@ private void registerCatalogPolicyScopes(DspHttpRemoteMessageDispatcher dispatch
dispatcher.registerPolicyScope(CatalogRequestMessage.class, CatalogRequestMessage::getPolicy, RequestCatalogPolicyContext::new);
dispatcher.registerPolicyScope(DatasetRequestMessage.class, DatasetRequestMessage::getPolicy, RequestCatalogPolicyContext::new);
}

private void registerVersionPolicyScopes(DspHttpRemoteMessageDispatcher dispatcher) {
dispatcher.registerPolicyScope(ProtocolVersionRequestMessage.class, ProtocolVersionRequestMessage::getPolicy, RequestVersionPolicyContext::new);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.protocol.dsp.catalog.http.dispatcher.delegate;
package org.eclipse.edc.protocol.dsp.http.serialization;

import okhttp3.ResponseBody;
import org.eclipse.edc.protocol.dsp.http.spi.dispatcher.response.DspHttpResponseBodyExtractor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.protocol.dsp.catalog.http.dispatcher.delegate;
package org.eclipse.edc.protocol.dsp.http.serialization;

import okhttp3.ResponseBody;
import org.eclipse.edc.spi.EdcException;
Expand Down
23 changes: 23 additions & 0 deletions data-protocols/dsp/dsp-version/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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
*
*/


plugins {
`java-library`
}

dependencies {
api(project(":data-protocols:dsp:dsp-version:dsp-version-http-api"))
api(project(":data-protocols:dsp:dsp-version:dsp-version-http-dispatcher"))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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
*
*/

plugins {
`java-library`
}

dependencies {
api(project(":data-protocols:dsp:dsp-http-core"))
api(project(":data-protocols:dsp:dsp-http-spi"))
api(project(":spi:control-plane:protocol-version-spi"))

testImplementation(testFixtures(project(":data-protocols:dsp:dsp-http-spi")))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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.eclipse.edc.protocol.dsp.version.http.dispatcher;

import org.eclipse.edc.connector.controlplane.protocolversion.spi.ProtocolVersionRequestMessage;
import org.eclipse.edc.protocol.dsp.http.dispatcher.GetDspHttpRequestFactory;
import org.eclipse.edc.protocol.dsp.http.serialization.ByteArrayBodyExtractor;
import org.eclipse.edc.protocol.dsp.http.spi.DspProtocolParser;
import org.eclipse.edc.protocol.dsp.http.spi.dispatcher.DspHttpRemoteMessageDispatcher;
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;

import static org.eclipse.edc.protocol.dsp.version.http.dispatcher.VersionApiPaths.PATH;

/**
* Creates and registers the HTTP dispatcher delegate for sending a version request as defined in
* the dataspace protocol specification.
*/
@Extension(value = DspVersionHttpDispatcherExtension.NAME)
public class DspVersionHttpDispatcherExtension implements ServiceExtension {

public static final String NAME = "Dataspace Protocol Version HTTP Dispatcher Extension";

@Inject
private DspHttpRemoteMessageDispatcher messageDispatcher;

@Inject
private DspProtocolParser dspProtocolParser;

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

@Override
public void initialize(ServiceExtensionContext context) {
var byteArrayBodyExtractor = new ByteArrayBodyExtractor();

messageDispatcher.registerMessage(
ProtocolVersionRequestMessage.class,
new GetDspHttpRequestFactory<>(dspProtocolParser, m -> PATH),
byteArrayBodyExtractor
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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.eclipse.edc.protocol.dsp.version.http.dispatcher;

/**
* API paths for version requests as defined in the dataspace protocol specification.
*/
public interface VersionApiPaths {

String PATH = "/.well-known/dspace-version";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# 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
#
#

org.eclipse.edc.protocol.dsp.version.http.dispatcher.DspVersionHttpDispatcherExtension
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{
"version": "4.0.0-alpha",
"urlPath": "/v4alpha",
"lastUpdated": "2024-11-21T14:24:00Z",
"lastUpdated": "2024-12-04T14:24:00Z",
"maturity": "alpha"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies {
api(project(":extensions:control-plane:api:management-api:edr-cache-api"))
api(project(":extensions:control-plane:api:management-api:policy-definition-api"))
api(project(":extensions:control-plane:api:management-api:transfer-process-api"))
api(project(":extensions:control-plane:api:management-api:protocol-version-api"))
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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
*
*/
plugins {
`java-library`
id(libs.plugins.swagger.get().pluginId)
}

dependencies {
api(project(":spi:control-plane:control-plane-spi"))

implementation(project(":core:common:lib:validator-lib"))
implementation(project(":extensions:common:api:api-core"))
implementation(project(":extensions:common:api:lib:management-api-lib"))

implementation(libs.jakarta.rsApi)

testImplementation(project(":core:common:junit"))
testImplementation(project(":core:common:lib:transform-lib"))
testImplementation(project(":core:control-plane:control-plane-core"))
testImplementation(project(":core:data-plane-selector:data-plane-selector-core"))
testImplementation(project(":extensions:common:http"))
testImplementation(project(":extensions:common:iam:iam-mock"))
testImplementation(testFixtures(project(":extensions:common:http:jersey-core")))
testImplementation(libs.restAssured)
}

edcBuild {
swagger {
apiGroup.set("management-api")
}
}


Loading
Loading