Skip to content

Commit a946470

Browse files
committed
fix: postman collection "Management API Tests", data-service usability and compilation of mxd-runtimes
1 parent 47bc6c8 commit a946470

File tree

7 files changed

+239
-28
lines changed

7 files changed

+239
-28
lines changed

mxd-runtimes/data-service-api/src/main/java/org/eclipse/tractusx/mxd/dataservice/DataServiceExtension.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.eclipse.edc.runtime.metamodel.annotation.Settings;
2626
import org.eclipse.edc.spi.system.ServiceExtension;
2727
import org.eclipse.edc.spi.system.ServiceExtensionContext;
28+
import org.eclipse.edc.spi.types.TypeManager;
2829
import org.eclipse.edc.web.spi.WebServer;
2930
import org.eclipse.edc.web.spi.WebService;
3031
import org.eclipse.edc.web.spi.configuration.PortMapping;
@@ -46,6 +47,8 @@ public class DataServiceExtension implements ServiceExtension {
4647
private DataServiceApiConfiguration apiConfig;
4748
@Inject
4849
private PortMappingRegistry portMappingRegistry;
50+
@Inject
51+
private TypeManager typeManager;
4952

5053
@Override
5154
public String name() {
@@ -59,7 +62,7 @@ public void initialize(ServiceExtensionContext context) {
5962

6063
var database = new ConcurrentHashMap<String, DataRecord>();
6164
populate(database);
62-
webService.registerResource(DATA_API_CONTEXT_NAME, new DataServiceApiController(database));
65+
webService.registerResource(DATA_API_CONTEXT_NAME, new DataServiceApiController(database, typeManager.getMapper()));
6366
}
6467

6568
private void populate(Map<String, DataRecord> database) {

mxd-runtimes/data-service-api/src/main/java/org/eclipse/tractusx/mxd/dataservice/api/DataServiceApi.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import io.swagger.v3.oas.annotations.parameters.RequestBody;
2323
import io.swagger.v3.oas.annotations.responses.ApiResponse;
2424
import io.swagger.v3.oas.annotations.tags.Tag;
25-
import org.eclipse.edc.spi.query.QuerySpec;
2625
import org.eclipse.edc.web.spi.ApiErrorDetail;
2726
import org.eclipse.tractusx.mxd.dataservice.model.DataRecord;
2827

@@ -63,7 +62,7 @@ public interface DataServiceApi {
6362
@ApiResponse(responseCode = "401", description = "Not authenticated: principal could not be identified",
6463
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiErrorDetail.class))))
6564
})
66-
void create(DataRecord dataRecord);
65+
String create(DataRecord dataRecord);
6766

6867

