Skip to content

Commit 29c5960

Browse files
Merge pull request #319 from com-pas/develop
New release
2 parents e994b99 + 4ab3174 commit 29c5960

File tree

16 files changed

+181
-19
lines changed

16 files changed

+181
-19
lines changed

.github/workflows/automate-projects.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ jobs:
1414
steps:
1515
- name: add-new-issues-to-organization-based-project-column
1616
if: github.event_name == 'issues' && github.event.action == 'opened'
17-
uses: alex-page/[email protected].2
17+
uses: alex-page/[email protected].3
1818
with:
1919
project: CoMPAS Issues Overview Board
2020
column: To do
2121
repo-token: ${{ secrets.ORG_GITHUB_ACTION_SECRET }}
2222
- name: add-new-pull-request-to-organization-based-project-column
2323
if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.action == 'opened'
24-
uses: alex-page/[email protected].2
24+
uses: alex-page/[email protected].3
2525
with:
2626
project: CoMPAS Pull Request Overview Board
2727
column: To do

app/src/main/docker/Dockerfile-basex.jvm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/app-jvm
2222
#
2323
###
24-
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7-923
24+
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7-1085
2525

2626
ARG JAVA_PACKAGE=java-17-openjdk-headless
2727
ARG RUN_JAVA_VERSION=1.3.8

app/src/main/docker/Dockerfile-basex.native

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# docker run -i --rm -p 8080:8080 quarkus/app
1515
#
1616
###
17-
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7-923
17+
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7-1085
1818
WORKDIR /work/
1919
RUN chown 1001 /work \
2020
&& chmod "g+rwX" /work \

app/src/main/docker/Dockerfile-postgresql.jvm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/app-jvm
2222
#
2323
###
24-
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7-923
24+
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7-1085
2525

2626
ARG JAVA_PACKAGE=java-17-openjdk-headless
2727
ARG RUN_JAVA_VERSION=1.3.8

