Skip to content
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 @@ -16,13 +16,12 @@

import java.util.List;

public record DataPlaneRegistrationRequest(List<String> allowedSourceTypes, List<String> allowedTransferTypes,
List<String> destinationProvisionTypes, String url) {
public record DataPlaneRegistrationRequest(String id, List<String> allowedTransferTypes, List<String> labels, String url) {

public static DataPlaneRegistrationRequest ofDefault() {
return new DataPlaneRegistrationRequest(List.of("HttpData", "HttpCertData"),
return new DataPlaneRegistrationRequest("dataplane-%s",
List.of("HttpData-PULL"),
List.of("HttpData", "HttpCertData", "httpData", "httpCertData"),
"http://dataplane.edc-v.svc.cluster.local:8083/api/control/v1/dataflows");
List.of(),
"http://siglet.edc-v.svc.cluster.local:8081/api/v1/%s/dataflows");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.metaformsystems.redline.infrastructure.client.management.dto.PolicySet;
import com.metaformsystems.redline.infrastructure.client.management.dto.TransferProcess;
import com.metaformsystems.redline.infrastructure.client.management.dto.TransferRequest;
import com.metaformsystems.redline.infrastructure.client.siglet.SigletApiClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -67,11 +68,13 @@ public class DataAccessService {
private final WebDidResolver webDidResolver;
private final ParticipantRepository participantRepository;
private final ManagementApiClient managementApiClient;
private final SigletApiClient sigletApiClient;

public DataAccessService(DataPlaneApiClient dataPlaneApiClient, WebDidResolver webDidResolver, ParticipantRepository participantRepository, ManagementApiClient managementApiClient) {
public DataAccessService(DataPlaneApiClient dataPlaneApiClient, WebDidResolver webDidResolver, ParticipantRepository participantRepository, ManagementApiClient managementApiClient, SigletApiClient sigletApiClient) {
this.dataPlaneApiClient = dataPlaneApiClient;
this.participantRepository = participantRepository;
this.managementApiClient = managementApiClient;
this.sigletApiClient = sigletApiClient;
this.catalogCache = new ConcurrentLruCache<>(100, key -> fetchCatalog(key.participantId(), key.did()));
this.webDidResolver = webDidResolver;
}
Expand Down Expand Up @@ -231,10 +234,14 @@ public String initiateTransferProcess(Long providerId, TransferProcessRequest tr

@Transactional
public TransferProcess getTransferProcess(Long participantId, String transferProcessId) {
var tp = managementApiClient.getTransferProcess(getContextId(participantId), transferProcessId);
var contextId = getContextId(participantId);
var tp = managementApiClient.getTransferProcess(contextId, transferProcessId);
if ("STARTED".equals(tp.getState())) { //download EDR as well
var edr = managementApiClient.getEdr(getContextId(participantId), transferProcessId);
tp.setContentDataAddress(edr);
// TODO shim layer for old EDR format
var edr = sigletApiClient.getDataAddress(contextId, transferProcessId);
tp.setContentDataAddress(Map.of(
"properties", Map.of("https://w3id.org/edc/v0.0.1/ns/authorization", edr.get("token"))
));
}
return tp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,10 @@ public void registerDataPlane(Long participantId, DataPlaneRegistrationRequest r

//todo: replace magic strings with parameters
managementApiClient.prepareDataplane(participantContextId, DataplaneRegistration.Builder.aDataplaneRegistration()
.allowedSourceTypes(request.allowedSourceTypes())
.id(request.id().formatted(participantContextId))
.allowedTransferTypes(request.allowedTransferTypes())
.destinationProvisionTypes(request.destinationProvisionTypes())
.url(request.url())
.labels(request.allowedTransferTypes())
.url(request.url().formatted(participantContextId))
.build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public byte[] downloadFile(String authToken, String fileId) {

Flux<DataBuffer> dataBufferFlux = dataPlanePublicClient.get()
.uri("/certs/" + fileId)
.header("Authorization", authToken)
.header("Authorization", "Bearer " + authToken)
.retrieve()
.bodyToFlux(DataBuffer.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,4 @@ public interface ManagementApiClient {

ContractAgreement getAgreement(String participantContextId, String negotiationId);

Map<String, Object> getEdr(String participantContextId, String transferProcessId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -332,17 +332,6 @@ public ContractAgreement getAgreement(String participantContextId, String negoti
.block();
}

@Override
public Map<String, Object> getEdr(String participantContextId, String transferProcessId) {
return controlPlaneWebClient.get()
.uri("/v1alpha/participants/{participantContextId}/edr/{transferProcessId}", participantContextId, transferProcessId)
.header("Authorization", "Bearer " + getToken(participantContextId))
.retrieve()
.bodyToMono(new ParameterizedTypeReference<Map<String, Object>>() {
})
.block();
}

private String getToken(String participantContextId) {
var participantProfile = participantRepository.findByParticipantContextId(participantContextId)
.orElseThrow(() -> new ObjectNotFoundException("Participant not found with context id: " + participantContextId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,11 @@
import java.util.List;

public class DataplaneRegistration {
private List<String> allowedSourceTypes;
private String id;
private List<String> allowedTransferTypes;
private String url;
private List<String> destinationProvisionTypes;
private List<String> labels;

public List<String> getAllowedSourceTypes() {
return allowedSourceTypes;
}

public void setAllowedSourceTypes(List<String> allowedSourceTypes) {
this.allowedSourceTypes = allowedSourceTypes;
}

public List<String> getAllowedTransferTypes() {
return allowedTransferTypes;
Expand All @@ -38,6 +31,10 @@ public void setAllowedTransferTypes(List<String> allowedTransferTypes) {
this.allowedTransferTypes = allowedTransferTypes;
}

public String getId() {
return id;
}

public String getUrl() {
return url;
}
Expand All @@ -46,12 +43,8 @@ public void setUrl(String url) {
this.url = url;
}

public List<String> getDestinationProvisionTypes() {
return destinationProvisionTypes;
}

public void setDestinationProvisionTypes(List<String> destinationProvisionTypes) {
this.destinationProvisionTypes = destinationProvisionTypes;
public List<String> getLabels() {
return labels;
}

public static final class Builder {
Expand All @@ -65,8 +58,13 @@ public static Builder aDataplaneRegistration() {
return new Builder();
}

public Builder allowedSourceTypes(List<String> allowedSourceTypes) {
dataplaneRegistration.setAllowedSourceTypes(allowedSourceTypes);
public Builder id(String id) {
dataplaneRegistration.id = id;
return this;
}

public Builder labels(List<String> labels) {
dataplaneRegistration.labels = labels;
return this;
}

Expand All @@ -84,9 +82,5 @@ public DataplaneRegistration build() {
return dataplaneRegistration;
}

public Builder destinationProvisionTypes(List<String> httpData) {
dataplaneRegistration.setDestinationProvisionTypes(httpData);
return this;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.metaformsystems.redline.infrastructure.client.siglet;

import java.util.Map;

public interface SigletApiClient {

Map<String, Object> getDataAddress(String participantContextId, String transferProcessId);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.metaformsystems.redline.infrastructure.client.siglet;

import org.springframework.core.ParameterizedTypeReference;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.client.WebClient;

import java.util.Map;

@Component
public class SigletApiClientImpl implements SigletApiClient{

private final WebClient sigletWebClient;

public SigletApiClientImpl(WebClient sigletWebClient) {
this.sigletWebClient = sigletWebClient;
}

@Override
public Map<String, Object> getDataAddress(String participantContextId, String transferProcessId) {
return sigletWebClient.get()
.uri("/tokens/{participantContextId}/{transferProcessId}", participantContextId, transferProcessId)
.retrieve()
.bodyToMono(new ParameterizedTypeReference<Map<String, Object>>() {
})
.block();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2026 Metaform Systems, Inc.
*
* 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:
* Metaform Systems, Inc. - initial API and implementation
*
*/

package com.metaformsystems.redline.infrastructure.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.client.WebClient;

@Configuration
public class SigletClientConfig {

@Value("${siglet.url:http://siglet.localhost}")
private String sigletUrl;

@Bean
public WebClient sigletWebClient(WebClient.Builder webClientBuilder) {
return webClientBuilder
.baseUrl(sigletUrl)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,8 @@ private ParticipantInfo onboardParticipant() {

private void registerDataPlane(String participantContextId) {
managementApiClient.prepareDataplane(participantContextId, DataplaneRegistration.Builder.aDataplaneRegistration()
.allowedSourceTypes(List.of("HttpData", "HttpCertData"))
.allowedTransferTypes(List.of("HttpData-PULL"))
.destinationProvisionTypes(List.of("HttpData", "HttpCertData", "httpData", "httpCertData"))
.url("http://dataplane.edc-v.svc.cluster.local:8083/api/control/v1/dataflows") //todo: replace with config
.url("http://siglet.edc-v.svc.cluster.local:8081/api/v1/dataflows") //todo: replace with config
.build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,6 @@ void shouldPrepareDataplane() throws InterruptedException {
// Arrange
var dataplaneRegistration = DataplaneRegistration.Builder.aDataplaneRegistration()
.url("http://localhost:8080")
.allowedSourceTypes(List.of("HttpData"))
.allowedTransferTypes(List.of("HttpData-PULL"))
.build();

Expand Down
Loading