From ca8f2bfec7c2839d88936d0793b331f8b106e5bc Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Tue, 16 May 2023 03:01:48 +0200 Subject: [PATCH 1/2] Rename all occurrences of "labyrinth" to maze and update dependencies. --- .drone.yml | 6 ++- README.md | 3 +- docker/Dockerfile | 4 +- maven-settings.xml | 5 +++ pom.xml | 40 +++++++------------ .../server/ConfigurationException.java | 2 +- .../{labyrinth => maze}/server/Main.java | 4 +- .../server/MazeServer.java} | 22 +++++----- .../server/OutputType.java | 38 +++++++++--------- .../server/ServerConfig.java | 6 +-- .../server/handler/AbstractHttpHandler.java | 2 +- .../server/handler/CreateHandler.java | 40 ++++++++++--------- .../handler/ParametersToMazeExtractor.java} | 31 +++++++------- .../server/handler/RenderV1Handler.java | 19 ++++----- .../server/handler/RenderV2Handler.java | 19 ++++----- .../server/handler/RequestParameter.java | 13 +++--- src/main/resources/logback.xml | 2 +- .../server/ServerConfigTest.java | 2 +- 18 files changed, 129 insertions(+), 129 deletions(-) rename src/main/java/ch/fritteli/{labyrinth => maze}/server/ConfigurationException.java (90%) rename src/main/java/ch/fritteli/{labyrinth => maze}/server/Main.java (75%) rename src/main/java/ch/fritteli/{labyrinth/server/LabyrinthServer.java => maze/server/MazeServer.java} (70%) rename src/main/java/ch/fritteli/{labyrinth => maze}/server/OutputType.java (63%) rename src/main/java/ch/fritteli/{labyrinth => maze}/server/ServerConfig.java (91%) rename src/main/java/ch/fritteli/{labyrinth => maze}/server/handler/AbstractHttpHandler.java (96%) rename src/main/java/ch/fritteli/{labyrinth => maze}/server/handler/CreateHandler.java (57%) rename src/main/java/ch/fritteli/{labyrinth/server/handler/ParametersToLabyrinthExtractor.java => maze/server/handler/ParametersToMazeExtractor.java} (74%) rename src/main/java/ch/fritteli/{labyrinth => maze}/server/handler/RenderV1Handler.java (78%) rename src/main/java/ch/fritteli/{labyrinth => maze}/server/handler/RenderV2Handler.java (78%) rename src/main/java/ch/fritteli/{labyrinth => maze}/server/handler/RequestParameter.java (94%) rename src/test/java/ch/fritteli/{labyrinth => maze}/server/ServerConfigTest.java (97%) diff --git a/.drone.yml b/.drone.yml index b0b33a6..934778b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -26,6 +26,8 @@ steps: environment: REPO_TOKEN: from_secret: repo-token + REPO_TOKEN_OSSRH: + from_secret: repo-token-ossrh commands: - mvn -s maven-settings.xml deploy -DskipTests=true when: @@ -41,7 +43,7 @@ steps: username: manuel password: from_secret: docker-token - repo: gittr.ch/java/labyrinth + repo: gittr.ch/java/a-maze-r tags: - latest dockerfile: docker/Dockerfile @@ -59,7 +61,7 @@ steps: username: manuel password: from_secret: docker-token - repo: gittr.ch/java/labyrinth + repo: gittr.ch/java/a-maze-r tags: - latest - ${DRONE_TAG} diff --git a/README.md b/README.md index 97bddbc..41c5b82 100644 --- a/README.md +++ b/README.md @@ -1,2 +1 @@ -# labyrinth-server - +# maze-server diff --git a/docker/Dockerfile b/docker/Dockerfile index df53dcb..8ba6147 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,7 +1,7 @@ FROM openjdk:17-slim -COPY target/labyrinth-server-*.jar /app/ +COPY target/maze-server-*.jar /app/ RUN rm /app/*-sources.jar RUN mv /app/*.jar /app/app.jar -CMD java -Dfritteli.labyrinth.server.host=0.0.0.0 -Dfritteli.labyrinth.server.port=80 -jar /app/app.jar +CMD java -Dfritteli.maze.server.host=0.0.0.0 -Dfritteli.maze.server.port=80 -jar /app/app.jar diff --git a/maven-settings.xml b/maven-settings.xml index 18a15cb..9e840fd 100644 --- a/maven-settings.xml +++ b/maven-settings.xml @@ -8,5 +8,10 @@ ci ${env.REPO_TOKEN} + + ossrh + fritteli + ${env.REPO_TOKEN_OSSRH} + diff --git a/pom.xml b/pom.xml index 0e1a9d5..4509031 100644 --- a/pom.xml +++ b/pom.xml @@ -5,26 +5,18 @@ ch.fritteli fritteli-build-parent - 2.0.4 + 5.0.0 - ch.fritteli.labyrinth - labyrinth-server + ch.fritteli.a-maze-r + maze-server 0.0.7-SNAPSHOT - The Labyrinth server, offering a REST endpoint to access the Labyrinth Generator. - https://manuel.friedli.info/labyrinth.html + The A-Maze-R server, offering a REST endpoint to access the Maze Generator. + https://manuel.friedli.info/maze.html - 17 - 17 - 24.0.1 - 5.9.2 - 0.0.8 - 1.4.6 - 1.18.26 - 2.0.7 + 0.1.0 2.3.5.Final - 0.10.4 @@ -45,9 +37,9 @@ - ch.fritteli.labyrinth - labyrinth-generator - ${labyrinth-generator.version} + ch.fritteli.a-maze-r + maze-generator + ${maze-generator.version} io.vavr @@ -64,12 +56,10 @@ org.slf4j slf4j-api - ${slf4j.version} ch.qos.logback logback-classic - ${logback.version} io.undertow @@ -87,16 +77,15 @@ org.apache.maven.plugins maven-shade-plugin - 3.4.1 - ch.fritteli.labyrinth.server.Main + ch.fritteli.maze.server.Main - ch.fritteli.labyrinth:labyrinth-generator + ch.fritteli.a-maze-r:maze-generator logback.xml @@ -128,14 +117,13 @@ org.apache.maven.plugins maven-site-plugin - 4.0.0-M6 - scm:git:https://gittr.ch/java/labyrinth-server.git - scm:git:ssh://git@gittr.ch/java/labyrinth-server.git - https://gittr.ch/java/labyrinth-server + scm:git:https://gittr.ch/java/maze-server.git + scm:git:ssh://git@gittr.ch/java/maze-server.git + https://gittr.ch/java/maze-server HEAD diff --git a/src/main/java/ch/fritteli/labyrinth/server/ConfigurationException.java b/src/main/java/ch/fritteli/maze/server/ConfigurationException.java similarity index 90% rename from src/main/java/ch/fritteli/labyrinth/server/ConfigurationException.java rename to src/main/java/ch/fritteli/maze/server/ConfigurationException.java index 1905a95..1159634 100644 --- a/src/main/java/ch/fritteli/labyrinth/server/ConfigurationException.java +++ b/src/main/java/ch/fritteli/maze/server/ConfigurationException.java @@ -1,4 +1,4 @@ -package ch.fritteli.labyrinth.server; +package ch.fritteli.maze.server; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/fritteli/labyrinth/server/Main.java b/src/main/java/ch/fritteli/maze/server/Main.java similarity index 75% rename from src/main/java/ch/fritteli/labyrinth/server/Main.java rename to src/main/java/ch/fritteli/maze/server/Main.java index 9800d8c..687fa4d 100644 --- a/src/main/java/ch/fritteli/labyrinth/server/Main.java +++ b/src/main/java/ch/fritteli/maze/server/Main.java @@ -1,4 +1,4 @@ -package ch.fritteli.labyrinth.server; +package ch.fritteli.maze.server; import lombok.experimental.UtilityClass; import lombok.extern.slf4j.Slf4j; @@ -8,7 +8,7 @@ import lombok.extern.slf4j.Slf4j; public class Main { public static void main(String[] args) { - LabyrinthServer.createAndStartServer() + MazeServer.createAndStartServer() .onFailure(e -> log.error("Failed to create server. Stopping.", e)); } } diff --git a/src/main/java/ch/fritteli/labyrinth/server/LabyrinthServer.java b/src/main/java/ch/fritteli/maze/server/MazeServer.java similarity index 70% rename from src/main/java/ch/fritteli/labyrinth/server/LabyrinthServer.java rename to src/main/java/ch/fritteli/maze/server/MazeServer.java index 4c7da3e..183db6d 100644 --- a/src/main/java/ch/fritteli/labyrinth/server/LabyrinthServer.java +++ b/src/main/java/ch/fritteli/maze/server/MazeServer.java @@ -1,8 +1,8 @@ -package ch.fritteli.labyrinth.server; +package ch.fritteli.maze.server; -import ch.fritteli.labyrinth.server.handler.CreateHandler; -import ch.fritteli.labyrinth.server.handler.RenderV1Handler; -import ch.fritteli.labyrinth.server.handler.RenderV2Handler; +import ch.fritteli.maze.server.handler.CreateHandler; +import ch.fritteli.maze.server.handler.RenderV1Handler; +import ch.fritteli.maze.server.handler.RenderV2Handler; import io.undertow.Undertow; import io.undertow.server.RoutingHandler; import io.vavr.control.Try; @@ -11,12 +11,12 @@ import lombok.NonNull; import lombok.extern.slf4j.Slf4j; @Slf4j -public class LabyrinthServer { +public class MazeServer { @NonNull private final Undertow undertow; - private LabyrinthServer(@NonNull final ServerConfig config) { + private MazeServer(@NonNull final ServerConfig config) { final String hostAddress = config.getAddress().getHostAddress(); final int port = config.getPort(); log.info("Starting Server at http://{}:{}/", hostAddress, port); @@ -32,15 +32,15 @@ public class LabyrinthServer { } @NonNull - public static Try createAndStartServer() { + public static Try createAndStartServer() { return Try.of(ServerConfig::init) - .flatMapTry(LabyrinthServer::createAndStartServer); + .flatMapTry(MazeServer::createAndStartServer); } @NonNull - public static Try createAndStartServer(@NonNull final ServerConfig config) { - return Try.of(() -> new LabyrinthServer(config)) - .peek(LabyrinthServer::start); + public static Try createAndStartServer(@NonNull final ServerConfig config) { + return Try.of(() -> new MazeServer(config)) + .peek(MazeServer::start); } private void start() { diff --git a/src/main/java/ch/fritteli/labyrinth/server/OutputType.java b/src/main/java/ch/fritteli/maze/server/OutputType.java similarity index 63% rename from src/main/java/ch/fritteli/labyrinth/server/OutputType.java rename to src/main/java/ch/fritteli/maze/server/OutputType.java index 767d4da..75c292f 100644 --- a/src/main/java/ch/fritteli/labyrinth/server/OutputType.java +++ b/src/main/java/ch/fritteli/maze/server/OutputType.java @@ -1,12 +1,12 @@ -package ch.fritteli.labyrinth.server; +package ch.fritteli.maze.server; -import ch.fritteli.labyrinth.generator.model.Labyrinth; -import ch.fritteli.labyrinth.generator.renderer.html.HTMLRenderer; -import ch.fritteli.labyrinth.generator.renderer.json.JsonRenderer; -import ch.fritteli.labyrinth.generator.renderer.pdf.PDFRenderer; -import ch.fritteli.labyrinth.generator.renderer.text.TextRenderer; -import ch.fritteli.labyrinth.generator.serialization.v1.SerializerDeserializerV1; -import ch.fritteli.labyrinth.generator.serialization.v2.SerializerDeserializerV2; +import ch.fritteli.maze.generator.renderer.html.HTMLRenderer; +import ch.fritteli.maze.generator.renderer.json.JsonRenderer; +import ch.fritteli.maze.generator.renderer.pdf.PDFRenderer; +import ch.fritteli.maze.generator.renderer.text.TextRenderer; +import ch.fritteli.maze.generator.serialization.v1.SerializerDeserializerV1; +import ch.fritteli.maze.generator.serialization.v2.SerializerDeserializerV2; +import ch.fritteli.maze.generator.model.Maze; import io.vavr.collection.List; import io.vavr.collection.Stream; import io.vavr.control.Option; @@ -20,37 +20,37 @@ import java.util.function.Function; public enum OutputType { TEXT_PLAIN("text/plain; charset=UTF-8", "txt", - labyrinth -> TextRenderer.newInstance().render(labyrinth).getBytes(StandardCharsets.UTF_8), + maze -> TextRenderer.newInstance().render(maze).getBytes(StandardCharsets.UTF_8), false, "t", "text"), HTML("text/html", "html", - labyrinth -> HTMLRenderer.newInstance().render(labyrinth).getBytes(StandardCharsets.UTF_8), + maze -> HTMLRenderer.newInstance().render(maze).getBytes(StandardCharsets.UTF_8), false, "h", "html"), JSON("application/json", "json", - labyrinth -> JsonRenderer.newInstance().render(labyrinth).getBytes(StandardCharsets.UTF_8), + maze -> JsonRenderer.newInstance().render(maze).getBytes(StandardCharsets.UTF_8), false, "j", "json"), JSONFILE("application/json", "json", - labyrinth -> JsonRenderer.newInstance().render(labyrinth).getBytes(StandardCharsets.UTF_8), + maze -> JsonRenderer.newInstance().render(maze).getBytes(StandardCharsets.UTF_8), true, "s", "jsonfile"), PDF("application/pdf", "pdf", - labyrinth -> PDFRenderer.newInstance().render(labyrinth).toByteArray(), + maze -> PDFRenderer.newInstance().render(maze).toByteArray(), false, "p", "pdf"), PDFFILE("application/pdf", "pdf", - labyrinth -> PDFRenderer.newInstance().render(labyrinth).toByteArray(), + maze -> PDFRenderer.newInstance().render(maze).toByteArray(), true, "f", "pdffile"), @@ -61,7 +61,7 @@ public enum OutputType { "b", "binary"), BINARY_V2("application/octet-stream", - "lab2", + "maze", SerializerDeserializerV2::serialize, true, "v", @@ -73,7 +73,7 @@ public enum OutputType { @NonNull private final String fileExtension; @NonNull - private final Function render; + private final Function render; @Getter private final boolean attachment; @Getter @@ -82,7 +82,7 @@ public enum OutputType { OutputType(@NonNull final String contentType, @NonNull final String fileExtension, - @NonNull final Function render, + @NonNull final Function render, final boolean attachment, @NonNull final String... names) { this.contentType = contentType; @@ -108,7 +108,7 @@ public enum OutputType { } @NonNull - public byte[] render(@NonNull final Labyrinth labyrinth) { - return this.render.apply(labyrinth); + public byte[] render(@NonNull final Maze maze) { + return this.render.apply(maze); } } diff --git a/src/main/java/ch/fritteli/labyrinth/server/ServerConfig.java b/src/main/java/ch/fritteli/maze/server/ServerConfig.java similarity index 91% rename from src/main/java/ch/fritteli/labyrinth/server/ServerConfig.java rename to src/main/java/ch/fritteli/maze/server/ServerConfig.java index 196b2c5..0811126 100644 --- a/src/main/java/ch/fritteli/labyrinth/server/ServerConfig.java +++ b/src/main/java/ch/fritteli/maze/server/ServerConfig.java @@ -1,4 +1,4 @@ -package ch.fritteli.labyrinth.server; +package ch.fritteli.maze.server; import io.vavr.control.Try; import lombok.AccessLevel; @@ -14,8 +14,8 @@ import java.net.InetAddress; @Slf4j @Value public class ServerConfig { - public static final String SYSPROP_HOST = "fritteli.labyrinth.server.host"; - public static final String SYSPROP_PORT = "fritteli.labyrinth.server.port"; + public static final String SYSPROP_HOST = "fritteli.maze.server.host"; + public static final String SYSPROP_PORT = "fritteli.maze.server.port"; @NonNull InetAddress address; diff --git a/src/main/java/ch/fritteli/labyrinth/server/handler/AbstractHttpHandler.java b/src/main/java/ch/fritteli/maze/server/handler/AbstractHttpHandler.java similarity index 96% rename from src/main/java/ch/fritteli/labyrinth/server/handler/AbstractHttpHandler.java rename to src/main/java/ch/fritteli/maze/server/handler/AbstractHttpHandler.java index 198c7a4..ac90f39 100644 --- a/src/main/java/ch/fritteli/labyrinth/server/handler/AbstractHttpHandler.java +++ b/src/main/java/ch/fritteli/maze/server/handler/AbstractHttpHandler.java @@ -1,4 +1,4 @@ -package ch.fritteli.labyrinth.server.handler; +package ch.fritteli.maze.server.handler; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; diff --git a/src/main/java/ch/fritteli/labyrinth/server/handler/CreateHandler.java b/src/main/java/ch/fritteli/maze/server/handler/CreateHandler.java similarity index 57% rename from src/main/java/ch/fritteli/labyrinth/server/handler/CreateHandler.java rename to src/main/java/ch/fritteli/maze/server/handler/CreateHandler.java index 344a907..a5a43a0 100644 --- a/src/main/java/ch/fritteli/labyrinth/server/handler/CreateHandler.java +++ b/src/main/java/ch/fritteli/maze/server/handler/CreateHandler.java @@ -1,7 +1,7 @@ -package ch.fritteli.labyrinth.server.handler; +package ch.fritteli.maze.server.handler; -import ch.fritteli.labyrinth.generator.model.Labyrinth; -import ch.fritteli.labyrinth.server.OutputType; +import ch.fritteli.maze.server.OutputType; +import ch.fritteli.maze.generator.model.Maze; import io.undertow.server.HttpServerExchange; import io.undertow.util.Headers; import io.undertow.util.HttpString; @@ -26,9 +26,9 @@ public class CreateHandler extends AbstractHttpHandler { protected void handle(@NonNull final HttpServerExchange exchange) { final Instant start = Instant.now(); log.debug("Handling create request"); - this.createLabyrinthFromRequestParameters(exchange.getQueryParameters()) + this.createMazeFromRequestParameters(exchange.getQueryParameters()) .onFailure(e -> { - log.error("Error creating Labyrinth from request", e); + log.error("Error creating maze from request", e); exchange.setStatusCode(StatusCodes.INTERNAL_SERVER_ERROR) .setReasonPhrase(StatusCodes.INTERNAL_SERVER_ERROR_STRING) .getResponseSender() @@ -36,31 +36,33 @@ public class CreateHandler extends AbstractHttpHandler { }) .forEach(tuple -> { final OutputType outputType = tuple._1(); - final Labyrinth labyrinth = tuple._2(); + final Maze maze = tuple._2(); final byte[] bytes; try { - bytes = outputType.render(labyrinth); + bytes = outputType.render(maze); } catch (@NonNull final Exception e) { - log.error("Error rendering Labyrinth", e); + log.error("Error rendering Maze", e); exchange.setStatusCode(StatusCodes.INTERNAL_SERVER_ERROR) .setReasonPhrase(StatusCodes.INTERNAL_SERVER_ERROR_STRING) .getResponseSender() - .send("Error creating the Labyrinth. Please contact the administrator. Request id=%s".formatted(MDC.get("correlationId"))); + .send("Error creating the maze. Please contact the administrator. Request id=%s".formatted(MDC.get("correlationId"))); return; } final long durationMillis = start.until(Instant.now(), ChronoUnit.MILLIS); exchange.getResponseHeaders() .put(Headers.CONTENT_TYPE, outputType.getContentType()) - .put(HttpString.tryFromString("X-Labyrinth-ID"), String.valueOf(labyrinth.getRandomSeed())) - .put(HttpString.tryFromString("X-Labyrinth-Width"), String.valueOf(labyrinth.getWidth())) - .put(HttpString.tryFromString("X-Labyrinth-Height"), String.valueOf(labyrinth.getHeight())) - .put(HttpString.tryFromString("X-Labyrinth-Generation-Duration-millis"), String.valueOf(durationMillis)); + .put(HttpString.tryFromString("X-Maze-ID"), String.valueOf(maze.getRandomSeed())) + .put(HttpString.tryFromString("X-Maze-Width"), String.valueOf(maze.getWidth())) + .put(HttpString.tryFromString("X-Maze-Height"), String.valueOf(maze.getHeight())) + // TODO read the algorithm from the maze once this is supported. + .put(HttpString.tryFromString("X-Maze-Algorithm"), "RandomDepthFirst") + .put(HttpString.tryFromString("X-Maze-Generation-Duration-millis"), String.valueOf(durationMillis)); if (outputType.isAttachment()) { exchange.getResponseHeaders() - .put(Headers.CONTENT_DISPOSITION, "attachment; filename=\"labyrinth-%dx%d-%d.%s\"".formatted( - labyrinth.getWidth(), - labyrinth.getHeight(), - labyrinth.getRandomSeed(), + .put(Headers.CONTENT_DISPOSITION, "attachment; filename=\"maze-%dx%d-%d.%s\"".formatted( + maze.getWidth(), + maze.getHeight(), + maze.getRandomSeed(), outputType.getFileExtension() )); } @@ -70,7 +72,7 @@ public class CreateHandler extends AbstractHttpHandler { } @NonNull - private Try> createLabyrinthFromRequestParameters(final Map> queryParameters) { - return new ParametersToLabyrinthExtractor(queryParameters).createLabyrinth(); + private Try> createMazeFromRequestParameters(final Map> queryParameters) { + return new ParametersToMazeExtractor(queryParameters).createMaze(); } } diff --git a/src/main/java/ch/fritteli/labyrinth/server/handler/ParametersToLabyrinthExtractor.java b/src/main/java/ch/fritteli/maze/server/handler/ParametersToMazeExtractor.java similarity index 74% rename from src/main/java/ch/fritteli/labyrinth/server/handler/ParametersToLabyrinthExtractor.java rename to src/main/java/ch/fritteli/maze/server/handler/ParametersToMazeExtractor.java index 1000677..f873490 100644 --- a/src/main/java/ch/fritteli/labyrinth/server/handler/ParametersToLabyrinthExtractor.java +++ b/src/main/java/ch/fritteli/maze/server/handler/ParametersToMazeExtractor.java @@ -1,28 +1,29 @@ -package ch.fritteli.labyrinth.server.handler; +package ch.fritteli.maze.server.handler; -import ch.fritteli.labyrinth.generator.Generator; -import ch.fritteli.labyrinth.generator.model.Labyrinth; -import ch.fritteli.labyrinth.generator.model.Position; -import ch.fritteli.labyrinth.server.OutputType; +import ch.fritteli.maze.server.OutputType; +import ch.fritteli.maze.generator.algorithm.RandomDepthFirst; +import ch.fritteli.maze.generator.model.Maze; +import ch.fritteli.maze.generator.model.Position; import io.vavr.Tuple; import io.vavr.Tuple2; import io.vavr.collection.Stream; import io.vavr.control.Option; import io.vavr.control.Try; -import java.util.Deque; -import java.util.Map; -import java.util.Random; import lombok.NonNull; import lombok.RequiredArgsConstructor; +import java.util.Deque; +import java.util.Map; +import java.util.Random; + @RequiredArgsConstructor -class ParametersToLabyrinthExtractor { +class ParametersToMazeExtractor { @NonNull private final Map> queryParameters; @NonNull - Try> createLabyrinth() { + Try> createMaze() { final Option output = getParameterValue(RequestParameter.OUTPUT); final Option width = getParameterValue(RequestParameter.WIDTH); final Option height = getParameterValue(RequestParameter.HEIGHT); @@ -50,14 +51,14 @@ class ParametersToLabyrinthExtractor { } return Try.of(() -> { - final Labyrinth labyrinth; + final Maze maze; if (start.isDefined() && end.isDefined()) { - labyrinth = new Labyrinth(width.get(), height.get(), id.getOrElse(() -> new Random().nextLong()), start.get(), end.get()); + maze = new Maze(width.get(), height.get(), id.getOrElse(() -> new Random().nextLong()), start.get(), end.get()); } else { - labyrinth = new Labyrinth(width.get(), height.get(), id.getOrElse(() -> new Random().nextLong())); + maze = new Maze(width.get(), height.get(), id.getOrElse(() -> new Random().nextLong())); } - new Generator(labyrinth).run(); - return Tuple.of(output.get(), labyrinth); + new RandomDepthFirst(maze).run(); + return Tuple.of(output.get(), maze); }); } diff --git a/src/main/java/ch/fritteli/labyrinth/server/handler/RenderV1Handler.java b/src/main/java/ch/fritteli/maze/server/handler/RenderV1Handler.java similarity index 78% rename from src/main/java/ch/fritteli/labyrinth/server/handler/RenderV1Handler.java rename to src/main/java/ch/fritteli/maze/server/handler/RenderV1Handler.java index a02810b..5b67423 100644 --- a/src/main/java/ch/fritteli/labyrinth/server/handler/RenderV1Handler.java +++ b/src/main/java/ch/fritteli/maze/server/handler/RenderV1Handler.java @@ -1,16 +1,17 @@ -package ch.fritteli.labyrinth.server.handler; +package ch.fritteli.maze.server.handler; -import ch.fritteli.labyrinth.generator.model.Labyrinth; -import ch.fritteli.labyrinth.generator.serialization.v1.SerializerDeserializerV1; -import ch.fritteli.labyrinth.server.OutputType; +import ch.fritteli.maze.server.OutputType; +import ch.fritteli.maze.generator.model.Maze; +import ch.fritteli.maze.generator.serialization.v1.SerializerDeserializerV1; import io.undertow.server.HttpServerExchange; import io.undertow.util.HeaderValues; import io.undertow.util.Headers; import io.undertow.util.StatusCodes; -import java.nio.ByteBuffer; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; +import java.nio.ByteBuffer; + @Slf4j public class RenderV1Handler extends AbstractHttpHandler { @@ -28,13 +29,13 @@ public class RenderV1Handler extends AbstractHttpHandler { final OutputType output = this.getOutputType(httpServerExchange); final byte[] render; try { - final Labyrinth labyrinth = SerializerDeserializerV1.deserialize(bytes); - render = output.render(labyrinth); + final Maze maze = SerializerDeserializerV1.deserialize(bytes); + render = output.render(maze); } catch (final Exception e) { - log.error("Error rendering binary labyrinth data", e); + log.error("Error rendering binary maze data", e); httpServerExchange.setStatusCode(StatusCodes.INTERNAL_SERVER_ERROR) .getResponseSender() - .send("Error rendering labyrinth: %s".formatted(e.getMessage())); + .send("Error rendering maze: %s".formatted(e.getMessage())); return; } httpServerExchange diff --git a/src/main/java/ch/fritteli/labyrinth/server/handler/RenderV2Handler.java b/src/main/java/ch/fritteli/maze/server/handler/RenderV2Handler.java similarity index 78% rename from src/main/java/ch/fritteli/labyrinth/server/handler/RenderV2Handler.java rename to src/main/java/ch/fritteli/maze/server/handler/RenderV2Handler.java index 80d0549..0ac2721 100644 --- a/src/main/java/ch/fritteli/labyrinth/server/handler/RenderV2Handler.java +++ b/src/main/java/ch/fritteli/maze/server/handler/RenderV2Handler.java @@ -1,16 +1,17 @@ -package ch.fritteli.labyrinth.server.handler; +package ch.fritteli.maze.server.handler; -import ch.fritteli.labyrinth.generator.model.Labyrinth; -import ch.fritteli.labyrinth.generator.serialization.v2.SerializerDeserializerV2; -import ch.fritteli.labyrinth.server.OutputType; +import ch.fritteli.maze.server.OutputType; +import ch.fritteli.maze.generator.model.Maze; +import ch.fritteli.maze.generator.serialization.v2.SerializerDeserializerV2; import io.undertow.server.HttpServerExchange; import io.undertow.util.HeaderValues; import io.undertow.util.Headers; import io.undertow.util.StatusCodes; -import java.nio.ByteBuffer; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; +import java.nio.ByteBuffer; + @Slf4j public class RenderV2Handler extends AbstractHttpHandler { @@ -28,13 +29,13 @@ public class RenderV2Handler extends AbstractHttpHandler { final OutputType output = this.getOutputType(httpServerExchange); final byte[] render; try { - final Labyrinth labyrinth = SerializerDeserializerV2.deserialize(bytes); - render = output.render(labyrinth); + final Maze maze = SerializerDeserializerV2.deserialize(bytes); + render = output.render(maze); } catch (final Exception e) { - log.error("Error rendering binary labyrinth data", e); + log.error("Error rendering binary maze data", e); httpServerExchange.setStatusCode(StatusCodes.INTERNAL_SERVER_ERROR) .getResponseSender() - .send("Error rendering labyrinth: %s".formatted(e.getMessage())); + .send("Error rendering maze: %s".formatted(e.getMessage())); return; } httpServerExchange diff --git a/src/main/java/ch/fritteli/labyrinth/server/handler/RequestParameter.java b/src/main/java/ch/fritteli/maze/server/handler/RequestParameter.java similarity index 94% rename from src/main/java/ch/fritteli/labyrinth/server/handler/RequestParameter.java rename to src/main/java/ch/fritteli/maze/server/handler/RequestParameter.java index dc1c59b..1051182 100644 --- a/src/main/java/ch/fritteli/labyrinth/server/handler/RequestParameter.java +++ b/src/main/java/ch/fritteli/maze/server/handler/RequestParameter.java @@ -1,20 +1,21 @@ -package ch.fritteli.labyrinth.server.handler; +package ch.fritteli.maze.server.handler; -import ch.fritteli.labyrinth.generator.model.Position; -import ch.fritteli.labyrinth.server.OutputType; +import ch.fritteli.maze.server.OutputType; +import ch.fritteli.maze.generator.model.Position; import io.vavr.Tuple2; import io.vavr.collection.HashMap; import io.vavr.collection.HashSet; import io.vavr.collection.Set; import io.vavr.control.Option; import io.vavr.control.Try; -import java.util.Deque; -import java.util.Map; -import java.util.function.Function; import lombok.Getter; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; +import java.util.Deque; +import java.util.Map; +import java.util.function.Function; + @Slf4j enum RequestParameter { WIDTH(p -> Try.of(() -> Integer.parseInt(p)) diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index d660474..ec49dd1 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -13,5 +13,5 @@ - + diff --git a/src/test/java/ch/fritteli/labyrinth/server/ServerConfigTest.java b/src/test/java/ch/fritteli/maze/server/ServerConfigTest.java similarity index 97% rename from src/test/java/ch/fritteli/labyrinth/server/ServerConfigTest.java rename to src/test/java/ch/fritteli/maze/server/ServerConfigTest.java index 23e31d7..7760147 100644 --- a/src/test/java/ch/fritteli/labyrinth/server/ServerConfigTest.java +++ b/src/test/java/ch/fritteli/maze/server/ServerConfigTest.java @@ -1,4 +1,4 @@ -package ch.fritteli.labyrinth.server; +package ch.fritteli.maze.server; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; From c63ce409a8e35748fc468f89855dd50e8624cfe4 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Tue, 16 May 2023 03:11:40 +0200 Subject: [PATCH 2/2] Clean up the POM in preparation for the ossrh repo. --- pom.xml | 131 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 81 insertions(+), 50 deletions(-) diff --git a/pom.xml b/pom.xml index 4509031..07e1a54 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 @@ -11,13 +12,17 @@ ch.fritteli.a-maze-r maze-server 0.0.7-SNAPSHOT + The A-Maze-R server, offering a REST endpoint to access the Maze Generator. https://manuel.friedli.info/maze.html + 2022 - - 0.1.0 - 2.3.5.Final - + + + GNU Affero General Public License + https://www.gnu.org/licenses/agpl-3.0.html + + @@ -35,6 +40,27 @@ + + scm:git:https://gittr.ch/java/maze-server.git + scm:git:ssh://git@gittr.ch/java/maze-server.git + https://gittr.ch/java/maze-server + HEAD + + + + + ossrh + Sonatype Maven Repository - Snapshots + https://s01.oss.sonatype.org/content/repositories/snapshots + + + + + 0.1.0 + 4.0.0-M8 + 2.3.5.Final + + ch.fritteli.a-maze-r @@ -79,7 +105,8 @@ maven-shade-plugin - + ch.fritteli.maze.server.Main @@ -117,51 +144,55 @@ org.apache.maven.plugins maven-site-plugin + ${maven-site-plugin.version} - - scm:git:https://gittr.ch/java/maze-server.git - scm:git:ssh://git@gittr.ch/java/maze-server.git - https://gittr.ch/java/maze-server - HEAD - - - - repo.gittr.ch - gittr.ch - https://repo.gittr.ch/releases/ - - - repo.gittr.ch - gittr.ch - https://repo.gittr.ch/snapshots/ - - - - - repo.gittr.ch.releases - https://repo.gittr.ch/releases/ - - true - never - - - false - never - - - - repo.gittr.ch.snapshots - https://repo.gittr.ch/snapshots/ - - false - never - - - true - always - - - + + + + release + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-gpg-plugin + + + sign-artifacts + verify + + sign + + + + + + + +