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 @@ -28,7 +28,7 @@ public interface DataPlaneApiClient {
* @param metadata optional metadata to describe the file
* @param data an input stream of the file data
*/
UploadResponse uploadMultipart(String participantContextId, Map<String, String> metadata, InputStream data);
UploadResponse uploadMultipart(String participantContextId, Map<String, Object> metadata, InputStream data);

/**
* This is used on the provider side to list all uploaded files
Expand All @@ -38,7 +38,7 @@ public interface DataPlaneApiClient {
/**
* This method is used on the consumer side to query all files that are offered on the network
*/
List<UploadResponse> queryProviderFiles(String participantContextId, QuerySpec querySpec);
List<UploadResponse> listPublicFiles(String participantContextId, QuerySpec querySpec);

/**
* Downloads a file from the provider's dataplane
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,24 @@

@Component
public class DataPlaneApiClientImpl implements DataPlaneApiClient {
private final WebClient dataPlaneWebClient;
private final WebClient dataPlanePublicClient;
private final WebClient dataPlaneInternalClient;
private final ParticipantRepository participantRepository;
private final TokenProvider tokenProvider;

public DataPlaneApiClientImpl(WebClient dataPlaneWebClient, ParticipantRepository participantRepository, TokenProvider tokenProvider) {
this.dataPlaneWebClient = dataPlaneWebClient.mutate()
public DataPlaneApiClientImpl(WebClient dataPlanePublicClient, WebClient dataPlaneInternalClient, ParticipantRepository participantRepository, TokenProvider tokenProvider) {
this.dataPlanePublicClient = dataPlanePublicClient.mutate()
.exchangeStrategies(ExchangeStrategies.builder()
.codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(50 * 1024 * 1024))
.build())
.build();
this.dataPlaneInternalClient = dataPlaneInternalClient;
this.participantRepository = participantRepository;
this.tokenProvider = tokenProvider;
}

@Override
public UploadResponse uploadMultipart(String participantContextId, Map<String, String> metadata, InputStream data) {
public UploadResponse uploadMultipart(String participantContextId, Map<String, Object> metadata, InputStream data) {
var bodyBuilder = new MultipartBodyBuilder();

// Add metadata fields
Expand All @@ -64,8 +66,8 @@ public UploadResponse uploadMultipart(String participantContextId, Map<String, S
.part("file", new InputStreamResource(data))
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE);

return dataPlaneWebClient.post()
.uri("/app/internal/api/control/certs")
return dataPlaneInternalClient.post()
.uri("/certs")
.header("Authorization", "Bearer " + getToken(participantContextId))
.contentType(MediaType.MULTIPART_FORM_DATA)
.bodyValue(bodyBuilder.build())
Expand All @@ -76,18 +78,18 @@ public UploadResponse uploadMultipart(String participantContextId, Map<String, S

@Override
public List<UploadResponse> getAllUploads() {
return dataPlaneWebClient.post()
.uri("/app/internal/api/control/certs/request")
return dataPlaneInternalClient.post()
.uri("/certs/request")
.retrieve()
.bodyToMono(new ParameterizedTypeReference<List<UploadResponse>>() {
})
.block();
}

@Override
public List<UploadResponse> queryProviderFiles(String participantContextId, QuerySpec querySpec) {
return dataPlaneWebClient.post()
.uri("/app/internal/api/control/certs/request")
public List<UploadResponse> listPublicFiles(String participantContextId, QuerySpec querySpec) {
return dataPlanePublicClient.post()
.uri("/certs/request")
.bodyValue(querySpec)
.retrieve()
.bodyToMono(new ParameterizedTypeReference<List<UploadResponse>>() {
Expand All @@ -98,8 +100,8 @@ public List<UploadResponse> queryProviderFiles(String participantContextId, Quer
@Override
public byte[] downloadFile(String authToken, String fileId) {

Flux<DataBuffer> dataBufferFlux = dataPlaneWebClient.get()
.uri("/app/public/api/data/certs/" + fileId)
Flux<DataBuffer> dataBufferFlux = dataPlanePublicClient.get()
.uri("/certs/" + fileId)
.header("Authorization", authToken)
.retrieve()
.bodyToFlux(DataBuffer.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,23 @@

@Configuration
public class DataPlaneConfig {
@Value("${dataplane.url:http://dp.localhost}")
private String dataPlaneUrl;
@Value("${dataplane.url:http://dp.localhost/app/public/api/data}")
private String dataPlanePublicUrl;

@Value("${dataplane.internal.url:http://dp.localhost/app/internal/api/control}")
private String dataPlaneInternalUrl;

@Bean
public WebClient dataPlanePublicClient(WebClient.Builder webClientBuilder) {
return webClientBuilder
.baseUrl(dataPlanePublicUrl)
.build();
}

@Bean
public WebClient dataPlaneWebClient(WebClient.Builder webClientBuilder) {
public WebClient dataPlaneInternalClient(WebClient.Builder webClientBuilder) {
return webClientBuilder
.baseUrl(dataPlaneUrl)
.baseUrl(dataPlaneInternalUrl)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.metaformsystems.redline.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -9,9 +13,14 @@

@RestController
@RequestMapping("/api/public")
@Tag(name = "Public", description = "Public endpoints for health checks and system information")
public class PublicController {

@GetMapping("/health")
@Operation(summary = "Health check", description = "Returns the health status of the application")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Application is healthy")
})
public ResponseEntity<Map<String, String>> health() {
return ResponseEntity.ok(Map.of(
"status", "UP",
Expand All @@ -21,6 +30,10 @@ public ResponseEntity<Map<String, String>> health() {
}

@GetMapping("/info")
@Operation(summary = "System information", description = "Returns basic information about the Redline API")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully retrieved system information")
})
public ResponseEntity<Map<String, String>> info() {
return ResponseEntity.ok(Map.of(
"name", "Redline API",
Expand Down
Loading
Loading