Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wfs-service: use a no-op LayerGroupContainmentCache #468

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config
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,26 +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
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 @@ -145,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 @@ -161,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
Loading