app/src/main/docker/Dockerfile-postgresql.native

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# docker run -i --rm -p 8080:8080 quarkus/app
1515
#
1616
###
17-
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7-923
17+
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7-1085
1818
WORKDIR /work/
1919
RUN chown 1001 /work \
2020
&& chmod "g+rwX" /work \

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,17 @@ public Uni<Void> deleteVersion(@PathParam(TYPE_PATH_PARAM) SclFileType type,
143143
compasSclDataService.delete(type, id, version);
144144
return Uni.createFrom().nullItem();
145145
}
146+
147+
@POST
148+
@Path("/checkname")
149+
@Consumes(MediaType.APPLICATION_XML)
150+
@Produces(MediaType.APPLICATION_XML)
151+
public Uni<DuplicateNameCheckResponse> checkDuplicateName(@PathParam(TYPE_PATH_PARAM) SclFileType type,
152+
@Valid DuplicateNameCheckRequest request) {
153+
LOGGER.info("Checking for duplicate SCL File name.");
154+
155+
var response = new DuplicateNameCheckResponse();
156+
response.setDuplicate(compasSclDataService.hasDuplicateSclName(type, request.getName()));
157+
return Uni.createFrom().item(response);
158+
}
146159
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// SPDX-FileCopyrightText: 2022 Alliander N.V.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
package org.lfenergy.compas.scl.data.rest.v1.model;
6+
7+
import org.eclipse.microprofile.openapi.annotations.media.Schema;
8+
import org.lfenergy.compas.core.commons.constraint.FilenameValid;
9+
10+
import javax.xml.bind.annotation.XmlAccessType;
11+
import javax.xml.bind.annotation.XmlAccessorType;
12+
import javax.xml.bind.annotation.XmlElement;
13+
import javax.xml.bind.annotation.XmlRootElement;
14+
15+
import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
16+
17+
@Schema(description = "Request to check for duplicate names.")
18+
@XmlRootElement(name = "DuplicateNameCheckRequest", namespace = SCL_DATA_SERVICE_V1_NS_URI)
19+
@XmlAccessorType(XmlAccessType.FIELD)
20+
public class DuplicateNameCheckRequest {
21+
@FilenameValid
22+
@Schema(description = "The name that will be stored as Private Element and can later be used to determine the filename.",
23+
example = "STATION-0012312")
24+
@XmlElement(name = "Name", namespace = SCL_DATA_SERVICE_V1_NS_URI, required = true)
25+
private String name;
26+
27+
public String getName() {
28+
return name;
29+
}
30+
31+
public void setName(String name) {
32+
this.name = name;
33+
}
34+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// SPDX-FileCopyrightText: 2022 Alliander N.V.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
package org.lfenergy.compas.scl.data.rest.v1.model;
6+
7+
import org.eclipse.microprofile.openapi.annotations.media.Schema;
8+
9+
import javax.xml.bind.annotation.XmlAccessType;
10+
import javax.xml.bind.annotation.XmlAccessorType;
11+
import javax.xml.bind.annotation.XmlElement;
12+
import javax.xml.bind.annotation.XmlRootElement;
13+
14+
import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
15+
16+
@Schema(description = "Response from duplicate name check in the database.")
17+
@XmlRootElement(name = "DuplicateNameCheckResponse", namespace = SCL_DATA_SERVICE_V1_NS_URI)
18+
@XmlAccessorType(XmlAccessType.FIELD)
19+
public class DuplicateNameCheckResponse {
20+
@Schema(description = "Boolean result for duplicate name check.")
21+
@XmlElement(name = "Duplicate", namespace = SCL_DATA_SERVICE_V1_NS_URI)
22+
private boolean duplicate;
23+
24+
public boolean isDuplicate() {
25+
return duplicate;
26+
}
27+
28+
public void setDuplicate(boolean duplicate) {
29+
this.duplicate = duplicate;
30+
}
31+
}

app/src/main/resources/application.properties

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ quarkus.http.auth.permission.SSD_DELETE_DELETE.paths=/compas-scl-data-service/sc
6060
quarkus.http.auth.permission.SSD_DELETE_DELETE.policy=SSD_DELETE
6161
quarkus.http.auth.permission.SSD_DELETE_DELETE.methods=DELETE
6262

63+
quarkus.http.auth.policy.SSD_CHECK_NAME.roles-allowed=SSD_READ
64+
quarkus.http.auth.permission.SSD_CHECK_NAME.paths=/compas-scl-data-service/scl/v1/SSD/checkname
65+
quarkus.http.auth.permission.SSD_CHECK_NAME.policy=SSD_READ
66+
quarkus.http.auth.permission.SSD_CHECK_NAME.methods=POST
67+
6368
quarkus.http.auth.permission.SSD_READ_GET_WS.paths=/compas-scl-data-service/scl-ws/v1/SSD/get
6469
quarkus.http.auth.permission.SSD_READ_GET_WS.policy=SSD_READ
6570
quarkus.http.auth.permission.SSD_READ_GET_VERSION_WS.paths=/compas-scl-data-service/scl-ws/v1/SSD/get-version
@@ -137,7 +142,6 @@ quarkus.http.auth.policy.SCD_DELETE.roles-allowed=SCD_DELETE
137142
quarkus.http.auth.permission.SCD_DELETE_DELETE.paths=/compas-scl-data-service/scl/v1/SCD/*
138143
quarkus.http.auth.permission.SCD_DELETE_DELETE.policy=SCD_DELETE
139144
quarkus.http.auth.permission.SCD_DELETE_DELETE.methods=DELETE
140-
141145
quarkus.http.auth.permission.SCD_READ_GET_WS.paths=/compas-scl-data-service/scl-ws/v1/SCD/get
142146
quarkus.http.auth.permission.SCD_READ_GET_WS.policy=SCD_READ
143147
quarkus.http.auth.permission.SCD_READ_GET_VERSION_WS.paths=/compas-scl-data-service/scl-ws/v1/SCD/get-version
@@ -147,6 +151,11 @@ quarkus.http.auth.permission.SCD_CREATE_POST_WS.policy=SCD_CREATE
147151
quarkus.http.auth.permission.SCD_UPDATE_PUT_WS.paths=/compas-scl-data-service/scl-ws/v1/SCD/update
148152
quarkus.http.auth.permission.SCD_UPDATE_PUT_WS.policy=SCD_UPDATE
149153

154+
quarkus.http.auth.policy.SCD_CHECK_NAME.roles-allowed=SCD_READ
155+
quarkus.http.auth.permission.SCD_CHECK_NAME.paths=/compas-scl-data-service/scl/v1/SCD/checkname
156+
quarkus.http.auth.permission.SCD_CHECK_NAME.policy=SCD_READ
157+
quarkus.http.auth.permission.SCD_CHECK_NAME.methods=POST
158+
150159
quarkus.http.auth.policy.CID_READ.roles-allowed=CID_READ
151160
quarkus.http.auth.permission.CID_READ_GET.paths=/compas-scl-data-service/scl/v1/CID/*
152161
quarkus.http.auth.permission.CID_READ_GET.policy=CID_READ
@@ -249,4 +258,4 @@ quarkus.http.auth.permission.STD_READ_GET_VERSION_WS.policy=STD_READ
249258
quarkus.http.auth.permission.STD_CREATE_POST_WS.paths=/compas-scl-data-service/scl-ws/v1/STD/create
250259
quarkus.http.auth.permission.STD_CREATE_POST_WS.policy=STD_CREATE
251260
quarkus.http.auth.permission.STD_UPDATE_PUT_WS.paths=/compas-scl-data-service/scl-ws/v1/STD/update
252-
quarkus.http.auth.permission.STD_UPDATE_PUT_WS.policy=STD_UPDATE
261+
quarkus.http.auth.permission.STD_UPDATE_PUT_WS.policy=STD_UPDATE

app/src/test/java/org/lfenergy/compas/scl/data/rest/v1/CompasSclDataResourceAsEditorTest.java

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.lfenergy.compas.scl.data.model.Item;
1717
import org.lfenergy.compas.scl.data.model.Version;
1818
import org.lfenergy.compas.scl.data.rest.v1.model.CreateRequest;
19+
import org.lfenergy.compas.scl.data.rest.v1.model.DuplicateNameCheckRequest;
1920
import org.lfenergy.compas.scl.data.rest.v1.model.UpdateRequest;
2021
import org.lfenergy.compas.scl.data.service.CompasSclDataService;
2122
import org.lfenergy.compas.scl.extensions.model.SclFileType;
@@ -27,7 +28,7 @@
2728

2829
import static io.restassured.RestAssured.given;
2930
import static io.restassured.path.xml.config.XmlPathConfig.xmlPathConfig;
30-
import static org.junit.jupiter.api.Assertions.assertEquals;
31+
import static org.junit.jupiter.api.Assertions.*;
3132
import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_NS_URI;
3233
import static org.lfenergy.compas.scl.data.rest.Constants.*;
3334
import static org.mockito.Mockito.*;
@@ -267,6 +268,54 @@ void deleteVersion_WhenCalled_ThenServiceCalled() {
267268
verify(compasSclDataService).delete(type, uuid, version);
268269
}
269270

271+
@Test
272+
void checkNameForDuplication_WhenCalled_WithDuplicateName_ThenServiceCalled() {
273+
var type = SclFileType.SCD;
274+
var name = "STATION-0012312";
275+
276+
when(compasSclDataService.hasDuplicateSclName(type, name)).thenReturn(true);
277+
278+
var request = new DuplicateNameCheckRequest();
279+
request.setName(name);
280+
281+
var response = given()
282+
.pathParam(TYPE_PATH_PARAM, type)
283+
.contentType(ContentType.XML)
284+
.body(request)
285+
.when().post("/checkname")
286+
.then()
287+
.statusCode(200)
288+
.extract()
289+
.response();
290+
291+
verify(compasSclDataService).hasDuplicateSclName(type, name);
292+
assertTrue(response.xmlPath().getBoolean("DuplicateNameCheckResponse.Duplicate"));
293+
}
294+
295+
@Test
296+
void checkNameForDuplication_WhenCalled_WithUniqueName_ThenServiceCalled() {
297+
var type = SclFileType.SCD;
298+
var name = "STATION-0012312";
299+
300+
when(compasSclDataService.hasDuplicateSclName(type, name)).thenReturn(false);
301+
302+
var request = new DuplicateNameCheckRequest();
303+
request.setName(name);
304+
305+
var response = given()
306+
.pathParam(TYPE_PATH_PARAM, type)
307+
.contentType(ContentType.XML)
308+
.body(request)
309+
.when().post("/checkname")
310+
.then()
311+
.statusCode(200)
312+
.extract()
313+
.response();
314+
315+
verify(compasSclDataService).hasDuplicateSclName(type, name);
316+
assertFalse(response.xmlPath().getBoolean("DuplicateNameCheckResponse.Duplicate"));
317+
}
318+
270319
private String readSCL() throws IOException {
271320
try (var inputStream = getClass().getResourceAsStream("/scl/icd_import_ied_test.scd")) {
272321
assert inputStream != null;

0 commit comments

Comments
 (0)