Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New release #153

Merged
merged 16 commits into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ SPDX-License-Identifier: Apache-2.0
<groupId>io.quarkus</groupId>
<artifactId>quarkus-websockets</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-validator</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
Expand All @@ -76,9 +80,10 @@ SPDX-License-Identifier: Apache-2.0
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-validator</artifactId>
<groupId>org.jboss.logmanager</groupId>
<artifactId>log4j2-jboss-logmanager</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-docker</artifactId>
Expand Down Expand Up @@ -133,11 +138,6 @@ SPDX-License-Identifier: Apache-2.0
<artifactId>openpojo</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/docker/Dockerfile.jvm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/app-jvm
#
###
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7-923

ARG JAVA_PACKAGE=java-17-openjdk-headless
ARG RUN_JAVA_VERSION=1.3.8
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/docker/Dockerfile.native
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# docker run -i --rm -p 8080:8080 quarkus/app
#
###
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7-923
WORKDIR /work/
RUN chown 1001 /work \
&& chmod "g+rwX" /work \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import io.quarkus.security.Authenticated;
import io.smallrye.mutiny.Uni;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lfenergy.compas.scl.validator.rest.v1.model.NsdocListResponse;
import org.lfenergy.compas.scl.validator.rest.v1.model.NsdocResponse;
import org.lfenergy.compas.scl.validator.service.NsdocService;
Expand All @@ -20,6 +22,8 @@
@RequestScoped
@Path("/nsdoc/v1")
public class NsdocResource {
private static final Logger LOGGER = LogManager.getLogger(NsdocResource.class);

private final NsdocService nsdocService;

public NsdocResource(NsdocService nsdocService) {
Expand All @@ -30,6 +34,7 @@ public NsdocResource(NsdocService nsdocService) {
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
public Uni<NsdocListResponse> list() {
LOGGER.info("Retrieving list of NSDoc Files");
var response = new NsdocListResponse();
response.setNsdocFiles(nsdocService.list());
return Uni.createFrom().item(response);
Expand All @@ -40,6 +45,7 @@ public Uni<NsdocListResponse> list() {
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
public Uni<NsdocResponse> get(@PathParam(ID_PARAM) UUID id) {
LOGGER.info("Retrieving NS Doc File '{}'", id);
var response = new NsdocResponse();
response.setNsdocFile(nsdocService.get(id));
return Uni.createFrom().item(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import io.quarkus.security.Authenticated;
import io.smallrye.mutiny.Uni;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lfenergy.compas.scl.extensions.model.SclFileType;
import org.lfenergy.compas.scl.validator.rest.v1.model.SclValidateRequest;
import org.lfenergy.compas.scl.validator.rest.v1.model.SclValidateResponse;
Expand All @@ -22,6 +24,8 @@
@RequestScoped
@Path("/validate/v1/{" + TYPE_PATH_PARAM + "}")
public class SclValidatorResource {
private static final Logger LOGGER = LogManager.getLogger(SclValidatorResource.class);

private final SclValidatorService sclValidatorService;

@Inject
Expand All @@ -34,6 +38,7 @@ public SclValidatorResource(SclValidatorService sclValidatorService) {
@Produces(MediaType.APPLICATION_XML)
public Uni<SclValidateResponse> validateSCL(@PathParam(TYPE_PATH_PARAM) SclFileType type,
@Valid SclValidateRequest request) {
LOGGER.info("Validating SCL File for type {}.", type);
var response = new SclValidateResponse();
response.setValidationErrorList(sclValidatorService.validate(type, request.getSclData()));
return Uni.createFrom().item(response);
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// SPDX-FileCopyrightText: 2022 Alliander N.V.
//
// SPDX-License-Identifier: Apache-2.0
package org.lfenergy.compas.scl.validator.rest.v1.event;
package org.lfenergy.compas.scl.validator.websocket.event;

import io.quarkus.vertx.ConsumeEvent;
import org.lfenergy.compas.core.websocket.WebsocketHandler;
import org.lfenergy.compas.scl.validator.rest.v1.model.SclValidateResponse;
import org.lfenergy.compas.scl.validator.service.SclValidatorService;
import org.lfenergy.compas.scl.validator.websocket.event.model.SclValidatorEventRequest;
import org.lfenergy.compas.scl.validator.websocket.v1.model.SclValidateWsResponse;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
Expand All @@ -25,8 +26,8 @@ public SclValidatorEventHandler(SclValidatorService sclValidatorService) {

@ConsumeEvent(value = "validate-ws", blocking = true)
public void validateWebsocketsEvent(SclValidatorEventRequest request) {
new WebsocketHandler<SclValidateResponse>().execute(request.getSession(), () -> {
var response = new SclValidateResponse();
new WebsocketHandler<SclValidateWsResponse>().execute(request.getSession(), () -> {
var response = new SclValidateWsResponse();
response.setValidationErrorList(sclValidatorService.validate(request.getType(), request.getSclData()));
return response;
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: 2022 Alliander N.V.
//
// SPDX-License-Identifier: Apache-2.0
package org.lfenergy.compas.scl.validator.rest.v1.event;
package org.lfenergy.compas.scl.validator.websocket.event.model;

import org.lfenergy.compas.scl.extensions.model.SclFileType;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
// SPDX-FileCopyrightText: 2022 Alliander N.V.
//
// SPDX-License-Identifier: Apache-2.0
package org.lfenergy.compas.scl.validator.rest.v1;
package org.lfenergy.compas.scl.validator.websocket.v1;

import io.quarkus.security.Authenticated;
import io.vertx.mutiny.core.eventbus.EventBus;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lfenergy.compas.core.websocket.ErrorResponseEncoder;
import org.lfenergy.compas.scl.extensions.model.SclFileType;
import org.lfenergy.compas.scl.validator.rest.v1.event.SclValidatorEventRequest;
import org.lfenergy.compas.scl.validator.rest.v1.model.SclValidateRequest;
import org.lfenergy.compas.scl.validator.rest.v1.websocket.SclValidateRequestDecoder;
import org.lfenergy.compas.scl.validator.rest.v1.websocket.SclValidateRequestEncoder;
import org.lfenergy.compas.scl.validator.rest.v1.websocket.SclValidateResponseDecoder;
import org.lfenergy.compas.scl.validator.rest.v1.websocket.SclValidateResponseEncoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.lfenergy.compas.scl.validator.websocket.event.model.SclValidatorEventRequest;
import org.lfenergy.compas.scl.validator.websocket.v1.decoder.SclValidateWsRequestDecoder;
import org.lfenergy.compas.scl.validator.websocket.v1.encoder.SclValidateWsResponseEncoder;
import org.lfenergy.compas.scl.validator.websocket.v1.model.SclValidateWsRequest;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.validation.Valid;
import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
Expand All @@ -28,10 +27,10 @@
@Authenticated
@ApplicationScoped
@ServerEndpoint(value = "/validate-ws/v1/{" + TYPE_PATH_PARAM + "}",
decoders = {SclValidateRequestDecoder.class, SclValidateResponseDecoder.class},
encoders = {SclValidateRequestEncoder.class, SclValidateResponseEncoder.class, ErrorResponseEncoder.class})
decoders = {SclValidateWsRequestDecoder.class},
encoders = {SclValidateWsResponseEncoder.class, ErrorResponseEncoder.class})
public class SclValidatorServerEndpoint {
private static final Logger LOGGER = LoggerFactory.getLogger(SclValidatorServerEndpoint.class);
private static final Logger LOGGER = LogManager.getLogger(SclValidatorServerEndpoint.class);

private final EventBus eventBus;

Expand All @@ -46,7 +45,9 @@ public void onOpen(Session session, @PathParam(TYPE_PATH_PARAM) String type) {
}

@OnMessage
public void onMessage(Session session, SclValidateRequest request, @PathParam(TYPE_PATH_PARAM) String type) {
public void onMessage(Session session,
@Valid SclValidateWsRequest request,
@PathParam(TYPE_PATH_PARAM) String type) {
LOGGER.info("Message from session {} for type {}.", session.getId(), type);
eventBus.send("validate-ws", new SclValidatorEventRequest(
session, SclFileType.valueOf(type), request.getSclData()));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-FileCopyrightText: 2022 Alliander N.V.
//
// SPDX-License-Identifier: Apache-2.0
package org.lfenergy.compas.scl.validator.websocket.v1.decoder;

import org.lfenergy.compas.core.websocket.AbstractDecoder;
import org.lfenergy.compas.core.websocket.WebsocketSupport;
import org.lfenergy.compas.scl.validator.websocket.v1.model.SclValidateWsRequest;

public class SclValidateWsRequestDecoder extends AbstractDecoder<SclValidateWsRequest> {
@Override
public boolean willDecode(String message) {
return (message != null);
}

@Override
public SclValidateWsRequest decode(String message) {
return WebsocketSupport.decode(message, SclValidateWsRequest.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-FileCopyrightText: 2022 Alliander N.V.
//
// SPDX-License-Identifier: Apache-2.0
package org.lfenergy.compas.scl.validator.websocket.v1.decoder;

import org.lfenergy.compas.core.websocket.AbstractDecoder;
import org.lfenergy.compas.core.websocket.WebsocketSupport;
import org.lfenergy.compas.scl.validator.websocket.v1.model.SclValidateWsResponse;

public class SclValidateWsResponseDecoder extends AbstractDecoder<SclValidateWsResponse> {
@Override
public boolean willDecode(String message) {
return (message != null);
}

@Override
public SclValidateWsResponse decode(String message) {
return WebsocketSupport.decode(message, SclValidateWsResponse.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-FileCopyrightText: 2022 Alliander N.V.
//
// SPDX-License-Identifier: Apache-2.0
package org.lfenergy.compas.scl.validator.websocket.v1.encoder;

import org.lfenergy.compas.core.websocket.AbstractEncoder;
import org.lfenergy.compas.core.websocket.WebsocketSupport;
import org.lfenergy.compas.scl.validator.websocket.v1.model.SclValidateWsRequest;

public class SclValidateWsRequestEncoder extends AbstractEncoder<SclValidateWsRequest> {
@Override
public String encode(SclValidateWsRequest jaxbObject) {
return WebsocketSupport.encode(jaxbObject, SclValidateWsRequest.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-FileCopyrightText: 2022 Alliander N.V.
//
// SPDX-License-Identifier: Apache-2.0
package org.lfenergy.compas.scl.validator.websocket.v1.encoder;

import org.lfenergy.compas.core.websocket.AbstractEncoder;
import org.lfenergy.compas.core.websocket.WebsocketSupport;
import org.lfenergy.compas.scl.validator.websocket.v1.model.SclValidateWsResponse;

public class SclValidateWsResponseEncoder extends AbstractEncoder<SclValidateWsResponse> {
@Override
public String encode(SclValidateWsResponse jaxbObject) {
return WebsocketSupport.encode(jaxbObject, SclValidateWsResponse.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-FileCopyrightText: 2022 Alliander N.V.
//
// SPDX-License-Identifier: Apache-2.0

package org.lfenergy.compas.scl.validator.websocket.v1.model;

import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.lfenergy.compas.scl.validator.rest.v1.model.SclValidateRequest;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import static org.lfenergy.compas.scl.validator.SclValidatorConstants.SCL_VALIDATOR_SERVICE_V1_NS_URI;

@Schema(description = "The Validation Request retrieved")
@XmlType(name = "SclValidateWsRequest", namespace = SCL_VALIDATOR_SERVICE_V1_NS_URI)
@XmlRootElement(name = "SclValidateWsRequest", namespace = SCL_VALIDATOR_SERVICE_V1_NS_URI)
@XmlAccessorType(XmlAccessType.FIELD)
public class SclValidateWsRequest extends SclValidateRequest {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-FileCopyrightText: 2022 Alliander N.V.
//
// SPDX-License-Identifier: Apache-2.0
package org.lfenergy.compas.scl.validator.websocket.v1.model;

import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.lfenergy.compas.scl.validator.rest.v1.model.SclValidateResponse;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import static org.lfenergy.compas.scl.validator.SclValidatorConstants.SCL_VALIDATOR_SERVICE_V1_NS_URI;

@Schema(description = "The Validation Response returned")
@XmlType(name = "SclValidateWsResponse", namespace = SCL_VALIDATOR_SERVICE_V1_NS_URI)
@XmlRootElement(name = "SclValidateWsResponse", namespace = SCL_VALIDATOR_SERVICE_V1_NS_URI)
@XmlAccessorType(XmlAccessType.FIELD)
public class SclValidateWsResponse extends SclValidateResponse {
}
Loading