From 986836b505a1023ad131d4ed164145a2bb566897 Mon Sep 17 00:00:00 2001 From: Pierre Mauduit Date: Mon, 29 Jan 2024 14:36:37 +0100 Subject: [PATCH] gwc - handles workspace-based paths (#380) --- .../gwc/GeoWebCacheUIAutoConfiguration.java | 37 ++++++++++++++++--- .../gwc/web/rest/GeoWebCacheController.java | 10 +---- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/gwc/autoconfigure/src/main/java/org/geoserver/cloud/autoconfigure/web/gwc/GeoWebCacheUIAutoConfiguration.java b/src/gwc/autoconfigure/src/main/java/org/geoserver/cloud/autoconfigure/web/gwc/GeoWebCacheUIAutoConfiguration.java index 39f5aee81..7e1002e52 100644 --- a/src/gwc/autoconfigure/src/main/java/org/geoserver/cloud/autoconfigure/web/gwc/GeoWebCacheUIAutoConfiguration.java +++ b/src/gwc/autoconfigure/src/main/java/org/geoserver/cloud/autoconfigure/web/gwc/GeoWebCacheUIAutoConfiguration.java @@ -6,9 +6,10 @@ import lombok.extern.slf4j.Slf4j; -import org.geoserver.cloud.autoconfigure.gwc.ConditionalOnGeoWebCacheRestConfigEnabled; +import org.geoserver.catalog.Catalog; import org.geoserver.cloud.autoconfigure.gwc.ConditionalOnWebUIEnabled; import org.geoserver.cloud.gwc.config.core.GeoWebCacheConfigurationProperties; +import org.geoserver.gwc.controller.GwcUrlHandlerMapping; import org.geowebcache.GeoWebCacheDispatcher; import org.geowebcache.rest.controller.ByteStreamController; import org.gwc.web.rest.GeoWebCacheController; @@ -32,13 +33,39 @@ GeoWebCacheController gwcController(GeoWebCacheDispatcher gwcDispatcher) { return new GeoWebCacheController(gwcDispatcher); } - /** - * Provide a handler for static web resources if missing, for example, because {@link - * ConditionalOnGeoWebCacheRestConfigEnabled} is disabled - */ + /** ConditionalOnGeoWebCacheRestConfigEnabled} is disabled */ @Bean @ConditionalOnMissingBean(ByteStreamController.class) ByteStreamController byteStreamController() { return new ByteStreamController(); } + + /** + * GS's src/web/gwc/src/main/java/applicationContext.xml + * + * + * + * + * + * + * + */ + @Bean + GwcUrlHandlerMapping gwcDemoUrlHandlerMapping(Catalog catalog) { + GwcUrlHandlerMapping handler = new GwcUrlHandlerMapping(catalog, "/gwc/demo"); + handler.setAlwaysUseFullPath(true); + handler.setOrder(10); + return handler; + } + + @Bean + GwcUrlHandlerMapping gwcRestWebUrlHandlerMapping(Catalog catalog) { + GwcUrlHandlerMapping handler = new GwcUrlHandlerMapping(catalog, "/gwc/rest/web"); + handler.setAlwaysUseFullPath(true); + handler.setOrder(10); + return handler; + } } diff --git a/src/gwc/services/src/main/java/org/gwc/web/rest/GeoWebCacheController.java b/src/gwc/services/src/main/java/org/gwc/web/rest/GeoWebCacheController.java index 021920b80..5b8cc0400 100644 --- a/src/gwc/services/src/main/java/org/gwc/web/rest/GeoWebCacheController.java +++ b/src/gwc/services/src/main/java/org/gwc/web/rest/GeoWebCacheController.java @@ -25,19 +25,13 @@ *

Copied from {@link GeoServerGWCDispatcherController} */ @Controller -@RequestMapping("/gwc") +@RequestMapping(path = {"/gwc", "/{namespace}/gwc"}) @RequiredArgsConstructor public class GeoWebCacheController { private final @NonNull GeoWebCacheDispatcher gwcDispatcher; - @GetMapping( - path = { - "", - "/home", - "/demo/**", - "/proxy/**", - }) + @GetMapping(path = {"", "/home", "/demo/**", "/proxy/**"}) public void handleGet(HttpServletRequest request, HttpServletResponse response) throws Exception { gwcDispatcher.handleRequest(request, response);