Skip to content

Commit 678897e

Browse files
authored
Merge pull request #337 from groldan/bug/gwc_rest_layer_encoding_1.0.x
Add missing gwc rest api encoder provider
2 parents 35f6703 + 51e7363 commit 678897e

File tree

2 files changed

+75
-9
lines changed

2 files changed

+75
-9
lines changed

src/gwc/autoconfigure/src/test/java/org/geoserver/cloud/autoconfigure/gwc/service/RESTConfigAutoConfigurationTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import static org.assertj.core.api.Assertions.assertThat;
88

99
import org.geoserver.cloud.autoconfigure.gwc.GeoWebCacheContextRunner;
10+
import org.geoserver.gwc.controller.GwcUrlHandlerMapping;
11+
import org.geoserver.gwc.layer.GWCGeoServerRESTConfigurationProvider;
1012
import org.geowebcache.rest.controller.TileLayerController;
1113
import org.geowebcache.rest.converter.GWCConverter;
1214
import org.junit.jupiter.api.BeforeEach;
@@ -51,8 +53,11 @@ void enabled() {
5153
runner.withPropertyValues("gwc.rest-config=true")
5254
.run(
5355
context -> {
54-
assertThat(context).hasSingleBean(GWCConverter.class);
55-
assertThat(context).hasSingleBean(TileLayerController.class);
56+
assertThat(context)
57+
.hasSingleBean(GWCConverter.class)
58+
.hasSingleBean(TileLayerController.class)
59+
.hasSingleBean(GWCGeoServerRESTConfigurationProvider.class)
60+
.hasSingleBean(GwcUrlHandlerMapping.class);
5661
});
5762
}
5863

src/gwc/services/src/main/java/org/geoserver/cloud/gwc/config/services/RESTConfigConfiguration.java

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
*/
55
package org.geoserver.cloud.gwc.config.services;
66

7+
import org.geoserver.catalog.Catalog;
8+
import org.geoserver.gwc.controller.GwcUrlHandlerMapping;
9+
import org.geoserver.gwc.layer.GWCGeoServerRESTConfigurationProvider;
710
import org.geowebcache.rest.converter.GWCConverter;
811
import org.geowebcache.util.ApplicationContextProvider;
912
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@@ -15,13 +18,27 @@
1518
* The original {@literal geowebcache-rest-context.xml}:
1619
*
1720
* <pre>{@code
18-
* <!-- Used by org.geoserver.rest.RestConfiguration when setting up converters -->
19-
* <bean id="gwcConverter" class="org.geowebcache.rest.converter.GWCConverter">
20-
* <constructor-arg ref="gwcAppCtx" />
21-
* </bean>
21+
* <!-- Used by org.geoserver.rest.RestConfiguration when setting up converters -->
22+
* <bean id="gwcConverter" class="org.geowebcache.rest.converter.GWCConverter">
23+
* <constructor-arg ref="gwcAppCtx" />
24+
* </bean>
2225
*
23-
* <context:component-scan base-package=
24-
* "org.geowebcache.rest, org.geowebcache.diskquota.rest.controller, org.geowebcache.service.wmts" />
26+
* <bean id="GWCGeoServerRESTConfigurationProvider" class="org.geoserver.gwc.layer.GWCGeoServerRESTConfigurationProvider">
27+
* <description>
28+
* XmlConfiguration contributor to set up XStream with GeoServer provided configuration objects for GWC's REST API
29+
* </description>
30+
* <constructor-arg ref="catalog"/>
31+
* </bean>
32+
*
33+
* <!-- Specific URL mapping for GWC WMTS REST API -->
34+
* <bean id="gwcWmtsRestUrlHandlerMapping" class="org.geoserver.gwc.controller.GwcUrlHandlerMapping">
35+
* <constructor-arg ref="catalog" />
36+
* <constructor-arg type="java.lang.String" value="/gwc/rest/wmts" />
37+
* <property name="alwaysUseFullPath" value="true" />
38+
* <property name="order" value="10" />
39+
* </bean>
40+
*
41+
* <context:component-scan base-package="org.geowebcache.rest, org.geowebcache.diskquota.rest.controller" />
2542
* }</pre>
2643
*
2744
* <p>scans too much. We're only scanning {@literal org.geowebcache.rest}. {@literal
@@ -50,7 +67,51 @@ public class RESTConfigConfiguration {
5067
* @param appCtx
5168
*/
5269
@SuppressWarnings("rawtypes")
53-
public @Bean GWCConverter<?> gwcConverter(ApplicationContextProvider appCtx) {
70+
@Bean
71+
GWCConverter<?> gwcConverter(ApplicationContextProvider appCtx) {
5472
return new GWCConverter(appCtx);
5573
}
74+
75+
/**
76+
* The original {@literal geowebcache-rest-context.xml}:
77+
*
78+
* <pre>{@code
79+
* <bean id="GWCGeoServerRESTConfigurationProvider" class="org.geoserver.gwc.layer.GWCGeoServerRESTConfigurationProvider">
80+
* <description>
81+
* XmlConfiguration contributor to set up XStream with GeoServer provided configuration objects for GWC's REST API
82+
* </description>
83+
* <constructor-arg ref="catalog"/>
84+
* </bean>
85+
* }</pre>
86+
*
87+
* @param catalog
88+
*/
89+
@Bean
90+
GWCGeoServerRESTConfigurationProvider gwcGeoServerRESTConfigurationProvider(Catalog catalog) {
91+
return new GWCGeoServerRESTConfigurationProvider(catalog);
92+
}
93+
94+
/**
95+
* The original {@literal geowebcache-rest-context.xml}:
96+
*
97+
* <pre>{@code
98+
* <!-- Specific URL mapping for GWC WMTS REST API -->
99+
* <bean id="gwcWmtsRestUrlHandlerMapping" class="org.geoserver.gwc.controller.GwcUrlHandlerMapping">
100+
* <constructor-arg ref="catalog" />
101+
* <constructor-arg type="java.lang.String" value="/gwc/rest/wmts" />
102+
* <property name="alwaysUseFullPath" value="true" />
103+
* <property name="order" value="10" />
104+
* </bean>
105+
* }</pre>
106+
*
107+
* @param catalog
108+
* @param catalog
109+
*/
110+
@Bean
111+
GwcUrlHandlerMapping gwcWmtsRestUrlHandlerMapping(Catalog catalog) {
112+
GwcUrlHandlerMapping handler = new GwcUrlHandlerMapping(catalog, "/gwc/rest/wmts");
113+
handler.setAlwaysUseFullPath(true);
114+
handler.setOrder(10);
115+
return handler;
116+
}
56117
}

0 commit comments

Comments
 (0)