From c29d2f52ecbdf6c987a5425ffa3079fb936d8442 Mon Sep 17 00:00:00 2001 From: gibert Date: Mon, 19 Feb 2024 16:50:47 +0100 Subject: [PATCH] Ajout des redirections pour 3 services + maj images du Dockerfile vers java 17 --- Dockerfile | 4 +- .../controller/RedirectionController.java | 39 +++++++++++++++++++ src/main/resources/application.properties | 1 + 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 src/main/java/fr/abes/theses/export/controller/RedirectionController.java diff --git a/Dockerfile b/Dockerfile index 34aa35e..dd0ca6d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ ### # Image pour la compilation -FROM maven:3-eclipse-temurin-11 as build-image +FROM maven:3-eclipse-temurin-17 as build-image WORKDIR /build/ # Installation et configuration de la locale FR RUN apt update && DEBIAN_FRONTEND=noninteractive apt -y install locales @@ -28,7 +28,7 @@ RUN mvn --batch-mode -e \ ### # Image pour le module theses-export -FROM eclipse-temurin:11-jre as api-export-image +FROM eclipse-temurin:17-jre as api-export-image WORKDIR /app/ COPY --from=build-image /build/target/*.jar /app/theses-api-export.jar ENTRYPOINT exec java $JAVA_OPTS -jar /app/theses-api-export.jar diff --git a/src/main/java/fr/abes/theses/export/controller/RedirectionController.java b/src/main/java/fr/abes/theses/export/controller/RedirectionController.java new file mode 100644 index 0000000..fb5cb87 --- /dev/null +++ b/src/main/java/fr/abes/theses/export/controller/RedirectionController.java @@ -0,0 +1,39 @@ +package fr.abes.theses.export.controller; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.net.URI; + +@Slf4j +@RestController +@RequestMapping("/") +public class RedirectionController { + + @Value("${racine}") + String racine; + + @GetMapping(value = "{nnt}.xml") + public ResponseEntity redirectXML(@PathVariable String nnt){ + + return ResponseEntity.status(HttpStatus.MOVED_PERMANENTLY).location(URI.create(racine + "/api/v1/theses/export/xml/" + nnt)).build(); + } + + @GetMapping(value = "{nnt}.rdf") + public ResponseEntity redirectRDF(@PathVariable String nnt){ + + return ResponseEntity.status(HttpStatus.MOVED_PERMANENTLY).location(URI.create(racine + "/api/v1/theses/export/rdf/" + nnt)).build(); + } + + @GetMapping(value = "{nnt}.tefudoc") + public ResponseEntity redirectTefudoc(@PathVariable String nnt){ + + return ResponseEntity.status(HttpStatus.MOVED_PERMANENTLY).location(URI.create(racine + "/api/v1/theses/export/tefudoc/" + nnt)).build(); + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index fc25791..feef1f3 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -12,3 +12,4 @@ spring.datasource.hikari.readOnly=true path.xsls= logging.level.fr.abes= +racine=