Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

refactor pgconfig package and class names replacing pgsql by pgconfig #467

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compose/catalog-pgconfig.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
volumes:
pgconfigdb_data: # volume for postgresql data, used to store the geoserver config through pgsqlconfig backend
pgconfigdb_data: # volume for postgresql data, used to store the geoserver config through pgconfig backend

#
# Configures all geoserver services to use the postgresql database server with pgconfig as catalog backend.
Expand Down
2 changes: 1 addition & 1 deletion config
Submodule config updated 1 files
+1 −1 geoserver_logging.yml
2 changes: 1 addition & 1 deletion docs/deploy/docker-compose/stable/pgconfig/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3.8"
volumes:
rabbitmq_data: # volume for rabbitmq data, so it doesn't create an anonymous one on each container
geowebcache_data:
pgconfigdb_data: # volume for postgresql data, used to store the geoserver config through pgsqlconfig backend
pgconfigdb_data: # volume for postgresql data, used to store the geoserver config through pgconfig backend

services:
pgconfigdb:
Expand Down
2 changes: 1 addition & 1 deletion src/catalog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Provides spring atuo-configuration for several catalog back-ends. Namely: tradit
* gs-cloud-catalog-cache
* gs-cloud-catalog-backend-datadir
* gs-cloud-catalog-backend-jdbcconfig
* gs-cloud-catalog-backend-pgsql
* gs-cloud-catalog-backend-pgconfig

## catalog-cache

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
name = "enabled",
havingValue = "true",
matchIfMissing = false)
public @interface ConditionalOnPgsqlBackendEnabled {}
public @interface ConditionalOnPgconfigBackendEnabled {}
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
package org.geoserver.cloud.autoconfigure.catalog.backend.pgconfig;

import org.geoserver.cloud.config.catalog.backend.core.CatalogProperties;
import org.geoserver.cloud.config.catalog.backend.pgconfig.PgsqlBackendConfiguration;
import org.geoserver.cloud.config.catalog.backend.pgconfig.PgconfigBackendConfiguration;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Import;

/**
* @since 1.4
*/
@AutoConfiguration(after = PgsqlMigrationAutoConfiguration.class)
@ConditionalOnPgsqlBackendEnabled
@AutoConfiguration(after = PgconfigMigrationAutoConfiguration.class)
@ConditionalOnPgconfigBackendEnabled
@EnableConfigurationProperties(CatalogProperties.class)
@Import(PgsqlBackendConfiguration.class)
public class PgsqlBackendAutoConfiguration {}
@Import(PgconfigBackendConfiguration.class)
public class PgconfigBackendAutoConfiguration {}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
package org.geoserver.cloud.autoconfigure.catalog.backend.pgconfig;

