Skip to content

Commit

Permalink
Merge pull request #290 from com-pas/develop
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
Dennis Labordus authored Nov 24, 2022
2 parents c4a55f6 + 62639a8 commit e994b99
Show file tree
Hide file tree
Showing 29 changed files with 216 additions and 114 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
servers: '[{ "id": "github-packages-compas", "username": "OWNER", "password": "${{ secrets.GITHUB_TOKEN }}" }]'
- name: Build with Maven (Pull Request)
if: ${{ github.event_name == 'pull_request' }}
run: ./mvnw -s custom_maven_settings.xml -B -Pjvm-image clean verify
run: ./mvnw -s custom_maven_settings.xml -B -Pnative-image clean verify
- name: Build with Maven (Push)
if: ${{ github.event_name == 'push' }}
run: ./mvnw -s custom_maven_settings.xml -B clean verify
2 changes: 1 addition & 1 deletion .github/workflows/release-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy with Maven to GitHub Packages and Docker Hub
run: ./mvnw -B -s custom_maven_settings.xml -Pjvm-image,release clean deploy
run: ./mvnw -B -s custom_maven_settings.xml -Pnative-image,release clean deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11 changes: 6 additions & 5 deletions app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ SPDX-License-Identifier: Apache-2.0
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>

<dependency>
<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 @@ -148,11 +154,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-basex.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-basex.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
2 changes: 1 addition & 1 deletion app/src/main/docker/Dockerfile-postgresql.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-postgresql.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,19 +5,18 @@

