Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
groldan committed May 14, 2024
1 parent ba8099d commit 6483a04
Show file tree
Hide file tree
Showing 8 changed files with 880 additions and 75 deletions.
2 changes: 1 addition & 1 deletion config
Submodule config updated 1 files
+7 −0 geoserver.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.geoserver.cloud.wfs.config.WfsAutoConfiguration,\
org.geoserver.cloud.wfs.config.WfsSecurityOverridesAutoconfiguration
org.geoserver.cloud.wfs.config.WfsAutoConfiguration
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@
*/
package org.geoserver.cloud.wfs.app;

import static org.assertj.core.api.Assertions.assertThat;

import org.geoserver.cloud.wfs.security.NoopLayerGroupContainmentCache;
import org.geoserver.security.impl.LayerGroupContainmentCache;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.context.ApplicationContext;
import org.xmlunit.assertj3.XmlAssert;

import java.util.Map;
Expand All @@ -24,8 +18,6 @@ abstract class WfsApplicationTest {

protected TestRestTemplate restTemplate = new TestRestTemplate("admin", "geoserver");

@Autowired protected ApplicationContext appContext;

@Test
void owsGetCapabilitiesSmokeTest(@LocalServerPort int servicePort) {
String url =
Expand All @@ -49,10 +41,4 @@ void wfsGetCapabilitiesSmokeTest(@LocalServerPort int servicePort) {
.withNamespaceContext(nscontext)
.hasXPath("/wfs:WFS_Capabilities");
}

@Test
void noopLayerGroupContainmentCache() {
var lgcc = appContext.getBean(LayerGroupContainmentCache.class);
assertThat(lgcc).isInstanceOf(NoopLayerGroupContainmentCache.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/
package org.geoserver.cloud.config.catalog.backend.core;

import lombok.extern.slf4j.Slf4j;

import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.LayerGroupVisibilityPolicy;
import org.geoserver.catalog.impl.AdvertisedCatalog;
Expand All @@ -23,20 +25,22 @@
import org.geoserver.security.SecureCatalogImpl;
import org.geoserver.security.impl.DataAccessRuleDAO;
import org.geoserver.security.impl.DefaultResourceAccessManager;
import org.geoserver.security.impl.GsCloudLayerGroupContainmentCache;
import org.geoserver.security.impl.LayerGroupContainmentCache;
import org.geoserver.security.impl.NoopLayerGroupContainmentCache;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.event.ApplicationContextEvent;
import org.springframework.context.event.ContextRefreshedEvent;

// proxyBeanMethods = true required to avoid circular reference exceptions, especially related to
// GeoServerExtensions still being created
@Configuration(proxyBeanMethods = true)
@EnableConfigurationProperties(CatalogProperties.class)
@Slf4j(topic = "org.geoserver.cloud.config.catalog.backend.core")
public class CoreBackendConfiguration {

@Bean
Expand Down Expand Up @@ -111,27 +115,40 @@ DefaultResourceAccessManager defaultResourceAccessManager( //
}

/**
* Added to {@literal gs-main.jar} in 2.22.x as
* Actuial {@link LayerGroupContainmentCache}, matches if the config proeprty {@code
* geoserver.security.layergroup-containmentcache=true}
*
* <pre>
* {@code
* <bean id="layerGroupContainmentCache" class="org.geoserver.security.impl.LayerGroupContainmentCache">
* <constructor-arg ref="rawCatalog"/>
* </bean>
* }
* <p>
* <strong>Overridden</strong> here to act only upon {@link ContextRefreshedEvent}
* instead of on every {@link ApplicationContextEvent},
* especially due to {@code org.springframework.cloud.client.discovery.event.HeartbeatEvent} and possibly
* others.
* <p>
* Update: as of geoserver 2.23.2, {@code LayerGroupContainmentCache} implements {@code ApplicationListener<ContextRefreshedEvent>}
* @see #noOpLayerGroupContainmentCache(Catalog)
*/
@Bean
@ConditionalOnMissingBean
LayerGroupContainmentCache layerGroupContainmentCache(
@Bean(name = "layerGroupContainmentCache")
@ConditionalOnGeoServerSecurityEnabled
@ConditionalOnProperty(
name = "geoserver.security.layergroup-containmentcache",
havingValue = "true",
matchIfMissing = false)
LayerGroupContainmentCache enabledLayerGroupContainmentCache(
@Qualifier("rawCatalog") Catalog rawCatalog) {
return new LayerGroupContainmentCache(rawCatalog);

log.info("using {}", GsCloudLayerGroupContainmentCache.class.getSimpleName());
return new GsCloudLayerGroupContainmentCache(rawCatalog);
}

/**
* Default {@link LayerGroupContainmentCache} is a no-op, matches if the config proeprty {@code
* geoserver.security.layergroup-containmentcache=false} or is not specified
*
* @see #enabledLayerGroupContainmentCache(Catalog)
*/
@Bean(name = "layerGroupContainmentCache")
@ConditionalOnGeoServerSecurityEnabled
@ConditionalOnProperty(
name = "geoserver.security.layergroup-containmentcache",
havingValue = "false",
matchIfMissing = true)
LayerGroupContainmentCache noOpLayerGroupContainmentCache() {

log.info("using {}", NoopLayerGroupContainmentCache.class.getSimpleName());
return new NoopLayerGroupContainmentCache();
}

@ConditionalOnGeoServerSecurityDisabled
Expand All @@ -146,8 +163,7 @@ Catalog secureCatalogDisabled(@Qualifier("rawCatalog") Catalog rawCatalog) {
*/
@Bean
Catalog advertisedCatalog(
@Qualifier("secureCatalog") Catalog secureCatalog, CatalogProperties properties)
throws Exception {
@Qualifier("secureCatalog") Catalog secureCatalog, CatalogProperties properties) {
if (properties.isAdvertised()) {
AdvertisedCatalog advertisedCatalog = new AdvertisedCatalog(secureCatalog);
advertisedCatalog.setLayerGroupVisibilityPolicy(LayerGroupVisibilityPolicy.HIDE_NEVER);
Expand All @@ -162,8 +178,8 @@ Catalog advertisedCatalog(
*/
@Bean(name = {"catalog", "localWorkspaceCatalog"})
Catalog localWorkspaceCatalog(
@Qualifier("advertisedCatalog") Catalog advertisedCatalog, CatalogProperties properties)
throws Exception {
@Qualifier("advertisedCatalog") Catalog advertisedCatalog,
CatalogProperties properties) {
return properties.isLocalWorkspace()
? new LocalWorkspaceCatalog(advertisedCatalog)
: advertisedCatalog;
Expand Down
Loading

0 comments on commit 6483a04

Please sign in to comment.