Skip to content

Commit 37066e4

Browse files
committed
feat: add endpoints to retrieve all versions and specific version of resources with content
Signed-off-by: Stiliyan Valkanov <stiliyan.valkanov@bearingpoint.com>
1 parent ea59ec9 commit 37066e4

11 files changed

Lines changed: 224 additions & 50 deletions

File tree

api/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ SPDX-License-Identifier: Apache-2.0
5454
<phase>none</phase>
5555

5656
<configuration>
57-
<inputSpec>${project.basedir}/plugins-custom-resources.yaml</inputSpec>
57+
<inputSpec>${project.basedir}/src/main/openapi/plugins-custom-resources.yaml</inputSpec>
5858
<generatorName>jaxrs-spec</generatorName>
5959
<output>${project.basedir}</output>
6060
<templateDirectory>${project.basedir}/src/main/resources/templates</templateDirectory>
@@ -63,7 +63,7 @@ SPDX-License-Identifier: Apache-2.0
6363
<configOptions>
6464
<sourceFolder>src/main/java</sourceFolder>
6565
<apiPackage>org.lfenergy.compas.scl.data.rest</apiPackage>
66-
<modelPackage>org.lfenergy.compas.scl.data.rest.dto</modelPackage>
66+
<modelPackage>org.lfenergy.compas.scl.data.rest.api.plugins.resources</modelPackage>
6767
<interfaceOnly>true</interfaceOnly>
6868
<useTags>true</useTags>
6969
<useJakartaEe>true</useJakartaEe>

api/src/main/java/org/lfenergy/compas/scl/data/rest/PluginsCustomResourcesApi.java

Lines changed: 62 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88
import java.util.Date;
99

1010
import org.lfenergy.compas.scl.data.rest.api.plugins.resources.PagedDataEntryResponse;
11-
import java.util.List;
1211
import java.util.UUID;
1312
import org.lfenergy.compas.scl.data.rest.api.plugins.resources.UploadDataResponse;
1413

1514
import jakarta.ws.rs.*;
1615

1716

1817
import java.io.InputStream;
19-
18+
import java.util.List;
2019
import jakarta.validation.constraints.*;
2120

2221
/**
@@ -26,6 +25,35 @@
2625
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", comments = "Generator version: 7.12.0")
2726
public interface PluginsCustomResourcesApi {
2827

28+
/**
29+
* Delete all data entries for the given data type
30+
*
31+
* @param id Data type of the entries to delete
32+
* @return Data entries deleted successfully
33+
* @return No data entries found for the given data type
34+
* @return Internal server error
35+
*/
36+
@DELETE
37+
@Path("/{id}")
38+
@Produces({ "application/json" })
39+
void deleteDataByType(@PathParam("id") String id);
40+
41+
42+
/**
43+
* Delete all data entries for the given data type and resource name
44+
*
45+
* @param dataType Data type of the entries to delete
46+
* @param name Name of the entries to delete
47+
* @return Data entries deleted successfully
48+
* @return No data entries found for the given data type and name
49+
* @return Internal server error
50+
*/
51+
@DELETE
52+
@Path("/{data-type}/{name}")
53+
@Produces({ "application/json" })
54+
void deleteDataByTypeAndName(@PathParam("data-type") String dataType,@PathParam("name") String name);
55+
56+
2957
/**
3058
* Retrieve metadata for all uploaded data entries with optional filtering
3159
*
@@ -45,30 +73,48 @@ public interface PluginsCustomResourcesApi {
4573

4674

4775
/**
48-
* Retrieve a single data entry by its unique identifier, including the full content
76+
* Returns all versions of the named resource as DataEntryWithContent objects
4977
*
50-
* @param id Unique identifier of the data entry
51-
* @return Data entry retrieved successfully
52-
* @return Data entry not found
78+
* @param dataType
79+
* @param name
80+
* @return List of versions with content
81+
* @return Resource not found
5382
* @return Internal server error
5483
*/
5584
@GET
56-
@Path("/{id}")
85+
@Path("/{data-type}/{name}/versions")
5786
@Produces({ "application/json" })
58-
DataEntryWithContent getDataById(@PathParam("id") UUID id);
87+
List<DataEntryWithContent> getAllVersionsWithContentByTypeAndName(@PathParam("data-type") String dataType,@PathParam("name") String name);
88+
5989

6090