import io.quarkus.security.Authenticated;
import io.smallrye.mutiny.Uni;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.microprofile.jwt.JsonWebToken;
import org.lfenergy.compas.scl.data.rest.UserInfoProperties;
import org.lfenergy.compas.scl.data.rest.v1.model.Type;
import org.lfenergy.compas.scl.data.rest.v1.model.TypeListResponse;
import org.lfenergy.compas.scl.data.rest.v1.model.UserInfoResponse;
import org.lfenergy.compas.scl.extensions.model.SclFileType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
Expand All @@ -30,7 +29,7 @@
@RequestScoped
@Path("/common/v1/")
public class CompasCommonResource {
private static final Logger LOGGER = LoggerFactory.getLogger(CompasCommonResource.class);
private static final Logger LOGGER = LogManager.getLogger(CompasCommonResource.class);

@Inject
JsonWebToken jsonWebToken;
Expand All @@ -41,8 +40,8 @@ public class CompasCommonResource {
@GET
@Path("/type/list")
@Produces(MediaType.APPLICATION_XML)
public Uni<TypeListResponse> list(@HeaderParam("Authorization") String authHeader) {
LOGGER.trace("Authorization Header '{}'", authHeader);
public Uni<TypeListResponse> list() {
LOGGER.info("Retrieving list of the types of SCL Files");

// Retrieve the roles the logged-in user has.
var roles = jsonWebToken.getGroups();
Expand All @@ -61,9 +60,8 @@ public Uni<TypeListResponse> list(@HeaderParam("Authorization") String authHeade
@GET
@Path("/userinfo")
@Produces(MediaType.APPLICATION_XML)
public Uni<UserInfoResponse> getUserInfo(@HeaderParam("Authorization") String authHeader) {
LOGGER.trace("Authorization Header '{}'", authHeader);

public Uni<UserInfoResponse> getUserInfo() {
LOGGER.info("Retrieving user information about {}", jsonWebToken.getName());
var response = new UserInfoResponse();
response.setName(jsonWebToken.getClaim(userInfoProperties.name()));
response.setSessionWarning(userInfoProperties.sessionWarning());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import io.quarkus.security.Authenticated;
import io.smallrye.common.annotation.Blocking;
import io.smallrye.mutiny.Uni;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.microprofile.jwt.JsonWebToken;
import org.lfenergy.compas.scl.data.model.Version;
import org.lfenergy.compas.scl.data.rest.UserInfoProperties;
import org.lfenergy.compas.scl.data.rest.v1.model.*;
import org.lfenergy.compas.scl.data.service.CompasSclDataService;
import org.lfenergy.compas.scl.extensions.model.SclFileType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
Expand All @@ -28,7 +28,7 @@
@RequestScoped
@Path("/scl/v1/{" + TYPE_PATH_PARAM + "}")
public class CompasSclDataResource {
private static final Logger LOGGER = LoggerFactory.getLogger(CompasSclDataResource.class);
private static final Logger LOGGER = LogManager.getLogger(CompasSclDataResource.class);

private final CompasSclDataService compasSclDataService;

Expand All @@ -49,6 +49,7 @@ public CompasSclDataResource(CompasSclDataService compasSclDataService) {
@Produces(MediaType.APPLICATION_XML)
public Uni<CreateResponse> create(@PathParam(TYPE_PATH_PARAM) SclFileType type,
@Valid CreateRequest request) {
LOGGER.info("Adding new SCL File for type {} to storage.", type);
String who = jsonWebToken.getClaim(userInfoProperties.who());
LOGGER.trace("Username used for Who {}", who);

Expand All @@ -62,6 +63,7 @@ public Uni<CreateResponse> create(@PathParam(TYPE_PATH_PARAM) SclFileType type,
@Path("/list")
@Produces(MediaType.APPLICATION_XML)
public Uni<ListResponse> list(@PathParam(TYPE_PATH_PARAM) SclFileType type) {
LOGGER.info("Listing SCL Files for type {} from storage.", type);
var response = new ListResponse();
response.setItems(compasSclDataService.list(type));
return Uni.createFrom().item(response);
Expand All @@ -72,6 +74,7 @@ public Uni<ListResponse> list(@PathParam(TYPE_PATH_PARAM) SclFileType type) {
@Produces(MediaType.APPLICATION_XML)
public Uni<VersionsResponse> listVersionsByUUID(@PathParam(TYPE_PATH_PARAM) SclFileType type,
@PathParam(ID_PATH_PARAM) UUID id) {
LOGGER.info("Listing versions of SCL File {} for type {} from storage.", id, type);
var response = new VersionsResponse();
response.setItems(compasSclDataService.listVersionsByUUID(type, id));
return Uni.createFrom().item(response);
Expand All @@ -82,6 +85,7 @@ public Uni<VersionsResponse> listVersionsByUUID(@PathParam(TYPE_PATH_PARAM) SclF
@Produces(MediaType.APPLICATION_XML)
public Uni<GetResponse> findByUUID(@PathParam(TYPE_PATH_PARAM) SclFileType type,
@PathParam(ID_PATH_PARAM) UUID id) {
LOGGER.info("Retrieving latest version of SCL File {} for type {} from storage.", id, type);
var response = new GetResponse();
response.setSclData(compasSclDataService.findByUUID(type, id));
return Uni.createFrom().item(response);
Expand All @@ -93,6 +97,7 @@ public Uni<GetResponse> findByUUID(@PathParam(TYPE_PATH_PARAM) SclFileType type,
public Uni<GetResponse> findByUUIDAndVersion(@PathParam(TYPE_PATH_PARAM) SclFileType type,
@PathParam(ID_PATH_PARAM) UUID id,
@PathParam(VERSION_PATH_PARAM) Version version) {
LOGGER.info("Retrieving version {} of SCL File {} for type {} from storage.", version, id, type);
var response = new GetResponse();
response.setSclData(compasSclDataService.findByUUID(type, id, version));
return Uni.createFrom().item(response);
Expand All @@ -106,6 +111,7 @@ public Uni<GetResponse> findByUUIDAndVersion(@PathParam(TYPE_PATH_PARAM) SclFile
public Uni<UpdateResponse> update(@PathParam(TYPE_PATH_PARAM) SclFileType type,
@PathParam(ID_PATH_PARAM) UUID id,
@Valid UpdateRequest request) {
LOGGER.info("Updating SCL File {} for type {} to storage.", id, type);
String who = jsonWebToken.getClaim(userInfoProperties.who());
LOGGER.trace("Username used for Who {}", who);

Expand All @@ -121,6 +127,7 @@ public Uni<UpdateResponse> update(@PathParam(TYPE_PATH_PARAM) SclFileType type,
@Produces(MediaType.APPLICATION_XML)
public Uni<Void> deleteAll(@PathParam(TYPE_PATH_PARAM) SclFileType type,
@PathParam(ID_PATH_PARAM) UUID id) {
LOGGER.info("Removing all versions of SCL File {} for type {} from storage.", id, type);
compasSclDataService.delete(type, id);
return Uni.createFrom().nullItem();
}
Expand All @@ -132,6 +139,7 @@ public Uni<Void> deleteAll(@PathParam(TYPE_PATH_PARAM) SclFileType type,
public Uni<Void> deleteVersion(@PathParam(TYPE_PATH_PARAM) SclFileType type,
@PathParam(ID_PATH_PARAM) UUID id,
@PathParam(VERSION_PATH_PARAM) Version version) {
LOGGER.info("Removing version {} of SCL File {} for type {} from storage.", version, id, type);
compasSclDataService.delete(type, id, version);
return Uni.createFrom().nullItem();
}
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.vertx.mutiny.core.eventbus.EventBus;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.microprofile.jwt.JsonWebToken;
import org.lfenergy.compas.core.websocket.ErrorResponseEncoder;
import org.lfenergy.compas.scl.data.rest.UserInfoProperties;
Expand All @@ -13,11 +15,10 @@
import org.lfenergy.compas.scl.data.websocket.v1.encoder.CreateWsResponseEncoder;
import org.lfenergy.compas.scl.data.websocket.v1.model.CreateWsRequest;
import org.lfenergy.compas.scl.extensions.model.SclFileType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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 @@ -31,7 +32,7 @@
decoders = {CreateWsRequestDecoder.class},
encoders = {CreateWsResponseEncoder.class, ErrorResponseEncoder.class})
public class CompasSclCreateServerEndpoint {
private static final Logger LOGGER = LoggerFactory.getLogger(CompasSclCreateServerEndpoint.class);
private static final Logger LOGGER = LogManager.getLogger(CompasSclCreateServerEndpoint.class);

private final EventBus eventBus;
private final JsonWebToken jsonWebToken;
Expand All @@ -52,7 +53,9 @@ public void onOpen(Session session, @PathParam(TYPE_PATH_PARAM) String type) {
}

@OnMessage
public void onCreateMessage(Session session, CreateWsRequest request, @PathParam(TYPE_PATH_PARAM) String type) {
public void onCreateMessage(Session session,
@Valid CreateWsRequest request,
@PathParam(TYPE_PATH_PARAM) String type) {
LOGGER.info("Message (create) from session {} for type {}.", session.getId(), type);

String who = jsonWebToken.getClaim(userInfoProperties.who());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@

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.data.websocket.event.model.GetEventRequest;
import org.lfenergy.compas.scl.data.websocket.v1.decoder.GetWsRequestDecoder;
import org.lfenergy.compas.scl.data.websocket.v1.encoder.GetWsResponseEncoder;
import org.lfenergy.compas.scl.data.websocket.v1.model.GetWsRequest;
import org.lfenergy.compas.scl.extensions.model.SclFileType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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 @@ -29,7 +30,7 @@
decoders = {GetWsRequestDecoder.class},
encoders = {GetWsResponseEncoder.class, ErrorResponseEncoder.class})
public class CompasSclGetServerEndpoint {
private static final Logger LOGGER = LoggerFactory.getLogger(CompasSclGetServerEndpoint.class);
private static final Logger LOGGER = LogManager.getLogger(CompasSclGetServerEndpoint.class);

private final EventBus eventBus;

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

@OnMessage
public void onGetMessage(Session session,
GetWsRequest request,
@Valid GetWsRequest request,
@PathParam(TYPE_PATH_PARAM) String type) {
LOGGER.info("Message (get) from session {} for type {}.", session.getId(), type);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@

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.data.model.Version;
import org.lfenergy.compas.scl.data.websocket.event.model.GetVersionEventRequest;
import org.lfenergy.compas.scl.data.websocket.v1.decoder.GetVersionWsRequestDecoder;
import org.lfenergy.compas.scl.data.websocket.v1.encoder.GetWsResponseEncoder;
import org.lfenergy.compas.scl.data.websocket.v1.model.GetVersionWsRequest;
import org.lfenergy.compas.scl.extensions.model.SclFileType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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 @@ -30,7 +31,7 @@
decoders = {GetVersionWsRequestDecoder.class},
encoders = {GetWsResponseEncoder.class, ErrorResponseEncoder.class})
public class CompasSclGetVersionServerEndpoint {
private static final Logger LOGGER = LoggerFactory.getLogger(CompasSclGetVersionServerEndpoint.class);
private static final Logger LOGGER = LogManager.getLogger(CompasSclGetVersionServerEndpoint.class);

private final EventBus eventBus;

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

@OnMessage
public void onGetVersionMessage(Session session,
GetVersionWsRequest request,
@Valid GetVersionWsRequest request,
@PathParam(TYPE_PATH_PARAM) String type) {
LOGGER.info("Message from session {} for type {}.", session.getId(), type);

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.vertx.mutiny.core.eventbus.EventBus;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.microprofile.jwt.JsonWebToken;
import org.lfenergy.compas.core.websocket.ErrorResponseEncoder;
import org.lfenergy.compas.scl.data.rest.UserInfoProperties;
Expand All @@ -13,11 +15,10 @@
import org.lfenergy.compas.scl.data.websocket.v1.encoder.UpdateWsResponseEncoder;
import org.lfenergy.compas.scl.data.websocket.v1.model.UpdateWsRequest;
import org.lfenergy.compas.scl.extensions.model.SclFileType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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 @@ -31,7 +32,7 @@
decoders = {UpdateWsRequestDecoder.class},
encoders = {UpdateWsResponseEncoder.class, ErrorResponseEncoder.class})
public class CompasSclUpdateServerEndpoint {
private static final Logger LOGGER = LoggerFactory.getLogger(CompasSclUpdateServerEndpoint.class);
private static final Logger LOGGER = LogManager.getLogger(CompasSclUpdateServerEndpoint.class);

private final EventBus eventBus;
private final JsonWebToken jsonWebToken;
Expand All @@ -52,7 +53,8 @@ public void onOpen(Session session, @PathParam(TYPE_PATH_PARAM) String type) {
}

@OnMessage
public void onUpdateMessage(Session session, UpdateWsRequest request,
public void onUpdateMessage(Session session,
@Valid UpdateWsRequest request,
@PathParam(TYPE_PATH_PARAM) String type) {
LOGGER.info("Message (update) from session {} for type {}.", session.getId(), type);

Expand Down
3 changes: 0 additions & 3 deletions app/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ quarkus.log.level = INFO
quarkus.log.category."org.lfenergy.compas.scl.data".level = INFO

# Add scanning these dependencies for scanning, also used by native compilation.
quarkus.index-dependency.hibernate-validator.group-id=org.hibernate.validator
quarkus.index-dependency.hibernate-validator.artifact-id=hibernate-validator

quarkus.index-dependency.websocket-commons.group-id = org.lfenergy.compas.core
quarkus.index-dependency.websocket-commons.artifact-id = websocket-commons

Expand Down
Loading

0 comments on commit e994b99

Please sign in to comment.