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

chore: package and file rename #421

Merged
merged 12 commits into from
Oct 28, 2024
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package ca.bc.gov.restapi.results.common.config;
package ca.bc.gov.restapi.results.common;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;

/** This class holds properties used for the application configuration. */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ConstantsConfig {
public class SilvaConstants {

public static final Integer MAX_PAGE_SIZE = 500;
public static final Integer MAX_PAGE_SIZE_OPENING_SEARCH = 2000;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ca.bc.gov.restapi.results.common.config;
package ca.bc.gov.restapi.results.common.configuration;

import java.util.Arrays;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -11,7 +11,7 @@
/** This class holds the configuration for CORS handling. */
@Slf4j
@Configuration
public class CorsConfig implements WebMvcConfigurer {
public class CorsConfiguration implements WebMvcConfigurer {

@Value("${server.allowed.cors.origins}")
private String[] allowedOrigins;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ca.bc.gov.restapi.results.common.config;
package ca.bc.gov.restapi.results.common.configuration;

import lombok.Getter;
import lombok.Setter;
Expand All @@ -10,7 +10,7 @@
@Setter
@Configuration
@ConfigurationProperties(prefix = "spring.datasource")
public class DataSourceConfig {
public class DataSourceConfiguration {

private String driverClassName;
private String url;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ca.bc.gov.restapi.results.common.config;
package ca.bc.gov.restapi.results.common.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -15,15 +15,15 @@ public class ExternalApiConfiguration {
/**
* Creates a RestClient bean for the Forest Client API.
*
* @param providersConfig the configuration properties for providers
* @param providersConfiguration the configuration properties for providers
* @return the configured RestClient instance for the Forest Client API
*/
@Bean
public RestClient forestClientApi(ProvidersConfig providersConfig) {
public RestClient forestClientApi(ProvidersConfiguration providersConfiguration) {
return RestClient
.builder()
.baseUrl(providersConfig.getForestClientBaseUri())
.defaultHeader("X-API-KEY", providersConfig.getForestClientApiKey())
.baseUrl(providersConfiguration.getForestClientBaseUri())
.defaultHeader("X-API-KEY", providersConfiguration.getForestClientApiKey())
.defaultHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ca.bc.gov.restapi.results.common.config;
package ca.bc.gov.restapi.results.common.configuration;

import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -7,7 +7,7 @@
/** This class contains configurations for all external APIs like address and keys. */
@Getter
@Configuration
public class ProvidersConfig {
public class ProvidersConfiguration {

@Value("${forest-client-api.address}")
private String forestClientBaseUri;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ca.bc.gov.restapi.results.common.config;
package ca.bc.gov.restapi.results.common.configuration;

import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -25,7 +25,7 @@
@Configuration
@EnableWebSecurity
@EnableMethodSecurity
public class SecurityConfig {
public class SecurityConfiguration {

@Value("${spring.security.oauth2.resourceserver.jwt.jwk-set-uri}")
String jwkSetUri;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ca.bc.gov.restapi.results.oracle.config;
package ca.bc.gov.restapi.results.oracle.configuration;

import jakarta.persistence.EntityManager;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -9,7 +9,7 @@

/** This class adds a listener for closing connection gracefully. */
@Component
public class OracleGracefulShutdownConfig implements ApplicationListener<ContextClosedEvent> {
public class OracleGracefulShutdownConfiguration implements ApplicationListener<ContextClosedEvent> {

@Autowired private EntityManager oracleEntityManager;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package ca.bc.gov.restapi.results.oracle.config;
package ca.bc.gov.restapi.results.oracle.configuration;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/** This class holds configurations for the Oracle Hikari connection pool. */
@Data
@Configuration
@ConfigurationProperties("spring.datasource.oracle")
public class OracleHikariConfig {
public class OracleHikariConfiguration {

private String driverClassName;
private String url;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ca.bc.gov.restapi.results.oracle.config;
package ca.bc.gov.restapi.results.oracle.configuration;

import ca.bc.gov.restapi.results.oracle.entity.CutBlockOpenAdminEntity;
import ca.bc.gov.restapi.results.oracle.entity.OpeningEntity;
Expand Down Expand Up @@ -38,7 +38,7 @@
},
entityManagerFactoryRef = "oracleEntityManagerFactory",
transactionManagerRef = "oracleTransactionManager")
public class OracleJpaConfig {
public class OracleJpaConfiguration {

/**
* Creates the EntityManagerFactory for the oracle database.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package ca.bc.gov.restapi.results.oracle.configuration;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
* This class holds persistence configurations for the Oracle database.
*/
@Configuration
public class OraclePersistenceConfiguration {

@Autowired
private OracleHikariConfiguration oracleHikariConfiguration;

@Bean
@ConfigurationProperties("spring.datasource.oracle")
public DataSourceProperties oracleDataSourceProperties() {
return new DataSourceProperties();
}

/**
* Creates a Postgres Datasource with all Hikari connection pool configuration.
*/
@Bean
@Primary
public DataSource oracleDataSource() {
HikariConfig config = new HikariConfig();
config.setJdbcUrl(oracleHikariConfiguration.getUrl());
config.setUsername(oracleHikariConfiguration.getUsername());
config.setPassword(oracleHikariConfiguration.getPassword());
config.setDriverClassName(oracleHikariConfiguration.getDriverClassName());
config.setConnectionTimeout(oracleHikariConfiguration.getConnectionTimeout());
config.setIdleTimeout(oracleHikariConfiguration.getIdleTimeout());
config.setMaxLifetime(oracleHikariConfiguration.getMaxLifetime());
config.setKeepaliveTime(oracleHikariConfiguration.getKeepaliveTime());
config.setPoolName(oracleHikariConfiguration.getPoolName());
config.setMinimumIdle(oracleHikariConfiguration.getMinimumIdle());
config.setMaximumPoolSize(oracleHikariConfiguration.getMaximumPoolSize());
config.setLeakDetectionThreshold(oracleHikariConfiguration.getLeakDetectionThreshold());

return new HikariDataSource(config);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ca.bc.gov.restapi.results.oracle.repository;

import ca.bc.gov.restapi.results.common.config.ConstantsConfig;
import ca.bc.gov.restapi.results.common.SilvaConstants;
import ca.bc.gov.restapi.results.common.pagination.PaginatedResult;
import ca.bc.gov.restapi.results.common.pagination.PaginationParameters;
import ca.bc.gov.restapi.results.oracle.dto.OpeningSearchFiltersDto;
Expand Down Expand Up @@ -42,7 +42,7 @@ public PaginatedResult<OpeningSearchResponseDto> searchOpeningQuery(
final Query query = setQueryParameters(filtersDto, sqlQuery);

// Limit to 500 records at the database
query.setMaxResults(ConstantsConfig.MAX_PAGE_SIZE);
query.setMaxResults(SilvaConstants.MAX_PAGE_SIZE);

List<?> result = query.getResultList();
int lastPage = PaginationUtil.getLastPage(result.size(), pagination.perPage());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ca.bc.gov.restapi.results.oracle.service;

import ca.bc.gov.restapi.results.common.config.ConstantsConfig;
import ca.bc.gov.restapi.results.common.SilvaConstants;
import ca.bc.gov.restapi.results.common.dto.ForestClientDto;
import ca.bc.gov.restapi.results.common.exception.MaxPageSizeException;
import ca.bc.gov.restapi.results.common.pagination.PaginatedResult;
Expand Down Expand Up @@ -62,8 +62,8 @@ public PaginatedResult<RecentOpeningDto> getRecentOpeningsCurrentUser(
pagination.page(),
pagination.perPage());

if (pagination.perPage() > ConstantsConfig.MAX_PAGE_SIZE) {
throw new MaxPageSizeException(ConstantsConfig.MAX_PAGE_SIZE);
if (pagination.perPage() > SilvaConstants.MAX_PAGE_SIZE) {
throw new MaxPageSizeException(SilvaConstants.MAX_PAGE_SIZE);
}

String entryUserId = loggedUserService.getLoggedUserId();
Expand Down Expand Up @@ -111,8 +111,8 @@ public PaginatedResult<RecentOpeningDto> getRecentOpenings(PaginationParameters
pagination.page(),
pagination.perPage());

if (pagination.perPage() > ConstantsConfig.MAX_PAGE_SIZE) {
throw new MaxPageSizeException(ConstantsConfig.MAX_PAGE_SIZE);
if (pagination.perPage() > SilvaConstants.MAX_PAGE_SIZE) {
throw new MaxPageSizeException(SilvaConstants.MAX_PAGE_SIZE);
}

// Openings
Expand Down Expand Up @@ -160,8 +160,8 @@ public PaginatedResult<OpeningSearchResponseDto> openingSearch(
pagination.page(),
pagination.perPage());

if (pagination.perPage() > ConstantsConfig.MAX_PAGE_SIZE_OPENING_SEARCH) {
throw new MaxPageSizeException(ConstantsConfig.MAX_PAGE_SIZE_OPENING_SEARCH);
if (pagination.perPage() > SilvaConstants.MAX_PAGE_SIZE_OPENING_SEARCH) {
throw new MaxPageSizeException(SilvaConstants.MAX_PAGE_SIZE_OPENING_SEARCH);
}

// Set the user in the filter, if required
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ca.bc.gov.restapi.results.postgres.config;
package ca.bc.gov.restapi.results.postgres.configuration;

import java.util.List;
import java.util.Objects;
Expand All @@ -14,7 +14,7 @@
@Setter
@Configuration
@ConfigurationProperties("nr.results")
public class DashboardUserManagerConfig {
public class DashboardUserManagerConfiguration {

private String[] dashboardJobUsers;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ca.bc.gov.restapi.results.postgres.config;
package ca.bc.gov.restapi.results.postgres.configuration;

import jakarta.persistence.EntityManager;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -9,7 +9,7 @@

/** This class adds a listener for closing connection gracefully. */
@Component
public class PostgresGracefulShutdownConfig implements ApplicationListener<ContextClosedEvent> {
public class PostgresGracefulShutdownConfiguration implements ApplicationListener<ContextClosedEvent> {

@Autowired private EntityManager postgresEntityManager;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ca.bc.gov.restapi.results.postgres.config;
package ca.bc.gov.restapi.results.postgres.configuration;

import lombok.Getter;
import lombok.Setter;
Expand All @@ -10,7 +10,7 @@
@Setter
@Configuration
@ConfigurationProperties("spring.datasource.postgres")
public class PostgresHikariConfig {
public class PostgresHikariConfiguration {

private String driverClassName;
private String url;
Expand Down
Loading
Loading