From 51f93efa08369e00d479f7cdb8b9ab12240a8633 Mon Sep 17 00:00:00 2001 From: Gabriel Roldan Date: Tue, 6 Aug 2024 20:39:57 -0300 Subject: [PATCH] Backport upgrade to GeoServer 2.25.3 and geonode OAuth2 support --- .github/workflows/build-and-push.yaml | 1 + compose/infra.yml | 2 +- docs/cosign/cosign.pub | 4 +++ .../cloud/gwc/app/GeoWebCacheApplication.java | 2 ++ .../gwc/src/main/resources/bootstrap.yml | 3 -- src/apps/geoserver/pom.xml | 5 +++ .../src/main/resources/bootstrap.yml | 3 -- .../wcs/src/main/resources/bootstrap.yml | 3 -- .../cloud/web/app/WebUIApplication.java | 2 +- .../web/service/ServiceInstanceRegistry.java | 2 +- .../webui/src/main/resources/bootstrap.yml | 3 -- .../wfs/src/main/resources/bootstrap.yml | 3 -- .../wps/src/main/resources/bootstrap.yml | 2 -- .../admin/src/main/resources/bootstrap.yml | 3 -- .../RegExpQueryRoutePredicateFactory.java | 5 ++- .../gateway/src/main/resources/bootstrap.yml | 2 -- ...ingEnvironmentAwareGeoToolsHttpClient.java | 7 +++-- ...nvironmentAdminAuthenticationProvider.java | 14 ++++----- .../jdbcconfig/CloudJdbcStoreProperties.java | 2 +- .../jdbcconfig/JdbcConfigUpdateSequence.java | 19 +++++------- .../cloud/event/bus/RemoteGeoServerEvent.java | 14 ++++----- .../catalog/PatchSerializationTest.java | 30 +++++++----------- .../geojson/GeoToolsGeoJsonModuleTest.java | 2 +- .../catalog/plugin/CatalogInfoLookup.java | 10 +++--- .../org/geoserver/catalog/plugin/Patch.java | 4 +-- .../catalog/plugin/PropertyDiff.java | 2 +- .../plugin/RepositoryCatalogFacadeImpl.java | 8 ++--- ...ockProviderGeoServerConfigurationLock.java | 10 +++--- .../plugin/locking/LockingCatalog.java | 25 ++++++--------- .../plugin/locking/LockingGeoServer.java | 19 ++++++------ .../plugin/rules/CatalogOpContext.java | 10 +++--- .../validation/DefaultCatalogValidator.java | 16 ++++------ .../config/plugin/GeoServerImpl.java | 5 ++- .../geoserver/catalog/CatalogTestData.java | 5 ++- .../plugin/CatalogConformanceTest.java | 7 ++--- .../catalog/plugin/XmlCatalogInfoLookup.java | 12 +++---- .../cloud/gwc/event/GeoWebCacheEvent.java | 10 ++++-- .../cloud/gwc/event/TileLayerEvent.java | 5 ++- .../bus/GeoWebCacheRemoteEventsBroker.java | 2 +- .../cloud/gwc/bus/RemoteGeoWebCacheEvent.java | 18 +++++------ .../FilteringXmlBeanDefinitionReader.java | 10 +++--- src/pom.xml | 18 +++++++---- src/starters/geonode/pom.xml | 31 +++++++++++++++++++ .../GeoNodeOAuth2AutoConfiguration.java | 30 ++++++++++++++++++ .../main/resources/META-INF/spring.factories | 2 ++ src/starters/pom.xml | 1 + 46 files changed, 212 insertions(+), 181 deletions(-) create mode 100644 docs/cosign/cosign.pub create mode 100644 src/starters/geonode/pom.xml create mode 100644 src/starters/geonode/src/main/java/org/geoserver/cloud/autoconfigure/geonode/GeoNodeOAuth2AutoConfiguration.java create mode 100644 src/starters/geonode/src/main/resources/META-INF/spring.factories diff --git a/.github/workflows/build-and-push.yaml b/.github/workflows/build-and-push.yaml index 6361e7683..53b92fa92 100644 --- a/.github/workflows/build-and-push.yaml +++ b/.github/workflows/build-and-push.yaml @@ -10,6 +10,7 @@ on: - "Makefile" - "pom.xml" - ".github/workflows/build-and-push.yaml" + - "config" - "src/**" tags: - '*' diff --git a/compose/infra.yml b/compose/infra.yml index 90df2fb28..9e902c664 100644 --- a/compose/infra.yml +++ b/compose/infra.yml @@ -21,7 +21,7 @@ services: - acl_data:/var/lib/postgresql/data rabbitmq: - image: rabbitmq:3.12.12 + image: rabbitmq:3.13.3-alpine user: ${GS_USER} tmpfs: - /var/lib/rabbitmq diff --git a/docs/cosign/cosign.pub b/docs/cosign/cosign.pub new file mode 100644 index 000000000..b128b2853 --- /dev/null +++ b/docs/cosign/cosign.pub @@ -0,0 +1,4 @@ +-----BEGIN PUBLIC KEY----- +MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEsUudw4Y6QJfiCMwBvu3KIssgfvEx +rCJ8pRHZL78ybbHiCPYyIwmy6RTOYaHePIFxDviZ0WZWH1fo3hrbw0b2ZQ== +-----END PUBLIC KEY----- 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 3d94a1886..33356ceab 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 @@ -7,8 +7,10 @@ import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.retry.annotation.EnableRetry; @SpringBootApplication +@EnableRetry public class GeoWebCacheApplication { public static void main(String[] args) { diff --git a/src/apps/geoserver/gwc/src/main/resources/bootstrap.yml b/src/apps/geoserver/gwc/src/main/resources/bootstrap.yml index 47afd724a..2063cd32c 100644 --- a/src/apps/geoserver/gwc/src/main/resources/bootstrap.yml +++ b/src/apps/geoserver/gwc/src/main/resources/bootstrap.yml @@ -67,9 +67,6 @@ spring: # override default of true, this service does not use the registry (when eureka client is enabled) eureka.client.fetch-registry: false -logging.level: - '[org.springframework.retry]': debug - --- # local profile, used for development only. Other settings like config and eureka urls in gs_cloud_bootstrap_profiles.yml spring.config.activate.on-profile: local diff --git a/src/apps/geoserver/pom.xml b/src/apps/geoserver/pom.xml index 77e010da9..ac99df5da 100644 --- a/src/apps/geoserver/pom.xml +++ b/src/apps/geoserver/pom.xml @@ -48,6 +48,11 @@ org.geoserver.cloud gs-cloud-starter-observability + + org.geoserver.cloud + gs-cloud-starter-geonode + ${project.version} + org.geoserver.cloud spring-boot-simplejndi diff --git a/src/apps/geoserver/restconfig/src/main/resources/bootstrap.yml b/src/apps/geoserver/restconfig/src/main/resources/bootstrap.yml index d56d0b036..a04ef0e95 100644 --- a/src/apps/geoserver/restconfig/src/main/resources/bootstrap.yml +++ b/src/apps/geoserver/restconfig/src/main/resources/bootstrap.yml @@ -41,9 +41,6 @@ spring: # override default of true, this service does not use the registry (when eureka client is enabled) eureka.client.fetch-registry: false -logging.level: - '[org.springframework.retry]': debug - --- # local profile, used for development only. Other settings like config and eureka urls in gs_cloud_bootstrap_profiles.yml spring.config.activate.on-profile: local diff --git a/src/apps/geoserver/wcs/src/main/resources/bootstrap.yml b/src/apps/geoserver/wcs/src/main/resources/bootstrap.yml index 85f367dde..4105f9059 100644 --- a/src/apps/geoserver/wcs/src/main/resources/bootstrap.yml +++ b/src/apps/geoserver/wcs/src/main/resources/bootstrap.yml @@ -39,9 +39,6 @@ spring: # override default of true, this service does not use the registry (when eureka client is enabled) eureka.client.fetch-registry: false -logging.level: - '[org.springframework.retry]': debug - --- # local profile, used for development only. Other settings like config and eureka urls in gs_cloud_bootstrap_profiles.yml spring.config.activate.on-profile: local diff --git a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/app/WebUIApplication.java b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/app/WebUIApplication.java index fca4410f4..c3c19aca2 100644 --- a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/app/WebUIApplication.java +++ b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/app/WebUIApplication.java @@ -34,7 +34,7 @@ public void onApplicationReady(ApplicationReadyEvent e) { final String instanceId = env.getProperty("info.instance-id"); String nodeOpts = System.getProperty("GEOSERVER_NODE_OPTS"); if (null == nodeOpts) { - nodeOpts = String.format("id:%s;color:FF0000", instanceId); + nodeOpts = "id:%s;color:FF0000".formatted(instanceId); System.setProperty("GEOSERVER_NODE_OPTS", nodeOpts); } } 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 2b7abd4cb..2be97864f 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 @@ -62,7 +62,7 @@ private String getStatus(org.springframework.cloud.client.ServiceInstance i) { private String buildUrl(org.springframework.cloud.client.ServiceInstance i) { URI uri = i.getUri(); if (uri == null) { - uri = URI.create(String.format("%s://%s:%s", i.getScheme(), i.getHost(), i.getPort())); + uri = URI.create("%s://%s:%s".formatted(i.getScheme(), i.getHost(), i.getPort())); } return uri.toString(); } diff --git a/src/apps/geoserver/webui/src/main/resources/bootstrap.yml b/src/apps/geoserver/webui/src/main/resources/bootstrap.yml index 7758675c9..6117c7458 100644 --- a/src/apps/geoserver/webui/src/main/resources/bootstrap.yml +++ b/src/apps/geoserver/webui/src/main/resources/bootstrap.yml @@ -94,9 +94,6 @@ geoserver: resource-browser: true catalog-bulk-load: true -logging.level: - '[org.springframework.retry]': debug - --- # local profile, used for development only. Other settings like config and eureka urls in gs_cloud_bootstrap_profiles.yml spring.config.activate.on-profile: local diff --git a/src/apps/geoserver/wfs/src/main/resources/bootstrap.yml b/src/apps/geoserver/wfs/src/main/resources/bootstrap.yml index bcd10bd4f..7b563fabe 100644 --- a/src/apps/geoserver/wfs/src/main/resources/bootstrap.yml +++ b/src/apps/geoserver/wfs/src/main/resources/bootstrap.yml @@ -42,9 +42,6 @@ spring: # override default of true, this service does not use the registry (when eureka client is enabled) eureka.client.fetch-registry: false -logging.level: - '[org.springframework.retry]': debug - --- # local profile, used for development only. Other settings like config and eureka urls in gs_cloud_bootstrap_profiles.yml spring.config.activate.on-profile: local diff --git a/src/apps/geoserver/wps/src/main/resources/bootstrap.yml b/src/apps/geoserver/wps/src/main/resources/bootstrap.yml index 2760031d3..3250b7581 100644 --- a/src/apps/geoserver/wps/src/main/resources/bootstrap.yml +++ b/src/apps/geoserver/wps/src/main/resources/bootstrap.yml @@ -39,8 +39,6 @@ spring: # override default of true, this service does not use the registry (when eureka client is enabled) eureka.client.fetch-registry: false -logging.level: - '[org.springframework.retry]': debug --- # local profile, used for development only. Other settings like config and eureka urls in gs_cloud_bootstrap_profiles.yml spring.config.activate.on-profile: local diff --git a/src/apps/infrastructure/admin/src/main/resources/bootstrap.yml b/src/apps/infrastructure/admin/src/main/resources/bootstrap.yml index d67944896..e609c3712 100644 --- a/src/apps/infrastructure/admin/src/main/resources/bootstrap.yml +++ b/src/apps/infrastructure/admin/src/main/resources/bootstrap.yml @@ -51,9 +51,6 @@ management: export: atlas.enabled: false -logging.level: - '[org.springframework.retry]': debug - --- # local profile, used for development only. Other settings like config and eureka urls in gs_cloud_bootstrap_profiles.yml spring.config.activate.on-profile: local 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 f40115293..91a34cf37 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 @@ -98,9 +98,8 @@ public boolean test(ServerWebExchange exchange) { @Override public String toString() { - return String.format( - "Query: param regexp='%s' value regexp='%s'", - config.getParamRegexp(), config.getValueRegexp()); + return "Query: param regexp='%s' value regexp='%s'" + .formatted(config.getParamRegexp(), config.getValueRegexp()); } } diff --git a/src/apps/infrastructure/gateway/src/main/resources/bootstrap.yml b/src/apps/infrastructure/gateway/src/main/resources/bootstrap.yml index 42dc6dd43..484dbb77e 100644 --- a/src/apps/infrastructure/gateway/src/main/resources/bootstrap.yml +++ b/src/apps/infrastructure/gateway/src/main/resources/bootstrap.yml @@ -15,8 +15,6 @@ spring: application: name: gateway-service jmx.enabled: false -logging.level: - '[org.springframework.retry]': debug # this service uses the registry (when eureka client is enabled) eureka.client: 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 7e4f523e1..9c9d5302b 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 @@ -169,9 +169,10 @@ private HttpClientBuilder builder() { HttpClientBuilder builder = HttpClientBuilder.create() .setUserAgent( - String.format( - "GeoTools/%s (%s)", - GeoTools.getVersion(), this.getClass().getSimpleName())) + "GeoTools/%s (%s)" + .formatted( + GeoTools.getVersion(), + this.getClass().getSimpleName())) .useSystemProperties() .setConnectionManager(connectionManager); if (credsProvider != null) { 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 2fe26d5ac..2e83c11da 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 @@ -66,22 +66,20 @@ void validateConfig() { final boolean passwordSet = StringUtils.hasText(adminPassword); if (userSet && !passwordSet) { String msg = - String.format( - """ + """ Found overriding admin username config property geoserver.admin.username=%s, \ but password not provided through config property geoserver.admin.password - """, - adminUserName); + """ + .formatted(adminUserName); throw new BeanInstantiationException(getClass(), msg); } if (passwordSet && !userSet) { String msg = - String.format( - """ + """ Found overriding admin password config property geoserver.admin.password, \ but admin username not provided through config property geoserver.admin.username - """, - adminUserName); + """ + .formatted(adminUserName); throw new BeanInstantiationException(getClass(), msg); } enabled = userSet && passwordSet; 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 adfdf1222..0b7ca9571 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 @@ -49,7 +49,7 @@ public File getCacheDirectory() { private static String defaultCacheDirectory() { String tmpdir = System.getProperty("java.io.tmpdir"); - return String.format("%s%sgeoserver-jdbcconfig-cache", tmpdir, File.separator); + return "%s%sgeoserver-jdbcconfig-cache".formatted(tmpdir, File.separator); } /** 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 6a2174e9e..bd2a3bb27 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,8 +4,6 @@ */ package org.geoserver.cloud.config.catalog.backend.jdbcconfig; -import static java.lang.String.format; - import lombok.NonNull; import lombok.RequiredArgsConstructor; @@ -59,22 +57,21 @@ public void afterPropertiesSet() throws Exception { String createSequenceStatement; if (props.isPostgreSQL()) { createSequenceStatement = - format("CREATE SEQUENCE IF NOT EXISTS %s AS BIGINT CYCLE", SEQUENCE_NAME); + "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 = format("SELECT last_value FROM %s", SEQUENCE_NAME); - incrementAndGetQuery = format("SELECT NEXTVAL('%s')", SEQUENCE_NAME); + getQuery = "SELECT last_value FROM %s".formatted(SEQUENCE_NAME); + incrementAndGetQuery = "SELECT NEXTVAL('%s')".formatted(SEQUENCE_NAME); } else if (props.isH2()) { - createSequenceStatement = format("CREATE SEQUENCE IF NOT EXISTS %s", SEQUENCE_NAME); + createSequenceStatement = "CREATE SEQUENCE IF NOT EXISTS %s".formatted(SEQUENCE_NAME); getQuery = - format( - """ + """ SELECT CURRENT_VALUE \ FROM INFORMATION_SCHEMA.SEQUENCES \ WHERE SEQUENCE_NAME = '%s' - """, - SEQUENCE_NAME.toUpperCase()); - incrementAndGetQuery = format("SELECT NEXTVAL('%s')", SEQUENCE_NAME); + """ + .formatted(SEQUENCE_NAME.toUpperCase()); + incrementAndGetQuery = "SELECT NEXTVAL('%s')".formatted(SEQUENCE_NAME); } else { throw new IllegalStateException("Db is not PostgreSQL nor H2"); } diff --git a/src/catalog/event-bus/src/main/java/org/geoserver/cloud/event/bus/RemoteGeoServerEvent.java b/src/catalog/event-bus/src/main/java/org/geoserver/cloud/event/bus/RemoteGeoServerEvent.java index 818e29dc9..94bf49f0d 100644 --- a/src/catalog/event-bus/src/main/java/org/geoserver/cloud/event/bus/RemoteGeoServerEvent.java +++ b/src/catalog/event-bus/src/main/java/org/geoserver/cloud/event/bus/RemoteGeoServerEvent.java @@ -36,13 +36,13 @@ public RemoteGeoServerEvent( @Override public String toString() { - return String.format( - "[%s id: '%s', originService: '%s', destinationService: '%s', payload: %s]", - getClass().getSimpleName(), - getId(), - getOriginService(), - getDestinationService(), - getEvent()); + return "[%s id: '%s', originService: '%s', destinationService: '%s', payload: %s]" + .formatted( + getClass().getSimpleName(), + getId(), + getOriginService(), + getDestinationService(), + getEvent()); } public String toShortString() { diff --git a/src/catalog/jackson-bindings/geoserver/src/test/java/org/geoserver/jackson/databind/catalog/PatchSerializationTest.java b/src/catalog/jackson-bindings/geoserver/src/test/java/org/geoserver/jackson/databind/catalog/PatchSerializationTest.java index 18bc532f9..c33d66edc 100644 --- a/src/catalog/jackson-bindings/geoserver/src/test/java/org/geoserver/jackson/databind/catalog/PatchSerializationTest.java +++ b/src/catalog/jackson-bindings/geoserver/src/test/java/org/geoserver/jackson/databind/catalog/PatchSerializationTest.java @@ -792,9 +792,8 @@ private Patch roundtrip(Patch patch) throws JsonProcessingException { Class type = ProxyUtils.referenceTypeOf(patchValue).orElseThrow(); Supplier desc = () -> { - return String.format( - "Patch value of type %s shall be encoded as reference, got value %s", - type.getCanonicalName(), typeName); + return "Patch value of type %s shall be encoded as reference, got value %s" + .formatted(type.getCanonicalName(), typeName); }; assertThat(typeName).as(desc).isEqualTo("ResolvingProxy"); } else { @@ -835,16 +834,14 @@ protected void assertNotAProxy(Object value) { assertThat(ProxyUtils.isResolvingProxy(info)) .as( () -> - String.format( - "%s should not be a ResolvingProxy: %s", - info.getId(), typeName(info))) + "%s should not be a ResolvingProxy: %s" + .formatted(info.getId(), typeName(info))) .isFalse(); assertThat(ProxyUtils.isModificationProxy(info)) .as( () -> - String.format( - "%s should not be a ModificationProxy: %s", - info.getId(), typeName(info))) + "%s should not be a ModificationProxy: %s" + .formatted(info.getId(), typeName(info))) .isFalse(); } } @@ -853,9 +850,8 @@ protected I assertModificationProxy(I info) { assertThat(ProxyUtils.isModificationProxy(info)) .as( () -> - String.format( - "%s should be a ModificationProxy, got %s", - info.getId(), typeName(info))) + "%s should be a ModificationProxy, got %s" + .formatted(info.getId(), typeName(info))) .isTrue(); I real = ModificationProxy.unwrap(info); @@ -874,9 +870,8 @@ protected void assertResolvingProxy(Info info) { assertThat(ProxyUtils.isResolvingProxy(info)) .as( () -> - String.format( - "%s should be a ResolvingProxy, got %s", - info.getId(), typeName(info))) + "%s should be a ResolvingProxy, got %s" + .formatted(info.getId(), typeName(info))) .isTrue(); } @@ -884,9 +879,8 @@ private void assertValueObject(Object valueObject, Class valueType) { if (valueObject instanceof Info info) { Supplier msg = () -> - String.format( - "expected pure value object of type %s, got %s", - valueType.getCanonicalName(), typeName(valueObject)); + "expected pure value object of type %s, got %s" + .formatted(valueType.getCanonicalName(), typeName(valueObject)); assertThat(ProxyUtils.isResolvingProxy(info)).as(msg).isFalse(); assertThat(ProxyUtils.isModificationProxy(info)).as(msg).isFalse(); } diff --git a/src/catalog/jackson-bindings/geotools/src/test/java/org/geotools/jackson/databind/geojson/GeoToolsGeoJsonModuleTest.java b/src/catalog/jackson-bindings/geotools/src/test/java/org/geotools/jackson/databind/geojson/GeoToolsGeoJsonModuleTest.java index 48a54d52d..cfccc77a4 100644 --- a/src/catalog/jackson-bindings/geotools/src/test/java/org/geotools/jackson/databind/geojson/GeoToolsGeoJsonModuleTest.java +++ b/src/catalog/jackson-bindings/geotools/src/test/java/org/geotools/jackson/databind/geojson/GeoToolsGeoJsonModuleTest.java @@ -168,7 +168,7 @@ private void assertActuallyEqualsExact(Geometry g1, Geometry g2) { for (int i = 0; i < cs1.length; i++) { Coordinate c1 = cs1[i]; Coordinate c2 = cs2[i]; - assertTrue(c1.equals3D(c2), String.format("expected %s, got %s", c1, c2)); + assertTrue(c1.equals3D(c2), "expected %s, got %s".formatted(c1, c2)); assertEquals(c1.getM(), c2.getM(), 1e-9d); } } diff --git a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/CatalogInfoLookup.java b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/CatalogInfoLookup.java index e1b607a51..70ee07ebd 100644 --- a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/CatalogInfoLookup.java +++ b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/CatalogInfoLookup.java @@ -168,11 +168,11 @@ public void add(T value) { synchronized (idMap) { if (null != idMap.putIfAbsent(value.getId(), value)) { String msg = - String.format( - "%s:%s(%s) already exists", - ClassMappings.fromImpl(value.getClass()), - value.getId(), - nameMapper.apply(value).getLocalPart()); + "%s:%s(%s) already exists" + .formatted( + ClassMappings.fromImpl(value.getClass()), + value.getId(), + nameMapper.apply(value).getLocalPart()); LOGGER.warning(msg); } Name name = nameMapper.apply(value); diff --git a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/Patch.java b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/Patch.java index ea7ef4894..42509aa23 100644 --- a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/Patch.java +++ b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/Patch.java @@ -203,8 +203,8 @@ private static boolean isCollection(Method getter) { public String toString() { String props = this.getPatches().stream() - .map(p -> String.format("(%s: %s)", p.getName(), p.getValue())) + .map(p -> "(%s: %s)".formatted(p.getName(), p.getValue())) .collect(Collectors.joining(",")); - return String.format("%s[%s]", getClass().getSimpleName(), props); + return "%s[%s]".formatted(getClass().getSimpleName(), props); } } diff --git a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/PropertyDiff.java b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/PropertyDiff.java index d3fe808d6..1c010ad1e 100644 --- a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/PropertyDiff.java +++ b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/PropertyDiff.java @@ -205,7 +205,7 @@ public static Change valueOf(String propertyName, Object oldValue, Object newVal @Override public String toString() { - return String.format("%s: {old: %s, new: %s}", propertyName, oldValue, newValue); + return "%s: {old: %s, new: %s}".formatted(propertyName, oldValue, newValue); } } diff --git a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/RepositoryCatalogFacadeImpl.java b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/RepositoryCatalogFacadeImpl.java index 02943115d..50e826e86 100644 --- a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/RepositoryCatalogFacadeImpl.java +++ b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/RepositoryCatalogFacadeImpl.java @@ -4,8 +4,6 @@ */ package org.geoserver.catalog.plugin; -import static java.lang.String.format; - import com.google.common.collect.Iterators; import com.google.common.collect.Streams; @@ -602,7 +600,6 @@ public int count(final Class of, Filter filter) { try { count = repository(of).count(of, filter); } catch (RuntimeException e) { - e.printStackTrace(); throw new CatalogException( "Error obtaining count of %s with filter %s" .formatted(of.getSimpleName(), filter), @@ -671,9 +668,8 @@ private void checkCanSort(final Query query) { private void checkCanSort(final Class type, SortBy order) { if (!canSort(type, order.getPropertyName().getPropertyName())) { throw new IllegalArgumentException( - format( - "Can't sort objects of type %s by %s", - type.getName(), order.getPropertyName())); + "Can't sort objects of type %s by %s" + .formatted(type.getName(), order.getPropertyName())); } } diff --git a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/locking/LockProviderGeoServerConfigurationLock.java b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/locking/LockProviderGeoServerConfigurationLock.java index 0ea4f8cbb..731cb76bb 100644 --- a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/locking/LockProviderGeoServerConfigurationLock.java +++ b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/locking/LockProviderGeoServerConfigurationLock.java @@ -6,8 +6,6 @@ import static org.geoserver.GeoServerConfigurationLock.LockType.WRITE; -import static java.lang.String.format; - import lombok.NonNull; import org.geoserver.GeoServerConfigurationLock; @@ -76,9 +74,11 @@ public boolean isWriteLocked() { final boolean globalWriteLocked = GLOBAL.get().isWriteLocked(); if (jvmWriteLocked != globalWriteLocked) { String msg = - format( - "local JVM and global write lock status discrepancy: globally held lock count: %d, jvm locked: %s. The global lock will forcedly be released.", - GLOBAL.get().writeHoldCount, jvmWriteLocked); + """ + local JVM and global write lock status discrepancy: \ + globally held lock count: %d, jvm locked: %s. The global lock will forcedly be released. + """ + .formatted(GLOBAL.get().writeHoldCount, jvmWriteLocked); GLOBAL.get().forceUnlock(); GLOBAL.remove(); diff --git a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/locking/LockingCatalog.java b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/locking/LockingCatalog.java index aa91b4a96..ffe3b3497 100644 --- a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/locking/LockingCatalog.java +++ b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/locking/LockingCatalog.java @@ -7,8 +7,6 @@ import static org.geoserver.catalog.plugin.locking.LockingSupport.nameOf; import static org.geoserver.catalog.plugin.locking.LockingSupport.typeOf; -import static java.lang.String.format; - import lombok.NonNull; import org.geoserver.GeoServerConfigurationLock; @@ -82,47 +80,44 @@ public void disableLocking() { public void setDefaultDataStore(@NonNull WorkspaceInfo workspace, DataStoreInfo store) { locking.runInWriteLock( () -> super.setDefaultDataStore(workspace, store), - format( - "setDefaultDataStore(%s, %s)", - workspace.getName(), store == null ? "null" : store.getName())); + "setDefaultDataStore(%s, %s)" + .formatted(workspace.getName(), store == null ? "null" : store.getName())); } @Override public void setDefaultNamespace(NamespaceInfo defaultNamespace) { locking.runInWriteLock( () -> super.setDefaultNamespace(defaultNamespace), - format( - "setDefaultNamespace(%s)", - defaultNamespace == null ? "null" : defaultNamespace.getName())); + "setDefaultNamespace(%s)" + .formatted(defaultNamespace == null ? "null" : defaultNamespace.getName())); } @Override public void setDefaultWorkspace(WorkspaceInfo defaultWorkspace) { locking.runInWriteLock( () -> super.setDefaultWorkspace(defaultWorkspace), - format( - "setDefaultWorkspace(%s)", - defaultWorkspace == null ? "null" : defaultWorkspace.getName())); + "setDefaultWorkspace(%s)" + .formatted(defaultWorkspace == null ? "null" : defaultWorkspace.getName())); } /** {@inheritDoc} */ protected @Override void doAdd(T info, UnaryOperator inserter) { locking.runInWriteLock( () -> super.doAdd(info, inserter), - format("add(%s[%s])", typeOf(info), nameOf(info))); + "add(%s[%s])".formatted(typeOf(info), nameOf(info))); } /** {@inheritDoc} */ protected @Override void doSave(final I info) { locking.runInWriteLock( - () -> super.doSave(info), format("save(%s[%s])", typeOf(info), nameOf(info))); + () -> super.doSave(info), "save(%s[%s])".formatted(typeOf(info), nameOf(info))); } /** {@inheritDoc} */ protected @Override void doRemove(T info, Class type) { locking.runInWriteLock( () -> super.doRemove(info, type), - format("remove(%s[%s])", typeOf(info), nameOf(info))); + "remove(%s[%s])".formatted(typeOf(info), nameOf(info))); } /** @@ -131,6 +126,6 @@ public void setDefaultWorkspace(WorkspaceInfo defaultWorkspace) { @Override public void save(StoreInfo store) { locking.runInWriteLock( - () -> super.save(store), format("save(%s[%s])", typeOf(store), nameOf(store))); + () -> super.save(store), "save(%s[%s])".formatted(typeOf(store), nameOf(store))); } } diff --git a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/locking/LockingGeoServer.java b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/locking/LockingGeoServer.java index 713e936c1..b48c93e00 100644 --- a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/locking/LockingGeoServer.java +++ b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/locking/LockingGeoServer.java @@ -7,8 +7,6 @@ import static org.geoserver.catalog.plugin.locking.LockingSupport.nameOf; import static org.geoserver.catalog.plugin.locking.LockingSupport.typeOf; -import static java.lang.String.format; - import lombok.NonNull; import org.geoserver.GeoServerConfigurationLock; @@ -55,34 +53,34 @@ public void disableLocking() { @Override public void setGlobal(GeoServerInfo global) { lockingSupport.runInWriteLock( - () -> super.setGlobal(global), format("setGlobal(%s)", nameOf(global))); + () -> super.setGlobal(global), "setGlobal(%s)".formatted(nameOf(global))); } @Override public void save(GeoServerInfo geoServer) { lockingSupport.runInWriteLock( - () -> super.save(geoServer), format("save(%s)", nameOf(geoServer))); + () -> super.save(geoServer), "save(%s)".formatted(nameOf(geoServer))); } @Override public void add(SettingsInfo settings) { lockingSupport.runInWriteLock( () -> super.add(settings), - format("add(%s[%s])", typeOf(settings), nameOf(settings))); + "add(%s[%s])".formatted(typeOf(settings), nameOf(settings))); } @Override public void save(SettingsInfo settings) { lockingSupport.runInWriteLock( () -> super.save(settings), - format("save(%s[%s])", typeOf(settings), nameOf(settings))); + "save(%s[%s])".formatted(typeOf(settings), nameOf(settings))); } @Override public void remove(SettingsInfo settings) { lockingSupport.runInWriteLock( () -> super.remove(settings), - format("remove(%s[%s])", typeOf(settings), nameOf(settings))); + "remove(%s[%s])".formatted(typeOf(settings), nameOf(settings))); } @Override @@ -98,20 +96,21 @@ public void save(LoggingInfo logging) { @Override public void add(ServiceInfo service) { lockingSupport.runInWriteLock( - () -> super.add(service), format("add(%s[%s])", typeOf(service), nameOf(service))); + () -> super.add(service), + "add(%s[%s])".formatted(typeOf(service), nameOf(service))); } @Override public void remove(ServiceInfo service) { lockingSupport.runInWriteLock( () -> super.remove(service), - format("remove(%s[%s])", typeOf(service), nameOf(service))); + "remove(%s[%s])".formatted(typeOf(service), nameOf(service))); } @Override public void save(ServiceInfo service) { lockingSupport.runInWriteLock( () -> super.save(service), - format("save(%s[%s])", typeOf(service), nameOf(service))); + "save(%s[%s])".formatted(typeOf(service), nameOf(service))); } } diff --git a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/rules/CatalogOpContext.java b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/rules/CatalogOpContext.java index cc4da5c63..9ab7f858d 100644 --- a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/rules/CatalogOpContext.java +++ b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/rules/CatalogOpContext.java @@ -133,10 +133,10 @@ public boolean is(String key) { public CatalogOpContext as(Class subtype) { if (subtype.isInstance(object)) return (CatalogOpContext) this; throw new IllegalArgumentException( - String.format( - "%s<%s> can't be type narrowed to <%s>", - getClass().getSimpleName(), - CatalogInfoTypeRegistry.determineKey(object.getClass()), - subtype.getSimpleName())); + "%s<%s> can't be type narrowed to <%s>" + .formatted( + getClass().getSimpleName(), + CatalogInfoTypeRegistry.determineKey(object.getClass()), + subtype.getSimpleName())); } } diff --git a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/validation/DefaultCatalogValidator.java b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/validation/DefaultCatalogValidator.java index 8692ba411..3501c0d55 100644 --- a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/validation/DefaultCatalogValidator.java +++ b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/validation/DefaultCatalogValidator.java @@ -4,8 +4,6 @@ */ package org.geoserver.catalog.plugin.validation; -import static java.lang.String.format; - import org.geoserver.catalog.Catalog; import org.geoserver.catalog.CatalogBuilder; import org.geoserver.catalog.CatalogInfo; @@ -87,9 +85,8 @@ public void validate(NamespaceInfo namespace, boolean isNew) { && !catalog.getCatalogCapabilities().supportsIsolatedWorkspaces()) { // isolated namespaces \ workspaces are not supported by this catalog throw new IllegalArgumentException( - String.format( - "Namespace '%s:%s' is isolated but isolated workspaces are not supported by this catalog.", - namespace.getPrefix(), namespace.getURI())); + "Namespace '%s:%s' is isolated but isolated workspaces are not supported by this catalog." + .formatted(namespace.getPrefix(), namespace.getURI())); } checkArgument( !namespace.getPrefix().equals(Catalog.DEFAULT), @@ -115,9 +112,8 @@ public void validate(NamespaceInfo namespace, boolean isNew) { new URI(namespace.getURI()); } catch (URISyntaxException e) { throw new IllegalArgumentException( - format( - "Invalid URI syntax for '%s' in namespace '%s'", - namespace.getURI(), namespace.getPrefix()), + "Invalid URI syntax for '%s' in namespace '%s'" + .formatted(namespace.getURI(), namespace.getPrefix()), e); } } @@ -398,13 +394,13 @@ public void validate(StyleInfo style, boolean isNew) { static void checkNotNull(Object value, String message, Object... messageArgs) { if (value == null) { - throw new NullPointerException(format(message, messageArgs)); + throw new NullPointerException(message.formatted(messageArgs)); } } static void checkArgument(boolean condition, String message, Object... messageArgs) { if (!condition) { - throw new IllegalArgumentException(format(message, messageArgs)); + throw new IllegalArgumentException(message.formatted(messageArgs)); } } diff --git a/src/catalog/plugin/src/main/java/org/geoserver/config/plugin/GeoServerImpl.java b/src/catalog/plugin/src/main/java/org/geoserver/config/plugin/GeoServerImpl.java index 8f0bd74fb..3eaa291a2 100644 --- a/src/catalog/plugin/src/main/java/org/geoserver/config/plugin/GeoServerImpl.java +++ b/src/catalog/plugin/src/main/java/org/geoserver/config/plugin/GeoServerImpl.java @@ -197,9 +197,8 @@ void validate(SettingsInfo settings) { Objects.requireNonNull( realws, () -> - String.format( - "Workspace %s(%s) attached to SettingsInfo does not exist", - workspace.getName(), workspace.getId())); + "Workspace %s(%s) attached to SettingsInfo does not exist" + .formatted(workspace.getName(), workspace.getId())); settings.setWorkspace(realws); } diff --git a/src/catalog/plugin/src/test/java/org/geoserver/catalog/CatalogTestData.java b/src/catalog/plugin/src/test/java/org/geoserver/catalog/CatalogTestData.java index 91c4fb32c..958a35ba3 100644 --- a/src/catalog/plugin/src/test/java/org/geoserver/catalog/CatalogTestData.java +++ b/src/catalog/plugin/src/test/java/org/geoserver/catalog/CatalogTestData.java @@ -555,9 +555,8 @@ public void assertInternationalStringPropertiesEqual(Info info1, Info info2) { Supplier msg = () -> - String.format( - "%s.%s:InternationalString", - info1.getClass().getSimpleName(), isp); + "%s.%s:InternationalString" + .formatted(info1.getClass().getSimpleName(), isp); assertEquals(i1, i2, msg); } } diff --git a/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/CatalogConformanceTest.java b/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/CatalogConformanceTest.java index 09bddeafc..1d58619be 100644 --- a/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/CatalogConformanceTest.java +++ b/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/CatalogConformanceTest.java @@ -29,8 +29,6 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doThrow; -import static java.lang.String.format; - import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.collect.Sets; @@ -1111,9 +1109,8 @@ private void verifyNamespaceOfStoreResources(StoreInfo store) { NamespaceInfo actual = resource.getNamespace(); assertNotNull(actual); String msg = - format( - "resource %s of store %s did not get its namespace updated", - resource.getName(), store.getName()); + "resource %s of store %s did not get its namespace updated" + .formatted(resource.getName(), store.getName()); assertEquals(expected, actual, msg); } } diff --git a/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/XmlCatalogInfoLookup.java b/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/XmlCatalogInfoLookup.java index 1fb8bd86a..254aaa555 100644 --- a/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/XmlCatalogInfoLookup.java +++ b/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/XmlCatalogInfoLookup.java @@ -113,9 +113,8 @@ public void add(T value) { String serialized = serialize(value); if (null != idMap.putIfAbsent(value.getId(), serialized)) { String msg = - String.format( - "%s:%s already exists, not replaced", - getContentType().getSimpleName(), value.getId()); + "%s:%s already exists, not replaced" + .formatted(getContentType().getSimpleName(), value.getId()); LOGGER.warning(msg); } } @@ -140,9 +139,10 @@ public I update(final I value, Patch patch) { .orElseThrow( () -> new NoSuchElementException( - String.format( - "%s with id %s does not exist", - type.getSimpleName(), value.getId()))); + "%s with id %s does not exist" + .formatted( + type.getSimpleName(), + value.getId()))); patch.applyTo(storedValue); idMap.put(value.getId(), serialize(storedValue)); diff --git a/src/gwc/core/src/main/java/org/geoserver/cloud/gwc/event/GeoWebCacheEvent.java b/src/gwc/core/src/main/java/org/geoserver/cloud/gwc/event/GeoWebCacheEvent.java index 505ae9ec4..e684475d0 100644 --- a/src/gwc/core/src/main/java/org/geoserver/cloud/gwc/event/GeoWebCacheEvent.java +++ b/src/gwc/core/src/main/java/org/geoserver/cloud/gwc/event/GeoWebCacheEvent.java @@ -42,9 +42,13 @@ protected GeoWebCacheEvent(Object source, Type eventType) { @Override public String toString() { - return String.format( - "%s[%s '%s' id: %s timestamp: %s]", - getClass().getSimpleName(), getEventType(), getObjectId(), getId(), getTimestamp()); + return "%s[%s '%s' id: %s timestamp: %s]" + .formatted( + getClass().getSimpleName(), + getEventType(), + getObjectId(), + getId(), + getTimestamp()); } protected abstract String getObjectId(); diff --git a/src/gwc/core/src/main/java/org/geoserver/cloud/gwc/event/TileLayerEvent.java b/src/gwc/core/src/main/java/org/geoserver/cloud/gwc/event/TileLayerEvent.java index b356f2dd9..0d3a8f77e 100644 --- a/src/gwc/core/src/main/java/org/geoserver/cloud/gwc/event/TileLayerEvent.java +++ b/src/gwc/core/src/main/java/org/geoserver/cloud/gwc/event/TileLayerEvent.java @@ -77,9 +77,8 @@ private static TileLayerEvent valueOf( @Override public String toString() { - return String.format( - "%s[%s id: %s, name: %s]", - getClass().getSimpleName(), getEventType(), getPublishedId(), getName()); + return "%s[%s id: %s, name: %s]" + .formatted(getClass().getSimpleName(), getEventType(), getPublishedId(), getName()); } protected @Override String getObjectId() { diff --git a/src/gwc/integration-bus/src/main/java/org/geoserver/cloud/gwc/bus/GeoWebCacheRemoteEventsBroker.java b/src/gwc/integration-bus/src/main/java/org/geoserver/cloud/gwc/bus/GeoWebCacheRemoteEventsBroker.java index b1c2f1c59..aabef620a 100644 --- a/src/gwc/integration-bus/src/main/java/org/geoserver/cloud/gwc/bus/GeoWebCacheRemoteEventsBroker.java +++ b/src/gwc/integration-bus/src/main/java/org/geoserver/cloud/gwc/bus/GeoWebCacheRemoteEventsBroker.java @@ -80,6 +80,6 @@ private boolean isFromSelf(RemoteGeoWebCacheEvent remoteEvent) { @Override public String toString() { - return String.format("%s(%s)", getClass().getSimpleName(), originService()); + return "%s(%s)".formatted(getClass().getSimpleName(), originService()); } } diff --git a/src/gwc/integration-bus/src/main/java/org/geoserver/cloud/gwc/bus/RemoteGeoWebCacheEvent.java b/src/gwc/integration-bus/src/main/java/org/geoserver/cloud/gwc/bus/RemoteGeoWebCacheEvent.java index 8b560f00d..d59fbc62c 100644 --- a/src/gwc/integration-bus/src/main/java/org/geoserver/cloud/gwc/bus/RemoteGeoWebCacheEvent.java +++ b/src/gwc/integration-bus/src/main/java/org/geoserver/cloud/gwc/bus/RemoteGeoWebCacheEvent.java @@ -44,15 +44,15 @@ protected RemoteGeoWebCacheEvent( @Override public String toString() { - return String.format( - "%s[%s '%s' id: %s origin: %s destination: %s timestamp: %s]", - getClass().getSimpleName(), - getEventType(), - getObjectId(), - getId(), - getOriginService(), - getDestinationService(), - getTimestamp()); + return "%s[%s '%s' id: %s origin: %s destination: %s timestamp: %s]" + .formatted( + getClass().getSimpleName(), + getEventType(), + getObjectId(), + getId(), + getOriginService(), + getDestinationService(), + getTimestamp()); } protected abstract String getObjectId(); diff --git a/src/library/spring-factory/src/main/java/org/geoserver/cloud/config/factory/FilteringXmlBeanDefinitionReader.java b/src/library/spring-factory/src/main/java/org/geoserver/cloud/config/factory/FilteringXmlBeanDefinitionReader.java index 6a7970e18..f37bdd035 100644 --- a/src/library/spring-factory/src/main/java/org/geoserver/cloud/config/factory/FilteringXmlBeanDefinitionReader.java +++ b/src/library/spring-factory/src/main/java/org/geoserver/cloud/config/factory/FilteringXmlBeanDefinitionReader.java @@ -244,9 +244,8 @@ private static synchronized Resource[] getAllClasspathResources( sw.stop(); if (log.isTraceEnabled()) { log.trace( - String.format( - "Loaded %,d classpath resources in %,dms", - classpathBaseResources.length, sw.getTotalTimeMillis())); + "Loaded %,d classpath resources in %,dms" + .formatted(classpathBaseResources.length, sw.getTotalTimeMillis())); } } return classpathBaseResources; @@ -293,9 +292,8 @@ private void addBeanNameIncludeFilter(final String regex, final String resourceL private IllegalArgumentException throwInvalidExpression( final String resourceLocation, String regex, Throwable cause) { String msg = - String.format( - "Invalid bean filter expression (%s), expected name=>, resource: %s", - regex, resourceLocation); + "Invalid bean filter expression (%s), expected name=>, resource: %s" + .formatted(regex, resourceLocation); throw new IllegalArgumentException(msg, cause); } diff --git a/src/pom.xml b/src/pom.xml index 211437678..8e39b5e7f 100644 --- a/src/pom.xml +++ b/src/pom.xml @@ -18,16 +18,17 @@ integration-tests - 17 - 17 + 21 + 21 2021.0.9 2.7.18 5.3.37 5.7.12 - 2.17.1 - 2.25.2.1-CLOUD - 31-SNAPSHOT + 2.17.2 + 2.25.3.0-SNAPSHOT + 31.3 2.2.0 + 42.7.3 4.1.46.Final @@ -483,6 +484,11 @@ gs-gwc ${gs.version} + + + org.geotools + * + com.h2database h2 @@ -1200,7 +1206,7 @@ org.postgresql postgresql - 42.7.3 + ${postgresql.version} com.jayway.jsonpath diff --git a/src/starters/geonode/pom.xml b/src/starters/geonode/pom.xml new file mode 100644 index 000000000..03422b601 --- /dev/null +++ b/src/starters/geonode/pom.xml @@ -0,0 +1,31 @@ + + + 4.0.0 + + org.geoserver.cloud + gs-cloud-starters + ${revision} + + gs-cloud-starter-geonode + jar + + + org.springframework.boot + spring-boot-autoconfigure + + + org.geoserver.cloud + gs-cloud-spring-factory + + + org.geoserver.community + gs-sec-oauth2-geonode + ${gs.version} + + + javax.servlet + javax.servlet-api + provided + + + diff --git a/src/starters/geonode/src/main/java/org/geoserver/cloud/autoconfigure/geonode/GeoNodeOAuth2AutoConfiguration.java b/src/starters/geonode/src/main/java/org/geoserver/cloud/autoconfigure/geonode/GeoNodeOAuth2AutoConfiguration.java new file mode 100644 index 000000000..069631aa7 --- /dev/null +++ b/src/starters/geonode/src/main/java/org/geoserver/cloud/autoconfigure/geonode/GeoNodeOAuth2AutoConfiguration.java @@ -0,0 +1,30 @@ +/* + * (c) 2024 Open Source Geospatial Foundation - all rights reserved This code is licensed under the + * GPL 2.0 license, available at the root application directory. + */ +package org.geoserver.cloud.autoconfigure.geonode; + +import lombok.extern.slf4j.Slf4j; + +import org.geoserver.cloud.config.factory.FilteringXmlBeanDefinitionReader; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.ImportResource; + +/** + * @since 1.9 + */ +@AutoConfiguration +@ComponentScan(basePackages = "org.geoserver.security.oauth2") +@ImportResource( + // gs-sec-oauth2-geonode is all what's needed, gs-sec-oauth2-core and gs-sec-oauth2-web are + // transitive but not required for this specific functionality + reader = FilteringXmlBeanDefinitionReader.class, // + locations = {"jar:gs-sec-oauth2-geonode-.*!/applicationContext.xml"}) +@Slf4j(topic = "org.geoserver.cloud.autoconfigure.geonode") +public class GeoNodeOAuth2AutoConfiguration { + + GeoNodeOAuth2AutoConfiguration() { + log.info("GeoNodeOAuth2AutoConfiguration loaded"); + } +} diff --git a/src/starters/geonode/src/main/resources/META-INF/spring.factories b/src/starters/geonode/src/main/resources/META-INF/spring.factories new file mode 100644 index 000000000..d7debaf33 --- /dev/null +++ b/src/starters/geonode/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +org.geoserver.cloud.autoconfigure.geonode.GeoNodeOAuth2AutoConfiguration \ No newline at end of file diff --git a/src/starters/pom.xml b/src/starters/pom.xml index a523c1d0b..b1457f124 100644 --- a/src/starters/pom.xml +++ b/src/starters/pom.xml @@ -18,6 +18,7 @@ webmvc wms-extensions security + geonode observability