6191
/**
62-
* Delete all data entries for the given data type
92+
* Returns the specified version of the named resource, with content
6393
*
64-
* @param dataType Data type of the entries to delete
65-
* @return Data entries deleted successfully
66-
* @return No data entries found for the given data type
94+
* @param dataType
95+
* @param name
96+
* @param version
97+
* @return Resource version with content
98+
* @return Resource version not found
6799
* @return Internal server error
68100
*/
69-
@DELETE
70-
@Path("/{data-type}")
71-
void deleteDataByType(@PathParam("data-type") String dataType);
101+
@GET
102+
@Path("/v1/{data-type}/{name}/{version}")
103+
@Produces({ "application/json" })
104+
DataEntryWithContent getSpecificVersionByTypeAndName(@PathParam("data-type") String dataType,@PathParam("name") String name,@PathParam("version") String version);
105+
106+
/**
107+
* Retrieve a single data entry by its unique identifier, including the full content
108+
*
109+
* @param id Unique identifier of the data entry
110+
* @return Data entry retrieved successfully
111+
* @return Data entry not found
112+
* @return Internal server error
113+
*/
114+
@GET
115+
@Path("/{id}")
116+
@Produces({ "application/json" })
117+
DataEntryWithContent getDataById(@PathParam("id") UUID id);
72118

73119

