Skip to content

Commit

Permalink
Merge pull request #337 from groldan/bug/gwc_rest_layer_encoding_1.0.x
Browse files Browse the repository at this point in the history
Add missing gwc rest api encoder provider
  • Loading branch information
groldan authored Jun 6, 2023
2 parents 35f6703 + 51e7363 commit 678897e
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import static org.assertj.core.api.Assertions.assertThat;

import org.geoserver.cloud.autoconfigure.gwc.GeoWebCacheContextRunner;
import org.geoserver.gwc.controller.GwcUrlHandlerMapping;
import org.geoserver.gwc.layer.GWCGeoServerRESTConfigurationProvider;
import org.geowebcache.rest.controller.TileLayerController;
import org.geowebcache.rest.converter.GWCConverter;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -51,8 +53,11 @@ void enabled() {
runner.withPropertyValues("gwc.rest-config=true")
.run(
context -> {
assertThat(context).hasSingleBean(GWCConverter.class);
assertThat(context).hasSingleBean(TileLayerController.class);
assertThat(context)
.hasSingleBean(GWCConverter.class)
.hasSingleBean(TileLayerController.class)
.hasSingleBean(GWCGeoServerRESTConfigurationProvider.class)
.hasSingleBean(GwcUrlHandlerMapping.class);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
*/
package org.geoserver.cloud.gwc.config.services;

import org.geoserver.catalog.Catalog;
import org.geoserver.gwc.controller.GwcUrlHandlerMapping;
import org.geoserver.gwc.layer.GWCGeoServerRESTConfigurationProvider;
import org.geowebcache.rest.converter.GWCConverter;
import org.geowebcache.util.ApplicationContextProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
Expand All @@ -15,13 +18,27 @@
* The original {@literal geowebcache-rest-context.xml}:
*
* <pre>{@code
* <!-- Used by org.geoserver.rest.RestConfiguration when setting up converters -->
* <bean id="gwcConverter" class="org.geowebcache.rest.converter.GWCConverter">
* <constructor-arg ref="gwcAppCtx" />
* </bean>
* <!-- Used by org.geoserver.rest.RestConfiguration when setting up converters -->
* <bean id="gwcConverter" class="org.geowebcache.rest.converter.GWCConverter">
* <constructor-arg ref="gwcAppCtx" />
* </bean>
*
* <context:component-scan base-package=
* "org.geowebcache.rest, org.geowebcache.diskquota.rest.controller, org.geowebcache.service.wmts" />
* <bean id="GWCGeoServerRESTConfigurationProvider" class="org.geoserver.gwc.layer.GWCGeoServerRESTConfigurationProvider">
* <description>
* XmlConfiguration contributor to set up XStream with GeoServer provided configuration objects for GWC's REST API
* </description>
* <constructor-arg ref="catalog"/>
* </bean>
*
* <!-- Specific URL mapping for GWC WMTS REST API -->
* <bean id="gwcWmtsRestUrlHandlerMapping" class="org.geoserver.gwc.controller.GwcUrlHandlerMapping">
* <constructor-arg ref="catalog" />
* <constructor-arg type="java.lang.String" value="/gwc/rest/wmts" />
* <property name="alwaysUseFullPath" value="true" />
* <property name="order" value="10" />
* </bean>
*
* <context:component-scan base-package="org.geowebcache.rest, org.geowebcache.diskquota.rest.controller" />
* }</pre>
*
* <p>scans too much. We're only scanning {@literal org.geowebcache.rest}. {@literal
Expand Down Expand Up @@ -50,7 +67,51 @@ public class RESTConfigConfiguration {
* @param appCtx
*/
@SuppressWarnings("rawtypes")
public @Bean GWCConverter<?> gwcConverter(ApplicationContextProvider appCtx) {
@Bean
GWCConverter<?> gwcConverter(ApplicationContextProvider appCtx) {
return new GWCConverter(appCtx);
}

/**
* The original {@literal geowebcache-rest-context.xml}:
*
* <pre>{@code
* <bean id="GWCGeoServerRESTConfigurationProvider" class="org.geoserver.gwc.layer.GWCGeoServerRESTConfigurationProvider">
* <description>
* XmlConfiguration contributor to set up XStream with GeoServer provided configuration objects for GWC's REST API
* </description>
* <constructor-arg ref="catalog"/>
* </bean>
* }</pre>
*
* @param catalog
*/
@Bean
GWCGeoServerRESTConfigurationProvider gwcGeoServerRESTConfigurationProvider(Catalog catalog) {
return new GWCGeoServerRESTConfigurationProvider(catalog);
}

/**
* The original {@literal geowebcache-rest-context.xml}:
*
* <pre>{@code
* <!-- Specific URL mapping for GWC WMTS REST API -->
* <bean id="gwcWmtsRestUrlHandlerMapping" class="org.geoserver.gwc.controller.GwcUrlHandlerMapping">
* <constructor-arg ref="catalog" />
* <constructor-arg type="java.lang.String" value="/gwc/rest/wmts" />
* <property name="alwaysUseFullPath" value="true" />
* <property name="order" value="10" />
* </bean>
* }</pre>
*
* @param catalog
* @param catalog
*/
@Bean
GwcUrlHandlerMapping gwcWmtsRestUrlHandlerMapping(Catalog catalog) {
GwcUrlHandlerMapping handler = new GwcUrlHandlerMapping(catalog, "/gwc/rest/wmts");
handler.setAlwaysUseFullPath(true);
handler.setOrder(10);
return handler;
}
}

0 comments on commit 678897e

Please sign in to comment.