Skip to content

Commit 32c76b6

Browse files
author
Dennis Labordus
committed
Updated CoMPAS Core version.
Signed-off-by: Dennis Labordus <[email protected]>
1 parent 0dcf229 commit 32c76b6

19 files changed

+416
-205
lines changed

app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclCreateServerEndpoint.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import javax.websocket.server.PathParam;
2323
import javax.websocket.server.ServerEndpoint;
2424

25+
import static org.lfenergy.compas.core.websocket.WebsocketSupport.handleException;
2526
import static org.lfenergy.compas.scl.data.rest.Constants.TYPE_PATH_PARAM;
2627

2728
@Authenticated
@@ -47,12 +48,12 @@ public CompasSclCreateServerEndpoint(EventBus eventBus,
4748

4849
@OnOpen
4950
public void onOpen(Session session, @PathParam(TYPE_PATH_PARAM) String type) {
50-
LOGGER.debug("Starting session {} for type {}.", session.getId(), type);
51+
LOGGER.debug("Starting (create) session {} for type {}.", session.getId(), type);
5152
}
5253

5354
@OnMessage
5455
public void onCreateMessage(Session session, CreateRequest request, @PathParam(TYPE_PATH_PARAM) String type) {
55-
LOGGER.info("Message from session {} for type {}.", session.getId(), type);
56+
LOGGER.info("Message (create) from session {} for type {}.", session.getId(), type);
5657

5758
String who = jsonWebToken.getClaim(userInfoProperties.who());
5859
LOGGER.trace("Username used for Who {}", who);
@@ -63,11 +64,12 @@ public void onCreateMessage(Session session, CreateRequest request, @PathParam(T
6364

6465
@OnError
6566
public void onError(Session session, @PathParam(TYPE_PATH_PARAM) String type, Throwable throwable) {
66-
LOGGER.warn("Error with session {} for type {}.", session.getId(), type, throwable);
67+
LOGGER.warn("Error (create) with session {} for type {}.", session.getId(), type, throwable);
68+
handleException(session, throwable);
6769
}
6870

6971
@OnClose
7072
public void onClose(Session session, @PathParam(TYPE_PATH_PARAM) String type) {
71-
LOGGER.debug("Closing session {} for type {}.", session.getId(), type);
73+
LOGGER.debug("Closing (create) session {} for type {}.", session.getId(), type);
7274
}
7375
}

app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclGetServerEndpoint.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import javax.websocket.server.PathParam;
2121
import javax.websocket.server.ServerEndpoint;
2222

23+
import static org.lfenergy.compas.core.websocket.WebsocketSupport.handleException;
2324
import static org.lfenergy.compas.scl.data.rest.Constants.TYPE_PATH_PARAM;
2425

2526
@Authenticated
@@ -39,25 +40,26 @@ public CompasSclGetServerEndpoint(EventBus eventBus) {
3940

4041
@OnOpen
4142
public void onOpen(Session session, @PathParam(TYPE_PATH_PARAM) String type) {
42-
LOGGER.debug("Starting session {} for type {}.", session.getId(), type);
43+
LOGGER.debug("Starting (get) session {} for type {}.", session.getId(), type);
4344
}
4445

4546
@OnMessage
4647
public void onGetMessage(Session session,
4748
GetRequest request,
4849
@PathParam(TYPE_PATH_PARAM) String type) {
49-
LOGGER.info("Message from session {} for type {}.", session.getId(), type);
50+
LOGGER.info("Message (get) from session {} for type {}.", session.getId(), type);
5051

5152
eventBus.send("get-ws", new GetEventRequest(session, SclFileType.valueOf(type), request.getId()));
5253
}
5354

5455
@OnError
5556
public void onError(Session session, @PathParam(TYPE_PATH_PARAM) String type, Throwable throwable) {
56-
LOGGER.warn("Error with session {} for type {}.", session.getId(), type, throwable);
57+
LOGGER.warn("Error (get) with session {} for type {}.", session.getId(), type, throwable);
58+
handleException(session, throwable);
5759
}
5860

5961
@OnClose
6062
public void onClose(Session session, @PathParam(TYPE_PATH_PARAM) String type) {
61-
LOGGER.debug("Closing session {} for type {}.", session.getId(), type);
63+
LOGGER.debug("Closing (get) session {} for type {}.", session.getId(), type);
6264
}
6365
}

app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclGetVersionServerEndpoint.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import javax.websocket.server.PathParam;
2222
import javax.websocket.server.ServerEndpoint;
2323

24+
import static org.lfenergy.compas.core.websocket.WebsocketSupport.handleException;
2425
import static org.lfenergy.compas.scl.data.rest.Constants.TYPE_PATH_PARAM;
2526

2627
@Authenticated
@@ -56,6 +57,7 @@ public void onGetVersionMessage(Session session,
5657
@OnError
5758
public void onError(Session session, @PathParam(TYPE_PATH_PARAM) String type, Throwable throwable) {
5859
LOGGER.warn("Error with session {} for type {}.", session.getId(), type, throwable);
60+
handleException(session, throwable);
5961
}
6062

6163
@OnClose

app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/CompasSclUpdateServerEndpoint.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import javax.websocket.server.PathParam;
2323
import javax.websocket.server.ServerEndpoint;
2424

25+
import static org.lfenergy.compas.core.websocket.WebsocketSupport.handleException;
2526
import static org.lfenergy.compas.scl.data.rest.Constants.TYPE_PATH_PARAM;
2627

2728
@Authenticated
@@ -47,13 +48,13 @@ public CompasSclUpdateServerEndpoint(EventBus eventBus,
4748

4849
@OnOpen
4950
public void onOpen(Session session, @PathParam(TYPE_PATH_PARAM) String type) {
50-
LOGGER.debug("Starting session {} for type {}.", session.getId(), type);
51+
LOGGER.debug("Starting (update) session {} for type {}.", session.getId(), type);
5152
}
5253

5354
@OnMessage
5455
public void onUpdateMessage(Session session, UpdateRequest request,
5556
@PathParam(TYPE_PATH_PARAM) String type) {
56-
LOGGER.info("Message from session {} for type {}.", session.getId(), type);
57+
LOGGER.info("Message (update) from session {} for type {}.", session.getId(), type);
5758

5859
String who = jsonWebToken.getClaim(userInfoProperties.who());
5960
LOGGER.trace("Username used for Who {}", who);
@@ -65,11 +66,12 @@ public void onUpdateMessage(Session session, UpdateRequest request,
6566

6667
@OnError
6768
public void onError(Session session, @PathParam(TYPE_PATH_PARAM) String type, Throwable throwable) {
68-
LOGGER.warn("Error with session {} for type {}.", session.getId(), type, throwable);
69+
LOGGER.warn("Error (update) with session {} for type {}.", session.getId(), type, throwable);
70+
handleException(session, throwable);
6971
}
7072

7173
@OnClose
7274
public void onClose(Session session, @PathParam(TYPE_PATH_PARAM) String type) {
73-
LOGGER.debug("Closing session {} for type {}.", session.getId(), type);
75+
LOGGER.debug("Closing (update) session {} for type {}.", session.getId(), type);
7476
}
7577
}

app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/CreateRequest.java

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,56 +5,18 @@
55
package org.lfenergy.compas.scl.data.websocket.v1.model;
66

77
import org.eclipse.microprofile.openapi.annotations.media.Schema;
8-
import org.lfenergy.compas.core.commons.constraint.FilenameValid;
98

10-
import javax.validation.constraints.NotBlank;
11-
import javax.xml.bind.annotation.*;
9+
import javax.xml.bind.annotation.XmlAccessType;
10+
import javax.xml.bind.annotation.XmlAccessorType;
11+
import javax.xml.bind.annotation.XmlRootElement;
12+
import javax.xml.bind.annotation.XmlType;
1213

1314
import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
1415

1516
@Schema(description = "Request to create a new entry in the database containing the SCL Element content.")
1617
@XmlType(name = "CreateWsRequest", namespace = SCL_DATA_SERVICE_V1_NS_URI)
1718
@XmlRootElement(name = "CreateWsRequest", namespace = SCL_DATA_SERVICE_V1_NS_URI)
1819
@XmlAccessorType(XmlAccessType.FIELD)
19-
public class CreateRequest {
20-
@FilenameValid
21-
@Schema(description = "The name that will be stored as Private Element and can later be used to determine the filename.",
22-
example = "STATION-0012312")
23-
@XmlElement(name = "Name", namespace = SCL_DATA_SERVICE_V1_NS_URI, required = true)
24-
private String name;
25-
26-
@Schema(description = "Comment that will be added to the new history record.", example = "New substation configuration for X")
27-
@XmlElement(name = "Comment", namespace = SCL_DATA_SERVICE_V1_NS_URI)
28-
private String comment;
29-
30-
@Schema(description = "The XML Content of the SCL added as CDATA. The content should contain a XML according to the IEC 61850 standard.",
31-
example = "<![CDATA[<SCL xmlns=\"http://www.iec.ch/61850/2003/SCL\">....</SCL>]]")
32-
@NotBlank
33-
@XmlElement(name = "SclData", namespace = SCL_DATA_SERVICE_V1_NS_URI)
34-
private String sclData;
35-
36-
public String getName() {
37-
return name;
38-
}
39-
40-
public void setName(String name) {
41-
this.name = name;
42-
}
43-
44-
public String getComment() {
45-
return comment;
46-
}
47-
48-
public void setComment(String comment) {
49-
this.comment = comment;
50-
}
51-
52-
public String getSclData() {
53-
return sclData;
54-
}
55-
56-
public void setSclData(String sclData) {
57-
this.sclData = sclData;
58-
}
20+
public class CreateRequest extends org.lfenergy.compas.scl.data.rest.v1.model.CreateRequest {
5921
}
6022

app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/CreateResponse.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,16 @@
55

66
import org.eclipse.microprofile.openapi.annotations.media.Schema;
77

8-
import javax.xml.bind.annotation.*;
8+
import javax.xml.bind.annotation.XmlAccessType;
9+
import javax.xml.bind.annotation.XmlAccessorType;
10+
import javax.xml.bind.annotation.XmlRootElement;
11+
import javax.xml.bind.annotation.XmlType;
912

1013
import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
1114

1215
@Schema(description = "Response from creating a new entry in the database containing the SCL Element content.")
1316
@XmlType(name = "CreateWsResponse", namespace = SCL_DATA_SERVICE_V1_NS_URI)
1417
@XmlRootElement(name = "CreateWsResponse", namespace = SCL_DATA_SERVICE_V1_NS_URI)
1518
@XmlAccessorType(XmlAccessType.FIELD)
16-
public class CreateResponse {
17-
@Schema(description = "The XML Content of the updated SCL added to the database. The content contains a XML according to the IEC 61850 standard.",
18-
example = "<![CDATA[<SCL xmlns=\"http://www.iec.ch/61850/2003/SCL\">....</SCL>]]")
19-
@XmlElement(name = "SclData", namespace = SCL_DATA_SERVICE_V1_NS_URI, required = true)
20-
private String sclData;
21-
22-
public String getSclData() {
23-
return sclData;
24-
}
25-
26-
public void setSclData(String sclData) {
27-
this.sclData = sclData;
28-
}
19+
public class CreateResponse extends org.lfenergy.compas.scl.data.rest.v1.model.CreateResponse {
2920
}

app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/GetResponse.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,16 @@
66

77
import org.eclipse.microprofile.openapi.annotations.media.Schema;
88

9-
import javax.xml.bind.annotation.*;
9+
import javax.xml.bind.annotation.XmlAccessType;
10+
import javax.xml.bind.annotation.XmlAccessorType;
11+
import javax.xml.bind.annotation.XmlRootElement;
12+
import javax.xml.bind.annotation.XmlType;
1013

1114
import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
1215

1316
@Schema(description = "Response from retrieving a SCL from the database containing the SCL Content.")
1417
@XmlType(name = "GetWsResponse", namespace = SCL_DATA_SERVICE_V1_NS_URI)
1518
@XmlRootElement(name = "GetWsResponse", namespace = SCL_DATA_SERVICE_V1_NS_URI)
1619
@XmlAccessorType(XmlAccessType.FIELD)
17-
public class GetResponse {
18-
@Schema(description = "The XML Content of the retrieved SCL from the database. The content contains a XML according to the IEC 61850 standard.",
19-
example = "<![CDATA[<SCL xmlns=\"http://www.iec.ch/61850/2003/SCL\">....</SCL>]]")
20-
@XmlElement(name = "SclData", namespace = SCL_DATA_SERVICE_V1_NS_URI, required = true)
21-
private String sclData;
22-
23-
public String getSclData() {
24-
return sclData;
25-
}
26-
27-
public void setSclData(String sclData) {
28-
this.sclData = sclData;
29-
}
20+
public class GetResponse extends org.lfenergy.compas.scl.data.rest.v1.model.GetResponse {
3021
}

app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/UpdateRequest.java

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
package org.lfenergy.compas.scl.data.websocket.v1.model;
66

77
import org.eclipse.microprofile.openapi.annotations.media.Schema;
8-
import org.lfenergy.compas.scl.data.model.ChangeSetType;
98

10-
import javax.validation.constraints.NotBlank;
11-
import javax.validation.constraints.NotNull;
129
import javax.xml.bind.annotation.*;
1310
import java.util.UUID;
1411

@@ -19,57 +16,17 @@
1916
@XmlType(name = "UpdateWsRequest", namespace = SCL_DATA_SERVICE_V1_NS_URI)
2017
@XmlRootElement(name = "UpdateWsRequest", namespace = SCL_DATA_SERVICE_V1_NS_URI)
2118
@XmlAccessorType(XmlAccessType.FIELD)
22-
public class UpdateRequest {
19+
public class UpdateRequest extends org.lfenergy.compas.scl.data.rest.v1.model.UpdateRequest {
2320
@Schema(description = "The ID of the SCL File.",
2421
example = "f7b98f4d-3fe4-4df2-8533-d7f0c1800344")
2522
@XmlElement(name = "Id", namespace = SCL_DATA_SERVICE_V1_NS_URI, required = true)
2623
private UUID id;
2724

28-
@NotNull(message = "{org.lfenergy.compas.changeset.notnull.message}")
29-
@Schema(description = "Indicates what kind of change to determine the new version.",
30-
example = "MAJOR")
31-
@XmlElement(name = "ChangeSet", namespace = SCL_DATA_SERVICE_V1_NS_URI, required = true)
32-
private ChangeSetType changeSetType;
33-
34-
@Schema(description = "Comment that will be added to the new history record.", example = "Renamed substation names")
35-
@XmlElement(name = "Comment", namespace = SCL_DATA_SERVICE_V1_NS_URI)
36-
private String comment;
37-
38-
@Schema(description = "The XML Content of the SCL added as CDATA. The content should contain a XML according to the IEC 61850 standard.",
39-
example = "<![CDATA[<SCL xmlns=\"http://www.iec.ch/61850/2003/SCL\">....</SCL>]]")
40-
@NotBlank
41-
@XmlElement(name = "SclData", namespace = SCL_DATA_SERVICE_V1_NS_URI)
42-
private String sclData;
43-
4425
public UUID getId() {
4526
return id;
4627
}
4728

4829
public void setId(UUID id) {
4930
this.id = id;
5031
}
51-
52-
public ChangeSetType getChangeSetType() {
53-
return changeSetType;
54-
}
55-
56-
public void setChangeSetType(ChangeSetType changeSetType) {
57-
this.changeSetType = changeSetType;
58-
}
59-
60-
public String getComment() {
61-
return comment;
62-
}
63-
64-
public void setComment(String comment) {
65-
this.comment = comment;
66-
}
67-
68-
public String getSclData() {
69-
return sclData;
70-
}
71-
72-
public void setSclData(String sclData) {
73-
this.sclData = sclData;
74-
}
7532
}

app/src/main/java/org/lfenergy/compas/scl/data/websocket/v1/model/UpdateResponse.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,16 @@
66

77
import org.eclipse.microprofile.openapi.annotations.media.Schema;
88

9-
import javax.xml.bind.annotation.*;
9+
import javax.xml.bind.annotation.XmlAccessType;
10+
import javax.xml.bind.annotation.XmlAccessorType;
11+
import javax.xml.bind.annotation.XmlRootElement;
12+
import javax.xml.bind.annotation.XmlType;
1013

1114
import static org.lfenergy.compas.scl.data.SclDataServiceConstants.SCL_DATA_SERVICE_V1_NS_URI;
1215

1316
@Schema(description = "Response from updating a new entry in the database containing the SCL Element content.")
1417
@XmlType(name = "UpdateWsResponse", namespace = SCL_DATA_SERVICE_V1_NS_URI)
1518
@XmlRootElement(name = "UpdateWsResponse", namespace = SCL_DATA_SERVICE_V1_NS_URI)
1619
@XmlAccessorType(XmlAccessType.FIELD)
17-
public class UpdateResponse {
18-
@Schema(description = "The XML Content of the updated SCL added to the database. The content contains a XML according to the IEC 61850 standard.",
19-
example = "<![CDATA[<SCL xmlns=\"http://www.iec.ch/61850/2003/SCL\">....</SCL>]]")
20-
@XmlElement(name = "SclData", namespace = SCL_DATA_SERVICE_V1_NS_URI, required = true)
21-
private String sclData;
22-
23-
public String getSclData() {
24-
return sclData;
25-
}
26-
27-
public void setSclData(String sclData) {
28-
this.sclData = sclData;
29-
}
20+
public class UpdateResponse extends org.lfenergy.compas.scl.data.rest.v1.model.UpdateResponse {
3021
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// SPDX-FileCopyrightText: 2022 Alliander N.V.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
package org.lfenergy.compas.scl.data.websocket.v1;
5+
6+
import io.quarkus.test.security.TestSecurity;
7+
import io.quarkus.test.security.jwt.Claim;
8+
import io.quarkus.test.security.jwt.JwtSecurity;
9+
10+
import static org.lfenergy.compas.scl.data.rest.Constants.*;
11+
12+
@TestSecurity(user = "test-editor", roles = {"SCD_" + READ_ROLE, "SCD_" + CREATE_ROLE, "SCD_" + UPDATE_ROLE})
13+
@JwtSecurity(claims = {
14+
// Default the claim "name" is configured for Who, so we will set this claim for the test.
15+
@Claim(key = "name", value = AbstractServerEndpointAsEditorTest.USERNAME)
16+
})
17+
public abstract class AbstractServerEndpointAsEditorTest extends AbstractServerEndpointTest {
18+
public static final String USERNAME = "Test Editor";
19+
20+
}

0 commit comments

Comments
 (0)