74120
/**
@@ -85,20 +131,6 @@ public interface PluginsCustomResourcesApi {
85131
List<DataEntry> getLatestDataByType(@PathParam("data-type") String dataType);
86132

87133

88-
/**
89-
* Delete all data entries for the given data type and resource name
90-
*
91-
* @param dataType Data type of the entries to delete
92-
* @param name Name of the entries to delete
93-
* @return Data entries deleted successfully
94-
* @return No data entries found for the given data type and name
95-
* @return Internal server error
96-
*/
97-
@DELETE
98-
@Path("/{data-type}/{name}")
99-
void deleteDataByTypeAndName(@PathParam("data-type") String dataType, @PathParam("name") String name);
100-
101-
102134
/**
103135
* Retrieve the latest version of a data entry for the given data type and resource name, including the full content
104136
*
@@ -111,7 +143,7 @@ public interface PluginsCustomResourcesApi {
111143
@GET
112144
@Path("/{data-type}/{name}/latest")
113145
@Produces({ "application/json" })
114-
DataEntryWithContent getLatestDataByTypeAndName(@PathParam("data-type") String dataType, @PathParam("name") String name);
146+
DataEntryWithContent getLatestDataByTypeAndName(@PathParam("data-type") String dataType,@PathParam("name") String name);
115147

116148

117149
/**

api/src/main/java/org/lfenergy/compas/scl/data/rest/api/plugins/resources/DataEntry.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
// SPDX-FileCopyrightText: 2026 BearingPoint GmbH
2-
//
3-
// SPDX-License-Identifier: Apache-2.0
41
package org.lfenergy.compas.scl.data.rest.api.plugins.resources;
52

63
import java.util.Date;
74
import java.util.UUID;
85
import jakarta.validation.constraints.*;
6+
import jakarta.validation.Valid;
97

108
import java.util.Objects;
119
import com.fasterxml.jackson.annotation.JsonProperty;

api/src/main/java/org/lfenergy/compas/scl/data/rest/api/plugins/resources/DataEntryWithContent.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
// SPDX-FileCopyrightText: 2026 BearingPoint GmbH
2-
//
3-
// SPDX-License-Identifier: Apache-2.0
41
package org.lfenergy.compas.scl.data.rest.api.plugins.resources;
52

63
import java.util.Date;
74
import java.util.UUID;
8-
5+
import org.lfenergy.compas.scl.data.rest.api.plugins.resources.DataEntry;
96
import jakarta.validation.constraints.*;
7+
import jakarta.validation.Valid;
108

119
import java.util.Objects;
1210
import com.fasterxml.jackson.annotation.JsonProperty;
1311
import com.fasterxml.jackson.annotation.JsonCreator;
12+
import com.fasterxml.jackson.annotation.JsonValue;
1413
import com.fasterxml.jackson.annotation.JsonTypeName;
1514

1615

api/src/main/java/org/lfenergy/compas/scl/data/rest/api/plugins/resources/Error.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
// SPDX-FileCopyrightText: 2026 BearingPoint GmbH
2-
//
3-
// SPDX-License-Identifier: Apache-2.0
41
package org.lfenergy.compas.scl.data.rest.api.plugins.resources;
52

63
import java.util.HashMap;
74
import java.util.Map;
85
import jakarta.validation.constraints.*;
96
import jakarta.validation.Valid;
7+
108
import java.util.Objects;
119
import com.fasterxml.jackson.annotation.JsonProperty;
1210
import com.fasterxml.jackson.annotation.JsonCreator;
11+
import com.fasterxml.jackson.annotation.JsonValue;
1312
import com.fasterxml.jackson.annotation.JsonTypeName;
1413

1514

api/src/main/java/org/lfenergy/compas/scl/data/rest/api/plugins/resources/PagedDataEntryResponse.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
// SPDX-FileCopyrightText: 2026 BearingPoint GmbH
2-
//
3-
// SPDX-License-Identifier: Apache-2.0
41
package org.lfenergy.compas.scl.data.rest.api.plugins.resources;
52

63
import java.util.ArrayList;
4+
import java.util.Arrays;
75
import java.util.List;
8-
6+
import org.lfenergy.compas.scl.data.rest.api.plugins.resources.DataEntry;
7+
import jakarta.validation.constraints.*;
98
import jakarta.validation.Valid;
109

1110
import java.util.Objects;
1211
import com.fasterxml.jackson.annotation.JsonProperty;
12+
import com.fasterxml.jackson.annotation.JsonCreator;
13+
import com.fasterxml.jackson.annotation.JsonValue;
1314
import com.fasterxml.jackson.annotation.JsonTypeName;
1415

1516

api/src/main/java/org/lfenergy/compas/scl/data/rest/api/plugins/resources/UploadDataResponse.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
// SPDX-FileCopyrightText: 2026 BearingPoint GmbH
2-
//
3-
// SPDX-License-Identifier: Apache-2.0
41
package org.lfenergy.compas.scl.data.rest.api.plugins.resources;
52

63
import java.util.Date;
74
import java.util.UUID;
5+
import jakarta.validation.constraints.*;
6+
import jakarta.validation.Valid;
87

98
import java.util.Objects;
109
import com.fasterxml.jackson.annotation.JsonProperty;
10+
import com.fasterxml.jackson.annotation.JsonCreator;
11+
import com.fasterxml.jackson.annotation.JsonValue;
1112
import com.fasterxml.jackson.annotation.JsonTypeName;
1213

1314

api/src/main/openapi/plugins-custom-resources.yaml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,91 @@ paths:
412412
schema:
413413
$ref: '#/components/schemas/Error'
414414

415+
416+
/plugins/resources/{data-type}/{name}/versions:
417+
get:
418+
tags:
419+
- plugins-custom-resources
420+
summary: List all versions of a resource by name and data type (with content)
421+
description: Returns all versions of the named resource as DataEntryWithContent objects
422+
operationId: getAllVersionsWithContentByTypeAndName
423+
parameters:
424+
- name: data-type
425+
in: path
426+
required: true
427+
schema:
428+
type: string
429+
- name: name
430+
in: path
431+
required: true
432+
schema:
433+
type: string
434+
responses:
435+
'200':
436+
description: List of versions with content
437+
content:
438+
application/json:
439+
schema:
440+
type: array
441+
items:
442+
$ref: '#/components/schemas/DataEntryWithContent'
443+
'404':
444+
description: Resource not found
445+
content:
446+
application/json:
447+
schema:
448+
$ref: '#/components/schemas/Error'
449+
'500':
450+
description: Internal server error
451+
content:
452+
application/json:
453+
schema:
454+
$ref: '#/components/schemas/Error'
455+
456+
457+
/plugins/resources/v1/{data-type}/{name}/{version}:
458+
get:
459+
tags:
460+
- plugins-custom-resources
461+
summary: Get a specific version of a resource
462+
description: Returns the specified version of the named resource, with content
463+
operationId: getSpecificVersionByTypeAndName
464+
parameters:
465+
- name: data-type
466+
in: path
467+
required: true
468+
schema:
469+
type: string
470+
- name: name
471+
in: path
472+
required: true
473+
schema:
474+
type: string
475+
- name: version
476+
in: path
477+
required: true
478+
schema:
479+
type: string
480+
responses:
481+
'200':
482+
description: Resource version with content
483+
content:
484+
application/json:
485+
schema:
486+
$ref: '#/components/schemas/DataEntryWithContent'
487+
'404':
488+
description: Resource version not found
489+
content:
490+
application/json:
491+
schema:
492+
$ref: '#/components/schemas/Error'
493+
'500':
494+
description: Internal server error
495+
content:
496+
application/json:
497+
schema:
498+
$ref: '#/components/schemas/Error'
499+
415500
/plugins/resources/{data-type}/{name}/latest:
416501
get:
417502
tags:

app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/CompasPluginsResource.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ public PagedDataEntryResponse getAllData(String type,
6666
return response;
6767
}
6868

69+
@Override
70+
public List<DataEntryWithContent> getAllVersionsWithContentByTypeAndName(String dataType, String name) {
71+
LOGGER.info("Getting all versions of a resource by name '{}' and type '{}'", name, dataType);
72+
return service.getAllVersionsWithContentByTypeAndName(dataType, name).stream()
73+
.map(this::toDataEntryWithContent)
74+
.toList();
75+
}
76+
77+
@Override
78+
public DataEntryWithContent getSpecificVersionByTypeAndName(String dataType, String name, String version) {
79+
LOGGER.info("Getting specific version of a resource by version '{}', name '{}' and type '{}'",version ,name, dataType);
80+
return toDataEntryWithContent(service.getSpecificVersionByTypeAndName(dataType, name, version));
81+
}
82+
6983
@Override
7084
public DataEntryWithContent getDataById(UUID id) {
7185
LOGGER.info("Getting plugins custom resource by id '{}'", id);
@@ -103,6 +117,7 @@ public DataEntryWithContent getLatestDataByTypeAndName(String dataType, String n
103117
return toDataEntryWithContent(entity);
104118
}
105119

120+
106121
@Override
107122
public UploadDataResponse uploadData(String type,
108123
String name,

0 commit comments

Comments
 (0)