6968
@Operation(description = "Updates an existing DataRecord with new values.",

mxd-runtimes/data-service-api/src/main/java/org/eclipse/tractusx/mxd/dataservice/api/DataServiceApiController.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
package org.eclipse.tractusx.mxd.dataservice.api;
1616

17+
import com.fasterxml.jackson.databind.JsonNode;
18+
import com.fasterxml.jackson.databind.ObjectMapper;
1719
import jakarta.ws.rs.Consumes;
1820
import jakarta.ws.rs.DELETE;
1921
import jakarta.ws.rs.GET;
@@ -23,13 +25,13 @@
2325
import jakarta.ws.rs.PathParam;
2426
import jakarta.ws.rs.Produces;
2527
import jakarta.ws.rs.core.MediaType;
26-
import org.eclipse.edc.web.spi.exception.InvalidRequestException;
28+
import org.eclipse.edc.spi.EdcException;
2729
import org.eclipse.edc.web.spi.exception.ObjectConflictException;
2830
import org.eclipse.edc.web.spi.exception.ObjectNotFoundException;
2931
import org.eclipse.tractusx.mxd.dataservice.model.DataRecord;
3032

33+
import java.io.IOException;
3134
import java.util.Collection;
32-
import java.util.Map;
3335
import java.util.concurrent.ConcurrentHashMap;
3436

3537
@Consumes(MediaType.APPLICATION_JSON)
@@ -38,9 +40,11 @@
3840
public class DataServiceApiController implements DataServiceApi {
3941

4042
private final ConcurrentHashMap<String, DataRecord> database;
43+
private final ObjectMapper objectMapper;
4144

42-
public DataServiceApiController(ConcurrentHashMap<String, DataRecord> database) {
45+
public DataServiceApiController(ConcurrentHashMap<String, DataRecord> database, ObjectMapper objectMapper) {
4346
this.database = database;
47+
this.objectMapper = objectMapper;
4448
}
4549

4650
@GET
@@ -61,11 +65,12 @@ public DataRecord findById(@PathParam("id") String id) {
6165

6266
@POST
6367
@Override
64-
public void create(DataRecord dataRecord) {
68+
public String create(DataRecord dataRecord) {
6569
if (database.containsKey(dataRecord.id())) {
6670
throw new ObjectConflictException("DataRecord with id " + dataRecord.id() + " already exists");
6771
}
6872
database.put(dataRecord.id(), dataRecord);
73+
return createJsonResponse(dataRecord.id());
6974
}
7075

7176
@PUT
@@ -86,4 +91,13 @@ public void delete(@PathParam("id") String id) {
8691
}
8792
database.remove(id);
8893
}
94+
95+
private String createJsonResponse(String id) {
96+
JsonNode jsonResponse = objectMapper.createObjectNode().put("id", id);
97+
try {
98+
return objectMapper.writeValueAsString(jsonResponse);
99+
} catch (IOException e) {
100+
throw new EdcException(e.getMessage());
101+
}
102+
}
89103
}

mxd-runtimes/tx-issuerservice/src/main/java/org/eclipse/edc/issuerservice/demo/attestation/DemoAttestationSourceFactory.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
public class DemoAttestationSourceFactory implements AttestationSourceFactory {
2222
@Override
2323
public AttestationSource createSource(AttestationDefinition definition) {
24-
var config = definition.configuration();
2524
return new DemoAttestationSource();
2625
}
2726

mxd/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ this should compile the Java code and build Docker images out of all runtimes. O
7373
KinD:
7474

7575
```shell
76-
kind load docker-image --name mxd data-service-api tx-identityhub tx-identityhub-sts tx-identityhub tx-catalog-server tx-sts
76+
kind load docker-image --name mxd data-service-api tx-identityhub tx-catalog-server tx-issuerservice
7777
```
7878

7979
### 2.3 Bring up the data space

mxd/data-service-api.tf

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,44 @@ resource "kubernetes_service" "data-service-api" {
124124
}
125125
}
126126

127+
resource "kubernetes_ingress_v1" "api-ingress" {
128+
metadata {
129+
name = "${var.humanReadableName}-ingress"
130+
namespace = var.namespace
131+
annotations = {
132+
"nginx.ingress.kubernetes.io/rewrite-target" = "/$2"
133+
"nginx.ingress.kubernetes.io/use-regex" = "true"
134+
}
135+
}
136+
spec {
137+
ingress_class_name = "nginx"
138+
rule {
139+
host = var.ingress-host
140+
http {
141+
path {
142+
path = "/data-service(/|$)(.*)"
143+
backend {
144+
service {
145+
name = "data-service-api"
146+
port {
147+
number = 8080
148+
}
149+
}
150+
}
151+
}
152+
}
153+
}
154+
}
155+
}
156+
157+
variable "ingress-host" {
158+
description = "Ingress Host"
159+
default = "localhost"
160+
}
161+
162+
variable "humanReadableName" {
163+
type = string
164+
description = "Human readable name of the data service, NOT the ID!!. Required."
165+
default = "data-service"
166+
}
167+

0 commit comments

Comments
 (0)