Skip to content

Commit

Permalink
Merge branch 'main' into feature/gateway-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhir authored Aug 12, 2024
2 parents d6c67cd + 26b7502 commit e92b90e
Show file tree
Hide file tree
Showing 14 changed files with 143 additions and 406 deletions.
2 changes: 1 addition & 1 deletion refarch-gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM registry.access.redhat.com/ubi9/openjdk-21:latest
FROM registry.access.redhat.com/ubi9/openjdk-21-runtime:latest

COPY target/*.jar /deployments/spring-boot-application.jar
27 changes: 19 additions & 8 deletions refarch-gateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,30 @@
<name>refarch-gateway</name>

<properties>
<!-- Compilation -->
<java.version>21</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.release>${java.version}</maven.compiler.release>

<jacoco.version>0.8.12</jacoco.version>
<maven-surefire-plugin.version>3.3.1</maven-surefire-plugin.version>
<!-- Core Frameworks -->
<spring-cloud.version>2023.0.3</spring-cloud.version>

<!-- Logging -->
<logstash-logback-encoder.version>8.0</logstash-logback-encoder.version>

<!-- Linting & Formatting -->
<spotless-maven-plugin.version>2.34.0</spotless-maven-plugin.version>
<itm-java-codeformat.version>1.0.10</itm-java-codeformat.version>
<maven-checkstyle-plugin.version>3.4.0</maven-checkstyle-plugin.version>

<spring-cloud.version>2023.0.3</spring-cloud.version>
<logstash-logback-encoder.version>8.0</logstash-logback-encoder.version>
<hazelcast.version>5.5.0</hazelcast.version>
<!-- Testing -->
<jacoco.version>0.8.12</jacoco.version>

<!-- Utility -->
<apache-commons-lang.version>3.16.0</apache-commons-lang.version>

<!-- Additional required dependencies -->
<hazelcast.version>5.5.0</hazelcast.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -83,7 +92,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down Expand Up @@ -133,7 +142,9 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<argLine>-Dfile.encoding=${project.build.sourceEncoding}</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import de.muenchen.refarch.integration.s3.client.api.FolderApiApi;
import de.muenchen.refarch.integration.s3.client.domain.model.SupportedFileExtensions;
import de.muenchen.refarch.integration.s3.client.properties.S3IntegrationClientProperties;
import de.muenchen.refarch.integration.s3.client.service.ApiClientFactory;
import de.muenchen.refarch.integration.s3.client.service.FileService;
import de.muenchen.refarch.integration.s3.client.service.S3DomainProvider;
import de.muenchen.refarch.integration.s3.client.service.S3StorageUrlProvider;
import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -19,7 +16,6 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.security.oauth2.client.AuthorizedClientServiceOAuth2AuthorizedClientManager;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientService;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
Expand All @@ -30,21 +26,6 @@
@ComponentScan(
basePackages = {
"de.muenchen.refarch.integration.s3.client"
},
excludeFilters = {
@ComponentScan.Filter(
type = FilterType.ASSIGNABLE_TYPE,
classes = {
/*
* Exclude to avoid multiple instantiation of multiple beans with same name.
* This class is instantiated in {@link S3IntegrationClientAutoConfiguration}
* to give the bean another name.
*/
ApiClient.class,
FileApiApi.class,
FolderApiApi.class
}
)
}
)
@RequiredArgsConstructor
Expand All @@ -62,20 +43,20 @@ public void init() {

@Bean
@ConditionalOnProperty(prefix = "refarch.s3.client", name = "enable-security", havingValue = "true")
public ApiClientFactory securedApiClientFactory(final ClientRegistrationRepository clientRegistrationRepository,
public ApiClient securedApiClient(final ClientRegistrationRepository clientRegistrationRepository,
final OAuth2AuthorizedClientService authorizedClientService) {
return new ApiClientFactory(
this.webClient(clientRegistrationRepository, authorizedClientService));
return new ApiClient(
this.authenticatedWebClient(clientRegistrationRepository, authorizedClientService));
}

@Bean
@ConditionalOnProperty(prefix = "refarch.s3.client", name = "enable-security", havingValue = "false", matchIfMissing = true)
public ApiClientFactory apiClientFactory() {
return new ApiClientFactory(
public ApiClient apiClient() {
return new ApiClient(
WebClient.builder().build());
}

private WebClient webClient(
private WebClient authenticatedWebClient(
final ClientRegistrationRepository clientRegistrationRepository,
final OAuth2AuthorizedClientService authorizedClientService) {
final var oauth = new ServletOAuth2AuthorizedClientExchangeFilterFunction(
Expand All @@ -102,7 +83,7 @@ public FileService fileService(final SupportedFileExtensions supportedFileExtens

/**
* Instance of a {@link FileService} containing supported file extensions configured within in the
* 'de.muenchen.oss.digiwf.s3' scope.
* 'de.muenchen.refarch.s3' scope.
*
* @return {@link FileService} for managing file extensions.
*/
Expand All @@ -113,30 +94,15 @@ public FileService fileServiceFromS3IntegrationClientProperties() {
this.s3IntegrationClientProperties.getMaxBatchSize());
}

/**
* Instance of an {@link S3StorageUrlProvider} containing an externally created
* {@link S3DomainProvider} for retrieving the S3 storage URL.
*
* @param s3DomainProvider Provider of domain specific S3 storages configured in process
* configurations.
* @return Provider of the S3 storage URL.
*/
@Bean
@ConditionalOnBean(S3DomainProvider.class)
public S3StorageUrlProvider s3StorageUrlProvider(final S3DomainProvider s3DomainProvider) {
return new S3StorageUrlProvider(s3DomainProvider, this.s3IntegrationClientProperties.getDocumentStorageUrl());
@ConditionalOnMissingBean
public FileApiApi fileApiApi(final ApiClient apiClient) {
return new FileApiApi(apiClient);
}

/**
* Instance of an {@link S3StorageUrlProvider} containing a default {@link S3DomainProvider}. The
* instance will only return the default S3 URL.
*
* @return Provider of the S3 storage URL.
*/
@Bean
@ConditionalOnMissingBean(S3DomainProvider.class)
public S3StorageUrlProvider s3StorageUrlProviderWithoutDomainProvider() {
return new S3StorageUrlProvider(this.s3IntegrationClientProperties.getDocumentStorageUrl());
@ConditionalOnMissingBean
public FolderApiApi folderApiApi(final ApiClient apiClient) {
return new FolderApiApi(apiClient);
}

}
Loading

0 comments on commit e92b90e

Please sign in to comment.