diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-05-18 13:36:14 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-05-18 14:34:54 +0200 |
| commit | 8ec4bd7584ad67b4aebd2a88a1e33902923a5375 (patch) | |
| tree | ea220eabeb4912fd640242277aa8441a1238d791 /opendc-web/opendc-web-ui-quarkus/runtime | |
| parent | 689c873ff68b6c8fd66740603dad6efa3bf8ab47 (diff) | |
refactor(web/ui): Remove module nesting in Quarkus extension
This change updates the OpenDC web UI Quarkus extension to live
completely in the `opendc-web` directory, as opposed to adding another
level of nesting. This also allows us to properly name the artifacts of
the Quarkus extension modules.
Diffstat (limited to 'opendc-web/opendc-web-ui-quarkus/runtime')
4 files changed, 0 insertions, 187 deletions
diff --git a/opendc-web/opendc-web-ui-quarkus/runtime/build.gradle.kts b/opendc-web/opendc-web-ui-quarkus/runtime/build.gradle.kts deleted file mode 100644 index f4131f0b..00000000 --- a/opendc-web/opendc-web-ui-quarkus/runtime/build.gradle.kts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2022 AtLarge Research - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -description = "Quarkus extension for serving OpenDC web interface" - -plugins { - `java-library-conventions` - id("io.quarkus.extension") -} - -dependencies { - implementation(enforcedPlatform(libs.quarkus.bom)) - - implementation(libs.quarkus.core.runtime) - implementation(libs.quarkus.vertx.http.runtime) - implementation(libs.quarkus.arc.runtime) -} diff --git a/opendc-web/opendc-web-ui-quarkus/runtime/src/main/java/org/opendc/web/ui/runtime/OpenDCUiRecorder.java b/opendc-web/opendc-web-ui-quarkus/runtime/src/main/java/org/opendc/web/ui/runtime/OpenDCUiRecorder.java deleted file mode 100644 index 026a9039..00000000 --- a/opendc-web/opendc-web-ui-quarkus/runtime/src/main/java/org/opendc/web/ui/runtime/OpenDCUiRecorder.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2022 AtLarge Research - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package org.opendc.web.ui.runtime; - -import io.quarkus.runtime.ShutdownContext; -import io.quarkus.runtime.annotations.Recorder; -import io.quarkus.vertx.http.runtime.devmode.FileSystemStaticHandler; -import io.quarkus.vertx.http.runtime.webjar.WebJarNotFoundHandler; -import io.quarkus.vertx.http.runtime.webjar.WebJarStaticHandler; -import io.vertx.core.Handler; -import io.vertx.ext.web.RoutingContext; - -import java.util.List; -import java.util.stream.Collectors; - -/** - * Helper class for serving the OpenDC web interface. - */ -@Recorder -public class OpenDCUiRecorder { - /** - * Construct a {@link Handler} for serving a page of the OpenDC web interface. - */ - public Handler<RoutingContext> pageHandler( - String finalDestination, - String page, - OpenDCUiRuntimeConfig runtimeConfig - ) { - if (runtimeConfig.enable) { - String pageDirectory = finalDestination + "/pages"; - return (event) -> { - event.response() - .setStatusCode(200) - .sendFile(pageDirectory + page + ".html"); - }; - } - - return new WebJarNotFoundHandler(); - } - - /** - * Construct a {@link Handler} for handling redirects in the OpenDC web interface. - */ - public Handler<RoutingContext> redirectHandler( - String destination, - int statusCode, - OpenDCUiRuntimeConfig runtimeConfig - ) { - if (runtimeConfig.enable) { - return (event) -> { - String query = event.request().query(); - String fullDestination = query != null ? destination + "?" + query : destination; - - event.response() - .setStatusCode(statusCode) - .putHeader("Location", fullDestination) - .end(); - }; - } - - return new WebJarNotFoundHandler(); - } - - /** - * Construct a {@link Handler} for serving the static files of the OpenDC web interface. - */ - public Handler<RoutingContext> staticHandler( - String finalDestination, - String path, - List<FileSystemStaticHandler.StaticWebRootConfiguration> webRootConfigurations, - OpenDCUiRuntimeConfig runtimeConfig, - ShutdownContext shutdownContext - ) { - if (runtimeConfig.enable) { - var augmentedWebRootConfigurations = webRootConfigurations - .stream() - .map(c -> new FileSystemStaticHandler.StaticWebRootConfiguration(c.getFileSystem(), c.getWebRoot().isEmpty() ? "static" : c.getWebRoot() + "/static")) - .collect(Collectors.toList()); - - WebJarStaticHandler handler = new WebJarStaticHandler(finalDestination + "/static", path, augmentedWebRootConfigurations); - shutdownContext.addShutdownTask(new ShutdownContext.CloseRunnable(handler)); - return handler; - } - - return new WebJarNotFoundHandler(); - } -} diff --git a/opendc-web/opendc-web-ui-quarkus/runtime/src/main/java/org/opendc/web/ui/runtime/OpenDCUiRuntimeConfig.java b/opendc-web/opendc-web-ui-quarkus/runtime/src/main/java/org/opendc/web/ui/runtime/OpenDCUiRuntimeConfig.java deleted file mode 100644 index 8ae3b6a2..00000000 --- a/opendc-web/opendc-web-ui-quarkus/runtime/src/main/java/org/opendc/web/ui/runtime/OpenDCUiRuntimeConfig.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2022 AtLarge Research - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package org.opendc.web.ui.runtime; - -import io.quarkus.runtime.annotations.ConfigItem; -import io.quarkus.runtime.annotations.ConfigPhase; -import io.quarkus.runtime.annotations.ConfigRoot; - -/** - * Configuration for the OpenDC web UI. - */ -@ConfigRoot(phase = ConfigPhase.RUN_TIME, name = "opendc-ui") -public class OpenDCUiRuntimeConfig { - /** - * Flag to indicate whether the web interface should be served by the OpenDC API server. - */ - @ConfigItem(defaultValue = "true") - public boolean enable; -} diff --git a/opendc-web/opendc-web-ui-quarkus/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/opendc-web/opendc-web-ui-quarkus/runtime/src/main/resources/META-INF/quarkus-extension.yaml deleted file mode 100644 index 581a1779..00000000 --- a/opendc-web/opendc-web-ui-quarkus/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -name: "OpenDC Web UI" -metadata: - status: "preview" - unlisted: true |