import org.geoserver.cloud.config.catalog.backend.pgconfig.PgsqlDataSourceConfiguration;
import org.geoserver.cloud.config.catalog.backend.pgconfig.PconfigDataSourceConfiguration;
import org.geoserver.cloud.config.jndidatasource.JNDIDataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Import;
Expand All @@ -13,6 +13,6 @@
* @since 1.4
*/
@AutoConfiguration(after = JNDIDataSourceAutoConfiguration.class)
@ConditionalOnPgsqlBackendEnabled
@Import(PgsqlDataSourceConfiguration.class)
public class PgsqlDataSourceAutoConfiguration {}
@ConditionalOnPgconfigBackendEnabled
@Import(PconfigDataSourceConfiguration.class)
public class PgconfigDataSourceAutoConfiguration {}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* @since 1.4
*/
@AutoConfiguration(after = PgsqlDataSourceAutoConfiguration.class)
@ConditionalOnPgsqlBackendEnabled
@AutoConfiguration(after = PgconfigDataSourceAutoConfiguration.class)
@ConditionalOnPgconfigBackendEnabled
@Import(DatabaseMigrationConfiguration.class)
public class PgsqlMigrationAutoConfiguration {}
public class PgconfigMigrationAutoConfiguration {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* (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.catalog.backend.pgconfig;

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) {
return new DataSourceTransactionManager(dataSource);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import org.geoserver.catalog.impl.CatalogImpl;
import org.geoserver.catalog.plugin.CatalogPlugin;
import org.geoserver.catalog.plugin.ExtendedCatalogFacade;
import org.geoserver.cloud.backend.pgconfig.catalog.PgsqlCatalogFacade;
import org.geoserver.cloud.backend.pgconfig.config.PgsqlGeoServerFacade;
import org.geoserver.cloud.backend.pgconfig.catalog.PgconfigCatalogFacade;
import org.geoserver.cloud.backend.pgconfig.config.PgconfigGeoServerFacade;
import org.geoserver.config.plugin.GeoServerImpl;
import org.springframework.jdbc.core.JdbcTemplate;

Expand All @@ -22,7 +22,7 @@
* @since 1.4
*/
@RequiredArgsConstructor
public class PgsqlBackendBuilder {
public class PgconfigBackendBuilder {

private final @NonNull DataSource dataSource;

Expand All @@ -31,19 +31,19 @@ public CatalogPlugin createCatalog() {
}

public GeoServerImpl createGeoServer(Catalog catalog) {
PgsqlGeoServerFacade facade = createGeoServerFacade();
PgconfigGeoServerFacade facade = createGeoServerFacade();
GeoServerImpl gs = new GeoServerImpl(facade);
gs.setCatalog(catalog);
return gs;
}

public PgsqlGeoServerFacade createGeoServerFacade() {
return new PgsqlGeoServerFacade(new JdbcTemplate(dataSource));
public PgconfigGeoServerFacade createGeoServerFacade() {
return new PgconfigGeoServerFacade(new JdbcTemplate(dataSource));
}

public ExtendedCatalogFacade createCatalogFacade() {
JdbcTemplate template = new JdbcTemplate(dataSource);
return new PgsqlCatalogFacade(template);
return new PgconfigCatalogFacade(template);
}

public <C extends CatalogImpl> C initCatalog(C catalog) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
import org.geoserver.catalog.plugin.resolving.CatalogPropertyResolver;
import org.geoserver.catalog.plugin.resolving.CollectionPropertiesInitializer;
import org.geoserver.catalog.plugin.resolving.ResolvingProxyResolver;
import org.geoserver.cloud.backend.pgconfig.catalog.repository.PgsqlCatalogInfoRepository;
import org.geoserver.cloud.backend.pgconfig.catalog.repository.PgsqlLayerGroupRepository;
import org.geoserver.cloud.backend.pgconfig.catalog.repository.PgsqlLayerRepository;
import org.geoserver.cloud.backend.pgconfig.catalog.repository.PgsqlNamespaceRepository;
import org.geoserver.cloud.backend.pgconfig.catalog.repository.PgsqlResourceRepository;
import org.geoserver.cloud.backend.pgconfig.catalog.repository.PgsqlStoreRepository;
import org.geoserver.cloud.backend.pgconfig.catalog.repository.PgsqlStyleRepository;
import org.geoserver.cloud.backend.pgconfig.catalog.repository.PgsqlWorkspaceRepository;
import org.geoserver.cloud.backend.pgconfig.catalog.repository.PgconfigCatalogInfoRepository;
import org.geoserver.cloud.backend.pgconfig.catalog.repository.PgconfigLayerGroupRepository;
import org.geoserver.cloud.backend.pgconfig.catalog.repository.PgconfigLayerRepository;
import org.geoserver.cloud.backend.pgconfig.catalog.repository.PgconfigNamespaceRepository;
import org.geoserver.cloud.backend.pgconfig.catalog.repository.PgconfigResourceRepository;
import org.geoserver.cloud.backend.pgconfig.catalog.repository.PgconfigStoreRepository;
import org.geoserver.cloud.backend.pgconfig.catalog.repository.PgconfigStyleRepository;
import org.geoserver.cloud.backend.pgconfig.catalog.repository.PgconfigWorkspaceRepository;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.function.Supplier;
Expand All @@ -28,17 +28,17 @@
/**
* @since 1.4
*/
public class PgsqlCatalogFacade extends RepositoryCatalogFacadeImpl {
public class PgconfigCatalogFacade extends RepositoryCatalogFacadeImpl {

public PgsqlCatalogFacade(@NonNull JdbcTemplate template) {
PgsqlNamespaceRepository namespaces = new PgsqlNamespaceRepository(template);
PgsqlWorkspaceRepository workspaces = new PgsqlWorkspaceRepository(template);
PgsqlStyleRepository styles = new PgsqlStyleRepository(template);
public PgconfigCatalogFacade(@NonNull JdbcTemplate template) {
PgconfigNamespaceRepository namespaces = new PgconfigNamespaceRepository(template);
PgconfigWorkspaceRepository workspaces = new PgconfigWorkspaceRepository(template);
PgconfigStyleRepository styles = new PgconfigStyleRepository(template);

PgsqlStoreRepository stores = new PgsqlStoreRepository(template);
PgsqlLayerRepository layers = new PgsqlLayerRepository(template, styles);
PgsqlResourceRepository resources = new PgsqlResourceRepository(template, layers);
PgsqlLayerGroupRepository layerGroups = new PgsqlLayerGroupRepository(template);
PgconfigStoreRepository stores = new PgconfigStoreRepository(template);
PgconfigLayerRepository layers = new PgconfigLayerRepository(template, styles);
PgconfigResourceRepository resources = new PgconfigResourceRepository(template, layers);
PgconfigLayerGroupRepository layerGroups = new PgconfigLayerGroupRepository(template);

super.setNamespaceRepository(namespaces);
super.setWorkspaceRepository(workspaces);
Expand All @@ -60,7 +60,7 @@ private void setOutboundResolver() {
UnaryOperator<CatalogInfo> resolvingFunction = resolvingFunction(this::getCatalog);

super.repositories.all().stream()
.map(PgsqlCatalogInfoRepository.class::cast)
.map(PgconfigCatalogInfoRepository.class::cast)
.forEach(repo -> repo.setOutboundResolver(resolvingFunction));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
*
* @since 1.4
*/
class PgsqlCatalogFilterSplitter extends PostPreProcessFilterSplittingVisitor {
class PgconfigCatalogFilterSplitter extends PostPreProcessFilterSplittingVisitor {

private Set<String> supportedPropertyNames;

public PgsqlCatalogFilterSplitter(@NonNull Set<String> supportedPropertyNames) {
super(PgsqlFilterCapabilities.capabilities(), null, null);
public PgconfigCatalogFilterSplitter(@NonNull Set<String> supportedPropertyNames) {
super(PgconfigFilterCapabilities.capabilities(), null, null);
this.supportedPropertyNames = supportedPropertyNames;
}

public static PgsqlCatalogFilterSplitter split(
public static PgconfigCatalogFilterSplitter split(
Filter filter, Set<String> supportedPropertyNames) {
var splitter = new PgsqlCatalogFilterSplitter(supportedPropertyNames);
var splitter = new PgconfigCatalogFilterSplitter(supportedPropertyNames);
filter.accept(splitter, null);
return splitter;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
* @since 1.4
*/
@UtilityClass
class PgsqlFilterCapabilities {
class PgconfigFilterCapabilities {

private static final FilterCapabilities INSTANCE = createFilterCapabilities();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
/**
* @since 1.4
*/
class PgsqlFilterToSQL extends PreparedFilterToSQL {
class PgconfigFilterToSQL extends PreparedFilterToSQL {

public static @Value class Result {
String whereClause;
Expand All @@ -65,15 +65,15 @@ class PgsqlFilterToSQL extends PreparedFilterToSQL {
/**
* @param dialect
*/
public PgsqlFilterToSQL(Writer out) {
public PgconfigFilterToSQL(Writer out) {
super(out);
setSqlNameEscape("\"");
super.setCapabilities(PgsqlFilterCapabilities.capabilities());
super.setCapabilities(PgconfigFilterCapabilities.capabilities());
}

public static Result evaluate(Filter filter) {
StringWriter out = new StringWriter();
var filterToPreparedStatement = new PgsqlFilterToSQL(out);
var filterToPreparedStatement = new PgconfigFilterToSQL(out);
filterToPreparedStatement.setSqlNameEscape("\"");
filter.accept(filterToPreparedStatement, null);
out.flush();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
package org.geoserver.cloud.backend.pgconfig.catalog.filter;

import static org.geoserver.cloud.backend.pgconfig.catalog.filter.CatalogInfoLiteralAdaptor.replaceCatalogInfoLiterals;
import static org.geoserver.cloud.backend.pgconfig.catalog.filter.PgsqlCatalogFilterSplitter.split;
import static org.geoserver.cloud.backend.pgconfig.catalog.filter.PgconfigCatalogFilterSplitter.split;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import org.geoserver.cloud.backend.pgconfig.catalog.filter.PgsqlFilterToSQL.Result;
import org.geoserver.cloud.backend.pgconfig.catalog.filter.PgconfigFilterToSQL.Result;
import org.geotools.api.filter.Filter;
import org.geotools.filter.visitor.SimplifyingFilterVisitor;

Expand All @@ -21,7 +21,7 @@
* @since 1.4
*/
@RequiredArgsConstructor
public class PgsqlQueryBuilder {
public class PgconfigQueryBuilder {

private final Filter origFilter;
private final Set<String> supportedPropertyNames;
Expand All @@ -35,7 +35,7 @@ public class PgsqlQueryBuilder {
@SuppressWarnings("rawtypes")
private @Getter List<Class> literalTypes;

public PgsqlQueryBuilder build() {
public PgconfigQueryBuilder build() {
if (Filter.INCLUDE.equals(origFilter)) {
return this;
}
Expand All @@ -49,7 +49,7 @@ public PgsqlQueryBuilder build() {

unsupportedFilter = simplify(splitter.getFilterPost());

Result encodeResult = PgsqlFilterToSQL.evaluate(supportedFilter);
Result encodeResult = PgconfigFilterToSQL.evaluate(supportedFilter);
whereClause = encodeResult.getWhereClause();
literalValues = encodeResult.getLiteralValues();
literalTypes = encodeResult.getLiteralTypes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
@Slf4j(topic = "org.geoserver.cloud.backend.pgconfig.catalog.repository")
public final class CatalogInfoRowMapper {

protected static final ObjectMapper objectMapper = PgsqlObjectMapper.newObjectMapper();
protected static final ObjectMapper objectMapper = PgconfigObjectMapper.newObjectMapper();

/** Lazily created by {@link #cache()} */
private Map<Class<?>, Map<String, CatalogInfo>> cache;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.geoserver.catalog.plugin.Query;
import org.geoserver.catalog.plugin.resolving.ResolvingCatalogInfoRepository;
import org.geoserver.catalog.plugin.resolving.ResolvingFacade;
import org.geoserver.cloud.backend.pgconfig.catalog.filter.PgsqlQueryBuilder;
import org.geoserver.cloud.backend.pgconfig.catalog.filter.PgconfigQueryBuilder;
import org.geotools.api.filter.Filter;
import org.geotools.api.filter.FilterFactory;
import org.geotools.api.filter.sort.SortBy;
Expand All @@ -46,11 +46,11 @@
* @since 1.4
*/
@Slf4j(topic = "org.geoserver.cloud.backend.pgconfig.catalog.repository")
public abstract class PgsqlCatalogInfoRepository<T extends CatalogInfo>
public abstract class PgconfigCatalogInfoRepository<T extends CatalogInfo>
extends ResolvingCatalogInfoRepository<T>
implements CatalogInfoRepository<T>, ResolvingFacade<T> {

protected static final ObjectMapper infoMapper = PgsqlObjectMapper.newObjectMapper();
protected static final ObjectMapper infoMapper = PgconfigObjectMapper.newObjectMapper();

protected static final FilterFactory FILTER_FACTORY = CommonFactoryFinder.getFilterFactory();

Expand All @@ -61,11 +61,11 @@ public abstract class PgsqlCatalogInfoRepository<T extends CatalogInfo>
/**
* @param template
*/
protected PgsqlCatalogInfoRepository(@NonNull JdbcTemplate template) {
protected PgconfigCatalogInfoRepository(@NonNull JdbcTemplate template) {
this(new LoggingTemplate(template));
}

protected PgsqlCatalogInfoRepository(@NonNull LoggingTemplate template) {
protected PgconfigCatalogInfoRepository(@NonNull LoggingTemplate template) {
super();
this.template = template;
}
Expand Down Expand Up @@ -159,7 +159,8 @@ public <U extends T> Stream<U> findAll(Query<U> query) {
final Filter filter = applyTypeFilter(query.getFilter(), query.getType());
final Class<U> type = query.getType();

final PgsqlQueryBuilder qb = new PgsqlQueryBuilder(filter, sortableProperties()).build();
final PgconfigQueryBuilder qb =
new PgconfigQueryBuilder(filter, sortableProperties()).build();
final Filter supportedFilter = qb.getSupportedFilter();
final Filter unsupportedFilter = qb.getUnsupportedFilter();
final String whereClause = qb.getWhereClause();
Expand Down Expand Up @@ -263,7 +264,8 @@ protected void checkCanSortBy(String property) {
@Override
public <U extends T> long count(Class<U> of, Filter filter) {
filter = applyTypeFilter(filter, of);
final PgsqlQueryBuilder qb = new PgsqlQueryBuilder(filter, sortableProperties()).build();
final PgconfigQueryBuilder qb =
new PgconfigQueryBuilder(filter, sortableProperties()).build();
final Filter supportedFilter = qb.getSupportedFilter();
final Filter unsupportedFilter = qb.getUnsupportedFilter();
final String whereClause = qb.getWhereClause();
Expand Down Expand Up @@ -294,7 +296,7 @@ public <U extends T> long count(Class<U> of, Filter filter) {
}

@SuppressWarnings("java:S1168")
private Object[] prepareParams(PgsqlQueryBuilder qb) {
private Object[] prepareParams(PgconfigQueryBuilder qb) {
List<Object> literalValues = qb.getLiteralValues();
if (literalValues.isEmpty()) return null;
return literalValues.stream().map(this::asPreparedValue).toArray();
Expand Down
Loading
Loading