diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml
index 86b422239..da9b98e4d 100644
--- a/.github/workflows/pull-request.yaml
+++ b/.github/workflows/pull-request.yaml
@@ -38,9 +38,11 @@ jobs:
java-version: '21'
cache: 'maven'
+ - name: Validate pom formatting
+ run: make lint-pom
+
- name: Validate source code formatting
- run: |
- make lint
+ run: make lint-java
- name: Test
run: |
diff --git a/.gitignore b/.gitignore
index 6305175bd..16027c07f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,3 +43,5 @@ docker-compose_datadir*
.env.yjp
hs_err_pid*.log
+
+.spotless-index
diff --git a/Makefile b/Makefile
index e507a40a3..1cc7e5b7e 100644
--- a/Makefile
+++ b/Makefile
@@ -13,12 +13,26 @@ clean:
./mvnw clean
.PHONY: lint
-lint:
- ./mvnw fmt:check sortpom:verify -Dsort.verifyFailOn=strict -Dsort.verifyFail=stop -ntp -T1C
+lint: lint-pom lint-java
+
+.PHONY: lint-pom
+lint-pom:
+ ./mvnw sortpom:verify -Dsort.verifyFailOn=strict -Dsort.verifyFail=stop -ntp -T1C
+
+.PHONY: lint-java
+lint-java:
+ ./mvnw spotless:check -ntp -T1C
.PHONY: format
-format:
- ./mvnw sortpom:sort fmt:format -ntp -T1C
+format: format-pom format-java
+
+.PHONY: format-pom
+format-pom:
+ ./mvnw sortpom:sort -ntp -T1C
+
+.PHONY: format-java
+format-java:
+ ./mvnw spotless:apply -ntp -T1C
.PHONY: install
install:
diff --git a/pom.xml b/pom.xml
index 1af25852a..962ed20fa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,8 +12,11 @@
1.9-SNAPSHOT
- format
false
+ apply
+ ${fmt.skip}
+ sort
+ ${fmt.skip}
UTF-8
https://sonarcloud.io
@@ -215,9 +218,9 @@
- com.spotify.fmt
- fmt-maven-plugin
- 2.21.1
+ com.diffplug.spotless
+ spotless-maven-plugin
+ 2.43.0
com.github.ekryd.sortpom
@@ -242,37 +245,43 @@
sortpom-maven-plugin
UTF-8
+ true
+ false
false
\n
- 2
stop
strict
- ${fmt.skip}
+ ${pom.fmt.skip}
- sort
- sort
+ ${pom.fmt.action}
- validate
+ verify
- com.spotify.fmt
- fmt-maven-plugin
+ com.diffplug.spotless
+ spotless-maven-plugin
- false
- .*\.java
- ${fmt.skip}
-
+
+
+ 2.50.0
+
+
+
+ true
+ ${project.basedir}/.spotless-index
+
- ${fmt.action}
+ ${spotless.action}
+ validate
diff --git a/src/apps/geoserver/gwc/src/main/java/org/geoserver/cloud/gwc/app/GeoWebCacheApplication.java b/src/apps/geoserver/gwc/src/main/java/org/geoserver/cloud/gwc/app/GeoWebCacheApplication.java
index 33356ceab..0196993a5 100644
--- a/src/apps/geoserver/gwc/src/main/java/org/geoserver/cloud/gwc/app/GeoWebCacheApplication.java
+++ b/src/apps/geoserver/gwc/src/main/java/org/geoserver/cloud/gwc/app/GeoWebCacheApplication.java
@@ -18,8 +18,7 @@ public static void main(String[] args) {
SpringApplication.run(GeoWebCacheApplication.class, args);
} catch (RuntimeException e) {
try {
- LoggerFactory.getLogger(GeoWebCacheApplication.class)
- .error("Application run failed", e);
+ LoggerFactory.getLogger(GeoWebCacheApplication.class).error("Application run failed", e);
} finally {
System.exit(-1);
}
diff --git a/src/apps/geoserver/gwc/src/main/java/org/geoserver/cloud/gwc/app/GeoWebCacheApplicationConfiguration.java b/src/apps/geoserver/gwc/src/main/java/org/geoserver/cloud/gwc/app/GeoWebCacheApplicationConfiguration.java
index 00900ec44..32af418dc 100644
--- a/src/apps/geoserver/gwc/src/main/java/org/geoserver/cloud/gwc/app/GeoWebCacheApplicationConfiguration.java
+++ b/src/apps/geoserver/gwc/src/main/java/org/geoserver/cloud/gwc/app/GeoWebCacheApplicationConfiguration.java
@@ -4,6 +4,14 @@
*/
package org.geoserver.cloud.gwc.app;
+import java.io.IOException;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
import org.geoserver.catalog.Catalog;
import org.geoserver.cloud.gwc.config.core.WebMapServiceMinimalConfiguration;
import org.geoserver.gwc.layer.GeoServerTileLayer;
@@ -22,16 +30,6 @@
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import org.springframework.web.servlet.resource.ResourceUrlProvider;
-import java.io.IOException;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-
@Configuration
public class GeoWebCacheApplicationConfiguration extends RestConfiguration {
@@ -44,8 +42,7 @@ public class GeoWebCacheApplicationConfiguration extends RestConfiguration {
*/
@Bean
@ConditionalOnMissingBean
- LegendSample legendSample(
- @Qualifier("rawCatalog") Catalog catalog, GeoServerResourceLoader loader) {
+ LegendSample legendSample(@Qualifier("rawCatalog") Catalog catalog, GeoServerResourceLoader loader) {
return new LegendSampleImpl(catalog, loader);
}
@@ -64,14 +61,12 @@ public void configureContentNegotiation(ContentNegotiationConfigurer configurer)
@Bean
@Override
public RequestMappingHandlerMapping requestMappingHandlerMapping(
- @Qualifier("mvcContentNegotiationManager")
- ContentNegotiationManager contentNegotiationManager,
+ @Qualifier("mvcContentNegotiationManager") ContentNegotiationManager contentNegotiationManager,
@Qualifier("mvcConversionService") FormattingConversionService conversionService,
@Qualifier("mvcResourceUrlProvider") ResourceUrlProvider resourceUrlProvider) {
RequestMappingHandlerMapping handlerMapping =
- super.requestMappingHandlerMapping(
- contentNegotiationManager, conversionService, resourceUrlProvider);
+ super.requestMappingHandlerMapping(contentNegotiationManager, conversionService, resourceUrlProvider);
handlerMapping.setUseSuffixPatternMatch(true);
handlerMapping.setUseRegisteredSuffixPatternMatch(true);
diff --git a/src/apps/geoserver/gwc/src/test/java/org/geoserver/cloud/gwc/app/GeoWebCacheApplicationTest.java b/src/apps/geoserver/gwc/src/test/java/org/geoserver/cloud/gwc/app/GeoWebCacheApplicationTest.java
index 0039127cd..7fcffb432 100644
--- a/src/apps/geoserver/gwc/src/test/java/org/geoserver/cloud/gwc/app/GeoWebCacheApplicationTest.java
+++ b/src/apps/geoserver/gwc/src/test/java/org/geoserver/cloud/gwc/app/GeoWebCacheApplicationTest.java
@@ -10,7 +10,6 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
-
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -26,7 +25,8 @@
@ActiveProfiles("test")
class GeoWebCacheApplicationTest {
- @Autowired private TestRestTemplate restTemplate;
+ @Autowired
+ private TestRestTemplate restTemplate;
@BeforeEach
void before() {
@@ -37,16 +37,14 @@ void before() {
@Test
void testRESTDefaultContentType() {
- ResponseEntity response =
- testGetRequestContentType("/gwc/rest/layers", APPLICATION_JSON);
+ ResponseEntity response = testGetRequestContentType("/gwc/rest/layers", APPLICATION_JSON);
JsonElement parsed = JsonParser.parseString(response.getBody());
assertThat(parsed.isJsonArray()).isTrue();
}
@Test
void testRESTPathExtensionContentNegotiation() {
- ResponseEntity response =
- testGetRequestContentType("/gwc/rest/layers.json", APPLICATION_JSON);
+ ResponseEntity response = testGetRequestContentType("/gwc/rest/layers.json", APPLICATION_JSON);
JsonElement parsed = JsonParser.parseString(response.getBody());
assertThat(parsed.isJsonArray()).isTrue();
diff --git a/src/apps/geoserver/restconfig/src/main/java/org/geoserver/cloud/restconfig/RestConfigApplication.java b/src/apps/geoserver/restconfig/src/main/java/org/geoserver/cloud/restconfig/RestConfigApplication.java
index 921cf39e8..db92c1053 100644
--- a/src/apps/geoserver/restconfig/src/main/java/org/geoserver/cloud/restconfig/RestConfigApplication.java
+++ b/src/apps/geoserver/restconfig/src/main/java/org/geoserver/cloud/restconfig/RestConfigApplication.java
@@ -18,8 +18,7 @@ public static void main(String[] args) {
SpringApplication.run(RestConfigApplication.class, args);
} catch (RuntimeException e) {
try {
- LoggerFactory.getLogger(RestConfigApplication.class)
- .error("Application run failed", e);
+ LoggerFactory.getLogger(RestConfigApplication.class).error("Application run failed", e);
} finally {
System.exit(-1);
}
diff --git a/src/apps/geoserver/restconfig/src/main/java/org/geoserver/cloud/restconfig/RestConfigApplicationConfiguration.java b/src/apps/geoserver/restconfig/src/main/java/org/geoserver/cloud/restconfig/RestConfigApplicationConfiguration.java
index 4fedbe307..47a396ed0 100644
--- a/src/apps/geoserver/restconfig/src/main/java/org/geoserver/cloud/restconfig/RestConfigApplicationConfiguration.java
+++ b/src/apps/geoserver/restconfig/src/main/java/org/geoserver/cloud/restconfig/RestConfigApplicationConfiguration.java
@@ -4,6 +4,14 @@
*/
package org.geoserver.cloud.restconfig;
+import java.io.IOException;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
import org.geoserver.rest.RequestInfo;
import org.geoserver.rest.RestConfiguration;
import org.geoserver.rest.catalog.AdminRequestCallback;
@@ -19,16 +27,6 @@
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import org.springframework.web.servlet.resource.ResourceUrlProvider;
-import java.io.IOException;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-
@Configuration
@ComponentScan(basePackageClasses = org.geoserver.rest.AbstractGeoServerController.class)
@SuppressWarnings("deprecation")
@@ -53,14 +51,12 @@ AdminRequestCallback adminRequestCallback() {
@Bean
@Override
public RequestMappingHandlerMapping requestMappingHandlerMapping(
- @Qualifier("mvcContentNegotiationManager")
- ContentNegotiationManager contentNegotiationManager,
+ @Qualifier("mvcContentNegotiationManager") ContentNegotiationManager contentNegotiationManager,
@Qualifier("mvcConversionService") FormattingConversionService conversionService,
@Qualifier("mvcResourceUrlProvider") ResourceUrlProvider resourceUrlProvider) {
RequestMappingHandlerMapping handlerMapping =
- super.requestMappingHandlerMapping(
- contentNegotiationManager, conversionService, resourceUrlProvider);
+ super.requestMappingHandlerMapping(contentNegotiationManager, conversionService, resourceUrlProvider);
handlerMapping.setUseSuffixPatternMatch(true);
handlerMapping.setUseRegisteredSuffixPatternMatch(true);
diff --git a/src/apps/geoserver/restconfig/src/test/java/org/geoserver/cloud/restconfig/RestConfigApplicationTest.java b/src/apps/geoserver/restconfig/src/test/java/org/geoserver/cloud/restconfig/RestConfigApplicationTest.java
index f9b8c677c..d903821a7 100644
--- a/src/apps/geoserver/restconfig/src/test/java/org/geoserver/cloud/restconfig/RestConfigApplicationTest.java
+++ b/src/apps/geoserver/restconfig/src/test/java/org/geoserver/cloud/restconfig/RestConfigApplicationTest.java
@@ -25,7 +25,8 @@
@ActiveProfiles("test")
class RestConfigApplicationTest {
- @Autowired private TestRestTemplate restTemplate;
+ @Autowired
+ private TestRestTemplate restTemplate;
@BeforeEach
void before() {
@@ -45,8 +46,7 @@ void testPathExtensionContentNegotiation() {
testPathExtensionContentType("/rest/styles/line.json", APPLICATION_JSON);
testPathExtensionContentType("/rest/styles/line.xml", APPLICATION_XML);
testPathExtensionContentType("/rest/styles/line.html", TEXT_HTML);
- testPathExtensionContentType(
- "/rest/styles/line.sld", MediaType.valueOf(SLDHandler.MIMETYPE_10));
+ testPathExtensionContentType("/rest/styles/line.sld", MediaType.valueOf(SLDHandler.MIMETYPE_10));
testPathExtensionContentType("/rest/workspaces.html", TEXT_HTML);
testPathExtensionContentType("/rest/workspaces.xml", APPLICATION_XML);
diff --git a/src/apps/geoserver/wcs/src/main/java/org/geoserver/cloud/wcs/WCSController.java b/src/apps/geoserver/wcs/src/main/java/org/geoserver/cloud/wcs/WCSController.java
index 1aba1b550..0a0be0b6a 100644
--- a/src/apps/geoserver/wcs/src/main/java/org/geoserver/cloud/wcs/WCSController.java
+++ b/src/apps/geoserver/wcs/src/main/java/org/geoserver/cloud/wcs/WCSController.java
@@ -4,9 +4,10 @@
*/
package org.geoserver.cloud.wcs;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
-
import org.geoserver.cloud.virtualservice.VirtualServiceVerifier;
import org.geoserver.ows.Dispatcher;
import org.springframework.stereotype.Controller;
@@ -15,9 +16,6 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.servlet.view.RedirectView;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
@RequiredArgsConstructor
public @Controller class WCSController {
@@ -34,20 +32,17 @@ public RedirectView redirectRootToGetCapabilities() {
/** Serve only WCS schemas from classpath (e.g. {@code /schemas/wcs/1.1.1/wcsAll.xsd}) */
@GetMapping(path = "/schemas/wcs/**")
- public void getSchema(HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ public void getSchema(HttpServletRequest request, HttpServletResponse response) throws Exception {
classPathPublisher.handleRequest(request, response);
}
@GetMapping(path = {"/wcs", "/ows"})
- public void handleGet(HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ public void handleGet(HttpServletRequest request, HttpServletResponse response) throws Exception {
dispatch(request, response);
}
@PostMapping(path = {"/wcs", "/ows"})
- public void handlePost(HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ public void handlePost(HttpServletRequest request, HttpServletResponse response) throws Exception {
dispatch(request, response);
}
@@ -97,8 +92,7 @@ public void handleVirtualServiceLayerPost(
dispatch(request, response);
}
- private void dispatch(HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ private void dispatch(HttpServletRequest request, HttpServletResponse response) throws Exception {
geoserverDispatcher.handleRequest(request, response);
}
}
diff --git a/src/apps/geoserver/wcs/src/test/java/org/geoserver/cloud/wcs/WcsApplicationTest.java b/src/apps/geoserver/wcs/src/test/java/org/geoserver/cloud/wcs/WcsApplicationTest.java
index 656a9568a..6984dd438 100644
--- a/src/apps/geoserver/wcs/src/test/java/org/geoserver/cloud/wcs/WcsApplicationTest.java
+++ b/src/apps/geoserver/wcs/src/test/java/org/geoserver/cloud/wcs/WcsApplicationTest.java
@@ -6,14 +6,13 @@
import static org.assertj.core.api.Assertions.assertThat;
+import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.test.context.ActiveProfiles;
-import java.util.stream.Stream;
-
@SpringBootTest
@ActiveProfiles("test")
class WcsApplicationTest {
@@ -27,18 +26,11 @@ void testWcsCoreBeans() {
expectBean("wcsURLMapping", org.geoserver.ows.OWSHandlerMapping.class);
expectBean("wcsLocalWorkspaceURLManger", org.geoserver.ows.LocalWorkspaceURLMangler.class);
expectBean("cqlKvpParser", org.geoserver.ows.kvp.CQLFilterKvpParser.class);
+ expectBean("coverageResponseDelegateFactory", org.geoserver.wcs.responses.CoverageResponseDelegateFinder.class);
expectBean(
- "coverageResponseDelegateFactory",
- org.geoserver.wcs.responses.CoverageResponseDelegateFinder.class);
- expectBean(
- "geotiffCoverageResponseDelegate",
- org.geoserver.wcs.responses.GeoTIFFCoverageResponseDelegate.class);
- expectBean(
- "imgCoverageResponseDelegate",
- org.geoserver.wcs.responses.IMGCoverageResponseDelegate.class);
- expectBean(
- "debugCoverageResponseDelegate",
- org.geoserver.wcs.responses.DebugCoverageResponseDelegate.class);
+ "geotiffCoverageResponseDelegate", org.geoserver.wcs.responses.GeoTIFFCoverageResponseDelegate.class);
+ expectBean("imgCoverageResponseDelegate", org.geoserver.wcs.responses.IMGCoverageResponseDelegate.class);
+ expectBean("debugCoverageResponseDelegate", org.geoserver.wcs.responses.DebugCoverageResponseDelegate.class);
expectBean("coverageCleaner", org.geoserver.wcs.CoverageCleanerCallback.class);
expectBean("wcsResourceVoter", org.geoserver.wcs.WCSResourceVoter.class);
expectBean("legacyWcsLoader", org.geoserver.wcs.WCSLoader.class);
@@ -47,18 +39,11 @@ void testWcsCoreBeans() {
expectBean("wcsURLMapping", org.geoserver.ows.OWSHandlerMapping.class);
expectBean("wcsLocalWorkspaceURLManger", org.geoserver.ows.LocalWorkspaceURLMangler.class);
expectBean("cqlKvpParser", org.geoserver.ows.kvp.CQLFilterKvpParser.class);
+ expectBean("coverageResponseDelegateFactory", org.geoserver.wcs.responses.CoverageResponseDelegateFinder.class);
expectBean(
- "coverageResponseDelegateFactory",
- org.geoserver.wcs.responses.CoverageResponseDelegateFinder.class);
- expectBean(
- "geotiffCoverageResponseDelegate",
- org.geoserver.wcs.responses.GeoTIFFCoverageResponseDelegate.class);
- expectBean(
- "imgCoverageResponseDelegate",
- org.geoserver.wcs.responses.IMGCoverageResponseDelegate.class);
- expectBean(
- "debugCoverageResponseDelegate",
- org.geoserver.wcs.responses.DebugCoverageResponseDelegate.class);
+ "geotiffCoverageResponseDelegate", org.geoserver.wcs.responses.GeoTIFFCoverageResponseDelegate.class);
+ expectBean("imgCoverageResponseDelegate", org.geoserver.wcs.responses.IMGCoverageResponseDelegate.class);
+ expectBean("debugCoverageResponseDelegate", org.geoserver.wcs.responses.DebugCoverageResponseDelegate.class);
expectBean("coverageCleaner", org.geoserver.wcs.CoverageCleanerCallback.class);
expectBean("wcsResourceVoter", org.geoserver.wcs.WCSResourceVoter.class);
}
diff --git a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/cloudnative/CloudNativeUIAutoConfiguration.java b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/cloudnative/CloudNativeUIAutoConfiguration.java
index 2a0e8908b..ab4f0e561 100644
--- a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/cloudnative/CloudNativeUIAutoConfiguration.java
+++ b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/cloudnative/CloudNativeUIAutoConfiguration.java
@@ -4,14 +4,12 @@
*/
package org.geoserver.cloud.autoconfigure.web.cloudnative;
+import javax.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.cloud.web.service.WebUiCloudServicesConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
-import javax.annotation.PostConstruct;
-
/**
* @since 1.0
*/
diff --git a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/core/AbstractWebUIAutoConfiguration.java b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/core/AbstractWebUIAutoConfiguration.java
index efb4d5d27..2b6614ea2 100644
--- a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/core/AbstractWebUIAutoConfiguration.java
+++ b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/core/AbstractWebUIAutoConfiguration.java
@@ -4,9 +4,8 @@
*/
package org.geoserver.cloud.autoconfigure.web.core;
-import lombok.extern.slf4j.Slf4j;
-
import javax.annotation.PostConstruct;
+import lombok.extern.slf4j.Slf4j;
@Slf4j(topic = "org.geoserver.cloud.autoconfigure.web")
public abstract class AbstractWebUIAutoConfiguration {
diff --git a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/core/WebCoreConfiguration.java b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/core/WebCoreConfiguration.java
index 2c942bb78..6058b10ad 100644
--- a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/core/WebCoreConfiguration.java
+++ b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/core/WebCoreConfiguration.java
@@ -18,8 +18,7 @@
@ImportResource( //
reader = FilteringXmlBeanDefinitionReader.class, //
locations = { //
- "jar:gs-web-core-.*!/applicationContext.xml#name="
- + WebCoreConfiguration.EXCLUDED_BEANS_PATTERN, //
+ "jar:gs-web-core-.*!/applicationContext.xml#name=" + WebCoreConfiguration.EXCLUDED_BEANS_PATTERN, //
"jar:gs-web-rest-.*!/applicationContext.xml" //
})
public class WebCoreConfiguration {
diff --git a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/core/WebUIContextInitializer.java b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/core/WebUIContextInitializer.java
index 34346ad8c..0278886ba 100644
--- a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/core/WebUIContextInitializer.java
+++ b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/core/WebUIContextInitializer.java
@@ -5,7 +5,6 @@
package org.geoserver.cloud.autoconfigure.web.core;
import lombok.extern.slf4j.Slf4j;
-
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.util.StringUtils;
@@ -15,8 +14,7 @@
* @since 1.8.2
*/
@Slf4j
-public class WebUIContextInitializer
- implements ApplicationContextInitializer {
+public class WebUIContextInitializer implements ApplicationContextInitializer {
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
@@ -31,9 +29,7 @@ private void setHomePageSelectionMode() {
String systemProp = System.getProperty("GeoServerHomePage.selectionMode");
if (StringUtils.hasText(systemProp)) {
- log.info(
- "GeoServerHomePage.selectionMode set to '{}' through system property",
- systemProp);
+ log.info("GeoServerHomePage.selectionMode set to '{}' through system property", systemProp);
} else {
String selectionMode = "TEXT";
log.info("GeoServerHomePage.selectionMode set to '{}' as default value", selectionMode);
diff --git a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/core/WebUIInitializer.java b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/core/WebUIInitializer.java
index 95b9c8bfd..e235f508b 100644
--- a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/core/WebUIInitializer.java
+++ b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/core/WebUIInitializer.java
@@ -7,7 +7,6 @@
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.config.GeoServer;
import org.geoserver.config.GeoServerInfo;
import org.geoserver.config.GeoServerInfo.WebUIMode;
@@ -30,9 +29,7 @@ public void initialize(GeoServer geoServer) throws Exception {
geoServer.save(global);
}
- Boolean hidefs =
- environment.getProperty(
- "geoserver.web-ui.file-browser.hide-file-system", Boolean.class);
+ Boolean hidefs = environment.getProperty("geoserver.web-ui.file-browser.hide-file-system", Boolean.class);
if (Boolean.TRUE.equals(hidefs)) {
log.info("Setting GEOSERVER_FILEBROWSER_HIDEFS=true System Property");
System.setProperty("GEOSERVER_FILEBROWSER_HIDEFS", "true");
diff --git a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/demo/LayerPreviewConfiguration.java b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/demo/LayerPreviewConfiguration.java
index 3bff28e92..9590cfb45 100644
--- a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/demo/LayerPreviewConfiguration.java
+++ b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/demo/LayerPreviewConfiguration.java
@@ -51,8 +51,7 @@ public String getConfigPrefix() {
locations = {"jar:gs-web-demo-.*!/applicationContext.xml#name=openLayersPreview"})
public class OpenLayersCommonFormatsConfiguration extends AbstractWebUIAutoConfiguration {
- static final String CONFIG_PREFIX =
- LayerPreviewConfiguration.COMMON_FORMATS_PREFIX + ".open-layers";
+ static final String CONFIG_PREFIX = LayerPreviewConfiguration.COMMON_FORMATS_PREFIX + ".open-layers";
@Override
public String getConfigPrefix() {
@@ -71,8 +70,7 @@ public String getConfigPrefix() {
locations = {"jar:gs-web-demo-.*!/applicationContext.xml#name=gMLPreview"})
public class GmlCommonFormatsConfiguration extends AbstractWebUIAutoConfiguration {
- static final String CONFIG_PREFIX =
- LayerPreviewConfiguration.COMMON_FORMATS_PREFIX + ".gml";
+ static final String CONFIG_PREFIX = LayerPreviewConfiguration.COMMON_FORMATS_PREFIX + ".gml";
@Override
public String getConfigPrefix() {
@@ -91,8 +89,7 @@ public String getConfigPrefix() {
locations = {"jar:gs-web-demo-.*!/applicationContext.xml#name=kMLPreview"})
public class KmlCommonFormatsConfiguration extends AbstractWebUIAutoConfiguration {
- static final String CONFIG_PREFIX =
- LayerPreviewConfiguration.COMMON_FORMATS_PREFIX + ".kml";
+ static final String CONFIG_PREFIX = LayerPreviewConfiguration.COMMON_FORMATS_PREFIX + ".kml";
@Override
public String getConfigPrefix() {
diff --git a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/demo/ReprojectionConsoleConfiguration.java b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/demo/ReprojectionConsoleConfiguration.java
index ae58e622c..f108ba8f5 100644
--- a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/demo/ReprojectionConsoleConfiguration.java
+++ b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/demo/ReprojectionConsoleConfiguration.java
@@ -23,8 +23,7 @@
locations = {"jar:gs-web-demo-.*!/applicationContext.xml#name=reprojectionConsole"})
public class ReprojectionConsoleConfiguration extends AbstractWebUIAutoConfiguration {
- static final String CONFIG_PREFIX =
- DemosAutoConfiguration.CONFIG_PREFIX + ".reprojection-console";
+ static final String CONFIG_PREFIX = DemosAutoConfiguration.CONFIG_PREFIX + ".reprojection-console";
@Override
public String getConfigPrefix() {
diff --git a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/demo/WcsRequestBuilderConfiguration.java b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/demo/WcsRequestBuilderConfiguration.java
index 0d0c4dde4..588d9506c 100644
--- a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/demo/WcsRequestBuilderConfiguration.java
+++ b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/demo/WcsRequestBuilderConfiguration.java
@@ -26,8 +26,7 @@
)
public class WcsRequestBuilderConfiguration extends AbstractWebUIAutoConfiguration {
- static final String CONFIG_PREFIX =
- DemosAutoConfiguration.CONFIG_PREFIX + ".wcs-request-builder";
+ static final String CONFIG_PREFIX = DemosAutoConfiguration.CONFIG_PREFIX + ".wcs-request-builder";
@Override
public String getConfigPrefix() {
diff --git a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/demo/WpsRequestBuilderConfiguration.java b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/demo/WpsRequestBuilderConfiguration.java
index d919ef0eb..9dc257c2a 100644
--- a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/demo/WpsRequestBuilderConfiguration.java
+++ b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/demo/WpsRequestBuilderConfiguration.java
@@ -23,8 +23,7 @@
locations = "jar:gs-web-wps-.*!/applicationContext.xml#name=wpsRequestBuilder")
public class WpsRequestBuilderConfiguration extends AbstractWebUIAutoConfiguration {
- static final String CONFIG_PREFIX =
- DemosAutoConfiguration.CONFIG_PREFIX + ".wps-request-builder";
+ static final String CONFIG_PREFIX = DemosAutoConfiguration.CONFIG_PREFIX + ".wps-request-builder";
@Override
public String getConfigPrefix() {
diff --git a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/extension/ExtensionsAutoConfiguration.java b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/extension/ExtensionsAutoConfiguration.java
index ef2bd3dab..d54c41474 100644
--- a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/extension/ExtensionsAutoConfiguration.java
+++ b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/extension/ExtensionsAutoConfiguration.java
@@ -9,7 +9,6 @@
import org.springframework.context.annotation.Import;
@Configuration
-@Import({
- ImporterAutoConfiguration.class //
+@Import({ImporterAutoConfiguration.class //
})
public class ExtensionsAutoConfiguration {}
diff --git a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/security/SecurityConfiguration.java b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/security/SecurityConfiguration.java
index 94f2c61c2..486c8957c 100644
--- a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/security/SecurityConfiguration.java
+++ b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/security/SecurityConfiguration.java
@@ -4,9 +4,14 @@
*/
package org.geoserver.cloud.autoconfigure.web.security;
+import java.io.IOException;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
-
import org.geoserver.cloud.config.factory.FilteringXmlBeanDefinitionReader;
import org.geoserver.security.filter.GeoServerLogoutFilter;
import org.springframework.beans.factory.annotation.Value;
@@ -16,14 +21,6 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
-import java.io.IOException;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-
@Configuration(proxyBeanMethods = true)
@ImportResource( //
reader = FilteringXmlBeanDefinitionReader.class, //
@@ -42,8 +39,7 @@ FilterRegistrationBean configurableLogoutUrlFilterR
ConfigurableLogoutUrlFilter filter = new ConfigurableLogoutUrlFilter(logoutUrl);
- FilterRegistrationBean registration =
- new FilterRegistrationBean<>();
+ FilterRegistrationBean registration = new FilterRegistrationBean<>();
registration.setFilter(filter);
registration.setOrder(1);
return registration;
diff --git a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/tools/ReprojectionConsoleConfiguration.java b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/tools/ReprojectionConsoleConfiguration.java
index 719526ae6..6db3ef087 100644
--- a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/tools/ReprojectionConsoleConfiguration.java
+++ b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/autoconfigure/web/tools/ReprojectionConsoleConfiguration.java
@@ -23,8 +23,7 @@
locations = {"jar:gs-web-demo-.*!/applicationContext.xml#name=reprojectionConsole"})
public class ReprojectionConsoleConfiguration extends AbstractWebUIAutoConfiguration {
- static final String CONFIG_PREFIX =
- ToolsAutoConfiguration.CONFIG_PREFIX + ".reprojection-console";
+ static final String CONFIG_PREFIX = ToolsAutoConfiguration.CONFIG_PREFIX + ".reprojection-console";
@Override
public String getConfigPrefix() {
diff --git a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/service/ServiceInstance.java b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/service/ServiceInstance.java
index 860500fe6..25f0c7721 100644
--- a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/service/ServiceInstance.java
+++ b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/service/ServiceInstance.java
@@ -4,9 +4,8 @@
*/
package org.geoserver.cloud.web.service;
-import lombok.Data;
-
import java.io.Serializable;
+import lombok.Data;
/**
* @since 1.0
diff --git a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/service/ServiceInstanceRegistry.java b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/service/ServiceInstanceRegistry.java
index 2be97864f..5cd540542 100644
--- a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/service/ServiceInstanceRegistry.java
+++ b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/service/ServiceInstanceRegistry.java
@@ -6,17 +6,14 @@
import com.netflix.appinfo.InstanceInfo;
import com.netflix.appinfo.InstanceInfo.InstanceStatus;
-
-import lombok.NonNull;
-import lombok.RequiredArgsConstructor;
-
-import org.springframework.cloud.client.discovery.DiscoveryClient;
-import org.springframework.cloud.netflix.eureka.EurekaServiceInstance;
-
import java.net.URI;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Stream;
+import lombok.NonNull;
+import lombok.RequiredArgsConstructor;
+import org.springframework.cloud.client.discovery.DiscoveryClient;
+import org.springframework.cloud.netflix.eureka.EurekaServiceInstance;
/**
* @since 1.0
diff --git a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/ui/GeoServerCloudHomePageContentProvider.java b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/ui/GeoServerCloudHomePageContentProvider.java
index 22b9c0410..ba0f0e286 100644
--- a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/ui/GeoServerCloudHomePageContentProvider.java
+++ b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/ui/GeoServerCloudHomePageContentProvider.java
@@ -6,7 +6,6 @@
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
-
import org.apache.wicket.Component;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.geoserver.security.GeoServerSecurityManager;
diff --git a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/ui/ServiceProvider.java b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/ui/ServiceProvider.java
index 71bff507b..970d93865 100644
--- a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/ui/ServiceProvider.java
+++ b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/ui/ServiceProvider.java
@@ -4,13 +4,12 @@
*/
package org.geoserver.cloud.web.ui;
+import java.util.List;
import org.geoserver.cloud.web.service.ServiceInstance;
import org.geoserver.cloud.web.service.ServiceInstanceRegistry;
import org.geoserver.web.GeoServerApplication;
import org.geoserver.web.wicket.GeoServerDataProvider;
-import java.util.List;
-
/**
* @since 1.0
*/
@@ -18,8 +17,7 @@ class ServiceProvider extends GeoServerDataProvider {
private static final long serialVersionUID = 1L;
public static final Property NAME = new BeanProperty<>("name", "name");
- public static final Property INSTANCEID =
- new BeanProperty<>("instanceId", "instanceId");
+ public static final Property INSTANCEID = new BeanProperty<>("instanceId", "instanceId");
public static final Property STATUS = new BeanProperty<>("status", "status");
public static final Property URI = new BeanProperty<>("uri", "uri");
diff --git a/src/apps/geoserver/webui/src/test/java/org/geoserver/cloud/web/app/AclIntegrationTest.java b/src/apps/geoserver/webui/src/test/java/org/geoserver/cloud/web/app/AclIntegrationTest.java
index 58cd0248b..7882b32cf 100644
--- a/src/apps/geoserver/webui/src/test/java/org/geoserver/cloud/web/app/AclIntegrationTest.java
+++ b/src/apps/geoserver/webui/src/test/java/org/geoserver/cloud/web/app/AclIntegrationTest.java
@@ -6,6 +6,9 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
import org.apache.wicket.util.tester.WicketTester;
import org.geoserver.web.GeoServerApplication;
import org.geoserver.web.GeoServerHomePage;
@@ -22,10 +25,6 @@
import org.springframework.security.core.context.SecurityContextImpl;
import org.springframework.test.context.ActiveProfiles;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
@SpringBootTest(
properties = {
"geoserver.acl.enabled: true",
diff --git a/src/apps/geoserver/webui/src/test/java/org/geoserver/cloud/web/app/WebUIApplicationTest.java b/src/apps/geoserver/webui/src/test/java/org/geoserver/cloud/web/app/WebUIApplicationTest.java
index a67d4a62e..ccb0e2803 100644
--- a/src/apps/geoserver/webui/src/test/java/org/geoserver/cloud/web/app/WebUIApplicationTest.java
+++ b/src/apps/geoserver/webui/src/test/java/org/geoserver/cloud/web/app/WebUIApplicationTest.java
@@ -8,6 +8,9 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
import org.apache.wicket.Component;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.list.ListItem;
@@ -33,10 +36,6 @@
import org.springframework.security.core.context.SecurityContextImpl;
import org.springframework.test.context.ActiveProfiles;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
@SpringBootTest(
properties = {
"spring.cloud.bus.enabled: false",
@@ -161,9 +160,8 @@ void GeoServerHomePage_smoke_test_service_links() {
protected void assertHidden(String id) {
TagTester tag = tester.getTagById(id);
- String msg =
- "expected custom 'unused' css class to hide the %s form inputs in custom GlobalSettingsPage.html"
- .formatted(id);
+ String msg = "expected custom 'unused' css class to hide the %s form inputs in custom GlobalSettingsPage.html"
+ .formatted(id);
assertEquals("unused", tag.getAttribute("class"), msg);
}
diff --git a/src/apps/geoserver/wfs/src/main/java/org/geoserver/cloud/wfs/app/WFSController.java b/src/apps/geoserver/wfs/src/main/java/org/geoserver/cloud/wfs/app/WFSController.java
index 3ec7ecb19..66fdfb6f1 100644
--- a/src/apps/geoserver/wfs/src/main/java/org/geoserver/cloud/wfs/app/WFSController.java
+++ b/src/apps/geoserver/wfs/src/main/java/org/geoserver/cloud/wfs/app/WFSController.java
@@ -4,9 +4,10 @@
*/
package org.geoserver.cloud.wfs.app;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
-
import org.geoserver.cloud.virtualservice.VirtualServiceVerifier;
import org.geoserver.ows.Dispatcher;
import org.springframework.stereotype.Controller;
@@ -15,9 +16,6 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.servlet.view.RedirectView;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
@Controller
@RequiredArgsConstructor
public class WFSController {
@@ -35,8 +33,7 @@ public RedirectView redirectRootToGetCapabilities() {
/** Serve only WFS schemas from classpath (e.g. {@code /schemas/wfs/2.0/wfs.xsd}) */
@GetMapping(path = "/schemas/wfs/**")
- public void getSchema(HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ public void getSchema(HttpServletRequest request, HttpServletResponse response) throws Exception {
classPathPublisher.handleRequest(request, response);
}
@@ -50,20 +47,17 @@ public void getSchema(HttpServletRequest request, HttpServletResponse response)
*
*/
@GetMapping(path = {"/webresources/wfs/**"})
- public void getStaticResource(HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ public void getStaticResource(HttpServletRequest request, HttpServletResponse response) throws Exception {
classPathPublisher.handleRequest(request, response);
}
@GetMapping(path = {"/wfs", "/ows"})
- public void handleGet(HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ public void handleGet(HttpServletRequest request, HttpServletResponse response) throws Exception {
dispatch(request, response);
}
@PostMapping(path = {"/wfs", "/ows"})
- public void handlePost(HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ public void handlePost(HttpServletRequest request, HttpServletResponse response) throws Exception {
dispatch(request, response);
}
@@ -113,8 +107,7 @@ public void handleVirtualServiceLayerPost(
dispatch(request, response);
}
- private void dispatch(HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ private void dispatch(HttpServletRequest request, HttpServletResponse response) throws Exception {
geoserverDispatcher.handleRequest(request, response);
}
}
diff --git a/src/apps/geoserver/wfs/src/test/java/org/geoserver/cloud/wfs/app/WfsApplicationDataDirectoryIT.java b/src/apps/geoserver/wfs/src/test/java/org/geoserver/cloud/wfs/app/WfsApplicationDataDirectoryIT.java
index ea25f6583..9876d65c6 100644
--- a/src/apps/geoserver/wfs/src/test/java/org/geoserver/cloud/wfs/app/WfsApplicationDataDirectoryIT.java
+++ b/src/apps/geoserver/wfs/src/test/java/org/geoserver/cloud/wfs/app/WfsApplicationDataDirectoryIT.java
@@ -4,6 +4,9 @@
*/
package org.geoserver.cloud.wfs.app;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
import org.junit.jupiter.api.io.TempDir;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@@ -11,10 +14,6 @@
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-
@SpringBootTest(classes = WfsApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
@ActiveProfiles("datadir")
class WfsApplicationDataDirectoryIT extends WfsApplicationTest {
diff --git a/src/apps/geoserver/wfs/src/test/java/org/geoserver/cloud/wfs/app/WfsApplicationPgconfigIT.java b/src/apps/geoserver/wfs/src/test/java/org/geoserver/cloud/wfs/app/WfsApplicationPgconfigIT.java
index ac03f68e5..2481e265f 100644
--- a/src/apps/geoserver/wfs/src/test/java/org/geoserver/cloud/wfs/app/WfsApplicationPgconfigIT.java
+++ b/src/apps/geoserver/wfs/src/test/java/org/geoserver/cloud/wfs/app/WfsApplicationPgconfigIT.java
@@ -18,7 +18,8 @@
@Testcontainers(disabledWithoutDocker = true)
class WfsApplicationPgconfigIT extends WfsApplicationTest {
- @Container static PostgreSQLContainer> container = new PostgreSQLContainer<>("postgres:15");
+ @Container
+ static PostgreSQLContainer> container = new PostgreSQLContainer<>("postgres:15");
/**
* Contribute the following properties defined in the {@literal pgconfigjndi} spring profile
@@ -35,9 +36,7 @@ class WfsApplicationPgconfigIT extends WfsApplicationTest {
@DynamicPropertySource
static void setUpDataDir(DynamicPropertyRegistry registry) {
registry.add("pgconfig.host", container::getHost);
- registry.add(
- "pgconfig.port",
- () -> container.getMappedPort(PostgreSQLContainer.POSTGRESQL_PORT));
+ registry.add("pgconfig.port", () -> container.getMappedPort(PostgreSQLContainer.POSTGRESQL_PORT));
registry.add("pgconfig.database", container::getDatabaseName);
registry.add("pgconfig.schema", () -> "pgconfigtestschema");
registry.add("pgconfig.username", container::getUsername);
diff --git a/src/apps/geoserver/wfs/src/test/java/org/geoserver/cloud/wfs/app/WfsApplicationTest.java b/src/apps/geoserver/wfs/src/test/java/org/geoserver/cloud/wfs/app/WfsApplicationTest.java
index ac2c1166d..591835683 100644
--- a/src/apps/geoserver/wfs/src/test/java/org/geoserver/cloud/wfs/app/WfsApplicationTest.java
+++ b/src/apps/geoserver/wfs/src/test/java/org/geoserver/cloud/wfs/app/WfsApplicationTest.java
@@ -4,6 +4,7 @@
*/
package org.geoserver.cloud.wfs.app;
+import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@@ -11,8 +12,6 @@
import org.springframework.boot.test.web.server.LocalServerPort;
import org.xmlunit.assertj3.XmlAssert;
-import java.util.Map;
-
@SpringBootTest(classes = WfsApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
abstract class WfsApplicationTest {
@@ -20,25 +19,17 @@ abstract class WfsApplicationTest {
@Test
void owsGetCapabilitiesSmokeTest(@LocalServerPort int servicePort) {
- String url =
- "http://localhost:%d/ows?SERVICE=WFS&REQUEST=GETCAPABILITIES&VERSION=1.1.0"
- .formatted(servicePort);
+ String url = "http://localhost:%d/ows?SERVICE=WFS&REQUEST=GETCAPABILITIES&VERSION=1.1.0".formatted(servicePort);
String caps = restTemplate.getForObject(url, String.class);
Map nscontext = Map.of("wfs", "http://www.opengis.net/wfs");
- XmlAssert.assertThat(caps)
- .withNamespaceContext(nscontext)
- .hasXPath("/wfs:WFS_Capabilities");
+ XmlAssert.assertThat(caps).withNamespaceContext(nscontext).hasXPath("/wfs:WFS_Capabilities");
}
@Test
void wfsGetCapabilitiesSmokeTest(@LocalServerPort int servicePort) {
- String url =
- "http://localhost:%d/wfs?SERVICE=WFS&REQUEST=GETCAPABILITIES&VERSION=1.1.0"
- .formatted(servicePort);
+ String url = "http://localhost:%d/wfs?SERVICE=WFS&REQUEST=GETCAPABILITIES&VERSION=1.1.0".formatted(servicePort);
String caps = restTemplate.getForObject(url, String.class);
Map nscontext = Map.of("wfs", "http://www.opengis.net/wfs");
- XmlAssert.assertThat(caps)
- .withNamespaceContext(nscontext)
- .hasXPath("/wfs:WFS_Capabilities");
+ XmlAssert.assertThat(caps).withNamespaceContext(nscontext).hasXPath("/wfs:WFS_Capabilities");
}
}
diff --git a/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/autoconfigure/wms/KMLAutoConfiguration.java b/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/autoconfigure/wms/KMLAutoConfiguration.java
index 462ffdf21..be11ca671 100644
--- a/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/autoconfigure/wms/KMLAutoConfiguration.java
+++ b/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/autoconfigure/wms/KMLAutoConfiguration.java
@@ -21,16 +21,11 @@
* @since 1.0
*/
@Configuration(proxyBeanMethods = false)
-@ConditionalOnProperty(
- name = "geoserver.wms.kml.enabled",
- havingValue = "true",
- matchIfMissing = true)
+@ConditionalOnProperty(name = "geoserver.wms.kml.enabled", havingValue = "true", matchIfMissing = true)
@ConditionalOnClass(MBStyleHandler.class)
@ImportResource( //
reader = FilteringXmlBeanDefinitionReader.class, //
- locations = {
- "jar:gs-kml-.*!/applicationContext.xml#name=^(?!WFSKMLOutputFormat|kmlURLMapping).*$"
- })
+ locations = {"jar:gs-kml-.*!/applicationContext.xml#name=^(?!WFSKMLOutputFormat|kmlURLMapping).*$"})
public class KMLAutoConfiguration {
@Bean
diff --git a/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/autoconfigure/wms/WmsApplicationAutoConfiguration.java b/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/autoconfigure/wms/WmsApplicationAutoConfiguration.java
index 13d6bb885..e3fc09391 100644
--- a/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/autoconfigure/wms/WmsApplicationAutoConfiguration.java
+++ b/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/autoconfigure/wms/WmsApplicationAutoConfiguration.java
@@ -31,10 +31,8 @@
@ImportResource( //
reader = FilteringXmlBeanDefinitionReader.class, //
locations = { //
- "jar:gs-wms-.*!/applicationContext.xml#name="
- + WmsApplicationAutoConfiguration.WMS_BEANS_BLACKLIST, //
- "jar:gs-wfs-.*!/applicationContext.xml#name="
- + WmsApplicationAutoConfiguration.WFS_BEANS_WHITELIST //
+ "jar:gs-wms-.*!/applicationContext.xml#name=" + WmsApplicationAutoConfiguration.WMS_BEANS_BLACKLIST, //
+ "jar:gs-wfs-.*!/applicationContext.xml#name=" + WmsApplicationAutoConfiguration.WFS_BEANS_WHITELIST //
})
public class WmsApplicationAutoConfiguration {
@@ -70,8 +68,7 @@ public class WmsApplicationAutoConfiguration {
* workspace and secured catalog decorators
*/
@Bean
- LegendSample legendSample(
- @Qualifier("rawCatalog") Catalog catalog, GeoServerResourceLoader loader) {
+ LegendSample legendSample(@Qualifier("rawCatalog") Catalog catalog, GeoServerResourceLoader loader) {
return new LegendSampleImpl(catalog, loader);
}
diff --git a/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/wms/controller/GetMapReflectorController.java b/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/wms/controller/GetMapReflectorController.java
index 66e83486a..8b28ecab6 100644
--- a/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/wms/controller/GetMapReflectorController.java
+++ b/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/wms/controller/GetMapReflectorController.java
@@ -4,16 +4,14 @@
*/
package org.geoserver.cloud.wms.controller;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
-
import org.geoserver.ows.Dispatcher;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
@Controller
@RequiredArgsConstructor
public class GetMapReflectorController {
@@ -21,8 +19,7 @@ public class GetMapReflectorController {
private final @NonNull Dispatcher geoserverDispatcher;
@GetMapping(path = {"/wms/reflect", "/{workspace}/wms/reflect"})
- public void getMapReflect(HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ public void getMapReflect(HttpServletRequest request, HttpServletResponse response) throws Exception {
geoserverDispatcher.handleRequest(request, response);
}
}
diff --git a/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/wms/controller/WMSController.java b/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/wms/controller/WMSController.java
index 71eb20779..00eb4f34a 100644
--- a/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/wms/controller/WMSController.java
+++ b/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/wms/controller/WMSController.java
@@ -4,9 +4,10 @@
*/
package org.geoserver.cloud.wms.controller;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
-
import org.geoserver.cloud.virtualservice.VirtualServiceVerifier;
import org.geoserver.ows.Dispatcher;
import org.springframework.stereotype.Controller;
@@ -15,9 +16,6 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.servlet.view.RedirectView;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
@Controller
@RequiredArgsConstructor
public class WMSController {
@@ -44,8 +42,7 @@ public RedirectView redirectRootToGetCapabilities() {
*
*/
@GetMapping(path = {"/schemas/wms/**"})
- public void getWmsSchema(HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ public void getWmsSchema(HttpServletRequest request, HttpServletResponse response) throws Exception {
classPathPublisher.handleRequest(request, response);
}
@@ -61,22 +58,18 @@ public void getWmsSchema(HttpServletRequest request, HttpServletResponse respons
* {@code /options.png}
*
*/
- @GetMapping(
- path = {"/openlayers/**", "/openlayers3/**", "/webresources/wms/**", "/options.png"})
- public void getStaticResource(HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ @GetMapping(path = {"/openlayers/**", "/openlayers3/**", "/webresources/wms/**", "/options.png"})
+ public void getStaticResource(HttpServletRequest request, HttpServletResponse response) throws Exception {
classPathPublisher.handleRequest(request, response);
}
@GetMapping(path = {"/wms", "/ows"})
- public void handleGet(HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ public void handleGet(HttpServletRequest request, HttpServletResponse response) throws Exception {
dispatch(request, response);
}
@PostMapping(path = {"/wms", "/ows"})
- public void handlePost(HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ public void handlePost(HttpServletRequest request, HttpServletResponse response) throws Exception {
dispatch(request, response);
}
@@ -126,8 +119,7 @@ public void handleVirtualServiceLayerPost(
dispatch(request, response);
}
- private void dispatch(HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ private void dispatch(HttpServletRequest request, HttpServletResponse response) throws Exception {
geoserverDispatcher.handleRequest(request, response);
}
}
diff --git a/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/wms/controller/kml/KMLIconsController.java b/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/wms/controller/kml/KMLIconsController.java
index 09790ea77..abce3e72b 100644
--- a/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/wms/controller/kml/KMLIconsController.java
+++ b/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/wms/controller/kml/KMLIconsController.java
@@ -4,18 +4,16 @@
*/
package org.geoserver.cloud.wms.controller.kml;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpServletResponse;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
-
import org.geoserver.kml.KMLReflector;
import org.geoserver.wms.icons.IconService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-import javax.servlet.http.HttpServletResponse;
-
/**
* Controller for KML icons at {@literal /kml/icon/**}.
*
@@ -44,8 +42,7 @@ public class KMLIconsController {
private final @NonNull IconService kmlIconService;
@GetMapping(path = "/kml/icon/**")
- public void getKmlIcon(HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ public void getKmlIcon(HttpServletRequest request, HttpServletResponse response) throws Exception {
kmlIconService.handleRequest(adaptRequest(request), response);
}
diff --git a/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/wms/controller/kml/KMLReflectorController.java b/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/wms/controller/kml/KMLReflectorController.java
index e99806b1e..6b7772395 100644
--- a/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/wms/controller/kml/KMLReflectorController.java
+++ b/src/apps/geoserver/wms/src/main/java/org/geoserver/cloud/wms/controller/kml/KMLReflectorController.java
@@ -4,17 +4,15 @@
*/
package org.geoserver.cloud.wms.controller.kml;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
-
import org.geoserver.kml.KMLReflector;
import org.geoserver.ows.Dispatcher;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
/**
* Controller for {@link KMLReflector} at {@literal /wms/kml?}/{@literal /{workspace}/wms/kml?}
*
@@ -31,8 +29,7 @@ public class KMLReflectorController {
private final @NonNull Dispatcher geoserverDispatcher;
@GetMapping(path = {"/wms/kml", "/{workspace}/wms/kml"})
- public void kmlReflect(HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ public void kmlReflect(HttpServletRequest request, HttpServletResponse response) throws Exception {
geoserverDispatcher.handleRequest(request, response);
}
diff --git a/src/apps/geoserver/wms/src/test/java/org/geoserver/cloud/wms/app/WmsApplicationDataDirectoryTest.java b/src/apps/geoserver/wms/src/test/java/org/geoserver/cloud/wms/app/WmsApplicationDataDirectoryTest.java
index 6a61d32ac..abf6a104d 100644
--- a/src/apps/geoserver/wms/src/test/java/org/geoserver/cloud/wms/app/WmsApplicationDataDirectoryTest.java
+++ b/src/apps/geoserver/wms/src/test/java/org/geoserver/cloud/wms/app/WmsApplicationDataDirectoryTest.java
@@ -4,6 +4,10 @@
*/
package org.geoserver.cloud.wms.app;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Map;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
@@ -16,11 +20,6 @@
import org.springframework.test.context.DynamicPropertySource;
import org.xmlunit.assertj3.XmlAssert;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Map;
-
@SpringBootTest(
classes = WmsApplication.class,
webEnvironment = WebEnvironment.RANDOM_PORT,
@@ -51,8 +50,6 @@ void getCapabilitiesSmokeTest() {
String url = baseURL + "?SERVICE=WMS&REQUEST=GETCAPABILITIES&VERSION=1.3.0";
String caps = restTemplate.getForObject(url, String.class);
Map nscontext = Map.of("wms", "http://www.opengis.net/wms");
- XmlAssert.assertThat(caps)
- .withNamespaceContext(nscontext)
- .hasXPath("/wms:WMS_Capabilities");
+ XmlAssert.assertThat(caps).withNamespaceContext(nscontext).hasXPath("/wms:WMS_Capabilities");
}
}
diff --git a/src/apps/geoserver/wms/src/test/java/org/geoserver/cloud/wms/app/WmsApplicationTest.java b/src/apps/geoserver/wms/src/test/java/org/geoserver/cloud/wms/app/WmsApplicationTest.java
index b707f63e6..2c5f9f6c9 100644
--- a/src/apps/geoserver/wms/src/test/java/org/geoserver/cloud/wms/app/WmsApplicationTest.java
+++ b/src/apps/geoserver/wms/src/test/java/org/geoserver/cloud/wms/app/WmsApplicationTest.java
@@ -34,9 +34,7 @@ void testExpectedBeansFromWmsApplicationAutoConfiguration() {
expectBean("webMapServiceController", WMSController.class);
expectBean("virtualServiceVerifier", VirtualServiceVerifier.class);
expectBean("getMapReflectorController", GetMapReflectorController.class);
- expectBean(
- "wms_1_1_1_GetCapabilitiesResponse",
- org.geoserver.wms.capabilities.GetCapabilitiesResponse.class);
+ expectBean("wms_1_1_1_GetCapabilitiesResponse", org.geoserver.wms.capabilities.GetCapabilitiesResponse.class);
}
@Test
diff --git a/src/apps/geoserver/wps/src/main/java/org/geoserver/cloud/wps/WPSController.java b/src/apps/geoserver/wps/src/main/java/org/geoserver/cloud/wps/WPSController.java
index 554a83037..693d1dd17 100644
--- a/src/apps/geoserver/wps/src/main/java/org/geoserver/cloud/wps/WPSController.java
+++ b/src/apps/geoserver/wps/src/main/java/org/geoserver/cloud/wps/WPSController.java
@@ -4,9 +4,10 @@
*/
package org.geoserver.cloud.wps;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
-
import org.geoserver.cloud.virtualservice.VirtualServiceVerifier;
import org.geoserver.ows.Dispatcher;
import org.springframework.stereotype.Controller;
@@ -15,9 +16,6 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.servlet.view.RedirectView;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
@Controller
@RequiredArgsConstructor
public class WPSController {
@@ -35,20 +33,17 @@ public RedirectView redirectRootToGetCapabilities() {
/** Serve only WPS schemas from classpath (e.g. {@code /schemas/wps/1.0.0/wpsAll.xsd}) */
@GetMapping(path = "/schemas/wps/**")
- public void getSchema(HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ public void getSchema(HttpServletRequest request, HttpServletResponse response) throws Exception {
classPathPublisher.handleRequest(request, response);
}
@GetMapping(path = {"/wps", "/ows"})
- public void handleGet(HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ public void handleGet(HttpServletRequest request, HttpServletResponse response) throws Exception {
dispatch(request, response);
}
@PostMapping(path = {"/wps", "/ows"})
- public void handlePost(HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ public void handlePost(HttpServletRequest request, HttpServletResponse response) throws Exception {
dispatch(request, response);
}
@@ -98,8 +93,7 @@ public void handleVirtualServiceLayerPost(
dispatch(request, response);
}
- private void dispatch(HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ private void dispatch(HttpServletRequest request, HttpServletResponse response) throws Exception {
geoserverDispatcher.handleRequest(request, response);
}
}
diff --git a/src/apps/geoserver/wps/src/test/java/org/geoserver/cloud/wps/WpsApplicationTest.java b/src/apps/geoserver/wps/src/test/java/org/geoserver/cloud/wps/WpsApplicationTest.java
index ff5ba25a5..556952071 100644
--- a/src/apps/geoserver/wps/src/test/java/org/geoserver/cloud/wps/WpsApplicationTest.java
+++ b/src/apps/geoserver/wps/src/test/java/org/geoserver/cloud/wps/WpsApplicationTest.java
@@ -4,6 +4,10 @@
*/
package org.geoserver.cloud.wps;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Map;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.springframework.boot.test.context.SpringBootTest;
@@ -15,11 +19,6 @@
import org.springframework.test.context.DynamicPropertySource;
import org.xmlunit.assertj3.XmlAssert;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Map;
-
@SpringBootTest(classes = WpsApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
class WpsApplicationTest {
@@ -38,9 +37,7 @@ static void setUpDataDir(DynamicPropertyRegistry registry) throws IOException {
@Test
void owsGetCapabilitiesSmokeTest(@LocalServerPort int servicePort) {
- String url =
- "http://localhost:%d/ows?SERVICE=WPS&REQUEST=GETCAPABILITIES&VERSION=1.0.0"
- .formatted(servicePort);
+ String url = "http://localhost:%d/ows?SERVICE=WPS&REQUEST=GETCAPABILITIES&VERSION=1.0.0".formatted(servicePort);
String caps = restTemplate.getForObject(url, String.class);
Map nscontext = Map.of("wps", "http://www.opengis.net/wps/1.0.0");
XmlAssert.assertThat(caps).withNamespaceContext(nscontext).hasXPath("/wps:Capabilities");
@@ -48,9 +45,7 @@ void owsGetCapabilitiesSmokeTest(@LocalServerPort int servicePort) {
@Test
void wpsGetCapabilitiesSmokeTest(@LocalServerPort int servicePort) {
- String url =
- "http://localhost:%d/wps?SERVICE=WPS&REQUEST=GETCAPABILITIES&VERSION=1.0.0"
- .formatted(servicePort);
+ String url = "http://localhost:%d/wps?SERVICE=WPS&REQUEST=GETCAPABILITIES&VERSION=1.0.0".formatted(servicePort);
String caps = restTemplate.getForObject(url, String.class);
Map nscontext = Map.of("wps", "http://www.opengis.net/wps/1.0.0");
XmlAssert.assertThat(caps).withNamespaceContext(nscontext).hasXPath("/wps:Capabilities");
diff --git a/src/apps/infrastructure/admin/src/main/java/org/geoserver/cloud/adminserver/SpringBootAdminServerApplication.java b/src/apps/infrastructure/admin/src/main/java/org/geoserver/cloud/adminserver/SpringBootAdminServerApplication.java
index 62c159799..bf18615be 100644
--- a/src/apps/infrastructure/admin/src/main/java/org/geoserver/cloud/adminserver/SpringBootAdminServerApplication.java
+++ b/src/apps/infrastructure/admin/src/main/java/org/geoserver/cloud/adminserver/SpringBootAdminServerApplication.java
@@ -5,7 +5,6 @@
package org.geoserver.cloud.adminserver;
import de.codecentric.boot.admin.server.config.EnableAdminServer;
-
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
diff --git a/src/apps/infrastructure/config/src/test/java/org/geoserver/cloud/config/ConfigApplicationTest.java b/src/apps/infrastructure/config/src/test/java/org/geoserver/cloud/config/ConfigApplicationTest.java
index e3a52d06a..1203ebba2 100644
--- a/src/apps/infrastructure/config/src/test/java/org/geoserver/cloud/config/ConfigApplicationTest.java
+++ b/src/apps/infrastructure/config/src/test/java/org/geoserver/cloud/config/ConfigApplicationTest.java
@@ -8,7 +8,6 @@
import static org.hamcrest.Matchers.equalTo;
import lombok.extern.slf4j.Slf4j;
-
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.skyscreamer.jsonassert.JSONAssert;
@@ -27,9 +26,11 @@
@ActiveProfiles({"native", "test"})
class ConfigApplicationTest {
- @LocalServerPort private int port;
+ @LocalServerPort
+ private int port;
- @Autowired private TestRestTemplate restTemplate;
+ @Autowired
+ private TestRestTemplate restTemplate;
private String baseUri;
@@ -41,8 +42,7 @@ void setup() {
@Test
void testNoProfile() throws Exception {
assertThat(
- this.restTemplate.getForEntity(baseUri, String.class).getStatusCode(),
- equalTo(HttpStatus.NOT_FOUND));
+ this.restTemplate.getForEntity(baseUri, String.class).getStatusCode(), equalTo(HttpStatus.NOT_FOUND));
}
@Test
diff --git a/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/autoconfigure/gateway/GatewaySharedAuthAutoConfiguration.java b/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/autoconfigure/gateway/GatewaySharedAuthAutoConfiguration.java
index 332c7d523..0c07675f4 100644
--- a/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/autoconfigure/gateway/GatewaySharedAuthAutoConfiguration.java
+++ b/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/autoconfigure/gateway/GatewaySharedAuthAutoConfiguration.java
@@ -4,16 +4,14 @@
*/
package org.geoserver.cloud.autoconfigure.gateway;
+import javax.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.cloud.security.gateway.sharedauth.GatewaySharedAuthenticationPostFilter;
import org.geoserver.cloud.security.gateway.sharedauth.GatewaySharedAuthenticationPreFilter;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
-import javax.annotation.PostConstruct;
-
@AutoConfiguration
@ConditionalOnProperty(
name = "geoserver.security.gateway-shared-auth.enabled",
diff --git a/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/gateway/filter/GlobalUriFilter.java b/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/gateway/filter/GlobalUriFilter.java
index 5da45c9b5..4fde6bcdd 100644
--- a/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/gateway/filter/GlobalUriFilter.java
+++ b/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/gateway/filter/GlobalUriFilter.java
@@ -7,6 +7,7 @@
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR;
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_ROUTE_ATTR;
+import java.net.URI;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.cloud.gateway.filter.ReactiveLoadBalancerClientFilter;
@@ -14,11 +15,8 @@
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
-
import reactor.core.publisher.Mono;
-import java.net.URI;
-
/**
* See gateway's issue #2065 "Double Encoded
@@ -54,8 +52,7 @@ private URI createUri(URI incomingUri, URI balanceUrl) {
final var port = balanceUrl.getPort() != -1 ? ":" + balanceUrl.getPort() : "";
final var rawPath = balanceUrl.getRawPath() != null ? balanceUrl.getRawPath() : "";
final var query = incomingUri.getRawQuery() != null ? "?" + incomingUri.getRawQuery() : "";
- return URI.create(
- balanceUrl.getScheme() + "://" + balanceUrl.getHost() + port + rawPath + query);
+ return URI.create(balanceUrl.getScheme() + "://" + balanceUrl.getHost() + port + rawPath + query);
}
private static boolean isUriEncoded(URI uri) {
diff --git a/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/gateway/filter/RouteProfileGatewayFilterFactory.java b/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/gateway/filter/RouteProfileGatewayFilterFactory.java
index 858a740fe..965fb1469 100644
--- a/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/gateway/filter/RouteProfileGatewayFilterFactory.java
+++ b/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/gateway/filter/RouteProfileGatewayFilterFactory.java
@@ -6,11 +6,14 @@
import static org.springframework.cloud.gateway.support.GatewayToStringStyler.filterToStringCreator;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import javax.validation.constraints.NotEmpty;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.experimental.Accessors;
-
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
@@ -19,15 +22,8 @@
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.server.ServerWebExchange;
-
import reactor.core.publisher.Mono;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import javax.validation.constraints.NotEmpty;
-
/** Allows to enable routes only if a given spring profile is enabled */
public class RouteProfileGatewayFilterFactory
extends AbstractGatewayFilterFactory {
@@ -104,7 +100,8 @@ public static class Config {
*/
public static final String HTTPSTATUS_KEY = "statusCode";
- @NotEmpty private String profile;
+ @NotEmpty
+ private String profile;
private int statusCode = HttpStatus.NOT_FOUND.value();
}
diff --git a/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/gateway/filter/StripBasePathGatewayFilterFactory.java b/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/gateway/filter/StripBasePathGatewayFilterFactory.java
index 175fb33c7..f43c8c5bc 100644
--- a/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/gateway/filter/StripBasePathGatewayFilterFactory.java
+++ b/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/gateway/filter/StripBasePathGatewayFilterFactory.java
@@ -6,8 +6,8 @@
import static com.google.common.base.Preconditions.checkArgument;
+import java.util.List;
import lombok.Data;
-
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
import org.springframework.cloud.gateway.filter.factory.StripPrefixGatewayFilterFactory;
@@ -15,8 +15,6 @@
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.util.StringUtils;
-import java.util.List;
-
/**
* See gateway's issue #1759 "Webflux base
@@ -77,9 +75,7 @@ public void checkPreconditions() {
if (prefix != null) {
checkArgument(prefix.startsWith("/"), "StripBasePath prefix must start with /");
- checkArgument(
- "/".equals(prefix) || !prefix.endsWith("/"),
- "StripBasePath prefix must not end with /");
+ checkArgument("/".equals(prefix) || !prefix.endsWith("/"), "StripBasePath prefix must not end with /");
}
}
}
diff --git a/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/gateway/predicate/RegExpQueryRoutePredicateFactory.java b/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/gateway/predicate/RegExpQueryRoutePredicateFactory.java
index 91a34cf37..1be270472 100644
--- a/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/gateway/predicate/RegExpQueryRoutePredicateFactory.java
+++ b/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/gateway/predicate/RegExpQueryRoutePredicateFactory.java
@@ -4,11 +4,17 @@
*/
package org.geoserver.cloud.gateway.predicate;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.Predicate;
+import java.util.regex.Pattern;
+import javax.validation.constraints.NotEmpty;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.experimental.Accessors;
-
import org.springframework.cloud.gateway.handler.predicate.AbstractRoutePredicateFactory;
import org.springframework.cloud.gateway.handler.predicate.GatewayPredicate;
import org.springframework.cloud.gateway.handler.predicate.QueryRoutePredicateFactory;
@@ -16,15 +22,6 @@
import org.springframework.validation.annotation.Validated;
import org.springframework.web.server.ServerWebExchange;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Predicate;
-import java.util.regex.Pattern;
-
-import javax.validation.constraints.NotEmpty;
-
/**
* Gateway predicate factory that allows matching by HTTP request query string parameters using
* {@link Pattern Java regular expressions} for both parameter name and value.
@@ -119,7 +116,8 @@ static boolean paramValueMatches(
@Validated
public static class Config {
- @NotEmpty private String paramRegexp;
+ @NotEmpty
+ private String paramRegexp;
private String valueRegexp;
}
diff --git a/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/security/gateway/sharedauth/GatewaySharedAuthenticationPostFilter.java b/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/security/gateway/sharedauth/GatewaySharedAuthenticationPostFilter.java
index 45d0516fd..05cb173b4 100644
--- a/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/security/gateway/sharedauth/GatewaySharedAuthenticationPostFilter.java
+++ b/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/security/gateway/sharedauth/GatewaySharedAuthenticationPostFilter.java
@@ -7,8 +7,11 @@
import static org.geoserver.cloud.security.gateway.sharedauth.SharedAuthConfigurationProperties.X_GSCLOUD_ROLES;
import static org.geoserver.cloud.security.gateway.sharedauth.SharedAuthConfigurationProperties.X_GSCLOUD_USERNAME;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
-
import org.springframework.boot.autoconfigure.neo4j.Neo4jProperties.Authentication;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
@@ -18,14 +21,8 @@
import org.springframework.util.StringUtils;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebSession;
-
import reactor.core.publisher.Mono;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
/**
* {@link GlobalFilter} working in tandem with {@link GatewaySharedAuthenticationPreFilter} to
* enable sharing the webui form-based authentication object with the other services.
@@ -69,9 +66,7 @@ public int getOrder() {
@Override
public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) {
- return chain.filter(exchange)
- .then(updateHeadersInSession(exchange))
- .then(removeResponseHeaders(exchange));
+ return chain.filter(exchange).then(updateHeadersInSession(exchange)).then(removeResponseHeaders(exchange));
}
/**
@@ -88,16 +83,11 @@ public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) {
private Mono updateHeadersInSession(ServerWebExchange exchange) {
return exchange.getSession()
- .flatMap(
- session ->
- updateSession(
- exchange.getRequest(),
- exchange.getResponse().getHeaders(),
- session));
+ .flatMap(session -> updateSession(
+ exchange.getRequest(), exchange.getResponse().getHeaders(), session));
}
- private Mono updateSession(
- ServerHttpRequest req, HttpHeaders responseHeaders, WebSession session) {
+ private Mono updateSession(ServerHttpRequest req, HttpHeaders responseHeaders, WebSession session) {
final var responseUser = responseHeaders.getFirst(X_GSCLOUD_USERNAME);
if (null == responseUser) {
return Mono.empty();
@@ -111,8 +101,7 @@ private Mono updateSession(
return Mono.fromRunnable(() -> loggedIn(session, responseUser, roles, req));
}
- private void loggedIn(
- WebSession session, String user, List roles, ServerHttpRequest req) {
+ private void loggedIn(WebSession session, String user, List roles, ServerHttpRequest req) {
var attributes = session.getAttributes();
var currUser = attributes.get(X_GSCLOUD_USERNAME);
var currRoles = attributes.get(X_GSCLOUD_ROLES);
@@ -155,11 +144,10 @@ private void loggedOut(WebSession session, ServerHttpRequest req) {
}
private Mono removeResponseHeaders(ServerWebExchange exchange) {
- return Mono.fromRunnable(
- () -> {
- HttpHeaders responseHeaders = exchange.getResponse().getHeaders();
- removeResponseHeaders(exchange.getRequest(), responseHeaders);
- });
+ return Mono.fromRunnable(() -> {
+ HttpHeaders responseHeaders = exchange.getResponse().getHeaders();
+ removeResponseHeaders(exchange.getRequest(), responseHeaders);
+ });
}
private void removeResponseHeaders(ServerHttpRequest req, HttpHeaders responseHeaders) {
@@ -169,14 +157,12 @@ private void removeResponseHeaders(ServerHttpRequest req, HttpHeaders responseHe
private void removeResponseHeader(ServerHttpRequest req, HttpHeaders headers, String name) {
removeHeader(headers, name)
- .ifPresent(
- value ->
- log.trace(
- "removed response header {}: '{}'. {} {}",
- name,
- value,
- req.getMethod(),
- req.getURI().getPath()));
+ .ifPresent(value -> log.trace(
+ "removed response header {}: '{}'. {} {}",
+ name,
+ value,
+ req.getMethod(),
+ req.getURI().getPath()));
}
private Optional removeHeader(HttpHeaders httpHeaders, String name) {
diff --git a/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/security/gateway/sharedauth/GatewaySharedAuthenticationPreFilter.java b/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/security/gateway/sharedauth/GatewaySharedAuthenticationPreFilter.java
index 11811a47b..19d728055 100644
--- a/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/security/gateway/sharedauth/GatewaySharedAuthenticationPreFilter.java
+++ b/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/security/gateway/sharedauth/GatewaySharedAuthenticationPreFilter.java
@@ -7,8 +7,12 @@
import static org.geoserver.cloud.security.gateway.sharedauth.SharedAuthConfigurationProperties.X_GSCLOUD_ROLES;
import static org.geoserver.cloud.security.gateway.sharedauth.SharedAuthConfigurationProperties.X_GSCLOUD_USERNAME;
+import java.net.InetSocketAddress;
+import java.net.URI;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
-
import org.springframework.boot.autoconfigure.neo4j.Neo4jProperties.Authentication;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
@@ -19,15 +23,8 @@
import org.springframework.util.StringUtils;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebSession;
-
import reactor.core.publisher.Mono;
-import java.net.InetSocketAddress;
-import java.net.URI;
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
/**
* {@link GlobalFilter} working in tandem with {@link GatewaySharedAuthenticationPostFilter} to
* enable sharing the webui form-based authentication object with the other services.
@@ -85,31 +82,28 @@ private Mono addHeadersFromSession(ServerWebExchange exchange
return exchange.getSession().map(session -> addHeadersFromSession(session, exchange));
}
- private ServerWebExchange addHeadersFromSession(
- WebSession session, ServerWebExchange exchange) {
+ private ServerWebExchange addHeadersFromSession(WebSession session, ServerWebExchange exchange) {
final String username = session.getAttribute(X_GSCLOUD_USERNAME);
if (StringUtils.hasText(username)) {
final List roles = session.getAttributeOrDefault(X_GSCLOUD_ROLES, List.of());
final var origRequest = exchange.getRequest();
- var request =
- origRequest
- .mutate()
- .headers(
- headers -> {
- headers.set(X_GSCLOUD_USERNAME, username);
- headers.remove(X_GSCLOUD_ROLES);
- roles.forEach(role -> headers.add(X_GSCLOUD_ROLES, role));
- log.debug(
- "appended shared-auth request headers from session[{}] {}: {}, {}: {} to {} {}",
- session.getId(),
- X_GSCLOUD_USERNAME,
- username,
- X_GSCLOUD_ROLES,
- roles,
- origRequest.getMethod(),
- origRequest.getURI().getPath());
- })
- .build();
+ var request = origRequest
+ .mutate()
+ .headers(headers -> {
+ headers.set(X_GSCLOUD_USERNAME, username);
+ headers.remove(X_GSCLOUD_ROLES);
+ roles.forEach(role -> headers.add(X_GSCLOUD_ROLES, role));
+ log.debug(
+ "appended shared-auth request headers from session[{}] {}: {}, {}: {} to {} {}",
+ session.getId(),
+ X_GSCLOUD_USERNAME,
+ username,
+ X_GSCLOUD_ROLES,
+ roles,
+ origRequest.getMethod(),
+ origRequest.getURI().getPath());
+ })
+ .build();
exchange = exchange.mutate().request(request).build();
} else {
@@ -127,11 +121,10 @@ private ServerWebExchange addHeadersFromSession(
private ServerWebExchange removeRequestHeaders(ServerWebExchange exchange) {
if (impersonationAttempt(exchange)) {
var origRequest = exchange.getRequest();
- var request =
- exchange.getRequest()
- .mutate()
- .headers(headers -> removeRequestHeaders(origRequest, headers))
- .build();
+ var request = exchange.getRequest()
+ .mutate()
+ .headers(headers -> removeRequestHeaders(origRequest, headers))
+ .build();
exchange = exchange.mutate().request(request).build();
}
return exchange;
@@ -142,22 +135,19 @@ private void removeRequestHeaders(ServerHttpRequest origRequest, HttpHeaders req
removeRequestHeader(origRequest, requestHeaders, X_GSCLOUD_ROLES);
}
- private void removeRequestHeader(
- ServerHttpRequest origRequest, HttpHeaders headers, String name) {
- removeHeader(headers, name)
- .ifPresent(
- value -> {
- HttpMethod method = origRequest.getMethod();
- URI uri = origRequest.getURI();
- InetSocketAddress remoteAddress = origRequest.getRemoteAddress();
- log.warn(
- "removed incoming request header {}: {}. Request: [{} {}], from: {}",
- name,
- value,
- method,
- uri,
- remoteAddress);
- });
+ private void removeRequestHeader(ServerHttpRequest origRequest, HttpHeaders headers, String name) {
+ removeHeader(headers, name).ifPresent(value -> {
+ HttpMethod method = origRequest.getMethod();
+ URI uri = origRequest.getURI();
+ InetSocketAddress remoteAddress = origRequest.getRemoteAddress();
+ log.warn(
+ "removed incoming request header {}: {}. Request: [{} {}], from: {}",
+ name,
+ value,
+ method,
+ uri,
+ remoteAddress);
+ });
}
private Optional removeHeader(HttpHeaders httpHeaders, String name) {
diff --git a/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/security/gateway/sharedauth/SharedAuthConfigurationProperties.java b/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/security/gateway/sharedauth/SharedAuthConfigurationProperties.java
index 0b0cfdc9a..cb94615fa 100644
--- a/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/security/gateway/sharedauth/SharedAuthConfigurationProperties.java
+++ b/src/apps/infrastructure/gateway/src/main/java/org/geoserver/cloud/security/gateway/sharedauth/SharedAuthConfigurationProperties.java
@@ -5,7 +5,6 @@
package org.geoserver.cloud.security.gateway.sharedauth;
import lombok.Data;
-
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
diff --git a/src/apps/infrastructure/gateway/src/test/java/org/geoserver/cloud/autoconfigure/gateway/GatewayApplicationAutoconfigurationTest.java b/src/apps/infrastructure/gateway/src/test/java/org/geoserver/cloud/autoconfigure/gateway/GatewayApplicationAutoconfigurationTest.java
index 24e0e617d..b2ea17476 100644
--- a/src/apps/infrastructure/gateway/src/test/java/org/geoserver/cloud/autoconfigure/gateway/GatewayApplicationAutoconfigurationTest.java
+++ b/src/apps/infrastructure/gateway/src/test/java/org/geoserver/cloud/autoconfigure/gateway/GatewayApplicationAutoconfigurationTest.java
@@ -15,19 +15,15 @@
class GatewayApplicationAutoconfigurationTest {
- private ReactiveWebApplicationContextRunner runner =
- new ReactiveWebApplicationContextRunner()
- .withConfiguration(
- AutoConfigurations.of(GatewayApplicationAutoconfiguration.class));
+ private ReactiveWebApplicationContextRunner runner = new ReactiveWebApplicationContextRunner()
+ .withConfiguration(AutoConfigurations.of(GatewayApplicationAutoconfiguration.class));
@Test
void testDefaultAppContextContributions() {
- runner.run(
- context ->
- assertThat(context)
- .hasNotFailed()
- .hasSingleBean(RegExpQueryRoutePredicateFactory.class)
- .hasSingleBean(RouteProfileGatewayFilterFactory.class)
- .hasSingleBean(StripBasePathGatewayFilterFactory.class));
+ runner.run(context -> assertThat(context)
+ .hasNotFailed()
+ .hasSingleBean(RegExpQueryRoutePredicateFactory.class)
+ .hasSingleBean(RouteProfileGatewayFilterFactory.class)
+ .hasSingleBean(StripBasePathGatewayFilterFactory.class));
}
}
diff --git a/src/apps/infrastructure/gateway/src/test/java/org/geoserver/cloud/autoconfigure/gateway/GatewaySharedAuthAutoConfigurationTest.java b/src/apps/infrastructure/gateway/src/test/java/org/geoserver/cloud/autoconfigure/gateway/GatewaySharedAuthAutoConfigurationTest.java
index 6a65a5de9..68432c4d6 100644
--- a/src/apps/infrastructure/gateway/src/test/java/org/geoserver/cloud/autoconfigure/gateway/GatewaySharedAuthAutoConfigurationTest.java
+++ b/src/apps/infrastructure/gateway/src/test/java/org/geoserver/cloud/autoconfigure/gateway/GatewaySharedAuthAutoConfigurationTest.java
@@ -14,10 +14,8 @@
class GatewaySharedAuthAutoConfigurationTest {
- private ReactiveWebApplicationContextRunner runner =
- new ReactiveWebApplicationContextRunner()
- .withConfiguration(
- AutoConfigurations.of(GatewaySharedAuthAutoConfiguration.class));
+ private ReactiveWebApplicationContextRunner runner = new ReactiveWebApplicationContextRunner()
+ .withConfiguration(AutoConfigurations.of(GatewaySharedAuthAutoConfiguration.class));
@Test
void enabledByDefault() {
@@ -26,28 +24,22 @@ void enabledByDefault() {
@Test
void enabledByConfig() {
- assertEnabled(
- runner.withPropertyValues("geoserver.security.gateway-shared-auth.enabled: true"));
+ assertEnabled(runner.withPropertyValues("geoserver.security.gateway-shared-auth.enabled: true"));
}
private void assertEnabled(ReactiveWebApplicationContextRunner contextRunner) {
- contextRunner.run(
- context ->
- assertThat(context)
- .hasNotFailed()
- .hasSingleBean(GatewaySharedAuthenticationPreFilter.class)
- .hasSingleBean(GatewaySharedAuthenticationPostFilter.class));
+ contextRunner.run(context -> assertThat(context)
+ .hasNotFailed()
+ .hasSingleBean(GatewaySharedAuthenticationPreFilter.class)
+ .hasSingleBean(GatewaySharedAuthenticationPostFilter.class));
}
@Test
void disableByConfig() {
runner.withPropertyValues("geoserver.security.gateway-shared-auth.enabled: false")
- .run(
- context ->
- assertThat(context)
- .hasNotFailed()
- .doesNotHaveBean(GatewaySharedAuthenticationPreFilter.class)
- .doesNotHaveBean(
- GatewaySharedAuthenticationPostFilter.class));
+ .run(context -> assertThat(context)
+ .hasNotFailed()
+ .doesNotHaveBean(GatewaySharedAuthenticationPreFilter.class)
+ .doesNotHaveBean(GatewaySharedAuthenticationPostFilter.class));
}
}
diff --git a/src/apps/infrastructure/gateway/src/test/java/org/geoserver/cloud/security/gateway/sharedauth/GatewaySharedAuthenticationTest.java b/src/apps/infrastructure/gateway/src/test/java/org/geoserver/cloud/security/gateway/sharedauth/GatewaySharedAuthenticationTest.java
index 2307fd385..a1411ef89 100644
--- a/src/apps/infrastructure/gateway/src/test/java/org/geoserver/cloud/security/gateway/sharedauth/GatewaySharedAuthenticationTest.java
+++ b/src/apps/infrastructure/gateway/src/test/java/org/geoserver/cloud/security/gateway/sharedauth/GatewaySharedAuthenticationTest.java
@@ -5,7 +5,6 @@
package org.geoserver.cloud.security.gateway.sharedauth;
import static com.github.tomakehurst.wiremock.stubbing.StubMapping.buildFrom;
-
import static org.assertj.core.api.Assertions.assertThat;
import com.github.tomakehurst.wiremock.client.WireMock;
@@ -14,9 +13,13 @@
import com.github.tomakehurst.wiremock.junit5.WireMockTest;
import com.github.tomakehurst.wiremock.stubbing.StubMapping;
import com.github.tomakehurst.wiremock.verification.LoggedRequest;
-
+import java.net.URI;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import lombok.NonNull;
-
import org.geoserver.cloud.gateway.GatewayApplication;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
@@ -44,13 +47,6 @@
import org.springframework.web.server.session.WebSessionManager;
import org.springframework.web.server.session.WebSessionStore;
-import java.net.URI;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
/**
* Wiremock integration test for a running gateway with {@link GatewaySharedAuthenticationPreFilter}
* and {@link GatewaySharedAuthenticationPostFilter}
@@ -174,14 +170,16 @@ static void registerRoutes(DynamicPropertyRegistry registry) {
registry.add("spring.cloud.gateway.routes[0].predicates[0]", () -> "Path=/**");
}
- @Autowired TestRestTemplate testRestTemplate;
+ @Autowired
+ TestRestTemplate testRestTemplate;
/**
* Concrete implementation of {@link WebSessionManager} as created by {@link
* EnableWebFluxConfiguration#webSessionManager()} so we can access {@link
* DefaultWebSessionManager#getSessionStore()}
*/
- @Autowired DefaultWebSessionManager webSessionManager;
+ @Autowired
+ DefaultWebSessionManager webSessionManager;
private URI login;
private URI logout;
@@ -214,23 +212,19 @@ void setUp(WireMockRuntimeInfo runtimeInfo) {
@DisplayName("pre-filter avoids impersonation attempts")
void preFilterRemovesIncomingSharedAuthHeaders(WireMockRuntimeInfo runtimeInfo) {
ResponseEntity response =
- getCapabilities(
- "x-gsc-username", "user", "x-gsc-roles", "ROLE_1", "x-gsc-roles", "ROLE_2");
+ getCapabilities("x-gsc-username", "user", "x-gsc-roles", "ROLE_1", "x-gsc-roles", "ROLE_2");
assertThat(response.getBody()).startsWith(" getcaps =
- getCapabilities("Cookie", "SESSION=%s".formatted(gatewaySessionId));
+ ResponseEntity getcaps = getCapabilities("Cookie", "SESSION=%s".formatted(gatewaySessionId));
assertThat(getcaps.getBody()).startsWith(" loginResponse = login();
final String gatewaySessionId = getGatewaySessionId(loginResponse.getHeaders());
@@ -307,11 +295,9 @@ void postFilterRemovesUserAndRolesFromSessionOnEmptyUserResponseHeader(
logout(gatewaySessionId);
Map attributes = getSessionAttributes(gatewaySessionId);
assertThat(attributes)
- .as(
- "GatewaySharedAuhenticationPostFilter did not remove x-gsc-username from the session")
+ .as("GatewaySharedAuhenticationPostFilter did not remove x-gsc-username from the session")
.doesNotContainKey("x-gsc-username")
- .as(
- "GatewaySharedAuhenticationPostFilter did not remove x-gsc-roles from the session")
+ .as("GatewaySharedAuhenticationPostFilter did not remove x-gsc-roles from the session")
.doesNotContainKey("x-gsc-roles");
}
@@ -327,18 +313,18 @@ void postFilterRemovesOutgoingSharedAuthHeaders(WireMockRuntimeInfo runtimeInfo)
ResponseEntity response = login();
HttpHeaders responseHeaders = response.getHeaders();
assertThat(responseHeaders)
- .as(
- "GatewaySharedAuhenticationGlobalFilter should have removed the x-gsc-username response header")
+ .as("GatewaySharedAuhenticationGlobalFilter should have removed the x-gsc-username response header")
.doesNotContainKey("x-gsc-username")
- .as(
- "GatewaySharedAuhenticationGlobalFilter should have removed the x-gsc-roles response header")
+ .as("GatewaySharedAuhenticationGlobalFilter should have removed the x-gsc-roles response header")
.doesNotContainKey("x-gsc-roles");
}
private String getGatewaySessionId(HttpHeaders responseHeaders) {
List cookies = responseHeaders.get("Set-Cookie");
- String cookie =
- cookies.stream().filter(c -> c.startsWith("SESSION=")).findFirst().orElseThrow();
+ String cookie = cookies.stream()
+ .filter(c -> c.startsWith("SESSION="))
+ .findFirst()
+ .orElseThrow();
String sessionId = cookie.substring("SESSION=".length());
sessionId = sessionId.substring(0, sessionId.indexOf(';'));
return sessionId;
@@ -362,34 +348,30 @@ private URI gatewayUriOf(StubMapping mapping) {
}
ResponseEntity login() {
- HttpEntity> entity =
- withHeaders( //
- "Accept", "text/html,application/xhtml+xml", //
- "Content-Type", "application/x-www-form-urlencoded");
+ HttpEntity> entity = withHeaders( //
+ "Accept", "text/html,application/xhtml+xml", //
+ "Content-Type", "application/x-www-form-urlencoded");
ResponseEntity response = testRestTemplate.postForEntity(login, entity, Void.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.FOUND);
HttpHeaders headers = response.getHeaders();
- assertThat(headers)
- .containsEntry("Location", List.of("http://0.0.0.0:9090/geoserver/cloud/web"));
+ assertThat(headers).containsEntry("Location", List.of("http://0.0.0.0:9090/geoserver/cloud/web"));
return response;
}
ResponseEntity logout(@NonNull String gatewaySessionId) {
- HttpEntity> entity =
- withHeaders( //
- "Accept", "text/html,application/xhtml+xml", //
- "Content-Type", "application/x-www-form-urlencoded",
- "Cookie", "SESSION=%s".formatted(gatewaySessionId));
+ HttpEntity> entity = withHeaders( //
+ "Accept", "text/html,application/xhtml+xml", //
+ "Content-Type", "application/x-www-form-urlencoded",
+ "Cookie", "SESSION=%s".formatted(gatewaySessionId));
ResponseEntity response = testRestTemplate.postForEntity(logout, entity, Void.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.FOUND);
HttpHeaders headers = response.getHeaders();
- assertThat(headers)
- .containsEntry("Location", List.of("http://0.0.0.0:9090/geoserver/cloud/web"));
+ assertThat(headers).containsEntry("Location", List.of("http://0.0.0.0:9090/geoserver/cloud/web"));
return response;
}
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/core/GeoServerBackendAutoConfiguration.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/core/GeoServerBackendAutoConfiguration.java
index b18c97800..714d8fd5f 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/core/GeoServerBackendAutoConfiguration.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/core/GeoServerBackendAutoConfiguration.java
@@ -22,7 +22,6 @@
*
* @see CoreBackendConfiguration
*/
-@AutoConfiguration(
- after = {GeoToolsHttpClientAutoConfiguration.class, JNDIDataSourceConfiguration.class})
+@AutoConfiguration(after = {GeoToolsHttpClientAutoConfiguration.class, JNDIDataSourceConfiguration.class})
@Import(CoreBackendConfiguration.class)
public class GeoServerBackendAutoConfiguration {}
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/core/LifecycleEventAutoConfiguration.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/core/LifecycleEventAutoConfiguration.java
index ce2986a85..ef1e12cfd 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/core/LifecycleEventAutoConfiguration.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/core/LifecycleEventAutoConfiguration.java
@@ -22,8 +22,7 @@
public class LifecycleEventAutoConfiguration {
@Bean
- LifecycleEventProcessor lifecycleEventProcessor(
- @Qualifier("geoServer") GeoServerImpl rawGeoServer) {
+ LifecycleEventProcessor lifecycleEventProcessor(@Qualifier("geoServer") GeoServerImpl rawGeoServer) {
return new LifecycleEventProcessor(rawGeoServer);
}
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/core/XstreamServiceLoadersAutoConfiguration.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/core/XstreamServiceLoadersAutoConfiguration.java
index 85592b645..76288e249 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/core/XstreamServiceLoadersAutoConfiguration.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/core/XstreamServiceLoadersAutoConfiguration.java
@@ -5,7 +5,6 @@
package org.geoserver.cloud.autoconfigure.catalog.backend.core;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.config.util.XStreamServiceLoader;
import org.geoserver.gwc.wmts.WMTSFactoryExtension;
import org.geoserver.gwc.wmts.WMTSXStreamLoader;
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/geotools/GeoToolsHttpClientAutoConfiguration.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/geotools/GeoToolsHttpClientAutoConfiguration.java
index 43f1f074f..86903643a 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/geotools/GeoToolsHttpClientAutoConfiguration.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/geotools/GeoToolsHttpClientAutoConfiguration.java
@@ -5,7 +5,6 @@
package org.geoserver.cloud.autoconfigure.geotools;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.cloud.autoconfigure.geotools.GeoToolsHttpClientProxyConfigurationProperties.ProxyHostConfig;
import org.geotools.http.HTTPClientFactory;
import org.springframework.boot.autoconfigure.AutoConfiguration;
@@ -67,10 +66,7 @@
*/
@AutoConfiguration
@EnableConfigurationProperties(GeoToolsHttpClientProxyConfigurationProperties.class)
-@ConditionalOnProperty(
- name = "geotools.httpclient.proxy.enabled",
- havingValue = "true",
- matchIfMissing = true)
+@ConditionalOnProperty(name = "geotools.httpclient.proxy.enabled", havingValue = "true", matchIfMissing = true)
@Slf4j(topic = "org.geotools.autoconfigure.httpclient")
public class GeoToolsHttpClientAutoConfiguration {
@@ -89,16 +85,12 @@ SpringEnvironmentAwareGeoToolsHttpClientFactory springEnvironmentAwareGeoToolsHt
private void log(ProxyHostConfig config, String protocol) {
config.host()
.ifPresentOrElse(
- host ->
- log.info(
- "{} proxy configured for GeoTools cascaded OWS stores: {}:{}, secured: {}",
- protocol,
- host,
- config.port(),
- config.isSecured()),
- () ->
- log.info(
- "No {} proxy configured for GeoTools cascaded OWS stores",
- protocol));
+ host -> log.info(
+ "{} proxy configured for GeoTools cascaded OWS stores: {}:{}, secured: {}",
+ protocol,
+ host,
+ config.port(),
+ config.isSecured()),
+ () -> log.info("No {} proxy configured for GeoTools cascaded OWS stores", protocol));
}
}
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/geotools/GeoToolsHttpClientProxyConfigurationProperties.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/geotools/GeoToolsHttpClientProxyConfigurationProperties.java
index 522914c8b..8050da17e 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/geotools/GeoToolsHttpClientProxyConfigurationProperties.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/geotools/GeoToolsHttpClientProxyConfigurationProperties.java
@@ -4,18 +4,16 @@
*/
package org.geoserver.cloud.autoconfigure.geotools;
+import java.net.http.HttpClient;
+import java.util.List;
+import java.util.Optional;
+import java.util.regex.Pattern;
import lombok.Data;
import lombok.NonNull;
-
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.util.StringUtils;
-import java.net.http.HttpClient;
-import java.util.List;
-import java.util.Optional;
-import java.util.regex.Pattern;
-
/**
* {@link EnableConfigurationProperties @EnableConfigurationProperties} to configure the HTTP proxy
* for the GeoTools {@link HttpClient} using Spring environment configuration.
@@ -61,16 +59,13 @@ public int port() {
}
public boolean isSecured() {
- return StringUtils.hasLength(host)
- && StringUtils.hasLength(user)
- && StringUtils.hasLength(password);
+ return StringUtils.hasLength(host) && StringUtils.hasLength(user) && StringUtils.hasLength(password);
}
}
public ProxyHostConfig ofProtocol(@NonNull String protocol) {
if ("http".equals(protocol)) return http == null ? new ProxyHostConfig() : http;
if ("https".equals(protocol)) return https == null ? new ProxyHostConfig() : https;
- throw new IllegalArgumentException(
- "Uknown protocol %s. Expected http(s)".formatted(protocol));
+ throw new IllegalArgumentException("Uknown protocol %s. Expected http(s)".formatted(protocol));
}
}
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/geotools/GeoToolsStaticContextInitializer.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/geotools/GeoToolsStaticContextInitializer.java
index 2cb8cf98b..9a6d2fd51 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/geotools/GeoToolsStaticContextInitializer.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/geotools/GeoToolsStaticContextInitializer.java
@@ -19,8 +19,7 @@
*
* @since 1.0
*/
-public class GeoToolsStaticContextInitializer
- implements ApplicationContextInitializer {
+public class GeoToolsStaticContextInitializer implements ApplicationContextInitializer {
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
@@ -30,15 +29,11 @@ public void initialize(ConfigurableApplicationContext applicationContext) {
}
System.setProperty("org.geotools.referencing.forceXY", "true");
- boolean useEnvAwareHttpClient =
- applicationContext
- .getEnvironment()
- .getProperty(
- "geotools.httpclient.proxy.enabled", Boolean.class, Boolean.TRUE);
+ boolean useEnvAwareHttpClient = applicationContext
+ .getEnvironment()
+ .getProperty("geotools.httpclient.proxy.enabled", Boolean.class, Boolean.TRUE);
if (useEnvAwareHttpClient) {
- Hints.putSystemDefault(
- Hints.HTTP_CLIENT_FACTORY,
- SpringEnvironmentAwareGeoToolsHttpClientFactory.class);
+ Hints.putSystemDefault(Hints.HTTP_CLIENT_FACTORY, SpringEnvironmentAwareGeoToolsHttpClientFactory.class);
}
}
}
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/geotools/SpringEnvironmentAwareGeoToolsHttpClient.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/geotools/SpringEnvironmentAwareGeoToolsHttpClient.java
index 9c9d5302b..394ab06a3 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/geotools/SpringEnvironmentAwareGeoToolsHttpClient.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/geotools/SpringEnvironmentAwareGeoToolsHttpClient.java
@@ -20,9 +20,19 @@
import static java.time.Duration.ofMillis;
import static java.time.Duration.ofSeconds;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import java.util.zip.GZIPInputStream;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
-
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
@@ -54,18 +64,6 @@
import org.geotools.util.factory.GeoTools;
import org.springframework.core.env.PropertyResolver;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URI;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.util.Map;
-import java.util.Optional;
-import java.util.stream.Collectors;
-import java.util.zip.GZIPInputStream;
-
/**
* Copy of GeoTools' {@link org.geotools.http.commons.MultithreadedHttpClient} due to its lack of
* extensibility, adding the ability to set up the Apache HTTPClient's proxy configuration from
@@ -91,13 +89,12 @@ public SpringEnvironmentAwareGeoToolsHttpClient(
connectionManager = new PoolingHttpClientConnectionManager();
connectionManager.setMaxTotal(6);
connectionManager.setDefaultMaxPerRoute(6);
- connectionConfig =
- RequestConfig.custom()
- .setCookieSpec(CookieSpecs.DEFAULT)
- .setExpectContinueEnabled(true)
- .setSocketTimeout((int) ofSeconds(30).toMillis())
- .setConnectTimeout((int) ofSeconds(30).toMillis())
- .build();
+ connectionConfig = RequestConfig.custom()
+ .setCookieSpec(CookieSpecs.DEFAULT)
+ .setExpectContinueEnabled(true)
+ .setSocketTimeout((int) ofSeconds(30).toMillis())
+ .setConnectTimeout((int) ofSeconds(30).toMillis())
+ .build();
resetCredentials();
client = builder().build();
}
@@ -158,23 +155,18 @@ private void setProxyCredentials(BasicCredentialsProvider provider, ProxyHostCon
}
}
- private void setTargetCredentials(
- BasicCredentialsProvider provider, String userName, String pwd) {
+ private void setTargetCredentials(BasicCredentialsProvider provider, String userName, String pwd) {
AuthScope authscope = AuthScope.ANY;
Credentials credentials = new UsernamePasswordCredentials(userName, pwd);
provider.setCredentials(authscope, credentials);
}
private HttpClientBuilder builder() {
- HttpClientBuilder builder =
- HttpClientBuilder.create()
- .setUserAgent(
- "GeoTools/%s (%s)"
- .formatted(
- GeoTools.getVersion(),
- this.getClass().getSimpleName()))
- .useSystemProperties()
- .setConnectionManager(connectionManager);
+ HttpClientBuilder builder = HttpClientBuilder.create()
+ .setUserAgent("GeoTools/%s (%s)"
+ .formatted(GeoTools.getVersion(), this.getClass().getSimpleName()))
+ .useSystemProperties()
+ .setConnectionManager(connectionManager);
if (credsProvider != null) {
builder.setDefaultCredentialsProvider(credsProvider);
}
@@ -182,16 +174,14 @@ private HttpClientBuilder builder() {
}
@Override
- public HttpMethodResponse post(
- final URL url, final InputStream postContent, final String postContentType)
+ public HttpMethodResponse post(final URL url, final InputStream postContent, final String postContentType)
throws IOException {
return post(url, postContent, postContentType, null);
}
@Override
public HttpMethodResponse post(
- URL url, InputStream postContent, String postContentType, Map headers)
- throws IOException {
+ URL url, InputStream postContent, String postContentType, Map headers) throws IOException {
if (headers == null) {
headers = Map.of();
} else {
@@ -204,10 +194,9 @@ public HttpMethodResponse post(
if (credsProvider != null) {
// we can't read the input stream twice as would be needed if the server asks us to
// authenticate
- String input =
- new BufferedReader(new InputStreamReader(postContent, StandardCharsets.UTF_8))
- .lines()
- .collect(Collectors.joining("\n"));
+ String input = new BufferedReader(new InputStreamReader(postContent, StandardCharsets.UTF_8))
+ .lines()
+ .collect(Collectors.joining("\n"));
requestEntity = new StringEntity(input);
} else {
requestEntity = new InputStreamEntity(postContent);
@@ -227,9 +216,8 @@ public HttpMethodResponse post(
if (200 != response.getStatusCode()) {
postMethod.releaseConnection();
- throw new IOException(
- "Server returned HTTP error code %d for URL %s"
- .formatted(response.getStatusCode(), url.toExternalForm()));
+ throw new IOException("Server returned HTTP error code %d for URL %s"
+ .formatted(response.getStatusCode(), url.toExternalForm()));
}
return response;
@@ -247,9 +235,7 @@ private HttpMethodResponse executeMethod(HttpRequestBase method) throws IOExcept
// see https://stackoverflow.com/a/21592593
AuthCache authCache = new BasicAuthCache();
URI target = method.getURI();
- authCache.put(
- new HttpHost(target.getHost(), target.getPort(), target.getScheme()),
- new BasicScheme());
+ authCache.put(new HttpHost(target.getHost(), target.getPort(), target.getScheme()), new BasicScheme());
localContext.setAuthCache(authCache);
resp = client.execute(method, localContext);
} else {
@@ -292,9 +278,8 @@ public HTTPResponse get(URL url, Map headers) throws IOException
if (200 != response.getStatusCode()) {
getMethod.releaseConnection();
- throw new IOException(
- "Server returned HTTP error code %d for URL %s"
- .formatted(response.getStatusCode(), url.toExternalForm()));
+ throw new IOException("Server returned HTTP error code %d for URL %s"
+ .formatted(response.getStatusCode(), url.toExternalForm()));
}
return response;
}
@@ -313,10 +298,9 @@ public int getConnectTimeout() {
@Override
public void setConnectTimeout(int connectTimeout) {
- connectionConfig =
- RequestConfig.copy(connectionConfig)
- .setConnectionRequestTimeout((int) ofSeconds(connectTimeout).toMillis())
- .build();
+ connectionConfig = RequestConfig.copy(connectionConfig)
+ .setConnectionRequestTimeout((int) ofSeconds(connectTimeout).toMillis())
+ .build();
}
@Override
@@ -326,10 +310,9 @@ public int getReadTimeout() {
@Override
public void setReadTimeout(int readTimeout) {
- connectionConfig =
- RequestConfig.copy(connectionConfig)
- .setSocketTimeout((int) ofSeconds(readTimeout).toMillis())
- .build();
+ connectionConfig = RequestConfig.copy(connectionConfig)
+ .setSocketTimeout((int) ofSeconds(readTimeout).toMillis())
+ .build();
}
@Override
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/geotools/SpringEnvironmentAwareGeoToolsHttpClientFactory.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/geotools/SpringEnvironmentAwareGeoToolsHttpClientFactory.java
index fe71f5e34..df36b5a44 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/geotools/SpringEnvironmentAwareGeoToolsHttpClientFactory.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/geotools/SpringEnvironmentAwareGeoToolsHttpClientFactory.java
@@ -4,15 +4,13 @@
*/
package org.geoserver.cloud.autoconfigure.geotools;
+import java.util.List;
import lombok.AccessLevel;
import lombok.Setter;
-
import org.geotools.http.AbstractHTTPClientFactory;
import org.geotools.http.HTTPBehavior;
import org.geotools.http.HTTPClient;
-import java.util.List;
-
/** */
public class SpringEnvironmentAwareGeoToolsHttpClientFactory extends AbstractHTTPClientFactory {
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/metrics/catalog/CatalogMetrics.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/metrics/catalog/CatalogMetrics.java
index 7a76d7b6a..9c5a6a720 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/metrics/catalog/CatalogMetrics.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/metrics/catalog/CatalogMetrics.java
@@ -7,18 +7,15 @@
import io.micrometer.core.instrument.Gauge;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.binder.MeterBinder;
-
+import java.util.function.Supplier;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.catalog.Catalog;
import org.geoserver.config.GeoServer;
import org.geoserver.config.GeoServerInfo;
import org.geoserver.platform.config.UpdateSequence;
-import java.util.function.Supplier;
-
/**
* Registers GeoServer {@link Catalog catalog} and {@link GeoServer config} metrics to be exported
* by micrometer's {@link MeterRegistry}.
@@ -71,28 +68,25 @@ public void bindTo(@NonNull MeterRegistry registry) {
}
}
- private void registerObservedUpdateSequence(
- MeterRegistry registry, final String instanceIdTag) {
+ private void registerObservedUpdateSequence(MeterRegistry registry, final String instanceIdTag) {
Supplier updateSequence = () -> config.getGlobal().getUpdateSequence();
- Gauge.Builder> updateSeqBuilder =
- Gauge.builder("geoserver.config.update_sequence", updateSequence)
- .description("GeoServer configuration update sequence")
- .baseUnit("sequence");
+ Gauge.Builder> updateSeqBuilder = Gauge.builder(
+ "geoserver.config.update_sequence", updateSequence)
+ .description("GeoServer configuration update sequence")
+ .baseUnit("sequence");
- if (null != instanceIdTag)
- updateSeqBuilder = updateSeqBuilder.tag("instance-id", instanceIdTag);
+ if (null != instanceIdTag) updateSeqBuilder = updateSeqBuilder.tag("instance-id", instanceIdTag);
updateSeqBuilder.register(registry);
}
private void registerUpdateSequence(MeterRegistry registry, final String instanceIdTag) {
Supplier updateSequence = realUpdateSequence::currValue;
- Gauge.Builder> updateSeqBuilder =
- Gauge.builder("geoserver.config.update_sequence.real", updateSequence)
- .description("Cluster-wide, canonical update sequence value")
- .baseUnit("sequence");
+ Gauge.Builder> updateSeqBuilder = Gauge.builder(
+ "geoserver.config.update_sequence.real", updateSequence)
+ .description("Cluster-wide, canonical update sequence value")
+ .baseUnit("sequence");
- if (null != instanceIdTag)
- updateSeqBuilder = updateSeqBuilder.tag("instance-id", instanceIdTag);
+ if (null != instanceIdTag) updateSeqBuilder = updateSeqBuilder.tag("instance-id", instanceIdTag);
updateSeqBuilder.register(registry);
}
}
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/metrics/catalog/CatalogMetricsAutoConfiguration.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/metrics/catalog/CatalogMetricsAutoConfiguration.java
index 5e1c80c9f..4ff109539 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/metrics/catalog/CatalogMetricsAutoConfiguration.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/metrics/catalog/CatalogMetricsAutoConfiguration.java
@@ -5,9 +5,7 @@
package org.geoserver.cloud.autoconfigure.metrics.catalog;
import io.micrometer.core.annotation.Timed;
-
import lombok.NonNull;
-
import org.geoserver.catalog.Catalog;
import org.geoserver.config.GeoServer;
import org.geoserver.platform.config.UpdateSequence;
@@ -27,8 +25,7 @@
* @see CatalogMetrics
* @since 1.0
*/
-@AutoConfiguration(
- after = {MetricsAutoConfiguration.class, CompositeMeterRegistryAutoConfiguration.class})
+@AutoConfiguration(after = {MetricsAutoConfiguration.class, CompositeMeterRegistryAutoConfiguration.class})
@ConditionalOnClass(Timed.class)
@ConditionalOnGeoServerMetricsEnabled
@EnableConfigurationProperties(GeoSeverMetricsConfigProperties.class)
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/metrics/catalog/ConditionalOnGeoServerMetricsEnabled.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/metrics/catalog/ConditionalOnGeoServerMetricsEnabled.java
index 89846ac49..c3f9af50d 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/metrics/catalog/ConditionalOnGeoServerMetricsEnabled.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/metrics/catalog/ConditionalOnGeoServerMetricsEnabled.java
@@ -6,16 +6,14 @@
import io.micrometer.core.annotation.Timed;
import io.micrometer.core.instrument.MeterRegistry;
-
-import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
-
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
/**
* Groups conditions that shall be met to enable geoserver metrics
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/metrics/catalog/GeoSeverMetricsConfigProperties.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/metrics/catalog/GeoSeverMetricsConfigProperties.java
index f8ae5566f..1afa52a40 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/metrics/catalog/GeoSeverMetricsConfigProperties.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/metrics/catalog/GeoSeverMetricsConfigProperties.java
@@ -6,7 +6,6 @@
package org.geoserver.cloud.autoconfigure.metrics.catalog;
import lombok.Data;
-
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/metrics/catalog/MetricsCatalogListener.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/metrics/catalog/MetricsCatalogListener.java
index d7439ec96..bad57ecc1 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/metrics/catalog/MetricsCatalogListener.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/metrics/catalog/MetricsCatalogListener.java
@@ -8,9 +8,8 @@
import io.micrometer.core.instrument.Counter.Builder;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.binder.BaseUnits;
-
+import javax.annotation.Nullable;
import lombok.NonNull;
-
import org.geoserver.catalog.CatalogException;
import org.geoserver.catalog.event.CatalogAddEvent;
import org.geoserver.catalog.event.CatalogListener;
@@ -18,8 +17,6 @@
import org.geoserver.catalog.event.CatalogPostModifyEvent;
import org.geoserver.catalog.event.CatalogRemoveEvent;
-import javax.annotation.Nullable;
-
class MetricsCatalogListener implements CatalogListener {
private final Counter added;
@@ -29,33 +26,25 @@ class MetricsCatalogListener implements CatalogListener {
public MetricsCatalogListener(@NonNull MeterRegistry registry, @Nullable String instanceId) {
- added =
- counter("geoserver.catalog.added", instanceId)
- .description(
- "Number of CatalogInfo objects added to this instance's Catalog")
- .register(registry);
- removed =
- counter("geoserver.catalog.removed", instanceId)
- .description(
- "Number of CatalogInfo objects removed on this instance's Catalog")
- .register(registry);
- modified =
- counter("geoserver.catalog.modified", instanceId)
- .description(
- "Number of modifications to CatalogInfo objects on this instance's Catalog")
- .register(registry);
+ added = counter("geoserver.catalog.added", instanceId)
+ .description("Number of CatalogInfo objects added to this instance's Catalog")
+ .register(registry);
+ removed = counter("geoserver.catalog.removed", instanceId)
+ .description("Number of CatalogInfo objects removed on this instance's Catalog")
+ .register(registry);
+ modified = counter("geoserver.catalog.modified", instanceId)
+ .description("Number of modifications to CatalogInfo objects on this instance's Catalog")
+ .register(registry);
- reloads =
- Counter.builder("geoserver.catalog.reloads")
- .description("Times the Catalog has been reloaded")
- .baseUnit(BaseUnits.OPERATIONS)
- .register(registry);
+ reloads = Counter.builder("geoserver.catalog.reloads")
+ .description("Times the Catalog has been reloaded")
+ .baseUnit(BaseUnits.OPERATIONS)
+ .register(registry);
}
private Counter.Builder counter(String name, String instanceId) {
- Builder builder =
- Counter.builder(name) //
- .baseUnit(BaseUnits.OPERATIONS);
+ Builder builder = Counter.builder(name) //
+ .baseUnit(BaseUnits.OPERATIONS);
if (null != instanceId) builder = builder.tag("instance-id", instanceId);
return builder;
}
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/security/ConditionalOnGeoServerSecurityDisabled.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/security/ConditionalOnGeoServerSecurityDisabled.java
index 11308c208..f67618497 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/security/ConditionalOnGeoServerSecurityDisabled.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/security/ConditionalOnGeoServerSecurityDisabled.java
@@ -4,20 +4,15 @@
*/
package org.geoserver.cloud.autoconfigure.security;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@Documented
-@ConditionalOnProperty(
- prefix = "geoserver.security",
- name = "enabled",
- havingValue = "false",
- matchIfMissing = false)
+@ConditionalOnProperty(prefix = "geoserver.security", name = "enabled", havingValue = "false", matchIfMissing = false)
public @interface ConditionalOnGeoServerSecurityDisabled {}
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/security/ConditionalOnGeoServerSecurityEnabled.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/security/ConditionalOnGeoServerSecurityEnabled.java
index 7c9442841..aed19cc8e 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/security/ConditionalOnGeoServerSecurityEnabled.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/security/ConditionalOnGeoServerSecurityEnabled.java
@@ -4,20 +4,15 @@
*/
package org.geoserver.cloud.autoconfigure.security;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@Documented
-@ConditionalOnProperty(
- prefix = "geoserver.security",
- name = "enabled",
- havingValue = "true",
- matchIfMissing = true)
+@ConditionalOnProperty(prefix = "geoserver.security", name = "enabled", havingValue = "true", matchIfMissing = true)
public @interface ConditionalOnGeoServerSecurityEnabled {}
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/security/GeoServerSecurityAutoConfiguration.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/security/GeoServerSecurityAutoConfiguration.java
index 0840a9f18..566980f97 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/security/GeoServerSecurityAutoConfiguration.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/autoconfigure/security/GeoServerSecurityAutoConfiguration.java
@@ -4,8 +4,8 @@
*/
package org.geoserver.cloud.autoconfigure.security;
+import javax.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.cloud.autoconfigure.catalog.backend.core.GeoServerBackendAutoConfiguration;
import org.geoserver.cloud.event.security.SecurityConfigChanged;
import org.geoserver.cloud.security.GeoServerSecurityConfiguration;
@@ -18,13 +18,8 @@
import org.springframework.context.annotation.Import;
import org.springframework.context.event.EventListener;
-import javax.annotation.PostConstruct;
-
@AutoConfiguration(after = GeoServerBackendAutoConfiguration.class)
-@Import({
- GeoServerSecurityAutoConfiguration.WhenEnabled.class,
- GeoServerSecurityAutoConfiguration.WhenDisabled.class
-})
+@Import({GeoServerSecurityAutoConfiguration.WhenEnabled.class, GeoServerSecurityAutoConfiguration.WhenDisabled.class})
@Slf4j(topic = "org.geoserver.cloud.autoconfigure.security")
public class GeoServerSecurityAutoConfiguration {
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/config/catalog/backend/core/CatalogProperties.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/config/catalog/backend/core/CatalogProperties.java
index 92f5a14c6..8a8cd5bc7 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/config/catalog/backend/core/CatalogProperties.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/config/catalog/backend/core/CatalogProperties.java
@@ -5,7 +5,6 @@
package org.geoserver.cloud.config.catalog.backend.core;
import lombok.Data;
-
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "geoserver.catalog")
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/config/catalog/backend/core/CoreBackendConfiguration.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/config/catalog/backend/core/CoreBackendConfiguration.java
index fbe321df0..f2683f504 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/config/catalog/backend/core/CoreBackendConfiguration.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/config/catalog/backend/core/CoreBackendConfiguration.java
@@ -5,7 +5,6 @@
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;
@@ -82,8 +81,7 @@ CatalogPlugin rawCatalog(
@DependsOn({"extensions", "dataDirectory", "accessRulesDao"})
@ConditionalOnGeoServerSecurityEnabled
@Bean
- Catalog secureCatalog(@Qualifier("rawCatalog") Catalog rawCatalog, CatalogProperties properties)
- throws Exception {
+ Catalog secureCatalog(@Qualifier("rawCatalog") Catalog rawCatalog, CatalogProperties properties) throws Exception {
if (properties.isSecure()) return new SecureCatalogImpl(rawCatalog);
return rawCatalog;
}
@@ -108,8 +106,7 @@ DefaultResourceAccessManager defaultResourceAccessManager( //
@Qualifier("rawCatalog") Catalog rawCatalog,
LayerGroupContainmentCache layerGroupContainmentCache) {
- DefaultResourceAccessManager accessManager =
- new DefaultResourceAccessManager(dao, rawCatalog);
+ DefaultResourceAccessManager accessManager = new DefaultResourceAccessManager(dao, rawCatalog);
accessManager.setGroupsCache(layerGroupContainmentCache);
return accessManager;
}
@@ -126,8 +123,7 @@ DefaultResourceAccessManager defaultResourceAccessManager( //
name = "geoserver.security.layergroup-containmentcache",
havingValue = "true",
matchIfMissing = false)
- LayerGroupContainmentCache enabledLayerGroupContainmentCache(
- @Qualifier("rawCatalog") Catalog rawCatalog) {
+ LayerGroupContainmentCache enabledLayerGroupContainmentCache(@Qualifier("rawCatalog") Catalog rawCatalog) {
log.info("using {}", GsCloudLayerGroupContainmentCache.class.getSimpleName());
return new GsCloudLayerGroupContainmentCache(rawCatalog);
@@ -162,8 +158,7 @@ Catalog secureCatalogDisabled(@Qualifier("rawCatalog") Catalog rawCatalog) {
* {@code secureCatalog} otherwise.
*/
@Bean
- Catalog advertisedCatalog(
- @Qualifier("secureCatalog") Catalog secureCatalog, CatalogProperties properties) {
+ Catalog advertisedCatalog(@Qualifier("secureCatalog") Catalog secureCatalog, CatalogProperties properties) {
if (properties.isAdvertised()) {
AdvertisedCatalog advertisedCatalog = new AdvertisedCatalog(secureCatalog);
advertisedCatalog.setLayerGroupVisibilityPolicy(LayerGroupVisibilityPolicy.HIDE_NEVER);
@@ -178,18 +173,14 @@ Catalog advertisedCatalog(
*/
@Bean(name = {"catalog", "localWorkspaceCatalog"})
Catalog localWorkspaceCatalog(
- @Qualifier("advertisedCatalog") Catalog advertisedCatalog,
- CatalogProperties properties) {
- return properties.isLocalWorkspace()
- ? new LocalWorkspaceCatalog(advertisedCatalog)
- : advertisedCatalog;
+ @Qualifier("advertisedCatalog") Catalog advertisedCatalog, CatalogProperties properties) {
+ return properties.isLocalWorkspace() ? new LocalWorkspaceCatalog(advertisedCatalog) : advertisedCatalog;
}
@ConditionalOnMissingBean(GeoServerImpl.class)
@Bean(name = "geoServer")
GeoServerImpl geoServer(
- @Qualifier("catalog") Catalog catalog,
- @Qualifier("geoserverFacade") GeoServerFacade facade) {
+ @Qualifier("catalog") Catalog catalog, @Qualifier("geoserverFacade") GeoServerFacade facade) {
GeoServerImpl gs = new GeoServerImpl(facade);
gs.setCatalog(catalog);
return gs;
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/event/remote/lifecycle/LifecycleEventProcessor.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/event/remote/lifecycle/LifecycleEventProcessor.java
index 95daeacf3..33e6f92ff 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/event/remote/lifecycle/LifecycleEventProcessor.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/event/remote/lifecycle/LifecycleEventProcessor.java
@@ -5,7 +5,6 @@
package org.geoserver.cloud.event.remote.lifecycle;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.cloud.config.catalog.events.CatalogApplicationEventPublisher;
import org.geoserver.cloud.event.GeoServerEvent;
import org.geoserver.cloud.event.lifecycle.ReloadEvent;
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/event/remote/resourcepool/RemoteEventResourcePoolProcessor.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/event/remote/resourcepool/RemoteEventResourcePoolProcessor.java
index fd87aa1bb..85ffac686 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/event/remote/resourcepool/RemoteEventResourcePoolProcessor.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/event/remote/resourcepool/RemoteEventResourcePoolProcessor.java
@@ -6,8 +6,8 @@
import static java.util.Optional.ofNullable;
+import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.CatalogInfo;
import org.geoserver.catalog.ResourceInfo;
@@ -24,8 +24,6 @@
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
-import java.util.Optional;
-
/**
* Cleans up cached {@link ResourcePool} entries upon remote {@link CatalogInfoAdded}s, {@link
* CatalogInfoModified}s, and {@link CatalogInfoRemoved}s.
@@ -58,18 +56,14 @@ public void onCatalogRemoteAddEvent(CatalogInfoAdded event) {
@Order(Ordered.HIGHEST_PRECEDENCE)
public void onCatalogRemoteRemoveEvent(CatalogInfoRemoved event) {
event.remote()
- .ifPresentOrElse(
- this::evictFromResourcePool,
- () -> log.trace("Ignoring event from self: {}", event));
+ .ifPresentOrElse(this::evictFromResourcePool, () -> log.trace("Ignoring event from self: {}", event));
}
@EventListener(CatalogInfoModified.class)
@Order(Ordered.HIGHEST_PRECEDENCE)
public void onCatalogRemoteModifyEvent(CatalogInfoModified event) {
event.remote()
- .ifPresentOrElse(
- this::evictFromResourcePool,
- () -> log.trace("Ignoring event from self: {}", event));
+ .ifPresentOrElse(this::evictFromResourcePool, () -> log.trace("Ignoring event from self: {}", event));
}
private void evictFromResourcePool(InfoEvent event) {
@@ -99,10 +93,6 @@ private void evictFromResourcePool(InfoEvent event) {
CacheClearingListener cleaner = new CacheClearingListener(resourcePool);
object.accept(cleaner);
}, //
- () ->
- log.debug(
- "{}({}) not found, unable to clean up its ResourcePool cache entry",
- infoType,
- id));
+ () -> log.debug("{}({}) not found, unable to clean up its ResourcePool cache entry", infoType, id));
}
}
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/security/CloudGeoServerSecurityManager.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/security/CloudGeoServerSecurityManager.java
index cdcfe28bd..a11ed176d 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/security/CloudGeoServerSecurityManager.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/security/CloudGeoServerSecurityManager.java
@@ -4,9 +4,14 @@
*/
package org.geoserver.cloud.security;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.cloud.event.security.SecurityConfigChanged;
import org.geoserver.config.GeoServerDataDirectory;
import org.geoserver.security.GeoServerSecurityManager;
@@ -22,13 +27,6 @@
import org.springframework.context.event.EventListener;
import org.springframework.security.authentication.AuthenticationProvider;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.function.Consumer;
-import java.util.function.Supplier;
-
/**
* Extends {@link GeoServerSecurityManager} to {@link #fireRemoteChangedEvent(String) notify} other
* services of changes to the security configuration happened on the currently running service, and
@@ -91,9 +89,7 @@ public void onRemoteSecurityConfigChangeEvent(SecurityConfigChanged event) {
return;
}
if (!isInitialized()) {
- log.info(
- "Ignoring security config change event, security subsystem not yet initialized: {}",
- event);
+ log.info("Ignoring security config change event, security subsystem not yet initialized: {}", event);
return;
}
log.info("Reloading security configuration due to change event: {}", event);
@@ -113,16 +109,14 @@ public void fireRemoteChangedEvent(@NonNull String reason) {
/** Override to {@link #fireChanged fire} a remote {@link SecurityConfigChanged} */
@Override
- public void saveRoleService(SecurityRoleServiceConfig config)
- throws IOException, SecurityConfigException {
+ public void saveRoleService(SecurityRoleServiceConfig config) throws IOException, SecurityConfigException {
super.saveRoleService(config);
fireRemoteChangedEvent("SecurityRoleServiceConfig changed");
}
/** Override to {@link #fireChanged fire} a remote {@link SecurityConfigChanged} */
@Override
- public void savePasswordPolicy(PasswordPolicyConfig config)
- throws IOException, SecurityConfigException {
+ public void savePasswordPolicy(PasswordPolicyConfig config) throws IOException, SecurityConfigException {
super.savePasswordPolicy(config);
fireRemoteChangedEvent("PasswordPolicyConfig changed");
}
@@ -145,8 +139,7 @@ public void saveAuthenticationProvider(SecurityAuthProviderConfig config)
/** Override to {@link #fireChanged fire} a remote {@link SecurityConfigChanged} */
@Override
- public void saveFilter(SecurityNamedServiceConfig config)
- throws IOException, SecurityConfigException {
+ public void saveFilter(SecurityNamedServiceConfig config) throws IOException, SecurityConfigException {
super.saveFilter(config);
fireRemoteChangedEvent("SecurityNamedServiceConfig changed");
}
@@ -161,10 +154,7 @@ public synchronized void saveSecurityConfig(SecurityManagerConfig config) throws
/** Override to {@link #fireChanged fire} a remote {@link SecurityConfigChanged} */
@Override
public synchronized void saveMasterPasswordConfig(
- MasterPasswordConfig config,
- char[] currPasswd,
- char[] newPasswd,
- char[] newPasswdConfirm)
+ MasterPasswordConfig config, char[] currPasswd, char[] newPasswd, char[] newPasswdConfirm)
throws Exception {
super.saveMasterPasswordConfig(config, currPasswd, newPasswd, newPasswdConfirm);
fireRemoteChangedEvent("MasterPasswordConfig changed");
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/security/EnvironmentAdminAuthenticationProvider.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/security/EnvironmentAdminAuthenticationProvider.java
index 2e83c11da..de2869d6d 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/security/EnvironmentAdminAuthenticationProvider.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/security/EnvironmentAdminAuthenticationProvider.java
@@ -6,8 +6,9 @@
import static org.springframework.util.StringUtils.hasText;
+import java.util.List;
+import javax.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.security.impl.GeoServerRole;
import org.geoserver.security.impl.GeoServerUser;
import org.springframework.beans.BeanInstantiationException;
@@ -23,10 +24,6 @@
import org.springframework.security.core.GrantedAuthority;
import org.springframework.util.StringUtils;
-import java.util.List;
-
-import javax.annotation.PostConstruct;
-
/**
* {@link AuthenticationProvider} that allows to set an administrator account (username and
* password) through {@link Environment} properties {@code ${geoserver.admin.username:admin}} and
@@ -90,10 +87,7 @@ void validateConfig() {
}
public static List adminRoles() {
- return List.of(
- new GeoServerRole("ADMIN"),
- GeoServerRole.ADMIN_ROLE,
- GeoServerRole.AUTHENTICATED_ROLE);
+ return List.of(new GeoServerRole("ADMIN"), GeoServerRole.ADMIN_ROLE, GeoServerRole.AUTHENTICATED_ROLE);
}
@Override
@@ -138,14 +132,12 @@ public Authentication authenticate(Authentication token) throws AuthenticationEx
if (expectedPassword.equals(pwd)) {
List adminRoles = adminRoles();
UsernamePasswordAuthenticationToken authenticated =
- UsernamePasswordAuthenticationToken.authenticated(
- expectedName, null, adminRoles);
+ UsernamePasswordAuthenticationToken.authenticated(expectedName, null, adminRoles);
authenticated.setDetails(token.getDetails());
return authenticated;
}
// this breaks the cycle through other providers, as opposed to
// BadCredentialsException
- throw new InternalAuthenticationServiceException(
- "Bad credentials for: %s".formatted(token.getPrincipal()));
+ throw new InternalAuthenticationServiceException("Bad credentials for: %s".formatted(token.getPrincipal()));
}
}
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/security/GeoServerSecurityConfiguration.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/security/GeoServerSecurityConfiguration.java
index 7a4dc206b..7641b16c7 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/security/GeoServerSecurityConfiguration.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/security/GeoServerSecurityConfiguration.java
@@ -4,8 +4,11 @@
*/
package org.geoserver.cloud.security;
+import java.util.List;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+import javax.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.cloud.autoconfigure.security.ConditionalOnGeoServerSecurityEnabled;
import org.geoserver.cloud.config.factory.FilteringXmlBeanDefinitionReader;
import org.geoserver.cloud.event.security.SecurityConfigChanged;
@@ -21,12 +24,6 @@
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.ImportResource;
-import java.util.List;
-import java.util.function.Consumer;
-import java.util.function.Supplier;
-
-import javax.annotation.PostConstruct;
-
/**
* Loads geoserver security bean definitions from {@code
* classpath*:/applicationSecurityContext.xml}.
@@ -58,8 +55,7 @@ public class GeoServerSecurityConfiguration {
private @Value("${geoserver.security.enabled:#{null}}") Boolean enabled;
public @PostConstruct void log() {
- log.info(
- "GeoServer security being configured through classpath*:/applicationSecurityContext.xml");
+ log.info("GeoServer security being configured through classpath*:/applicationSecurityContext.xml");
}
@Bean
@@ -87,7 +83,6 @@ CloudGeoServerSecurityManager cloudAuthenticationManager( //
Consumer publisher = localContextPublisher::publishEvent;
Supplier updateSequenceIncrementor = updateSequence::nextValue;
- return new CloudGeoServerSecurityManager(
- dataDir, publisher, updateSequenceIncrementor, List.of(envAuth));
+ return new CloudGeoServerSecurityManager(dataDir, publisher, updateSequenceIncrementor, List.of(envAuth));
}
}
diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/security/impl/GsCloudLayerGroupContainmentCache.java b/src/catalog/backends/common/src/main/java/org/geoserver/security/impl/GsCloudLayerGroupContainmentCache.java
index cbb06a4d8..56afdb6bb 100644
--- a/src/catalog/backends/common/src/main/java/org/geoserver/security/impl/GsCloudLayerGroupContainmentCache.java
+++ b/src/catalog/backends/common/src/main/java/org/geoserver/security/impl/GsCloudLayerGroupContainmentCache.java
@@ -6,10 +6,16 @@
import com.google.common.base.Stopwatch;
import com.google.common.collect.Maps;
-
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.CatalogException;
import org.geoserver.catalog.CatalogInfo;
@@ -33,15 +39,6 @@
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.web.context.WebApplicationContext;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.concurrent.CompletableFuture;
-
/**
* Alternative to {@link LayerGroupContainmentCache}
*
@@ -71,8 +68,7 @@
*/
@Slf4j
@SuppressWarnings({"java:S2177", "java:S6201", "java:S3776", "java:S3398"})
-public class GsCloudLayerGroupContainmentCache extends LayerGroupContainmentCache
- implements ApplicationContextAware {
+public class GsCloudLayerGroupContainmentCache extends LayerGroupContainmentCache implements ApplicationContextAware {
private Catalog rawCatalog;
private ApplicationContext applicationContext;
@@ -146,7 +142,9 @@ private void doBuildLayerGroupCaches() {
sw,
groupCache.size(),
resourceContainmentCache.size(),
- resourceContainmentCache.values().stream().flatMap(Set::stream).count());
+ resourceContainmentCache.values().stream()
+ .flatMap(Set::stream)
+ .count());
}
private LayerGroupSummary createGroupInfo(LayerGroupInfo group, LayerGroupSummary groupData) {
@@ -162,8 +160,7 @@ private void registerContainedGroups(LayerGroupInfo group, LayerGroupSummary gro
.forEach(p -> registerContainerGroup(groupData, p));
}
- private void registerContainerGroup(
- LayerGroupSummary container, LayerGroupInfo containedGroup) {
+ private void registerContainerGroup(LayerGroupSummary container, LayerGroupInfo containedGroup) {
LayerGroupSummary contained = getGroupData(containedGroup);
if (container != null && contained != null) {
contained.containerGroups.add(container);
@@ -171,10 +168,7 @@ private void registerContainerGroup(
}
private void addGroupInfo(LayerGroupInfo lg, LayerGroupSummary groupData) {
- lg.getLayers().stream()
- .filter(IS_LAYER)
- .map(LayerInfo.class::cast)
- .forEach(p -> addGroupInfo(groupData, p));
+ lg.getLayers().stream().filter(IS_LAYER).map(LayerInfo.class::cast).forEach(p -> addGroupInfo(groupData, p));
}
private void addGroupInfo(LayerGroupSummary groupData, LayerInfo containedLayer) {
@@ -329,7 +323,8 @@ private void handleNameChange(CatalogModifyEvent event, LayerGroupSummary summar
private void handleWorkspaceChange(CatalogModifyEvent event, LayerGroupSummary summary) {
int wsIdx = event.getPropertyNames().indexOf("workspace");
if (wsIdx != -1) {
- WorkspaceInfo newWorkspace = (WorkspaceInfo) event.getNewValues().get(wsIdx);
+ WorkspaceInfo newWorkspace =
+ (WorkspaceInfo) event.getNewValues().get(wsIdx);
summary.workspace = newWorkspace == null ? null : newWorkspace.getName();
}
}
@@ -357,9 +352,7 @@ private void handleModeChange(CatalogModifyEvent event, LayerGroupSummary summar
}
private void updateContainedLayers(
- @NonNull LayerGroupSummary groupSummary,
- List oldLayers,
- List newLayers) {
+ @NonNull LayerGroupSummary groupSummary, List oldLayers, List newLayers) {
// do not rely on PublishedInfo.equals()...
var difference = Maps.difference(toIdMap(oldLayers), toIdMap(newLayers));
diff --git a/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/core/LifecycleEventAutoConfigurationTest.java b/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/core/LifecycleEventAutoConfigurationTest.java
index 893bcb287..aef51a25f 100644
--- a/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/core/LifecycleEventAutoConfigurationTest.java
+++ b/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/core/LifecycleEventAutoConfigurationTest.java
@@ -15,25 +15,18 @@
class LifecycleEventAutoConfigurationTest {
- private final ApplicationContextRunner runner =
- new ApplicationContextRunner()
- .withBean("geoServer", GeoServerImpl.class)
- .withConfiguration(
- AutoConfigurations.of(LifecycleEventAutoConfiguration.class));
+ private final ApplicationContextRunner runner = new ApplicationContextRunner()
+ .withBean("geoServer", GeoServerImpl.class)
+ .withConfiguration(AutoConfigurations.of(LifecycleEventAutoConfiguration.class));
@Test
void testDefaultAppContextContributions() {
- runner.run(
- context -> assertThat(context).hasNotFailed().hasBean("lifecycleEventProcessor"));
+ runner.run(context -> assertThat(context).hasNotFailed().hasBean("lifecycleEventProcessor"));
}
@Test
void whenDependentClassesAreNotPresent_thenBeanMissing() {
runner.withClassLoader(new FilteredClassLoader(LifecycleEvent.class))
- .run(
- context ->
- assertThat(context)
- .hasNotFailed()
- .doesNotHaveBean("lifecycleEventProcessor"));
+ .run(context -> assertThat(context).hasNotFailed().doesNotHaveBean("lifecycleEventProcessor"));
}
}
diff --git a/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/core/RemoteEventResourcePoolCleanupUpAutoConfigurationTest.java b/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/core/RemoteEventResourcePoolCleanupUpAutoConfigurationTest.java
index 2d0c8eddf..359e478b4 100644
--- a/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/core/RemoteEventResourcePoolCleanupUpAutoConfigurationTest.java
+++ b/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/core/RemoteEventResourcePoolCleanupUpAutoConfigurationTest.java
@@ -15,29 +15,18 @@
class RemoteEventResourcePoolCleanupUpAutoConfigurationTest {
- private final ApplicationContextRunner runner =
- new ApplicationContextRunner()
- .withBean("rawCatalog", CatalogPlugin.class)
- .withConfiguration(
- AutoConfigurations.of(
- RemoteEventResourcePoolCleanupUpAutoConfiguration.class));
+ private final ApplicationContextRunner runner = new ApplicationContextRunner()
+ .withBean("rawCatalog", CatalogPlugin.class)
+ .withConfiguration(AutoConfigurations.of(RemoteEventResourcePoolCleanupUpAutoConfiguration.class));
@Test
void testDefaultAppContextContributions() {
- runner.run(
- context ->
- assertThat(context)
- .hasNotFailed()
- .hasBean("remoteEventResourcePoolProcessor"));
+ runner.run(context -> assertThat(context).hasNotFailed().hasBean("remoteEventResourcePoolProcessor"));
}
@Test
void whenDependentClassesAreNotPresent_thenBeanMissing() {
runner.withClassLoader(new FilteredClassLoader(InfoEvent.class))
- .run(
- context ->
- assertThat(context)
- .hasNotFailed()
- .doesNotHaveBean("remoteEventResourcePoolProcessor"));
+ .run(context -> assertThat(context).hasNotFailed().doesNotHaveBean("remoteEventResourcePoolProcessor"));
}
}
diff --git a/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/geotools/GeoToolsHttpClientAutoConfigurationTest.java b/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/geotools/GeoToolsHttpClientAutoConfigurationTest.java
index 6d209911c..e175c72c6 100644
--- a/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/geotools/GeoToolsHttpClientAutoConfigurationTest.java
+++ b/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/geotools/GeoToolsHttpClientAutoConfigurationTest.java
@@ -20,11 +20,9 @@
*/
class GeoToolsHttpClientAutoConfigurationTest {
- private WebApplicationContextRunner runner =
- new WebApplicationContextRunner() //
- .withInitializer(new GeoToolsStaticContextInitializer()) //
- .withConfiguration(
- AutoConfigurations.of(GeoToolsHttpClientAutoConfiguration.class));
+ private WebApplicationContextRunner runner = new WebApplicationContextRunner() //
+ .withInitializer(new GeoToolsStaticContextInitializer()) //
+ .withConfiguration(AutoConfigurations.of(GeoToolsHttpClientAutoConfiguration.class));
private final String forceXYSystemProperty = "org.geotools.referencing.forceXY";
@@ -36,27 +34,22 @@ void clearSystemPropertiesAndGeoToolsHints() {
@Test
void enabledByDefault() {
- runner.run(
- context -> {
- assertThat(context)
- .hasSingleBean(GeoToolsHttpClientProxyConfigurationProperties.class);
- assertThat(context)
- .hasSingleBean(SpringEnvironmentAwareGeoToolsHttpClientFactory.class);
- assertThat(
- context.getBean(
- GeoToolsHttpClientProxyConfigurationProperties.class))
- .hasFieldOrPropertyWithValue("enabled", true);
+ runner.run(context -> {
+ assertThat(context).hasSingleBean(GeoToolsHttpClientProxyConfigurationProperties.class);
+ assertThat(context).hasSingleBean(SpringEnvironmentAwareGeoToolsHttpClientFactory.class);
+ assertThat(context.getBean(GeoToolsHttpClientProxyConfigurationProperties.class))
+ .hasFieldOrPropertyWithValue("enabled", true);
- HTTPClient client = HTTPClientFinder.createClient();
- assertThat(client)
- .as(
- """
+ HTTPClient client = HTTPClientFinder.createClient();
+ assertThat(client)
+ .as(
+ """
Expected SpringEnvironmentAwareGeoToolsHttpClient \
after GeoToolsStaticContextInitializer sets \
SpringEnvironmentAwareGeoToolsHttpClientFactory as the default factory
""")
- .isInstanceOf(SpringEnvironmentAwareGeoToolsHttpClient.class);
- });
+ .isInstanceOf(SpringEnvironmentAwareGeoToolsHttpClient.class);
+ });
}
@Test
@@ -71,23 +64,17 @@ void testInitializerSetsHttpClientFactorySystemProperty() {
final var expected = SpringEnvironmentAwareGeoToolsHttpClientFactory.class;
assertNull(Hints.getSystemDefault(Hints.HTTP_CLIENT_FACTORY));
- runner.run(
- context ->
- assertThat(Hints.getSystemDefault(Hints.HTTP_CLIENT_FACTORY))
- .isEqualTo(expected));
+ runner.run(context ->
+ assertThat(Hints.getSystemDefault(Hints.HTTP_CLIENT_FACTORY)).isEqualTo(expected));
Hints.removeSystemDefault(Hints.HTTP_CLIENT_FACTORY);
runner.withPropertyValues("geotools.httpclient.proxy.enabled: true")
- .run(
- context ->
- assertThat(Hints.getSystemDefault(Hints.HTTP_CLIENT_FACTORY))
- .isEqualTo(expected));
+ .run(context -> assertThat(Hints.getSystemDefault(Hints.HTTP_CLIENT_FACTORY))
+ .isEqualTo(expected));
Hints.removeSystemDefault(Hints.HTTP_CLIENT_FACTORY);
runner.withPropertyValues("geotools.httpclient.proxy.enabled: false")
- .run(
- context ->
- assertThat(Hints.getSystemDefault(Hints.HTTP_CLIENT_FACTORY))
- .isNull());
+ .run(context -> assertThat(Hints.getSystemDefault(Hints.HTTP_CLIENT_FACTORY))
+ .isNull());
}
}
diff --git a/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/security/EnvironmentAdminAuthenticationProviderTest.java b/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/security/EnvironmentAdminAuthenticationProviderTest.java
index 020ca0bbb..4559b2bd3 100644
--- a/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/security/EnvironmentAdminAuthenticationProviderTest.java
+++ b/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/security/EnvironmentAdminAuthenticationProviderTest.java
@@ -7,6 +7,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import java.io.File;
import org.geoserver.cloud.security.EnvironmentAdminAuthenticationProvider;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
@@ -19,8 +20,6 @@
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
-import java.io.File;
-
/**
* {@link EnableAutoConfiguration @EnableAutoConfiguration} tests for {@link
* GeoServerSecurityAutoConfiguration}'s {@link EnvironmentAdminAuthenticationProvider}
@@ -29,7 +28,8 @@
*/
class EnvironmentAdminAuthenticationProviderTest {
- @TempDir File tempDir;
+ @TempDir
+ File tempDir;
private ApplicationContextRunner runner;
@@ -39,147 +39,122 @@ void setUp() {
}
@Test
- @DisplayName(
- "When username is set and password is not set Then FAILS to load the application context")
+ @DisplayName("When username is set and password is not set Then FAILS to load the application context")
void fails_if_password_not_set() {
runner.withPropertyValues(
// USERNAME SET
"geoserver.admin.username=myAdmin",
// PASSWORD NOT SET
"geoserver.admin.password=")
- .run(
- context -> {
- assertThat(context)
- .hasFailed()
- .getFailure()
- .hasMessageContaining(
- "password not provided through config property geoserver.admin.password");
- });
+ .run(context -> {
+ assertThat(context)
+ .hasFailed()
+ .getFailure()
+ .hasMessageContaining(
+ "password not provided through config property geoserver.admin.password");
+ });
}
@Test
- @DisplayName(
- "When password is set and username is not set Then FAILS to load the application context")
+ @DisplayName("When password is set and username is not set Then FAILS to load the application context")
void fails_if_username_not_set() {
runner.withPropertyValues(
// USERNAME NOT SET
"geoserver.admin.username=",
// PASSWORD SET
"geoserver.admin.password=s3cr3t")
- .run(
- context -> {
- assertThat(context)
- .hasFailed()
- .getFailure()
- .hasMessageContaining(
- "admin username not provided through config property geoserver.admin.username");
- });
+ .run(context -> {
+ assertThat(context)
+ .hasFailed()
+ .getFailure()
+ .hasMessageContaining(
+ "admin username not provided through config property geoserver.admin.username");
+ });
}
// success case with default admin user
@Test
- @DisplayName(
- "When using default admin username and password matches Then returns an authenticated token")
+ @DisplayName("When using default admin username and password matches Then returns an authenticated token")
void default_admin_and_password_matches() {
- runner.withPropertyValues(
- "geoserver.admin.username=admin", "geoserver.admin.password=s3cr3t")
- .run(
- context -> {
- assertThat(context).hasNotFailed();
- Authentication token = userNamePasswordToken("admin", "s3cr3t");
- Authentication authenticated =
- envAuthProvider(context).authenticate(token);
- assertThat(authenticated)
- .isInstanceOf(UsernamePasswordAuthenticationToken.class)
- .isNotSameAs(token);
-
- assertThat(authenticated)
- .as("should return a fully authenticated token")
- .hasFieldOrPropertyWithValue("authenticated", true);
-
- assertThat(authenticated)
- .as("should have the expected admin roles")
- .hasFieldOrPropertyWithValue(
- "authorities",
- EnvironmentAdminAuthenticationProvider.adminRoles());
- });
+ runner.withPropertyValues("geoserver.admin.username=admin", "geoserver.admin.password=s3cr3t")
+ .run(context -> {
+ assertThat(context).hasNotFailed();
+ Authentication token = userNamePasswordToken("admin", "s3cr3t");
+ Authentication authenticated = envAuthProvider(context).authenticate(token);
+ assertThat(authenticated)
+ .isInstanceOf(UsernamePasswordAuthenticationToken.class)
+ .isNotSameAs(token);
+
+ assertThat(authenticated)
+ .as("should return a fully authenticated token")
+ .hasFieldOrPropertyWithValue("authenticated", true);
+
+ assertThat(authenticated)
+ .as("should have the expected admin roles")
+ .hasFieldOrPropertyWithValue(
+ "authorities", EnvironmentAdminAuthenticationProvider.adminRoles());
+ });
}
// success case with a non default admin username
@Test
- @DisplayName(
- "When NOT using default admin username and password matches Then returns an authenticated token")
+ @DisplayName("When NOT using default admin username and password matches Then returns an authenticated token")
void non_default_admin_and_password_matches() {
- runner.withPropertyValues(
- "geoserver.admin.username=JohnTheAdmin", "geoserver.admin.password=s3cr3t")
- .run(
- context -> {
- assertThat(context).hasNotFailed();
- Authentication token = userNamePasswordToken("JohnTheAdmin", "s3cr3t");
- Authentication authenticated =
- envAuthProvider(context).authenticate(token);
- assertThat(authenticated)
- .isInstanceOf(UsernamePasswordAuthenticationToken.class)
- .isNotSameAs(token);
-
- assertThat(authenticated)
- .as("should return a fully authenticated token")
- .hasFieldOrPropertyWithValue("authenticated", true);
-
- assertThat(authenticated)
- .as("should have the expected admin roles")
- .hasFieldOrPropertyWithValue(
- "authorities",
- EnvironmentAdminAuthenticationProvider.adminRoles());
- });
+ runner.withPropertyValues("geoserver.admin.username=JohnTheAdmin", "geoserver.admin.password=s3cr3t")
+ .run(context -> {
+ assertThat(context).hasNotFailed();
+ Authentication token = userNamePasswordToken("JohnTheAdmin", "s3cr3t");
+ Authentication authenticated = envAuthProvider(context).authenticate(token);
+ assertThat(authenticated)
+ .isInstanceOf(UsernamePasswordAuthenticationToken.class)
+ .isNotSameAs(token);
+
+ assertThat(authenticated)
+ .as("should return a fully authenticated token")
+ .hasFieldOrPropertyWithValue("authenticated", true);
+
+ assertThat(authenticated)
+ .as("should have the expected admin roles")
+ .hasFieldOrPropertyWithValue(
+ "authorities", EnvironmentAdminAuthenticationProvider.adminRoles());
+ });
}
@Test
- @DisplayName(
- "When using default admin username and password does not match Then breaks the auth chain")
+ @DisplayName("When using default admin username and password does not match Then breaks the auth chain")
void default_admin_bad_credentials() {
- runner.withPropertyValues(
- "geoserver.admin.username=admin", "geoserver.admin.password=s3cr3t")
- .run(
- context -> {
- assertThat(context).hasNotFailed();
- Authentication token = userNamePasswordToken("admin", "badPWD");
- EnvironmentAdminAuthenticationProvider envAuthProvider =
- envAuthProvider(context);
-
- assertThrows(
- InternalAuthenticationServiceException.class,
- () -> envAuthProvider.authenticate(token));
- });
+ runner.withPropertyValues("geoserver.admin.username=admin", "geoserver.admin.password=s3cr3t")
+ .run(context -> {
+ assertThat(context).hasNotFailed();
+ Authentication token = userNamePasswordToken("admin", "badPWD");
+ EnvironmentAdminAuthenticationProvider envAuthProvider = envAuthProvider(context);
+
+ assertThrows(
+ InternalAuthenticationServiceException.class, () -> envAuthProvider.authenticate(token));
+ });
}
@Test
@DisplayName("When not using admin as username Then the default admin username cannot be used")
void if_configured_hides_default_admin() {
- runner.withPropertyValues(
- "geoserver.admin.username=MyCustomAdmin", "geoserver.admin.password=s3cr3t")
- .run(
- context -> {
- assertThat(context).hasNotFailed();
-
- Authentication defaultAdminCredentials =
- userNamePasswordToken("admin", "geoserver");
- EnvironmentAdminAuthenticationProvider authProvider =
- envAuthProvider(context);
- assertThrows(
- InternalAuthenticationServiceException.class,
- () -> authProvider.authenticate(defaultAdminCredentials),
- "The admin user should be disabled if geoserver.admin.username is set to another value");
- });
+ runner.withPropertyValues("geoserver.admin.username=MyCustomAdmin", "geoserver.admin.password=s3cr3t")
+ .run(context -> {
+ assertThat(context).hasNotFailed();
+
+ Authentication defaultAdminCredentials = userNamePasswordToken("admin", "geoserver");
+ EnvironmentAdminAuthenticationProvider authProvider = envAuthProvider(context);
+ assertThrows(
+ InternalAuthenticationServiceException.class,
+ () -> authProvider.authenticate(defaultAdminCredentials),
+ "The admin user should be disabled if geoserver.admin.username is set to another value");
+ });
}
- protected UsernamePasswordAuthenticationToken userNamePasswordToken(
- String principal, String credentials) {
+ protected UsernamePasswordAuthenticationToken userNamePasswordToken(String principal, String credentials) {
return new UsernamePasswordAuthenticationToken(principal, credentials);
}
- protected EnvironmentAdminAuthenticationProvider envAuthProvider(
- AssertableApplicationContext context) {
+ protected EnvironmentAdminAuthenticationProvider envAuthProvider(AssertableApplicationContext context) {
return context.getBean(EnvironmentAdminAuthenticationProvider.class);
}
}
diff --git a/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/security/GeoServerSecurityAutoConfigurationTest.java b/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/security/GeoServerSecurityAutoConfigurationTest.java
index 4153d2793..e41564561 100644
--- a/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/security/GeoServerSecurityAutoConfigurationTest.java
+++ b/src/catalog/backends/common/src/test/java/org/geoserver/cloud/autoconfigure/security/GeoServerSecurityAutoConfigurationTest.java
@@ -7,6 +7,8 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
+import java.io.File;
+import java.util.List;
import org.geoserver.catalog.Catalog;
import org.geoserver.cloud.config.factory.FilteringXmlBeanDefinitionReader;
import org.geoserver.cloud.security.CloudGeoServerSecurityManager;
@@ -26,9 +28,6 @@
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
-import java.io.File;
-import java.util.List;
-
/**
* {@link EnableAutoConfiguration @EnableAutoConfiguration} tests for {@link
* GeoServerSecurityAutoConfiguration}
@@ -37,7 +36,8 @@
*/
class GeoServerSecurityAutoConfigurationTest {
- @TempDir File tempDir;
+ @TempDir
+ File tempDir;
private ApplicationContextRunner runner;
@@ -70,12 +70,10 @@ static ApplicationContextRunner createContextRunner(File tempDir) {
@Test
void disabled() {
runner.withPropertyValues("geoserver.security.enabled: false") //
- .run(
- context -> {
- assertThat(context).hasNotFailed();
- assertThat(context)
- .doesNotHaveBean(CloudGeoServerSecurityManager.class);
- });
+ .run(context -> {
+ assertThat(context).hasNotFailed();
+ assertThat(context).doesNotHaveBean(CloudGeoServerSecurityManager.class);
+ });
}
@Test
@@ -89,24 +87,20 @@ void enabledExplicitly() {
}
private void testEnabled(ApplicationContextRunner runner) {
- runner.run(
- context -> {
- assertThat(context).hasNotFailed();
- assertThat(context).hasBean("authenticationManager");
- assertThat(context.getBean("authenticationManager"))
- .isInstanceOf(CloudGeoServerSecurityManager.class);
+ runner.run(context -> {
+ assertThat(context).hasNotFailed();
+ assertThat(context).hasBean("authenticationManager");
+ assertThat(context.getBean("authenticationManager")).isInstanceOf(CloudGeoServerSecurityManager.class);
- // gs-main's applicationSecurityContext.xml contributions
- SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
- new FilteringXmlBeanDefinitionReader(registry)
- .loadBeanDefinitions(
- GeoServerSecurityConfiguration
- .APPLICATION_SECURITY_CONTEXT_FILTER);
- List names = List.of(registry.getBeanDefinitionNames());
- assertThat(names).isNotEmpty();
- for (String name : names) {
- assertThat(context).hasBean(name);
- }
- });
+ // gs-main's applicationSecurityContext.xml contributions
+ SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
+ new FilteringXmlBeanDefinitionReader(registry)
+ .loadBeanDefinitions(GeoServerSecurityConfiguration.APPLICATION_SECURITY_CONTEXT_FILTER);
+ List names = List.of(registry.getBeanDefinitionNames());
+ assertThat(names).isNotEmpty();
+ for (String name : names) {
+ assertThat(context).hasBean(name);
+ }
+ });
}
}
diff --git a/src/catalog/backends/common/src/test/java/org/geoserver/security/impl/GsCloudLayerGroupContainmentCacheTest.java b/src/catalog/backends/common/src/test/java/org/geoserver/security/impl/GsCloudLayerGroupContainmentCacheTest.java
index 0d2600ca6..8bcc2a87e 100644
--- a/src/catalog/backends/common/src/test/java/org/geoserver/security/impl/GsCloudLayerGroupContainmentCacheTest.java
+++ b/src/catalog/backends/common/src/test/java/org/geoserver/security/impl/GsCloudLayerGroupContainmentCacheTest.java
@@ -14,6 +14,22 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UncheckedIOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import javax.xml.namespace.QName;
import org.geoserver.catalog.CascadeDeleteVisitor;
import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.CatalogBuilder;
@@ -44,24 +60,6 @@
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.web.context.WebApplicationContext;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UncheckedIOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import javax.xml.namespace.QName;
-
/**
* Tests {@link LayerGroupContainmentCache} udpates in face of catalog setup and changes
*
@@ -85,7 +83,8 @@ class GsCloudLayerGroupContainmentCacheTest {
private static Catalog catalog;
- @TempDir static Path tmpDir;
+ @TempDir
+ static Path tmpDir;
@BeforeAll
public static void setupBaseCatalog() throws Exception {
@@ -106,8 +105,7 @@ public static void setupBaseCatalog() throws Exception {
String nsURI = catalog.getDefaultNamespace().getURI();
var resolver = new PathMatchingResourcePatternResolver(MockData.class.getClassLoader());
- Resource[] resources =
- resolver.getResources("classpath:org/geoserver/data/test/*.properties");
+ Resource[] resources = resolver.getResources("classpath:org/geoserver/data/test/*.properties");
List propFiles = Stream.of(resources).map(Resource::getFilename).toList();
propFiles.stream()
.filter(f -> !f.equals("MarsPoi.properties")) // crs 49900 unknown
@@ -186,8 +184,7 @@ public void clearLayerGroups() {
}
}
- private LayerGroupInfo addLayerGroup(
- String name, Mode mode, WorkspaceInfo ws, PublishedInfo... layers) {
+ private LayerGroupInfo addLayerGroup(String name, Mode mode, WorkspaceInfo ws, PublishedInfo... layers) {
CatalogBuilder cb = new CatalogBuilder(catalog);
LayerGroupInfo group = catalog.getFactory().createLayerGroup();
@@ -242,8 +239,7 @@ private String getLayerId(QName name) {
@Test
void buildLayerGroupCaches() {
- GsCloudLayerGroupContainmentCache layerGroupContainmentCache =
- new GsCloudLayerGroupContainmentCache(catalog);
+ GsCloudLayerGroupContainmentCache layerGroupContainmentCache = new GsCloudLayerGroupContainmentCache(catalog);
ContextRefreshedEvent contextRefreshedEvent = mock(ContextRefreshedEvent.class);
WebApplicationContext context = mock(WebApplicationContext.class);
when(contextRefreshedEvent.getApplicationContext()).thenReturn(context);
@@ -272,8 +268,7 @@ void testInitialSetup() {
// now check the groups containing the layers (nature being SINGLE, not a container)
assertThat(containerNamesForResource(MockData.LAKES), equalTo(set(CONTAINER_GROUP)));
assertThat(containerNamesForResource(MockData.FORESTS), equalTo(set(CONTAINER_GROUP)));
- assertThat(
- containerNamesForResource(MockData.ROAD_SEGMENTS), equalTo(set(CONTAINER_GROUP)));
+ assertThat(containerNamesForResource(MockData.ROAD_SEGMENTS), equalTo(set(CONTAINER_GROUP)));
}
@Test
@@ -305,8 +300,7 @@ void testRemoveLayerFromNature() {
assertThat(containerNamesForResource(MockData.LAKES), empty());
assertThat(containerNamesForResource(MockData.FORESTS), equalTo(set(CONTAINER_GROUP)));
- assertThat(
- containerNamesForResource(MockData.ROAD_SEGMENTS), equalTo(set(CONTAINER_GROUP)));
+ assertThat(containerNamesForResource(MockData.ROAD_SEGMENTS), equalTo(set(CONTAINER_GROUP)));
}
@Test
@@ -330,8 +324,7 @@ void testRemoveNatureFromContainer() {
assertThat(containerNamesForGroup(nature), empty());
assertThat(containerNamesForResource(MockData.LAKES), empty());
assertThat(containerNamesForResource(MockData.FORESTS), empty());
- assertThat(
- containerNamesForResource(MockData.ROAD_SEGMENTS), equalTo(set(CONTAINER_GROUP)));
+ assertThat(containerNamesForResource(MockData.ROAD_SEGMENTS), equalTo(set(CONTAINER_GROUP)));
}
@Test
@@ -353,9 +346,7 @@ void testAddRemoveNamed() {
// add and check containment
LayerGroupInfo named = addLayerGroup(NAMED_GROUP, Mode.NAMED, null, lakes, neatline);
- assertThat(
- containerNamesForResource(MockData.LAKES),
- equalTo(set(CONTAINER_GROUP, NAMED_GROUP)));
+ assertThat(containerNamesForResource(MockData.LAKES), equalTo(set(CONTAINER_GROUP, NAMED_GROUP)));
assertThat(containerNamesForResource(MockData.MAP_NEATLINE), equalTo(set(NAMED_GROUP)));
assertThat(containerNamesForGroup(named), empty());
@@ -377,12 +368,8 @@ void testAddRemoveNestedNamed() {
container.getLayers().add(nestedNamed);
container.getStyles().add(null);
catalog.save(container);
- assertThat(
- containerNamesForResource(MockData.LAKES),
- equalTo(set(CONTAINER_GROUP, NESTED_NAMED)));
- assertThat(
- containerNamesForResource(MockData.MAP_NEATLINE),
- equalTo(set(CONTAINER_GROUP, NESTED_NAMED)));
+ assertThat(containerNamesForResource(MockData.LAKES), equalTo(set(CONTAINER_GROUP, NESTED_NAMED)));
+ assertThat(containerNamesForResource(MockData.MAP_NEATLINE), equalTo(set(CONTAINER_GROUP, NESTED_NAMED)));
assertThat(containerNamesForGroup(nestedNamed), equalTo(set(CONTAINER_GROUP)));
// delete and check containment
diff --git a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/datadir/ConditionalOnDataDirectoryEnabled.java b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/datadir/ConditionalOnDataDirectoryEnabled.java
index e0e72db0c..fc3ef8b30 100644
--- a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/datadir/ConditionalOnDataDirectoryEnabled.java
+++ b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/datadir/ConditionalOnDataDirectoryEnabled.java
@@ -4,13 +4,12 @@
*/
package org.geoserver.cloud.autoconfigure.catalog.backend.datadir;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
diff --git a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/catalog/backend/datadir/EventualConsistencyEnforcer.java b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/catalog/backend/datadir/EventualConsistencyEnforcer.java
index 4a3ad5511..061080c9b 100644
--- a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/catalog/backend/datadir/EventualConsistencyEnforcer.java
+++ b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/catalog/backend/datadir/EventualConsistencyEnforcer.java
@@ -5,13 +5,21 @@
package org.geoserver.cloud.catalog.backend.datadir;
import com.google.common.collect.Sets;
-
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import java.util.concurrent.locks.ReentrantLock;
import lombok.AllArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.catalog.CatalogInfo;
import org.geoserver.catalog.DataStoreInfo;
import org.geoserver.catalog.NamespaceInfo;
@@ -26,17 +34,6 @@
import org.geoserver.config.impl.GeoServerLifecycleHandler;
import org.springframework.lang.Nullable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.Callable;
-import java.util.concurrent.locks.ReentrantLock;
-
/**
* Aids {@link EventuallyConsistentCatalogFacade} in ensuring the catalog stays consistent and
* eventually converges while remote events may arrive out of order and {@link CatalogInfo}s
@@ -59,7 +56,8 @@ public class EventualConsistencyEnforcer implements GeoServerLifecycleHandler {
private final Map>> pendingOperations = new HashMap<>();
- @Setter private ExtendedCatalogFacade rawFacade;
+ @Setter
+ private ExtendedCatalogFacade rawFacade;
private final ReentrantLock lock = new ReentrantLock();
@@ -130,9 +128,7 @@ private void tryResolvePending(String missingRef) {
}
Optional found = rawFacade.get(missingRef);
if (found.isPresent()) {
- log.debug(
- "previously missing ref {} found, resolving pending operations waiting for it",
- missingRef);
+ log.debug("previously missing ref {} found, resolving pending operations waiting for it", missingRef);
tryResolvePending(found.orElseThrow());
} else {
log.debug(
@@ -188,8 +184,7 @@ public void setDefaultNamespace(@Nullable NamespaceInfo namespace) {
execute(new SetDefaultNamespace(namespace));
}
- public void setDefaultDataStore(
- @NonNull WorkspaceInfo workspace, @Nullable DataStoreInfo store) {
+ public void setDefaultDataStore(@NonNull WorkspaceInfo workspace, @Nullable DataStoreInfo store) {
execute(new SetDefaultDataStore(workspace, store));
}
@@ -251,7 +246,9 @@ protected boolean completedSuccessfully() {
private void setPending(String missingRef, ConsistencyOp> deferredOp) {
log.debug("missing ref {}, deferring execution of {}", missingRef, deferredOp);
- pendingOperations.computeIfAbsent(missingRef, ref -> new ArrayList<>()).add(deferredOp);
+ pendingOperations
+ .computeIfAbsent(missingRef, ref -> new ArrayList<>())
+ .add(deferredOp);
}
private void unsetPending(String resolvedRef, ConsistencyOp> completedOp) {
@@ -331,14 +328,11 @@ protected T resolve() {
Class type = ConfigInfoType.valueOf(info).type();
rawFacade
.get(info.getId(), type)
- .ifPresentOrElse(
- existing ->
- log.info("Ignoring add, object exists {}", info.getId()),
- () -> {
- T added = rawFacade.add(info);
- this.info = added;
- success = true;
- });
+ .ifPresentOrElse(existing -> log.info("Ignoring add, object exists {}", info.getId()), () -> {
+ T added = rawFacade.add(info);
+ this.info = added;
+ success = true;
+ });
}
// return info to comply with the catalog facade add() contract
// but delay insertion of info as it has unresolved references
@@ -368,8 +362,7 @@ private class UpdateOp extends ConsistencyOp {
@Override
public String toString() {
return "%s(%s, patch: %s)"
- .formatted(
- getClass().getSimpleName(), toUpdate.getId(), patch.getPropertyNames());
+ .formatted(getClass().getSimpleName(), toUpdate.getId(), patch.getPropertyNames());
}
@Override
@@ -466,10 +459,7 @@ private void completeOrDiscard(ConsistencyOp> dependant) {
final String id = info.getId();
execute(dependant);
if (dependant.completedSuccessfully()) {
- log.debug(
- "successfully executed {} depending on {} before removing it",
- dependant,
- id);
+ log.debug("successfully executed {} depending on {} before removing it", dependant, id);
} else {
log.warn(
"operation dependant on {} didn't complete successfully before removing it. It will be discarded: {}",
@@ -484,7 +474,8 @@ private void completeOrDiscard(ConsistencyOp> dependant) {
@RequiredArgsConstructor
private class SetDefaultWorkspace extends ConsistencyOp {
- @Nullable private final WorkspaceInfo workspace;
+ @Nullable
+ private final WorkspaceInfo workspace;
@Override
Set getMissingRefs() {
@@ -513,15 +504,14 @@ protected Void resolve() {
@Override
public String toString() {
return "%s(workspace: %s)"
- .formatted(
- getClass().getSimpleName(),
- (workspace == null ? null : workspace.getId()));
+ .formatted(getClass().getSimpleName(), (workspace == null ? null : workspace.getId()));
}
}
@RequiredArgsConstructor
private class SetDefaultNamespace extends ConsistencyOp {
- @Nullable private final NamespaceInfo namespace;
+ @Nullable
+ private final NamespaceInfo namespace;
@Override
Set getMissingRefs() {
@@ -550,16 +540,17 @@ protected Void resolve() {
@Override
public String toString() {
return "%s(namespace: %s)"
- .formatted(
- getClass().getSimpleName(),
- (namespace == null ? null : namespace.getId()));
+ .formatted(getClass().getSimpleName(), (namespace == null ? null : namespace.getId()));
}
}
@AllArgsConstructor
private class SetDefaultDataStore extends ConsistencyOp {
- @NonNull private WorkspaceInfo workspace;
- @Nullable private DataStoreInfo store;
+ @NonNull
+ private WorkspaceInfo workspace;
+
+ @Nullable
+ private DataStoreInfo store;
@Override
Set getMissingRefs() {
@@ -602,10 +593,7 @@ protected Void resolve() {
@Override
public String toString() {
return "%s(workspace: %s, store: %s)"
- .formatted(
- getClass().getSimpleName(),
- workspace.getId(),
- (store == null ? null : store.getId()));
+ .formatted(getClass().getSimpleName(), workspace.getId(), (store == null ? null : store.getId()));
}
}
}
diff --git a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/catalog/backend/datadir/EventuallyConsistentCatalogFacade.java b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/catalog/backend/datadir/EventuallyConsistentCatalogFacade.java
index 52bcb65e8..f317aa436 100644
--- a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/catalog/backend/datadir/EventuallyConsistentCatalogFacade.java
+++ b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/catalog/backend/datadir/EventuallyConsistentCatalogFacade.java
@@ -4,10 +4,13 @@
*/
package org.geoserver.cloud.catalog.backend.datadir;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
import lombok.NonNull;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.catalog.CatalogInfo;
import org.geoserver.catalog.DataStoreInfo;
import org.geoserver.catalog.LayerGroupInfo;
@@ -28,11 +31,6 @@
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
-import java.util.Objects;
-import java.util.concurrent.TimeUnit;
-import java.util.function.Predicate;
-import java.util.function.Supplier;
-
/**
*
*
@@ -184,13 +182,10 @@ public T getStore(String id, Class clazz) {
}
@Override
- public T getStoreByName(
- WorkspaceInfo workspace, String name, Class clazz) {
+ public T getStoreByName(WorkspaceInfo workspace, String name, Class clazz) {
return retryOnNull(
() -> super.getStoreByName(workspace, name, clazz), //
- () ->
- "getStoreByName(%s, %s, %s)"
- .formatted(nameof(workspace), name, clazz.getSimpleName()));
+ () -> "getStoreByName(%s, %s, %s)".formatted(nameof(workspace), name, clazz.getSimpleName()));
}
@Override
@@ -201,23 +196,17 @@ public T getResource(String id, Class clazz) {
}
@Override
- public T getResourceByName(
- NamespaceInfo namespace, String name, Class clazz) {
+ public T getResourceByName(NamespaceInfo namespace, String name, Class clazz) {
return retryOnNull(
() -> super.getResourceByName(namespace, name, clazz), //
- () ->
- "getResourceByName(%s, %s, %s)"
- .formatted(nameof(namespace), name, clazz.getSimpleName()));
+ () -> "getResourceByName(%s, %s, %s)".formatted(nameof(namespace), name, clazz.getSimpleName()));
}
@Override
- public T getResourceByStore(
- StoreInfo store, String name, Class clazz) {
+ public T getResourceByStore(StoreInfo store, String name, Class clazz) {
return retryOnNull(
() -> super.getResourceByStore(store, name, clazz), //
- () ->
- "getResourceByStore(%s, %s, %s)"
- .formatted(nameof(store), name, clazz.getSimpleName()));
+ () -> "getResourceByStore(%s, %s, %s)".formatted(nameof(store), name, clazz.getSimpleName()));
}
@Override
@@ -339,8 +328,7 @@ private boolean isRestRequest() {
return false;
}
- private T doRetry(
- Supplier supplier, Predicate predicate, Supplier op, T ret) {
+ private T doRetry(Supplier supplier, Predicate predicate, Supplier op, T ret) {
// poor man's Retry implementation
final int maxAttempts = retryAttemptMillis.length;
final String opDesc = op.get();
diff --git a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/DataDirectoryBackendConfiguration.java b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/DataDirectoryBackendConfiguration.java
index 4670c2bb6..7b07de983 100644
--- a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/DataDirectoryBackendConfiguration.java
+++ b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/DataDirectoryBackendConfiguration.java
@@ -4,9 +4,13 @@
*/
package org.geoserver.cloud.config.catalog.backend.datadirectory;
+import java.io.File;
+import java.nio.file.Path;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.GeoServerConfigurationLock;
import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.plugin.CatalogPlugin;
@@ -35,12 +39,6 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
-import java.io.File;
-import java.nio.file.Path;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-
/** */
@Configuration(proxyBeanMethods = true)
@Slf4j(topic = "org.geoserver.cloud.config.datadirectory")
@@ -67,8 +65,7 @@ public DataDirectoryBackendConfiguration(
@Bean
ModuleStatusImpl moduleStatus() {
- ModuleStatusImpl module =
- new ModuleStatusImpl("gs-cloud-backend-datadir", "DataDirectory loader");
+ ModuleStatusImpl module = new ModuleStatusImpl("gs-cloud-backend-datadir", "DataDirectory loader");
module.setAvailable(true);
module.setEnabled(true);
return module;
@@ -119,9 +116,7 @@ LockingGeoServer geoServer(@Qualifier("catalog") Catalog catalog) {
List retries = ecConfig.getRetries();
if (retries != null && !retries.isEmpty()) {
waitMillis = retries.stream().mapToInt(Integer::intValue).toArray();
- log.info(
- "Data directory catalog facade eventual consistency retries in ms: {}",
- retries);
+ log.info("Data directory catalog facade eventual consistency retries in ms: {}", retries);
}
}
EventualConsistencyEnforcer tracker = converger.orElseThrow();
@@ -157,8 +152,7 @@ LockingGeoServer geoServer(@Qualifier("catalog") Catalog catalog) {
GeoServerResourceLoader resourceLoader = resourceLoader();
Catalog rawCatalog = rawCatalog();
LockingGeoServer geoserver = geoServer(rawCatalog);
- return new DataDirectoryGeoServerLoader(
- updateSequence, resourceLoader, geoserver, rawCatalog);
+ return new DataDirectoryGeoServerLoader(updateSequence, resourceLoader, geoserver, rawCatalog);
}
/**
@@ -211,8 +205,7 @@ GeoServerLoader geoServerLoaderImplParallel(GeoServerSecurityManager securityMan
private Path dataDirectoryFile() {
DataDirectoryProperties config = this.dataDirectoryConfig;
Path path = config.getLocation();
- Objects.requireNonNull(
- path, "geoserver.backend.data-directory.location config property resolves to null");
+ Objects.requireNonNull(path, "geoserver.backend.data-directory.location config property resolves to null");
return path;
}
}
diff --git a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/DataDirectoryGeoServerLoader.java b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/DataDirectoryGeoServerLoader.java
index dd106b9fa..6b064a2e7 100644
--- a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/DataDirectoryGeoServerLoader.java
+++ b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/DataDirectoryGeoServerLoader.java
@@ -4,9 +4,11 @@
*/
package org.geoserver.cloud.config.catalog.backend.datadirectory;
+import java.io.IOException;
+import java.util.Set;
+import javax.annotation.PostConstruct;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.GeoServerConfigurationLock;
import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.plugin.CatalogPluginStyleResourcePersister;
@@ -24,11 +26,6 @@
import org.geoserver.platform.GeoServerResourceLoader;
import org.geoserver.platform.config.UpdateSequence;
-import java.io.IOException;
-import java.util.Set;
-
-import javax.annotation.PostConstruct;
-
/**
* {@link Catalog} and {@link GeoServer config} loader for the data-directory backend, loads the
* configuration from disk as soon as the spring bean wiring is {@link #load() ready}; {@link
@@ -154,8 +151,7 @@ protected void loadCatalog(Catalog catalog, XStreamPersister xp) throws Exceptio
catalog.removeListeners(GeoServerConfigPersister.class);
catalog.removeListeners(GeoServerResourcePersister.class);
- catalog.addListener(
- new CatalogPluginGeoServerConfigPersister(catalog.getResourceLoader(), xp));
+ catalog.addListener(new CatalogPluginGeoServerConfigPersister(catalog.getResourceLoader(), xp));
catalog.addListener(new CatalogPluginStyleResourcePersister(catalog));
}
}
diff --git a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/DataDirectoryLoaderSupport.java b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/DataDirectoryLoaderSupport.java
index d578eb95d..504f10f91 100644
--- a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/DataDirectoryLoaderSupport.java
+++ b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/DataDirectoryLoaderSupport.java
@@ -4,10 +4,13 @@
*/
package org.geoserver.cloud.config.catalog.backend.datadirectory;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.config.ConfigurationListener;
import org.geoserver.config.GeoServer;
import org.geoserver.config.GeoServerConfigPersister;
@@ -20,11 +23,6 @@
import org.geoserver.platform.resource.Resource;
import org.geoserver.platform.resource.Resources;
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
-import java.util.stream.Collectors;
-
/**
* @since 1.0
*/
@@ -63,37 +61,32 @@ public Optional preload(GeoServer gs, XStreamServiceLoader> loade
public void persistNewlyCreatedServices(GeoServer geoServer, Set existingServiceNames) {
- ServicePersister servicePersister =
- geoServer.getListeners().stream()
- .filter(ServicePersister.class::isInstance)
- .map(ServicePersister.class::cast)
- .findFirst()
- .orElseThrow();
+ ServicePersister servicePersister = geoServer.getListeners().stream()
+ .filter(ServicePersister.class::isInstance)
+ .map(ServicePersister.class::cast)
+ .findFirst()
+ .orElseThrow();
geoServer.getServices().stream()
.filter(s -> !existingServiceNames.contains(s.getName()))
- .forEach(
- s -> {
- log.info("Persisting created service {}", s.getId());
- servicePersister.handlePostServiceChange(s);
- });
+ .forEach(s -> {
+ log.info("Persisting created service {}", s.getId());
+ servicePersister.handlePostServiceChange(s);
+ });
}
- public void replaceCatalogInfoPersisterWithFixedVersion(
- final GeoServer geoServer, XStreamPersister xp) {
+ public void replaceCatalogInfoPersisterWithFixedVersion(final GeoServer geoServer, XStreamPersister xp) {
- ConfigurationListener configPersister =
- geoServer.getListeners().stream()
- .filter(GeoServerConfigPersister.class::isInstance)
- .findFirst()
- .orElse(null);
+ ConfigurationListener configPersister = geoServer.getListeners().stream()
+ .filter(GeoServerConfigPersister.class::isInstance)
+ .findFirst()
+ .orElse(null);
if (configPersister != null) {
geoServer.removeListener(configPersister);
}
GeoServerConfigPersister fixedCatalogInfoPersister =
- new CatalogPluginGeoServerConfigPersister(
- geoServer.getCatalog().getResourceLoader(), xp);
+ new CatalogPluginGeoServerConfigPersister(geoServer.getCatalog().getResourceLoader(), xp);
geoServer.addListener(fixedCatalogInfoPersister);
}
@@ -108,8 +101,7 @@ public void initializeEmptyConfig(final GeoServer geoServer) {
geoServer.setLogging(geoServer.getFactory().createLogging());
}
// ensure we have a service configuration for every service we know about
- final List loaders =
- GeoServerExtensions.extensions(XStreamServiceLoader.class);
+ final List loaders = GeoServerExtensions.extensions(XStreamServiceLoader.class);
for (XStreamServiceLoader l : loaders) {
ServiceInfo serviceInfo = geoServer.getService(l.getServiceClass());
if (serviceInfo == null) {
diff --git a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/DataDirectoryProperties.java b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/DataDirectoryProperties.java
index f5bf0f4a8..b15934698 100644
--- a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/DataDirectoryProperties.java
+++ b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/DataDirectoryProperties.java
@@ -4,15 +4,13 @@
*/
package org.geoserver.cloud.config.catalog.backend.datadirectory;
+import java.nio.file.Path;
+import java.util.List;
import lombok.Data;
-
import org.geoserver.cloud.autoconfigure.catalog.backend.datadir.DataDirectoryAutoConfiguration;
import org.geoserver.cloud.config.catalog.backend.core.GeoServerBackendConfigurer;
import org.springframework.boot.context.properties.ConfigurationProperties;
-import java.nio.file.Path;
-import java.util.List;
-
/**
* Configuration properties to use GeoServer's traditional, file-system based data-directory as the
* {@link GeoServerBackendConfigurer catalog and configuration backend} through the {@link
@@ -25,8 +23,7 @@ public class DataDirectoryProperties {
private boolean enabled;
private Path location;
private boolean parallelLoader = true;
- private DataDirectoryProperties.EventualConsistencyConfig eventualConsistency =
- new EventualConsistencyConfig();
+ private DataDirectoryProperties.EventualConsistencyConfig eventualConsistency = new EventualConsistencyConfig();
/**
* Eventual consistency enfocement configuration. Bus events may come out of order under stress
diff --git a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/DataDirectoryUpdateSequence.java b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/DataDirectoryUpdateSequence.java
index 8694d3542..87649febf 100644
--- a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/DataDirectoryUpdateSequence.java
+++ b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/DataDirectoryUpdateSequence.java
@@ -4,10 +4,19 @@
*/
package org.geoserver.cloud.config.catalog.backend.datadirectory;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.UncheckedIOException;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.util.Optional;
+import java.util.Properties;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.impl.ModificationProxy;
import org.geoserver.config.GeoServer;
@@ -23,17 +32,6 @@
import org.geoserver.platform.resource.ResourceStore;
import org.geoserver.platform.resource.Resources;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.UncheckedIOException;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.util.Optional;
-import java.util.Properties;
-
/**
* @since 1.0
*/
@@ -168,8 +166,7 @@ private void save(Resource resource, Properties props) throws IOException {
protected Properties load(Resource resource) throws IOException {
byte[] contents = resource.getContents();
Properties props = new Properties();
- InputStreamReader reader =
- new InputStreamReader(new ByteArrayInputStream(contents), CHARSET);
+ InputStreamReader reader = new InputStreamReader(new ByteArrayInputStream(contents), CHARSET);
props.load(reader);
return props;
}
diff --git a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/NoServletContextDataDirectoryResourceStore.java b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/NoServletContextDataDirectoryResourceStore.java
index e954e628c..6a09e88b2 100644
--- a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/NoServletContextDataDirectoryResourceStore.java
+++ b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/NoServletContextDataDirectoryResourceStore.java
@@ -4,15 +4,12 @@
*/
package org.geoserver.cloud.config.catalog.backend.datadirectory;
-import lombok.extern.slf4j.Slf4j;
-
-import org.geoserver.platform.resource.DataDirectoryResourceStore;
-import org.geoserver.platform.resource.FileSystemResourceStore;
-
import java.io.File;
import java.util.Objects;
-
import javax.servlet.ServletContext;
+import lombok.extern.slf4j.Slf4j;
+import org.geoserver.platform.resource.DataDirectoryResourceStore;
+import org.geoserver.platform.resource.FileSystemResourceStore;
/**
* {@link DataDirectoryResourceStore} that works both for webmvc (servlet) and reactive (WebFlux)
@@ -30,11 +27,9 @@ public NoServletContextDataDirectoryResourceStore(File resourceDirectory) {
if (resourceDirectory.isFile()) {
throw new IllegalArgumentException(
- "Directory required, file present at this location %s"
- .formatted(resourceDirectory));
+ "Directory required, file present at this location %s".formatted(resourceDirectory));
} else if (!resourceDirectory.isDirectory() && !resourceDirectory.mkdirs()) {
- throw new IllegalArgumentException(
- "Unable to create directory %s".formatted(resourceDirectory));
+ throw new IllegalArgumentException("Unable to create directory %s".formatted(resourceDirectory));
}
this.setBaseDirectory(resourceDirectory);
}
diff --git a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/NoServletContextFileLockProvider.java b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/NoServletContextFileLockProvider.java
index f37e5791d..c6d70c784 100644
--- a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/NoServletContextFileLockProvider.java
+++ b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/NoServletContextFileLockProvider.java
@@ -4,15 +4,12 @@
*/
package org.geoserver.cloud.config.catalog.backend.datadirectory;
+import java.io.File;
+import javax.servlet.ServletContext;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.platform.resource.FileLockProvider;
-import java.io.File;
-
-import javax.servlet.ServletContext;
-
/**
* {@link FileLockProvider} that expects the data directory file at its constructor, overriding
* {@link #setServletContext} to be ignored.
diff --git a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/ParallelDataDirectoryGeoServerLoader.java b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/ParallelDataDirectoryGeoServerLoader.java
index e7fb20b02..f3de8cbb2 100644
--- a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/ParallelDataDirectoryGeoServerLoader.java
+++ b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/config/catalog/backend/datadirectory/ParallelDataDirectoryGeoServerLoader.java
@@ -10,9 +10,12 @@
import static org.geoserver.catalog.StyleInfo.DEFAULT_POLYGON;
import static org.geoserver.catalog.StyleInfo.DEFAULT_RASTER;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Set;
+import javax.annotation.PostConstruct;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.GeoServerConfigurationLock;
import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.FeatureTypeCallback;
@@ -36,12 +39,6 @@
import org.geotools.api.referencing.NoSuchAuthorityCodeException;
import org.vfny.geoserver.util.DataStoreUtils;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Set;
-
-import javax.annotation.PostConstruct;
-
/**
* Extends the parallel {@link org.geoserver.catalog.datadir.DataDirectoryGeoServerLoader} to
* account for extra care needed on a cloud environment with potentially multiple instances starting
@@ -67,8 +64,7 @@
* @see DataDirectoryGeoServerLoader
*/
@Slf4j
-public class ParallelDataDirectoryGeoServerLoader
- extends org.geoserver.catalog.datadir.DataDirectoryGeoServerLoader {
+public class ParallelDataDirectoryGeoServerLoader extends org.geoserver.catalog.datadir.DataDirectoryGeoServerLoader {
private @NonNull UpdateSequence updateSequence;
private @NonNull Catalog rawCatalog;
@@ -131,15 +127,13 @@ private void triggerCollaboratorBeansLoading() throws FactoryException {
// misconfigured layers may end up calling FeatureTypeInfo.getFeatureType(), which in turn
// will trigger GeoServerExtensions and deadlock on the main thread's while spring is
// building up beans
- DataStoreUtils.getAvailableDataStoreFactories()
- .forEach(
- f -> {
- try {
- DataStoreUtils.aquireFactory(f.getDisplayName());
- } catch (Exception ignore) {
- //
- }
- });
+ DataStoreUtils.getAvailableDataStoreFactories().forEach(f -> {
+ try {
+ DataStoreUtils.aquireFactory(f.getDisplayName());
+ } catch (Exception ignore) {
+ //
+ }
+ });
GeoServerExtensions.extensions(FeatureTypeCallback.class);
}
@@ -151,8 +145,7 @@ public void loadCatalog(Catalog catalog, XStreamPersister xp) throws Exception {
catalog.removeListeners(GeoServerConfigPersister.class);
catalog.removeListeners(GeoServerResourcePersister.class);
- catalog.addListener(
- new CatalogPluginGeoServerConfigPersister(catalog.getResourceLoader(), xp));
+ catalog.addListener(new CatalogPluginGeoServerConfigPersister(catalog.getResourceLoader(), xp));
catalog.addListener(new CatalogPluginStyleResourcePersister(catalog));
}
@@ -187,13 +180,7 @@ public void loadGeoServer(GeoServer geoServer, XStreamPersister xp) throws Excep
*/
@Override
protected void initializeDefaultStyles(Catalog catalog) throws IOException {
- if (styleMissing(
- catalog,
- DEFAULT_POINT,
- DEFAULT_LINE,
- DEFAULT_POLYGON,
- DEFAULT_RASTER,
- DEFAULT_GENERIC)) {
+ if (styleMissing(catalog, DEFAULT_POINT, DEFAULT_LINE, DEFAULT_POLYGON, DEFAULT_RASTER, DEFAULT_GENERIC)) {
log.info("Initializing default styles");
GeoServerConfigurationLock configLock = lockingGeoserver.getConfigurationLock();
diff --git a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/event/remote/datadir/RemoteEventDataDirectoryProcessor.java b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/event/remote/datadir/RemoteEventDataDirectoryProcessor.java
index f1e10478b..586ebf117 100644
--- a/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/event/remote/datadir/RemoteEventDataDirectoryProcessor.java
+++ b/src/catalog/backends/datadir/src/main/java/org/geoserver/cloud/event/remote/datadir/RemoteEventDataDirectoryProcessor.java
@@ -4,10 +4,11 @@
*/
package org.geoserver.cloud.event.remote.datadir;
+import java.util.function.Consumer;
+import java.util.function.Function;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.catalog.CatalogInfo;
import org.geoserver.catalog.DataStoreInfo;
import org.geoserver.catalog.Info;
@@ -33,9 +34,6 @@
import org.geoserver.config.plugin.RepositoryGeoServerFacade;
import org.springframework.context.event.EventListener;
-import java.util.function.Consumer;
-import java.util.function.Function;
-
/**
* Listens to {@link RemoteCatalogEvent}s and updates the local catalog
*
@@ -94,20 +92,13 @@ public void onRemoteRemoveEvent(InfoRemoved event) {
facade.remove(info);
log.debug("Removed {}({}), from local catalog", type, objectId);
},
- () ->
- log.warn(
- "Can't remove {}({}), not present in local catalog",
- type,
- objectId));
+ () -> log.warn("Can't remove {}({}), not present in local catalog", type, objectId));
} else {
boolean removed =
switch (type) {
case SERVICE -> remove(
- objectId,
- id -> configFacade.getService(id, ServiceInfo.class),
- configFacade::remove);
- case SETTINGS -> remove(
- objectId, configFacade::getSettings, configFacade::remove);
+ objectId, id -> configFacade.getService(id, ServiceInfo.class), configFacade::remove);
+ case SETTINGS -> remove(objectId, configFacade::getSettings, configFacade::remove);
default -> false;
};
if (removed) {
@@ -130,8 +121,7 @@ public void onRemoteAddEvent(InfoAdded extends Info> event) {
log.error("Remote add event didn't send the object payload for {}({})", type, objectId);
return;
}
- if (log.isDebugEnabled())
- log.debug("Adding object from event {}: {}", event.toShortString(), object);
+ if (log.isDebugEnabled()) log.debug("Adding object from event {}: {}", event.toShortString(), object);
ExtendedCatalogFacade facade = catalogFacade();
switch (object) {
case CatalogInfo info -> facade.add(info);
@@ -140,8 +130,7 @@ public void onRemoteAddEvent(InfoAdded extends Info> event) {
case LoggingInfo config -> log.debug("ignoring unused LoggingInfo {}", config);
default -> log.warn("Don't know how to handle remote envent {})", event);
}
- if (log.isDebugEnabled())
- log.debug("Added object from event {}: {}", event.toShortString(), object);
+ if (log.isDebugEnabled()) log.debug("Added object from event {}: {}", event.toShortString(), object);
}
@EventListener(InfoModified.class)
@@ -179,11 +168,7 @@ public void onRemoteModifyEvent(InfoModified event) {
}
if (log.isDebugEnabled())
- log.debug(
- "Object updated: {}({}). Properties: {}",
- type,
- event.getObjectId(),
- patch.getPropertyNames());
+ log.debug("Object updated: {}({}). Properties: {}", type, event.getObjectId(), patch.getPropertyNames());
}
private Info loadInfo(InfoModified event) {
@@ -241,8 +226,7 @@ public void onRemoteDefaultDataStoreEvent(DefaultDataStoreSet event) {
ExtendedCatalogFacade facade = catalogFacade();
- WorkspaceInfo workspace =
- ResolvingProxy.create(event.getWorkspaceId(), WorkspaceInfo.class);
+ WorkspaceInfo workspace = ResolvingProxy.create(event.getWorkspaceId(), WorkspaceInfo.class);
DataStoreInfo store = null;
if (null != event.getDefaultDataStoreId()) {
@@ -251,8 +235,7 @@ public void onRemoteDefaultDataStoreEvent(DefaultDataStoreSet event) {
facade.setDefaultDataStore(workspace, store);
}
- private boolean remove(
- String id, Function supplier, Consumer super T> remover) {
+ private boolean remove(String id, Function supplier, Consumer super T> remover) {
T info = supplier.apply(id);
if (info == null) {
return false;
diff --git a/src/catalog/backends/datadir/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/datadir/DataDirectoryAutoConfigurationTest.java b/src/catalog/backends/datadir/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/datadir/DataDirectoryAutoConfigurationTest.java
index ca49bfa42..5703d52b3 100644
--- a/src/catalog/backends/datadir/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/datadir/DataDirectoryAutoConfigurationTest.java
+++ b/src/catalog/backends/datadir/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/datadir/DataDirectoryAutoConfigurationTest.java
@@ -7,6 +7,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertSame;
+import java.nio.file.Paths;
import org.geoserver.GeoServerConfigurationLock;
import org.geoserver.catalog.CatalogFacade;
import org.geoserver.catalog.plugin.CatalogPlugin;
@@ -26,153 +27,118 @@
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
-import java.nio.file.Paths;
-
/**
* Test {@link DataDirectoryBackendConfiguration} through {@link DataDirectoryAutoConfiguration}
* when {@code geoserver.backend.data-directory.enabled=true}
*/
class DataDirectoryAutoConfigurationTest {
- private ApplicationContextRunner runner =
- new ApplicationContextRunner()
- .withConfiguration(
- AutoConfigurations.of(
- // AutoConfigurations from gs-cloud-catalog-backend-common
- org.geoserver.cloud.autoconfigure.geotools
- .GeoToolsHttpClientAutoConfiguration.class,
- org.geoserver.cloud.autoconfigure.catalog.backend.core
- .GeoServerBackendAutoConfiguration.class,
- org.geoserver.cloud.autoconfigure.catalog.backend.core
- .DefaultUpdateSequenceAutoConfiguration.class,
- org.geoserver.cloud.autoconfigure.catalog.backend.core
- .XstreamServiceLoadersAutoConfiguration.class,
- org.geoserver.cloud.autoconfigure.catalog.backend.core
- .RemoteEventResourcePoolCleanupUpAutoConfiguration
- .class,
- org.geoserver.cloud.autoconfigure.security
- .GeoServerSecurityAutoConfiguration.class,
- org.geoserver.cloud.autoconfigure.metrics.catalog
- .CatalogMetricsAutoConfiguration.class,
- // AutoConfigurations from gs-cloud-catalog-backend-datadir
- org.geoserver.cloud.autoconfigure.catalog.backend.datadir
- .DataDirectoryAutoConfiguration.class //
- ))
- //
- .withPropertyValues(
- "geoserver.backend.dataDirectory.enabled=true", //
- "geoserver.backend.dataDirectory.location=/tmp/data_dir_autoconfiguration_test" //
- );
+ private ApplicationContextRunner runner = new ApplicationContextRunner()
+ .withConfiguration(AutoConfigurations.of(
+ // AutoConfigurations from gs-cloud-catalog-backend-common
+ org.geoserver.cloud.autoconfigure.geotools.GeoToolsHttpClientAutoConfiguration.class,
+ org.geoserver.cloud.autoconfigure.catalog.backend.core.GeoServerBackendAutoConfiguration.class,
+ org.geoserver.cloud.autoconfigure.catalog.backend.core.DefaultUpdateSequenceAutoConfiguration.class,
+ org.geoserver.cloud.autoconfigure.catalog.backend.core.XstreamServiceLoadersAutoConfiguration.class,
+ org.geoserver.cloud.autoconfigure.catalog.backend.core
+ .RemoteEventResourcePoolCleanupUpAutoConfiguration.class,
+ org.geoserver.cloud.autoconfigure.security.GeoServerSecurityAutoConfiguration.class,
+ org.geoserver.cloud.autoconfigure.metrics.catalog.CatalogMetricsAutoConfiguration.class,
+ // AutoConfigurations from gs-cloud-catalog-backend-datadir
+ org.geoserver.cloud.autoconfigure.catalog.backend.datadir.DataDirectoryAutoConfiguration.class //
+ ))
+ //
+ .withPropertyValues(
+ "geoserver.backend.dataDirectory.enabled=true", //
+ "geoserver.backend.dataDirectory.location=/tmp/data_dir_autoconfiguration_test" //
+ );
@Test
void testProperties() {
- runner.run(
- context -> {
- assertThat(context).hasNotFailed();
- assertThat(context).hasSingleBean(DataDirectoryProperties.class);
- assertThat(context)
- .getBean(DataDirectoryProperties.class)
- .hasFieldOrPropertyWithValue(
- "location", Paths.get("/tmp/data_dir_autoconfiguration_test"));
- });
+ runner.run(context -> {
+ assertThat(context).hasNotFailed();
+ assertThat(context).hasSingleBean(DataDirectoryProperties.class);
+ assertThat(context)
+ .getBean(DataDirectoryProperties.class)
+ .hasFieldOrPropertyWithValue("location", Paths.get("/tmp/data_dir_autoconfiguration_test"));
+ });
}
@Test
void testCatalog() {
- runner.run(
- context -> {
- assertThat(context).getBean("rawCatalog").isInstanceOf(LockingCatalog.class);
- });
+ runner.run(context -> {
+ assertThat(context).getBean("rawCatalog").isInstanceOf(LockingCatalog.class);
+ });
}
@Test
void testGeoServer() {
- runner.run(
- context -> {
- assertThat(context).getBean("geoServer").isInstanceOf(LockingGeoServer.class);
- });
+ runner.run(context -> {
+ assertThat(context).getBean("geoServer").isInstanceOf(LockingGeoServer.class);
+ });
}
@Test
void testCatalogFacadeIsRawCatalogFacade() {
- runner.run(
- context -> {
- CatalogFacade rawCatalogFacade =
- context.getBean("catalogFacade", CatalogFacade.class);
- CatalogPlugin rawCatalog = context.getBean("rawCatalog", CatalogPlugin.class);
- assertSame(rawCatalogFacade, rawCatalog.getRawFacade());
- });
+ runner.run(context -> {
+ CatalogFacade rawCatalogFacade = context.getBean("catalogFacade", CatalogFacade.class);
+ CatalogPlugin rawCatalog = context.getBean("rawCatalog", CatalogPlugin.class);
+ assertSame(rawCatalogFacade, rawCatalog.getRawFacade());
+ });
}
@Test
void testResourceLoader() {
- runner.run(
- context -> {
- assertThat(context)
- .getBean("resourceLoader")
- .isInstanceOf(GeoServerResourceLoader.class);
- });
+ runner.run(context -> {
+ assertThat(context).getBean("resourceLoader").isInstanceOf(GeoServerResourceLoader.class);
+ });
}
@Test
void testGeoserverFacade() {
- runner.run(
- context -> {
- assertThat(context)
- .getBean("geoserverFacade")
- .isInstanceOf(RepositoryGeoServerFacade.class);
- });
+ runner.run(context -> {
+ assertThat(context).getBean("geoserverFacade").isInstanceOf(RepositoryGeoServerFacade.class);
+ });
}
@Test
void testGeoserverLoaderLegacy() {
runner.withPropertyValues("geoserver.backend.data-directory.parallel-loader=false")
- .run(
- context -> {
- assertThat(context)
- .getBean("geoServerLoaderImpl")
- .isInstanceOf(DataDirectoryGeoServerLoader.class);
- });
+ .run(context -> {
+ assertThat(context).getBean("geoServerLoaderImpl").isInstanceOf(DataDirectoryGeoServerLoader.class);
+ });
}
@Test
void testGeoserverLoader() {
- runner.run(
- context -> {
- assertThat(context)
- .getBean("geoServerLoaderImpl")
- .isInstanceOf(ParallelDataDirectoryGeoServerLoader.class);
- });
+ runner.run(context -> {
+ assertThat(context).getBean("geoServerLoaderImpl").isInstanceOf(ParallelDataDirectoryGeoServerLoader.class);
+ });
}
@Test
void testResourceStoreImpl() {
- runner.run(
- context -> {
- assertThat(context)
- .getBean("resourceStoreImpl")
- .isInstanceOf(NoServletContextDataDirectoryResourceStore.class);
- });
+ runner.run(context -> {
+ assertThat(context)
+ .getBean("resourceStoreImpl")
+ .isInstanceOf(NoServletContextDataDirectoryResourceStore.class);
+ });
}
@Test
void testUpdateSequence() {
- runner.run(
- context -> {
- assertThat(context)
- .getBean(UpdateSequence.class)
- .isInstanceOf(DataDirectoryUpdateSequence.class);
- });
+ runner.run(context -> {
+ assertThat(context).getBean(UpdateSequence.class).isInstanceOf(DataDirectoryUpdateSequence.class);
+ });
}
@Test
void testGeoServerConfigurationLock() {
- runner.run(
- context -> {
- assertThat(context)
- .getBean(GeoServerConfigurationLock.class)
- .isInstanceOf(LockProviderGeoServerConfigurationLock.class);
- });
+ runner.run(context -> {
+ assertThat(context)
+ .getBean(GeoServerConfigurationLock.class)
+ .isInstanceOf(LockProviderGeoServerConfigurationLock.class);
+ });
}
}
diff --git a/src/catalog/backends/datadir/src/test/java/org/geoserver/cloud/catalog/backend/datadir/EventuallyConsistentCatalogFacadeTest.java b/src/catalog/backends/datadir/src/test/java/org/geoserver/cloud/catalog/backend/datadir/EventuallyConsistentCatalogFacadeTest.java
index 80c001bfa..9334b11ad 100644
--- a/src/catalog/backends/datadir/src/test/java/org/geoserver/cloud/catalog/backend/datadir/EventuallyConsistentCatalogFacadeTest.java
+++ b/src/catalog/backends/datadir/src/test/java/org/geoserver/cloud/catalog/backend/datadir/EventuallyConsistentCatalogFacadeTest.java
@@ -11,6 +11,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
+import java.util.function.Consumer;
import org.geoserver.catalog.CatalogInfo;
import org.geoserver.catalog.CoverageInfo;
import org.geoserver.catalog.CoverageStoreInfo;
@@ -33,8 +34,6 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import java.util.function.Consumer;
-
class EventuallyConsistentCatalogFacadeTest {
EventualConsistencyEnforcer tracker;
diff --git a/src/catalog/backends/datadir/src/test/java/org/geoserver/cloud/event/remote/datadir/RemoteEventDataDirectoryProcessorTest.java b/src/catalog/backends/datadir/src/test/java/org/geoserver/cloud/event/remote/datadir/RemoteEventDataDirectoryProcessorTest.java
index 44fe1c346..ce507238a 100644
--- a/src/catalog/backends/datadir/src/test/java/org/geoserver/cloud/event/remote/datadir/RemoteEventDataDirectoryProcessorTest.java
+++ b/src/catalog/backends/datadir/src/test/java/org/geoserver/cloud/event/remote/datadir/RemoteEventDataDirectoryProcessorTest.java
@@ -14,6 +14,8 @@
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
+import java.util.List;
+import java.util.Optional;
import org.geoserver.catalog.CatalogInfo;
import org.geoserver.catalog.WorkspaceInfo;
import org.geoserver.catalog.impl.ModificationProxy;
@@ -47,9 +49,6 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import java.util.List;
-import java.util.Optional;
-
class RemoteEventDataDirectoryProcessorTest {
ExtendedCatalogFacade mockFacade;
@@ -74,13 +73,9 @@ void testRemoteEventDataDirectoryProcessor() {
RepositoryGeoServerFacade configFacade = mock(RepositoryGeoServerFacade.class);
CatalogPlugin rawCatalog = mock(CatalogPlugin.class);
- assertThrows(
- NullPointerException.class,
- () -> new RemoteEventDataDirectoryProcessor(null, rawCatalog));
+ assertThrows(NullPointerException.class, () -> new RemoteEventDataDirectoryProcessor(null, rawCatalog));
- assertThrows(
- NullPointerException.class,
- () -> new RemoteEventDataDirectoryProcessor(configFacade, null));
+ assertThrows(NullPointerException.class, () -> new RemoteEventDataDirectoryProcessor(configFacade, null));
var catalogFacade = mock(ExtendedCatalogFacade.class);
when(rawCatalog.getFacade()).thenReturn(catalogFacade);
@@ -147,8 +142,7 @@ void testOnRemoteRemoveEvent_ConfigInfo() {
((WorkspaceInfoImpl) settings.getWorkspace()).setId("ws-id");
settings.getWorkspace().setName("ws");
- when(mockGeoServerFacade.getService(service.getId(), ServiceInfo.class))
- .thenReturn(service);
+ when(mockGeoServerFacade.getService(service.getId(), ServiceInfo.class)).thenReturn(service);
when(mockGeoServerFacade.getSettings(settings.getId())).thenReturn(settings);
ServiceRemoved serviceEvent = ServiceRemoved.createLocal(101, service);
@@ -256,8 +250,7 @@ void testOnRemoteModifyEvent_IgnoresSetDefaultEvents() {
@Test
void testOnRemoteModifyEvent_GeoServerInfo() {
- when(mockGeoServerFacade.getGlobal())
- .thenReturn(ModificationProxy.create(global, GeoServerInfo.class));
+ when(mockGeoServerFacade.getGlobal()).thenReturn(ModificationProxy.create(global, GeoServerInfo.class));
global.setFeatureTypeCacheSize(1);
var proxied = mockGeoServerFacade.getGlobal();
diff --git a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/ConditionalOnJdbcConfigEnabled.java b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/ConditionalOnJdbcConfigEnabled.java
index 1b83c0218..aa3a0c639 100644
--- a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/ConditionalOnJdbcConfigEnabled.java
+++ b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/ConditionalOnJdbcConfigEnabled.java
@@ -4,16 +4,15 @@
*/
package org.geoserver.cloud.autoconfigure.catalog.backend.jdbcconfig;
-import org.geoserver.jdbcconfig.catalog.JDBCCatalogFacade;
-import org.geoserver.jdbcconfig.config.JDBCGeoServerFacade;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.geoserver.jdbcconfig.catalog.JDBCCatalogFacade;
+import org.geoserver.jdbcconfig.config.JDBCGeoServerFacade;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
diff --git a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/ConditionalOnJdbcConfigWebUIEnabled.java b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/ConditionalOnJdbcConfigWebUIEnabled.java
index 52c882c20..73062b266 100644
--- a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/ConditionalOnJdbcConfigWebUIEnabled.java
+++ b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/ConditionalOnJdbcConfigWebUIEnabled.java
@@ -4,14 +4,13 @@
*/
package org.geoserver.cloud.autoconfigure.catalog.backend.jdbcconfig;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
diff --git a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/RemoteEventJdbcConfigAutoConfiguration.java b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/RemoteEventJdbcConfigAutoConfiguration.java
index dbbff465b..95afcca69 100644
--- a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/RemoteEventJdbcConfigAutoConfiguration.java
+++ b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/RemoteEventJdbcConfigAutoConfiguration.java
@@ -16,8 +16,7 @@
public class RemoteEventJdbcConfigAutoConfiguration {
@Bean
- RemoteEventJdbcConfigProcessor jdbcConfigRemoteEventProcessor(
- ConfigDatabase jdbcConfigDatabase) {
+ RemoteEventJdbcConfigProcessor jdbcConfigRemoteEventProcessor(ConfigDatabase jdbcConfigDatabase) {
return new RemoteEventJdbcConfigProcessor(jdbcConfigDatabase);
}
}
diff --git a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/CloudJdbcConfigDatabase.java b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/CloudJdbcConfigDatabase.java
index 4fd860523..95604c402 100644
--- a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/CloudJdbcConfigDatabase.java
+++ b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/CloudJdbcConfigDatabase.java
@@ -4,6 +4,7 @@
*/
package org.geoserver.cloud.config.catalog.backend.jdbcconfig;
+import javax.sql.DataSource;
import org.geoserver.catalog.Info;
import org.geoserver.catalog.impl.CatalogImpl;
import org.geoserver.catalog.impl.ModificationProxy;
@@ -13,8 +14,6 @@
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
-import javax.sql.DataSource;
-
/**
* Overrides {@link #save} and {@link #remove} to {@link #clearCache(Info) dispose the internal
* cache} for both the {@link ModificationProxy} wrapped object (as it may contain identity
diff --git a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/CloudJdbcConfigProperties.java b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/CloudJdbcConfigProperties.java
index 4cfbbfd3d..c789fb7d6 100644
--- a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/CloudJdbcConfigProperties.java
+++ b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/CloudJdbcConfigProperties.java
@@ -6,23 +6,19 @@
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
-
-import lombok.EqualsAndHashCode;
-
-import org.geoserver.jdbcconfig.internal.ConfigDatabase;
-import org.geoserver.jdbcconfig.internal.JDBCConfigProperties;
-import org.geoserver.jdbcconfig.internal.JDBCConfigPropertiesFactoryBean;
-import org.geoserver.jdbcloader.DataSourceFactoryBean;
-import org.geoserver.platform.resource.Resource;
-
import java.io.IOException;
import java.net.URL;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
-
import javax.sql.DataSource;
+import lombok.EqualsAndHashCode;
+import org.geoserver.jdbcconfig.internal.ConfigDatabase;
+import org.geoserver.jdbcconfig.internal.JDBCConfigProperties;
+import org.geoserver.jdbcconfig.internal.JDBCConfigPropertiesFactoryBean;
+import org.geoserver.jdbcloader.DataSourceFactoryBean;
+import org.geoserver.platform.resource.Resource;
/** Extends {@link JDBCConfigProperties} to not need a {@link JDBCConfigPropertiesFactoryBean} */
@EqualsAndHashCode(callSuper = true)
diff --git a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/CloudJdbcGeoServerLoader.java b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/CloudJdbcGeoServerLoader.java
index ae3cf3307..432cc76f5 100644
--- a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/CloudJdbcGeoServerLoader.java
+++ b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/CloudJdbcGeoServerLoader.java
@@ -4,6 +4,9 @@
*/
package org.geoserver.cloud.config.catalog.backend.jdbcconfig;
+import java.io.IOException;
+import java.util.List;
+import javax.annotation.PostConstruct;
import org.geoserver.catalog.Catalog;
import org.geoserver.cloud.config.catalog.backend.core.CoreBackendConfiguration;
import org.geoserver.config.DefaultGeoServerLoader;
@@ -21,11 +24,6 @@
import org.geoserver.platform.GeoServerResourceLoader;
import org.geoserver.platform.resource.Resource.Lock;
-import java.io.IOException;
-import java.util.List;
-
-import javax.annotation.PostConstruct;
-
/**
* {@link Catalog} and {@link GeoServer config} loader for the jdbcconfig backend, loads the
* configuration as soon as the spring bean wiring is {@link #load() ready}; {@link
@@ -79,8 +77,7 @@ protected void loadGeoServer(GeoServer geoServer, XStreamPersister xp) {
geoServer.setLogging(geoServer.getFactory().createLogging());
}
// ensure we have a service configuration for every service we know about
- final List loaders =
- GeoServerExtensions.extensions(XStreamServiceLoader.class);
+ final List loaders = GeoServerExtensions.extensions(XStreamServiceLoader.class);
for (XStreamServiceLoader l : loaders) {
ServiceInfo s = geoServer.getService(l.getServiceClass());
if (s == null) {
diff --git a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/CloudJdbcGeoserverFacade.java b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/CloudJdbcGeoserverFacade.java
index 3fb75d7fb..74f0b0660 100644
--- a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/CloudJdbcGeoserverFacade.java
+++ b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/CloudJdbcGeoserverFacade.java
@@ -10,7 +10,13 @@
import static org.geoserver.catalog.Predicates.isNull;
import com.google.common.base.Preconditions;
-
+import java.lang.reflect.Proxy;
+import java.rmi.server.UID;
+import java.util.Collection;
+import java.util.List;
+import java.util.logging.Logger;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.geoserver.catalog.Info;
import org.geoserver.catalog.WorkspaceInfo;
import org.geoserver.catalog.impl.ModificationProxy;
@@ -26,15 +32,6 @@
import org.geotools.api.filter.Filter;
import org.geotools.util.logging.Logging;
-import java.lang.reflect.Proxy;
-import java.rmi.server.UID;
-import java.util.Collection;
-import java.util.List;
-import java.util.logging.Logger;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
/**
* Copy of {@link JDBCGeoServerFacade} that does not try reinitialize logging, can't extend it
* 'cause the field "geoServer" is private and need to override {@link #setGeoServer(GeoServer)}
@@ -226,8 +223,7 @@ public T getService(final Class clazz) {
@SuppressWarnings("unchecked")
@Override
- public T getService(
- final WorkspaceInfo workspace, final Class clazz) {
+ public T getService(final WorkspaceInfo workspace, final Class clazz) {
return (T) db.getService(workspace, clazz);
}
@@ -249,9 +245,7 @@ public T getServiceByName(
}
private T findByName(
- @Nonnull final String name,
- @Nullable final WorkspaceInfo workspace,
- @Nonnull final Class clazz)
+ @Nonnull final String name, @Nullable final WorkspaceInfo workspace, @Nonnull final Class clazz)
throws AssertionError {
Filter filter = equal("name", name);
diff --git a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/CloudJdbcStoreProperties.java b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/CloudJdbcStoreProperties.java
index 0b7ca9571..c7a2e4991 100644
--- a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/CloudJdbcStoreProperties.java
+++ b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/CloudJdbcStoreProperties.java
@@ -6,14 +6,6 @@
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
-
-import lombok.EqualsAndHashCode;
-
-import org.geoserver.jdbcloader.DataSourceFactoryBean;
-import org.geoserver.jdbcstore.internal.JDBCResourceStoreProperties;
-import org.geoserver.jdbcstore.internal.JDBCResourceStorePropertiesFactoryBean;
-import org.geoserver.platform.resource.Resource;
-
import java.io.File;
import java.io.IOException;
import java.net.URL;
@@ -21,8 +13,12 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
-
import javax.sql.DataSource;
+import lombok.EqualsAndHashCode;
+import org.geoserver.jdbcloader.DataSourceFactoryBean;
+import org.geoserver.jdbcstore.internal.JDBCResourceStoreProperties;
+import org.geoserver.jdbcstore.internal.JDBCResourceStorePropertiesFactoryBean;
+import org.geoserver.platform.resource.Resource;
/**
* Extends {@link JDBCResourceStoreProperties} to not need a {@link
diff --git a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/JDBCConfigBackendConfigurer.java b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/JDBCConfigBackendConfigurer.java
index 6a1ed5d3d..9618bf40f 100644
--- a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/JDBCConfigBackendConfigurer.java
+++ b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/JDBCConfigBackendConfigurer.java
@@ -7,12 +7,19 @@
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.zaxxer.hikari.HikariDataSource;
-
+import java.io.File;
+import java.io.IOException;
+import java.io.Serializable;
+import java.nio.file.Path;
+import java.sql.Driver;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.TimeUnit;
+import javax.sql.DataSource;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.GeoServerConfigurationLock;
import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.plugin.CatalogFacadeExtensionAdapter;
@@ -59,17 +66,6 @@
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.util.StringUtils;
-import java.io.File;
-import java.io.IOException;
-import java.io.Serializable;
-import java.nio.file.Path;
-import java.sql.Driver;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.TimeUnit;
-
-import javax.sql.DataSource;
-
/**
* Configure JDBC Config catalog
*
@@ -123,13 +119,10 @@ public class JDBCConfigBackendConfigurer extends GeoServerBackendConfigurer {
private JdbcConfigConfigurationProperties jdbcconfigConfig;
public JDBCConfigBackendConfigurer(
- JdbcConfigConfigurationProperties backendConfig,
- @Value("${info.instance-id:}") String instanceId) {
+ JdbcConfigConfigurationProperties backendConfig, @Value("${info.instance-id:}") String instanceId) {
this.jdbcconfigConfig = backendConfig;
this.instanceId = instanceId;
- log.info(
- "Loading geoserver config backend with {}",
- JDBCConfigBackendConfigurer.class.getSimpleName());
+ log.info("Loading geoserver config backend with {}", JDBCConfigBackendConfigurer.class.getSimpleName());
}
@DependsOn("jdbcConfigDataSourceStartupValidator")
@@ -177,12 +170,7 @@ CloudJdbcStoreProperties jdbcStoreProperties() {
return loader;
}
- @DependsOn({
- "extensions",
- "JDBCConfigDB",
- "jdbcConfigDataSourceStartupValidator",
- "noopCacheProvider"
- })
+ @DependsOn({"extensions", "JDBCConfigDB", "jdbcConfigDataSourceStartupValidator", "noopCacheProvider"})
@Bean(name = {"resourceStoreImpl"})
protected @Override ResourceStore resourceStoreImpl() {
@@ -277,8 +265,7 @@ DefaultLockRepository jdbcLockRepository() {
Catalog rawCatalog = (Catalog) GeoServerExtensions.bean("rawCatalog");
GeoServer geoserver = (GeoServer) GeoServerExtensions.bean("geoServer");
try {
- return new CloudJdbcGeoServerLoader(
- rawCatalog, geoserver, resourceLoader(), config, configdb);
+ return new CloudJdbcGeoServerLoader(rawCatalog, geoserver, resourceLoader(), config, configdb);
} catch (Exception e) {
throw new BeanInstantiationException(JDBCGeoServerLoader.class, e.getMessage(), e);
}
@@ -312,9 +299,7 @@ ConfigDatabase jdbcConfigDB() {
}
private boolean initDbSchema(
- JDBCConfigProperties catalogConfig,
- CloudJdbcStoreProperties resourceStoreConfig,
- ConfigDatabase configDb) {
+ JDBCConfigProperties catalogConfig, CloudJdbcStoreProperties resourceStoreConfig, ConfigDatabase configDb) {
// Need to check whether the db needs to be initialized here because secureCatalog's
// constructor may use the CatalogFacade during initialization (by means of the
// DefaultResourceAccessManager), before JDBCGeoServerLoader.setCatalogFacade() was called
@@ -360,12 +345,12 @@ CacheProvider noopCacheProvider() {
return new CacheProvider() {
@SuppressWarnings("rawtypes")
- private final Cache noOpCache = CacheBuilder.newBuilder().maximumSize(0).build();
+ private final Cache noOpCache =
+ CacheBuilder.newBuilder().maximumSize(0).build();
@SuppressWarnings("unchecked")
@Override
- public Cache getCache(
- String cacheName) {
+ public Cache getCache(String cacheName) {
return noOpCache;
}
};
@@ -377,8 +362,7 @@ private static class CloudJdbcConfigCacheProvider implements org.geoserver.util.
@Override
@SuppressWarnings("unchecked")
- public Cache getCache(
- @NonNull String cacheName) {
+ public Cache getCache(@NonNull String cacheName) {
return (Cache) caches.computeIfAbsent(cacheName, this::newCache);
}
@@ -455,10 +439,9 @@ ExtendedDataSourceProperties jdbcconfigDataSourceProperties() {
@ConfigurationProperties(prefix = "geoserver.backend.jdbcconfig.datasource")
DataSource jdbcConfigDataSource() {
ExtendedDataSourceProperties props = jdbcconfigDataSourceProperties();
- HikariDataSource dataSource =
- props.initializeDataSourceBuilder() //
- .type(HikariDataSource.class)
- .build();
+ HikariDataSource dataSource = props.initializeDataSourceBuilder() //
+ .type(HikariDataSource.class)
+ .build();
dataSource.setMaximumPoolSize(props.getMaximumPoolSize());
dataSource.setMinimumIdle(props.getMinimumIdle());
diff --git a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/JdbcConfigConfigurationProperties.java b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/JdbcConfigConfigurationProperties.java
index 5ba86a95b..9b527b7da 100644
--- a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/JdbcConfigConfigurationProperties.java
+++ b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/JdbcConfigConfigurationProperties.java
@@ -4,15 +4,13 @@
*/
package org.geoserver.cloud.config.catalog.backend.jdbcconfig;
+import java.nio.file.Path;
import lombok.Data;
-
import org.geoserver.cloud.autoconfigure.catalog.backend.jdbcconfig.JDBCConfigAutoConfiguration;
import org.geoserver.cloud.config.catalog.backend.core.GeoServerBackendConfigurer;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
-import java.nio.file.Path;
-
/**
* Configuration properties to use GeoServer's {@code jdbcconfig} and {@code jdbcstore} community
* modules as the {@link GeoServerBackendConfigurer catalog and configuration backend} through the
diff --git a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/JdbcConfigUpdateSequence.java b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/JdbcConfigUpdateSequence.java
index bd2a3bb27..d0799132f 100644
--- a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/JdbcConfigUpdateSequence.java
+++ b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/config/catalog/backend/jdbcconfig/JdbcConfigUpdateSequence.java
@@ -4,22 +4,19 @@
*/
package org.geoserver.cloud.config.catalog.backend.jdbcconfig;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import javax.sql.DataSource;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
-
import org.geoserver.config.GeoServerFacade;
import org.geoserver.config.GeoServerInfo;
import org.geoserver.jdbcconfig.internal.ConfigDatabase;
import org.geoserver.platform.config.UpdateSequence;
import org.springframework.beans.factory.InitializingBean;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import javax.sql.DataSource;
-
/**
* @since 1.0
*/
@@ -56,8 +53,7 @@ public synchronized long nextValue() {
public void afterPropertiesSet() throws Exception {
String createSequenceStatement;
if (props.isPostgreSQL()) {
- createSequenceStatement =
- "CREATE SEQUENCE IF NOT EXISTS %s AS BIGINT CYCLE".formatted(SEQUENCE_NAME);
+ createSequenceStatement = "CREATE SEQUENCE IF NOT EXISTS %s AS BIGINT CYCLE".formatted(SEQUENCE_NAME);
// not using CURRVAL() to avoid the "currval of sequence "" is not yet defined in
// this session" error
getQuery = "SELECT last_value FROM %s".formatted(SEQUENCE_NAME);
@@ -90,8 +86,7 @@ protected long runAndGetLong(String query) {
if (rs.next()) {
return rs.getLong(1);
}
- throw new IllegalStateException(
- "Query did not return a result: %s".formatted(getQuery));
+ throw new IllegalStateException("Query did not return a result: %s".formatted(getQuery));
} finally {
c.setAutoCommit(true);
}
diff --git a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/event/remote/jdbcconfig/RemoteEventJdbcConfigProcessor.java b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/event/remote/jdbcconfig/RemoteEventJdbcConfigProcessor.java
index 250322a0b..a5f65b5b9 100644
--- a/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/event/remote/jdbcconfig/RemoteEventJdbcConfigProcessor.java
+++ b/src/catalog/backends/jdbcconfig/src/main/java/org/geoserver/cloud/event/remote/jdbcconfig/RemoteEventJdbcConfigProcessor.java
@@ -7,7 +7,6 @@
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.catalog.CatalogInfo;
import org.geoserver.cloud.event.info.ConfigInfoType;
import org.geoserver.cloud.event.info.InfoEvent;
@@ -37,18 +36,15 @@ public void onRemoteModifyEvent(InfoModified event) {
}
private void evictConfigDatabaseEntry(InfoEvent event) {
- event.remote()
- .ifPresent(
- remoteEvent -> {
- ConfigInfoType infoType = event.getObjectType();
- if (ConfigInfoType.CATALOG.equals(infoType)) {
- log.trace(
- "ignore catalog default workspace or default namespace change event, no need to treat it.");
- } else {
- log.debug("Evict JDBCConfig cache for {}", event);
- String catalogInfoId = event.getObjectId();
- jdbcConfigDatabase.clearCacheIfPresent(catalogInfoId);
- }
- });
+ event.remote().ifPresent(remoteEvent -> {
+ ConfigInfoType infoType = event.getObjectType();
+ if (ConfigInfoType.CATALOG.equals(infoType)) {
+ log.trace("ignore catalog default workspace or default namespace change event, no need to treat it.");
+ } else {
+ log.debug("Evict JDBCConfig cache for {}", event);
+ String catalogInfoId = event.getObjectId();
+ jdbcConfigDatabase.clearCacheIfPresent(catalogInfoId);
+ }
+ });
}
}
diff --git a/src/catalog/backends/jdbcconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/JDBCConfigAutoConfigurationTest.java b/src/catalog/backends/jdbcconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/JDBCConfigAutoConfigurationTest.java
index f8ad73048..1887ea55a 100644
--- a/src/catalog/backends/jdbcconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/JDBCConfigAutoConfigurationTest.java
+++ b/src/catalog/backends/jdbcconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/JDBCConfigAutoConfigurationTest.java
@@ -10,6 +10,7 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
+import java.nio.file.Paths;
import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.WorkspaceInfo;
import org.geoserver.catalog.impl.CatalogImpl;
@@ -28,8 +29,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
-import java.nio.file.Paths;
-
/**
* Test {@link JDBCConfigBackendConfigurer} through {@link JDBCConfigAutoConfiguration} when {@code
* geoserver.backend.jdbcconfig.enabled=true}
@@ -60,8 +59,7 @@ void testProperties() {
void testCatalogFacade() {
assertThat(rawCatalogFacade, instanceOf(CatalogFacadeExtensionAdapter.class));
assertThat(
- ((CatalogFacadeExtensionAdapter) rawCatalogFacade).getSubject(),
- instanceOf(JDBCCatalogFacade.class));
+ ((CatalogFacadeExtensionAdapter) rawCatalogFacade).getSubject(), instanceOf(JDBCCatalogFacade.class));
}
@Test
diff --git a/src/catalog/backends/jdbcconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/JDBCConfigAutoConfigurationWebDisabledTest.java b/src/catalog/backends/jdbcconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/JDBCConfigAutoConfigurationWebDisabledTest.java
index 1d2937ef4..262c8fc89 100644
--- a/src/catalog/backends/jdbcconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/JDBCConfigAutoConfigurationWebDisabledTest.java
+++ b/src/catalog/backends/jdbcconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/JDBCConfigAutoConfigurationWebDisabledTest.java
@@ -19,16 +19,11 @@
*/
@SpringBootTest(
classes = AutoConfigurationTestConfiguration.class,
- properties = {
- "geoserver.backend.jdbcconfig.enabled=true",
- "geoserver.backend.jdbcconfig.web.enabled=false"
- })
+ properties = {"geoserver.backend.jdbcconfig.enabled=true", "geoserver.backend.jdbcconfig.web.enabled=false"})
class JDBCConfigAutoConfigurationWebDisabledTest extends JDBCConfigTest {
@Test
void testJDBCConfigStatusProvider() {
- assertThrows(
- NoSuchBeanDefinitionException.class,
- () -> context.getBean(JDBCConfigStatusProvider.class));
+ assertThrows(NoSuchBeanDefinitionException.class, () -> context.getBean(JDBCConfigStatusProvider.class));
}
}
diff --git a/src/catalog/backends/jdbcconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/JDBCConfigAutoConfigurationWebEnabledTest.java b/src/catalog/backends/jdbcconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/JDBCConfigAutoConfigurationWebEnabledTest.java
index b9db0f486..3b895c150 100644
--- a/src/catalog/backends/jdbcconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/JDBCConfigAutoConfigurationWebEnabledTest.java
+++ b/src/catalog/backends/jdbcconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/JDBCConfigAutoConfigurationWebEnabledTest.java
@@ -19,17 +19,12 @@
*/
@SpringBootTest(
classes = AutoConfigurationTestConfiguration.class,
- properties = {
- "geoserver.backend.jdbcconfig.enabled=true",
- "geoserver.backend.jdbcconfig.web.enabled=true"
- })
+ properties = {"geoserver.backend.jdbcconfig.enabled=true", "geoserver.backend.jdbcconfig.web.enabled=true"})
@ActiveProfiles("test")
class JDBCConfigAutoConfigurationWebEnabledTest extends JDBCConfigTest {
@Test
void testJDBCConfigStatusProvider() {
- assertThat(
- context.getBean("JDBCConfigStatusProvider"),
- instanceOf(JDBCConfigStatusProvider.class));
+ assertThat(context.getBean("JDBCConfigStatusProvider"), instanceOf(JDBCConfigStatusProvider.class));
}
}
diff --git a/src/catalog/backends/jdbcconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/JDBCConfigTest.java b/src/catalog/backends/jdbcconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/JDBCConfigTest.java
index a1d2ec20d..6823f7bd5 100644
--- a/src/catalog/backends/jdbcconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/JDBCConfigTest.java
+++ b/src/catalog/backends/jdbcconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/JDBCConfigTest.java
@@ -5,7 +5,7 @@
package org.geoserver.cloud.autoconfigure.catalog.backend.jdbcconfig;
import com.zaxxer.hikari.HikariDataSource;
-
+import javax.sql.DataSource;
import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.CatalogFacade;
import org.geoserver.config.GeoServer;
@@ -19,8 +19,6 @@
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ActiveProfiles;
-import javax.sql.DataSource;
-
/**
* Closes the {@link DataSource} after each test run, otherwise, being an in-memory H2 db (as
* configured in {@code bootstrap-test.yml}) the first test class will succeed and the following
@@ -37,8 +35,7 @@ public abstract class JDBCConfigTest {
protected @Autowired @Qualifier("catalogFacade") CatalogFacade rawCatalogFacade;
protected @Autowired @Qualifier("geoServer") GeoServer geoServer;
protected @Autowired @Qualifier("resourceLoader") GeoServerResourceLoader resourceLoader;
- protected @Autowired(required = false) @Qualifier("geoserverFacade") GeoServerFacade
- geoserverFacade;
+ protected @Autowired(required = false) @Qualifier("geoserverFacade") GeoServerFacade geoserverFacade;
protected @Autowired @Qualifier("geoServerLoaderImpl") GeoServerLoader geoserverLoader;
protected @Autowired @Qualifier("resourceStoreImpl") ResourceStore resourceStoreImpl;
diff --git a/src/catalog/backends/jdbcconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/JdbcConfigDataSourceTest.java b/src/catalog/backends/jdbcconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/JdbcConfigDataSourceTest.java
index c6cbc2644..820a469d0 100644
--- a/src/catalog/backends/jdbcconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/JdbcConfigDataSourceTest.java
+++ b/src/catalog/backends/jdbcconfig/src/test/java/org/geoserver/cloud/autoconfigure/catalog/backend/jdbcconfig/JdbcConfigDataSourceTest.java
@@ -11,15 +11,12 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.zaxxer.hikari.HikariDataSource;
-
-import org.junit.jupiter.api.Test;
-import org.springframework.boot.test.context.SpringBootTest;
-
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLTransientConnectionException;
-
import javax.sql.DataSource;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest(
classes = AutoConfigurationTestConfiguration.class,
diff --git a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/pgconfig/ConditionalOnPgconfigBackendEnabled.java b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/pgconfig/ConditionalOnPgconfigBackendEnabled.java
index 3b8740d0b..7ffffe4c6 100644
--- a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/pgconfig/ConditionalOnPgconfigBackendEnabled.java
+++ b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/pgconfig/ConditionalOnPgconfigBackendEnabled.java
@@ -4,13 +4,12 @@
*/
package org.geoserver.cloud.autoconfigure.catalog.backend.pgconfig;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
/**
* @since 1.4
diff --git a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/pgconfig/PgconfigTransactionManagerAutoConfiguration.java b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/pgconfig/PgconfigTransactionManagerAutoConfiguration.java
index 534c26b0f..7422912c9 100644
--- a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/pgconfig/PgconfigTransactionManagerAutoConfiguration.java
+++ b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/autoconfigure/catalog/backend/pgconfig/PgconfigTransactionManagerAutoConfiguration.java
@@ -4,22 +4,20 @@
*/
package org.geoserver.cloud.autoconfigure.catalog.backend.pgconfig;
+import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
-import javax.sql.DataSource;
-
@AutoConfiguration(after = PgconfigDataSourceAutoConfiguration.class)
@ConditionalOnPgconfigBackendEnabled
@EnableTransactionManagement
public class PgconfigTransactionManagerAutoConfiguration {
@Bean
- DataSourceTransactionManager pgconfigTransactionManager(
- @Qualifier("pgconfigDataSource") DataSource dataSource) {
+ DataSourceTransactionManager pgconfigTransactionManager(@Qualifier("pgconfigDataSource") DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
}
diff --git a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/PgconfigBackendBuilder.java b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/PgconfigBackendBuilder.java
index d99676941..25f5d423b 100644
--- a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/PgconfigBackendBuilder.java
+++ b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/PgconfigBackendBuilder.java
@@ -4,9 +4,9 @@
*/
package org.geoserver.cloud.backend.pgconfig;
+import javax.sql.DataSource;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
-
import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.impl.CatalogImpl;
import org.geoserver.catalog.plugin.CatalogPlugin;
@@ -16,8 +16,6 @@
import org.geoserver.config.plugin.GeoServerImpl;
import org.springframework.jdbc.core.JdbcTemplate;
-import javax.sql.DataSource;
-
/**
* @since 1.4
*/
diff --git a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/PgconfigCatalogFacade.java b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/PgconfigCatalogFacade.java
index d90cea2f7..d806ac931 100644
--- a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/PgconfigCatalogFacade.java
+++ b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/PgconfigCatalogFacade.java
@@ -4,8 +4,9 @@
*/
package org.geoserver.cloud.backend.pgconfig.catalog;
+import java.util.function.Supplier;
+import java.util.function.UnaryOperator;
import lombok.NonNull;
-
import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.CatalogInfo;
import org.geoserver.catalog.plugin.RepositoryCatalogFacadeImpl;
@@ -22,9 +23,6 @@
import org.geoserver.cloud.backend.pgconfig.catalog.repository.PgconfigWorkspaceRepository;
import org.springframework.jdbc.core.JdbcTemplate;
-import java.util.function.Supplier;
-import java.util.function.UnaryOperator;
-
/**
* @since 1.4
*/
@@ -64,11 +62,9 @@ private void setOutboundResolver() {
.forEach(repo -> repo.setOutboundResolver(resolvingFunction));
}
- public static UnaryOperator resolvingFunction(
- Supplier catalog) {
+ public static UnaryOperator resolvingFunction(Supplier catalog) {
return CatalogPropertyResolver.of(catalog)
- .andThen(ResolvingProxyResolver.of(catalog))
- .andThen(CollectionPropertiesInitializer.instance())
- ::apply;
+ .andThen(ResolvingProxyResolver.of(catalog))
+ .andThen(CollectionPropertiesInitializer.instance())::apply;
}
}
diff --git a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/CatalogInfoLiteralAdaptor.java b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/CatalogInfoLiteralAdaptor.java
index dc28c1ebe..0578b3592 100644
--- a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/CatalogInfoLiteralAdaptor.java
+++ b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/CatalogInfoLiteralAdaptor.java
@@ -4,9 +4,10 @@
*/
package org.geoserver.cloud.backend.pgconfig.catalog.filter;
+import java.util.Optional;
+import java.util.Set;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
-
import org.geoserver.catalog.CatalogInfo;
import org.geoserver.catalog.WorkspaceInfo;
import org.geotools.api.filter.BinaryComparisonOperator;
@@ -25,9 +26,6 @@
import org.geotools.factory.CommonFactoryFinder;
import org.geotools.filter.visitor.DuplicatingFilterVisitor;
-import java.util.Optional;
-import java.util.Set;
-
/**
* Converts binary comparison operators using a property name and a {@link CatalogInfo} instance
* literal as a comparison by id.
@@ -52,8 +50,7 @@ public CatalogInfoLiteralAdaptor(@NonNull Set supportedPropertyNames) {
this.supportedPropertyNames = supportedPropertyNames;
}
- public static Filter replaceCatalogInfoLiterals(
- Filter filter, Set supportedPropertyNames) {
+ public static Filter replaceCatalogInfoLiterals(Filter filter, Set supportedPropertyNames) {
var adaptor = new CatalogInfoLiteralAdaptor(supportedPropertyNames);
return (Filter) filter.accept(adaptor, null);
}
@@ -101,8 +98,7 @@ private static interface BinaryComparisonBuilder F adapt(
- F filter, BinaryComparisonBuilder builder) {
+ private F adapt(F filter, BinaryComparisonBuilder builder) {
PropertyName prop = propertyName(filter);
Literal literal = literal(filter);
@@ -118,10 +114,7 @@ private F adapt(
boolean matchingCase = filter.isMatchingCase();
MatchAction matchAction = filter.getMatchAction();
filter = builder.build(prop, literal, matchingCase, matchAction);
- log.debug(
- "Fitler with CatalogInfo literal '{}' translated to '{}'",
- orig,
- filter);
+ log.debug("Fitler with CatalogInfo literal '{}' translated to '{}'", orig, filter);
}
}
}
diff --git a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/PgconfigCatalogFilterSplitter.java b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/PgconfigCatalogFilterSplitter.java
index f28be896b..cea68768f 100644
--- a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/PgconfigCatalogFilterSplitter.java
+++ b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/PgconfigCatalogFilterSplitter.java
@@ -4,14 +4,12 @@
*/
package org.geoserver.cloud.backend.pgconfig.catalog.filter;
+import java.util.Set;
import lombok.NonNull;
-
import org.geotools.api.filter.Filter;
import org.geotools.api.filter.expression.PropertyName;
import org.geotools.filter.visitor.PostPreProcessFilterSplittingVisitor;
-import java.util.Set;
-
/**
* Splits a {@link Filter} into supported and unsupported filters for SQL encoding and
* post-filtering, based on the supported column names provided in the constructor.
@@ -27,8 +25,7 @@ public PgconfigCatalogFilterSplitter(@NonNull Set supportedPropertyNames
this.supportedPropertyNames = supportedPropertyNames;
}
- public static PgconfigCatalogFilterSplitter split(
- Filter filter, Set supportedPropertyNames) {
+ public static PgconfigCatalogFilterSplitter split(Filter filter, Set supportedPropertyNames) {
var splitter = new PgconfigCatalogFilterSplitter(supportedPropertyNames);
filter.accept(splitter, null);
return splitter;
diff --git a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/PgconfigFilterCapabilities.java b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/PgconfigFilterCapabilities.java
index bcd9a1a00..41a2b48ac 100644
--- a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/PgconfigFilterCapabilities.java
+++ b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/PgconfigFilterCapabilities.java
@@ -5,7 +5,6 @@
package org.geoserver.cloud.backend.pgconfig.catalog.filter;
import lombok.experimental.UtilityClass;
-
import org.geoserver.function.IsInstanceOf;
import org.geotools.api.filter.ExcludeFilter;
import org.geotools.api.filter.Id;
diff --git a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/PgconfigFilterToSQL.java b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/PgconfigFilterToSQL.java
index 56e7b9ade..04bc719d1 100644
--- a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/PgconfigFilterToSQL.java
+++ b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/PgconfigFilterToSQL.java
@@ -4,9 +4,18 @@
*/
package org.geoserver.cloud.backend.pgconfig.catalog.filter;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.UncheckedIOException;
+import java.io.Writer;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import lombok.NonNull;
import lombok.Value;
-
import org.geoserver.catalog.CatalogInfo;
import org.geoserver.catalog.impl.ClassMappings;
import org.geoserver.function.IsInstanceOf;
@@ -38,17 +47,6 @@
import org.geotools.jdbc.PreparedFilterToSQL;
import org.geotools.util.Converters;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.UncheckedIOException;
-import java.io.Writer;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
/**
* @since 1.4
*/
@@ -90,20 +88,18 @@ public Object visit(PropertyIsEqualTo filter, Object extraData) {
Expression left = filter.getExpression1();
Expression right = filter.getExpression2();
- PropertyName prop =
- Optional.of(left)
- .filter(PropertyName.class::isInstance)
- .or(() -> Optional.of(right).filter(PropertyName.class::isInstance))
- .map(PropertyName.class::cast)
- .orElse(null);
+ PropertyName prop = Optional.of(left)
+ .filter(PropertyName.class::isInstance)
+ .or(() -> Optional.of(right).filter(PropertyName.class::isInstance))
+ .map(PropertyName.class::cast)
+ .orElse(null);
if (isArray(prop)) {
Expression value = right;
if (right instanceof Literal literal) {
- String values =
- asList(literal.getValue()).stream()
- .map(o -> Converters.convert(o, String.class))
- .map("'%s'"::formatted)
- .collect(Collectors.joining(","));
+ String values = asList(literal.getValue()).stream()
+ .map(o -> Converters.convert(o, String.class))
+ .map("'%s'"::formatted)
+ .collect(Collectors.joining(","));
value = new LiteralExpressionImpl("ARRAY[%s]".formatted(values));
}
try {
@@ -165,8 +161,7 @@ public Object visit(PropertyIsLike filter, Object extraData) {
literal += multi;
}
- String pattern =
- LikeFilterImpl.convertToSQL92(esc, multi, single, matchCase, literal, false);
+ String pattern = LikeFilterImpl.convertToSQL92(esc, multi, single, matchCase, literal, false);
try {
att.accept(this, extraData);
@@ -331,11 +326,9 @@ protected boolean visitFunction(Function function) throws IOException {
Class extends CatalogInfo> type = typeExpr.evaluate(null, Class.class);
String types = infoTypes(type);
- String f =
- """
+ String f = """
"@type" = ANY('{%s}')
- """
- .formatted(types);
+ """.formatted(types);
out.write(f);
return true;
}
@@ -349,11 +342,8 @@ protected boolean visitFunction(Function function) throws IOException {
if (clazz.isInterface()) cm = ClassMappings.fromInterface(clazz);
else cm = ClassMappings.fromImpl(clazz);
if (null == cm)
- throw new IllegalArgumentException(
- "Unknown type for IsInstanceOf: " + clazz.getCanonicalName());
+ throw new IllegalArgumentException("Unknown type for IsInstanceOf: " + clazz.getCanonicalName());
- return Stream.of(cm.concreteInterfaces())
- .map(Class::getSimpleName)
- .collect(Collectors.joining(","));
+ return Stream.of(cm.concreteInterfaces()).map(Class::getSimpleName).collect(Collectors.joining(","));
}
}
diff --git a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/PgconfigQueryBuilder.java b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/PgconfigQueryBuilder.java
index 2b13602c7..dc29c393e 100644
--- a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/PgconfigQueryBuilder.java
+++ b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/PgconfigQueryBuilder.java
@@ -7,16 +7,14 @@
import static org.geoserver.cloud.backend.pgconfig.catalog.filter.CatalogInfoLiteralAdaptor.replaceCatalogInfoLiterals;
import static org.geoserver.cloud.backend.pgconfig.catalog.filter.PgconfigCatalogFilterSplitter.split;
+import java.util.List;
+import java.util.Set;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-
import org.geoserver.cloud.backend.pgconfig.catalog.filter.PgconfigFilterToSQL.Result;
import org.geotools.api.filter.Filter;
import org.geotools.filter.visitor.SimplifyingFilterVisitor;
-import java.util.List;
-import java.util.Set;
-
/**
* @since 1.4
*/
@@ -57,8 +55,7 @@ public PgconfigQueryBuilder build() {
}
private Filter adaptToSql(Filter filterPre) {
- Filter supported =
- ToPgsqlCompatibleFilterDuplicator.adapt(filterPre, supportedPropertyNames);
+ Filter supported = ToPgsqlCompatibleFilterDuplicator.adapt(filterPre, supportedPropertyNames);
return simplify(supported);
}
diff --git a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/ToPgsqlCompatibleFilterDuplicator.java b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/ToPgsqlCompatibleFilterDuplicator.java
index 3bc37fd10..fe19ddc84 100644
--- a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/ToPgsqlCompatibleFilterDuplicator.java
+++ b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/filter/ToPgsqlCompatibleFilterDuplicator.java
@@ -4,9 +4,15 @@
*/
package org.geoserver.cloud.backend.pgconfig.catalog.filter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import javax.annotation.Nullable;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
-
import org.geotools.api.filter.BinaryComparisonOperator;
import org.geotools.api.filter.Filter;
import org.geotools.api.filter.MultiValuedFilter.MatchAction;
@@ -22,15 +28,6 @@
import org.geotools.api.filter.expression.PropertyName;
import org.geotools.filter.visitor.DuplicatingFilterVisitor;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-import java.util.function.BiFunction;
-import java.util.function.Function;
-
-import javax.annotation.Nullable;
-
/**
* Duplicates a supported filter making it directly translatable to SQL taking care of subtleties
* like {@link MatchAction} and case matching.
@@ -40,7 +37,8 @@
@RequiredArgsConstructor
class ToPgsqlCompatibleFilterDuplicator extends DuplicatingFilterVisitor {
- @NonNull private final Set supportedPropertyNames;
+ @NonNull
+ private final Set supportedPropertyNames;
/**
* @param supportedFilter Filter that's already been deemed as supported
@@ -157,8 +155,7 @@ private Function, Filter> createOredOrAndedBuilder(final MatchActio
/**
* Only if exactly one of the possible combinations match, the result is true (aggregated XOR)
*/
- private Filter aggregateXor(
- BinaryComparisonOperator origFilter, Expression leftExpr, final List