Skip to content

Commit 66a091f

Browse files
author
Dennis Labordus
authored
Merge pull request #42 from com-pas/develop
New release
2 parents 0f85fdc + 0fcb3e0 commit 66a091f

File tree

48 files changed

+1025
-28
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1025
-28
lines changed

README.md

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,61 @@ described in the URL above that the URL can be overwritten locally with an HTTPS
3030
Check the [Development](DEVELOPMENT.md) page for more detail information how to work with this repository, because of
3131
the mixture with RiseClipse.
3232

33+
## Custom OCL Files
34+
35+
There is a way to add custom OCL Files to the validator, for instance to force company specific rules. In the Docker
36+
Image there is a volume `/data/ocl` which can be used to add these files, see our compas-deployment project for an
37+
example how to.
38+
39+
In this directory, you can use subdirectories like `SemanticConstraints` as RiseClipse is doing. And there is a special
40+
filter that when you create a directory `FileSpecifics`. In this directory you can create for instance a directory `CID`
41+
to put constraints specific for an SCL File Type. Known types are `SSD`, `IID`, `ICD`, `SCD`, `CID`, `SED`, `ISD`,
42+
`STD`.
43+
44+
For instance,
45+
46+
```
47+
data
48+
└── ocl
49+
├── FileSpecifics
50+
│ └── CID
51+
│ └── Busbar.ocl
52+
└── SemanticConstraints
53+
└── Busbar.ocl
54+
```
55+
56+
If you are using the validator are library (using JAR Files) there is a property to configure the directory, see
57+
[Common Environment variables](#common-environment-variables)
58+
59+
## NSDoc Files
60+
61+
Because NSDoc File can't be distributed in an OpenSource Project these need to be added during deployment. In the Docker
62+
Image there is a volume `/data/nsdoc` which can be used to add these files, see our compas-deployment project for an
63+
example how to.
64+
65+
Only direct files found in this directory will be processed. Invalid NSDoc Files will be ignored. A directory can look
66+
like this for instance,
67+
68+
```
69+
data
70+
└── nsdoc
71+
├── IEC_61850-7-2_2007B3-en.nsdoc
72+
├── IEC_61850-7-3_2007B3-en.nsdoc
73+
└── IEC_61850-7-4_2007B3-en.nsdoc
74+
75+
```
76+
77+
If you are using the validator are library (using JAR Files) there is a property to configure the directory, see
78+
[Common Environment variables](#common-environment-variables)
79+
3380
## Common Environment variables
3481

3582
Below environment variable(s) can be used to configure the validator.
3683

37-
| Environment variable | Java Property | Description | Example |
38-
|---------------------------------------|---------------------------------------|---------------------------------------------------|-----------|
39-
| COMPAS_VALIDATOR_OCL_CUSTOM_DIRECTORY | compas.validator.ocl.custom.directory | Reference to a directory to load custom OCL Files | /data/ocl |
84+
| Environment variable | Java Property | Description | Example |
85+
|---------------------------------------|---------------------------------------|-------------------------------------------------------------|-------------|
86+
| COMPAS_VALIDATOR_OCL_CUSTOM_DIRECTORY | compas.validator.ocl.custom.directory | Reference to a directory to load custom OCL Files | /data/ocl |
87+
| COMPAS_VALIDATOR_NSDOC_DIRECTORY | compas.validator.nsdoc.directory | Reference to a directory where the NSDoc Files can be found | /data/nsdoc |
4088

4189
## Security
4290

app/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ SPDX-License-Identifier: Apache-2.0
2222
<quarkus.container-image.name>compas-scl-validator</quarkus.container-image.name>
2323
</properties>
2424

25-
<dependencyManagement>
26-
<dependencies>
27-
</dependencies>
28-
</dependencyManagement>
29-
3025
<dependencies>
3126
<dependency>
3227
<groupId>org.lfenergy.compas.scl.validator</groupId>

app/src/main/docker/Dockerfile.jvm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ COPY --chown=1001 target/quarkus-app/app/ /deployments/app/
4949
COPY --chown=1001 target/quarkus-app/quarkus/ /deployments/quarkus/
5050

5151
RUN mkdir -p /data/ocl \
52+
&& mkdir -p /data/nsdoc \
5253
&& mkdir -p /data/temp \
5354
&& chown -R 1001 /data \
5455
&& chmod -R "g+rwX" /data
5556
VOLUME /data/ocl
57+
VOLUME /data/nsdoc
5658

5759
EXPOSE 8080
5860
USER 1001

app/src/main/docker/Dockerfile.native

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ RUN chown 1001 /work \
2222
COPY --chown=1001:root target/*-runner /work/application
2323

2424
RUN mkdir -p /data/ocl \
25+
&& mkdir -p /data/nsdoc \
2526
&& mkdir -p /data/temp \
2627
&& chown -R 1001 /data \
2728
&& chmod -R "g+rwX" /data
2829
VOLUME /data/ocl
30+
VOLUME /data/nsdoc
2931

3032
EXPOSE 8080
3133
USER 1001

app/src/main/java/org/lfenergy/compas/scl/validator/rest/CompasSclValidatorConfiguration.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
// SPDX-License-Identifier: Apache-2.0
44
package org.lfenergy.compas.scl.validator.rest;
55

6+
import io.quarkus.runtime.Startup;
67
import org.lfenergy.compas.core.commons.ElementConverter;
78
import org.lfenergy.compas.scl.validator.collector.CompasOclFileCollector;
89
import org.lfenergy.compas.scl.validator.collector.OclFileCollector;
10+
import org.lfenergy.compas.scl.validator.common.NsdocFinder;
911
import org.lfenergy.compas.scl.validator.impl.SclRiseClipseValidator;
1012

1113
import javax.enterprise.context.ApplicationScoped;
@@ -33,4 +35,11 @@ public SclRiseClipseValidator createSclRiseClipseValidator(OclFileCollector oclF
3335
ValidatorProperties properties) {
3436
return new SclRiseClipseValidator(oclFileCollector, properties.tempDirectory());
3537
}
38+
39+
@Produces
40+
@Startup
41+
@ApplicationScoped
42+
public NsdocFinder createNsdocFinder(ValidatorProperties properties) {
43+
return new NsdocFinder(properties.nsdocDirectory());
44+
}
3645
}

app/src/main/java/org/lfenergy/compas/scl/validator/rest/SclResourceConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ public final class SclResourceConstants {
99
}
1010

1111
public static final String TYPE_PATH_PARAM = "type";
12+
public static final String ID_PARAM = "id";
1213
}

app/src/main/java/org/lfenergy/compas/scl/validator/rest/ValidatorProperties.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ public interface ValidatorProperties {
1313
@WithName("ocl.custom.directory")
1414
String oclCustomDirectory();
1515

16+
@WithName("nsdoc.directory")
17+
String nsdocDirectory();
18+
1619
@WithName("temp.directory")
1720
Path tempDirectory();
1821
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SPDX-FileCopyrightText: 2021 Alliander N.V.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
package org.lfenergy.compas.scl.validator.rest.exception;
5+
6+
import org.lfenergy.compas.core.jaxrs.model.ErrorResponse;
7+
import org.lfenergy.compas.scl.validator.exception.NsdocFileNotFoundException;
8+
9+
import javax.ws.rs.core.Response;
10+
import javax.ws.rs.ext.ExceptionMapper;
11+
import javax.ws.rs.ext.Provider;
12+
13+
@Provider
14+
public class NsdocNotFoundExceptionHandler implements ExceptionMapper<NsdocFileNotFoundException> {
15+
@Override
16+
public Response toResponse(NsdocFileNotFoundException exception) {
17+
var response = new ErrorResponse();
18+
response.addErrorMessage(exception.getErrorCode(), exception.getMessage());
19+
return Response.status(Response.Status.NOT_FOUND).entity(response).build();
20+
}
21+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// SPDX-FileCopyrightText: 2022 Alliander N.V.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
package org.lfenergy.compas.scl.validator.rest.v1;
5+
6+
import io.quarkus.security.Authenticated;
7+
import org.lfenergy.compas.scl.validator.rest.v1.model.NsdocListResponse;
8+
import org.lfenergy.compas.scl.validator.service.NsdocService;
9+
10+
import javax.enterprise.context.RequestScoped;
11+
import javax.ws.rs.*;
12+
import javax.ws.rs.core.MediaType;
13+
import java.util.UUID;
14+
15+
import static org.lfenergy.compas.scl.validator.rest.SclResourceConstants.ID_PARAM;
16+
17+
@Authenticated
18+
@RequestScoped
19+
@Path("/nsdoc/v1")
20+
public class NsdocResource {
21+
private final NsdocService nsdocService;
22+
23+
public NsdocResource(NsdocService nsdocService) {
24+
this.nsdocService = nsdocService;
25+
}
26+
27+
@GET
28+
@Consumes(MediaType.APPLICATION_XML)
29+
@Produces(MediaType.APPLICATION_XML)
30+
public NsdocListResponse list() {
31+
NsdocListResponse response = new NsdocListResponse();
32+
response.setNsdocFiles(nsdocService.list());
33+
return response;
34+
}
35+
36+
@GET
37+
@Path("{" + ID_PARAM + "}")
38+
@Consumes(MediaType.APPLICATION_XML)
39+
@Produces(MediaType.APPLICATION_XML)
40+
public String get(@PathParam(ID_PARAM) UUID id) {
41+
return nsdocService.get(id);
42+
}
43+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// SPDX-FileCopyrightText: 2022 Alliander N.V.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
package org.lfenergy.compas.scl.validator.rest.v1.model;
5+
6+
import org.eclipse.microprofile.openapi.annotations.media.Schema;
7+
import org.lfenergy.compas.scl.validator.model.NsdocFile;
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+
import java.util.Collection;
14+
15+
import static org.lfenergy.compas.scl.validator.SclValidatorConstants.SCL_VALIDATOR_SERVICE_V1_NS_URI;
16+
17+
@Schema(description = "The response with the list of known NSDoc Files.")
18+
@XmlRootElement(name = "NsdocListResponse", namespace = SCL_VALIDATOR_SERVICE_V1_NS_URI)
19+
@XmlAccessorType(XmlAccessType.FIELD)
20+
public class NsdocListResponse {
21+
@Schema(description = "The list of known NSDoc Files")
22+
@XmlElement(name = "NsdocFile", namespace = SCL_VALIDATOR_SERVICE_V1_NS_URI)
23+
private Collection<NsdocFile> nsdocFiles;
24+
25+
public Collection<NsdocFile> getNsdocFiles() {
26+
return nsdocFiles;
27+
}
28+
29+
public void setNsdocFiles(Collection<NsdocFile> nsdocFiles) {
30+
this.nsdocFiles = nsdocFiles;
31+
}
32+
}

0 commit comments

Comments
 (0)