Skip to content

Commit

Permalink
Mdas 933 refactoring eai komponenten (#50)
Browse files Browse the repository at this point in the history
* 🎨 Spottless Camel Route formatting off.

* ♻️ Refactoring mobidam-eai-commons-starter

* ♻️ Review refactoring (lib without spring related aspects).

* ♻️ Review refactoring (CommonError.class introduced).

* ♻️ S3CredentialProviderTest moved to mobidam-eai-commons-starter.

* ♻📝 RELEASENOTES.md updated.

* ♻📝 README.md updated.

* 🔧 Release Version mobidam-eai-commons-starter.

* ♻️ Review changes.

* ♻️ Review changes (mobidam-eai-commons-starter:0.0.2, add comment to test cases, remove stub from test).

* ♻️ HTTP constant introduced. 📝 Readme updated.
  • Loading branch information
sfi2022 authored Dec 2, 2024
1 parent 573d23c commit e0768cd
Show file tree
Hide file tree
Showing 30 changed files with 257 additions and 559 deletions.
7 changes: 5 additions & 2 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Release-Notes

## Sprint 20 (13.11.2024 - 03.12.2024)
### Entfernt
- Vespa Bucket Credentials entfernt
- Update auf mobidam-eai-commons-starter:0.0.2.
- Update Apache Camel.

## Sprint 19 (22.10.2024 - 12.11.2024)
- Umstellung auf mobidam-eai-commons-starter.

## Sprint 15 (30.07.2024 - 20.08.2024)
### Entfernt
Expand Down
21 changes: 13 additions & 8 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,20 @@ Mit der Rest Ressource GET '.../filesInFolder?bucketName=bucket1&path=...&archiv

### Konfiguration

Zur Konfiguration der Credentials der Buckets dient das Property ***mobidam.s3.bucket-credential-config***.
Zur Konfiguration der Credentials der Buckets dient das Property ***de.muenchen.mobidam.common.s3.bucket-credential-configs***.
Dieses ist als Map gestaltet und enthält die default Tenant-Credentials. Nach Bedarf können der Access-Key und Secret-Key für die einzelnen Buckets separat konfiguriert werden:
```
tenant-default:
access-key-env-var: MOBIDAM_ACCESS_KEY
secret-key-env-var: MOBIDAM_SECRET_KEY
int-mdasc-mdasdev:
access-key-env-var: MOBIDAM_BUCKET2_ACCESS_KEY
secret-key-env-var: MOBIDAM_BUCKET2_SECRET_KEY
de.muenchen.mobidam:
common:
s3:
bucket-credential-configs:
tenant-default:
access-key-env-var: MOBIDAM_ACCESS_KEY
secret-key-env-var: MOBIDAM_SECRET_KEY
int-mdasc-mdasdev:
access-key-env-var: MOBIDAM_BUCKET2_ACCESS_KEY
secret-key-env-var: MOBIDAM_BUCKET2_SECRET_KEY
```
Die Umgebungsvariablen müssen entsprechend in der Laufzeitumgebung bereitgestellt werden:
```
Expand All @@ -117,7 +122,7 @@ Alle im S3 archivierten Dateien werden nach einer Ablauffrist automatisch über

application.yaml:
```
mobidam:
de.muenchen.mobidam:
archive:
expiration-months: 1
```
Expand Down
18 changes: 7 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<maven.compiler.release>${java.version}</maven.compiler.release>

<!-- Frameworks -->
<camel.version>4.1.0</camel.version>
<camel.version>4.8.0</camel.version>
<spring.boot.version>3.1.4</spring.boot.version>

<!-- Other Maven Plugins -->
Expand Down Expand Up @@ -123,10 +123,7 @@
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-servlet-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jackson</artifactId>
</dependency>

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-quartz</artifactId>
Expand Down Expand Up @@ -187,6 +184,11 @@
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-jose</artifactId>
</dependency>
<dependency>
<groupId>de.muenchen.oss.mobidam</groupId>
<artifactId>mobidam-eai-commons-starter</artifactId>
<version>0.0.2</version>
</dependency>

<!-- Database -->
<dependency>
Expand Down Expand Up @@ -262,12 +264,6 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>3.0.2</version>
</dependency>

<!-- Logging -->
<dependency>
<groupId>net.logstash.logback</groupId>
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/de/muenchen/mobidam/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,10 @@ public class Constants {
public static final String CAMEL_SERVLET_CONTEXT_PATH_PRESIGNED_URL = "/presignedUrl";
public static final String CAMEL_SERVLET_CONTEXT_PATH_ARCHIVE = "/archive";
public static final String PARAMETER_ARCHIVED = "archived";
public static final String PARAMETER_BUCKET_NAME = "bucketName";
public static final String PARAMETER_OBJECT_NAME = "objectName";
public static final String PARAMETER_PATH = "path";
public static final String ARCHIVE_PATH = "archive/";

// S3 url parameter
public static final String S3_PREFIX = "prefix=";

// Headers for bucket credentials
public static final String ACCESS_KEY = "accessKey";
public static final String SECRET_KEY = "secretKey";
}
44 changes: 44 additions & 0 deletions src/main/java/de/muenchen/mobidam/config/CredentialConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* The MIT License
* Copyright © 2024 Landeshauptstadt München | it@M
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package de.muenchen.mobidam.config;

import de.muenchen.mobidam.eai.common.config.S3BucketCredentialConfig;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
* This class represents the configuration for S3 bucket credentials.
* It contains a map of S3Credentials objects, with the keys being the names of the S3 buckets.
*/
@Component
@ConfigurationProperties(prefix = "de.muenchen.mobidam.common.s3")
@Getter
@Setter
public class CredentialConfig {

private Map<String, S3BucketCredentialConfig.BucketCredentialConfig> bucketCredentialConfig;

}
16 changes: 0 additions & 16 deletions src/main/java/de/muenchen/mobidam/config/EnvironmentReader.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
@Profile("!no-security")
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
@RequiredArgsConstructor
public class SecurityConfiguration {

@Bean
Expand Down

This file was deleted.

This file was deleted.

128 changes: 0 additions & 128 deletions src/main/java/de/muenchen/mobidam/rest/ErrorResponse.java

This file was deleted.

10 changes: 5 additions & 5 deletions src/main/java/de/muenchen/mobidam/s3/RestResponseWrapper.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package de.muenchen.mobidam.s3;

import de.muenchen.mobidam.Constants;
import de.muenchen.mobidam.exception.ErrorResponseBuilder;
import de.muenchen.mobidam.exception.MobidamException;
import de.muenchen.mobidam.eai.common.exception.CommonError;
import de.muenchen.mobidam.eai.common.exception.ErrorResponseBuilder;
import de.muenchen.mobidam.eai.common.exception.MobidamException;
import de.muenchen.mobidam.rest.BucketContentInner;
import de.muenchen.mobidam.rest.ErrorResponse;
import de.muenchen.mobidam.rest.PresignedUrl;
import java.math.BigDecimal;
import java.util.ArrayList;
Expand Down Expand Up @@ -70,8 +70,8 @@ private void presignedUrl(Exchange exchange) throws MobidamException {
var links = exchange.getIn().getBody(Collection.class);

if (links.isEmpty()) {
ErrorResponse res = ErrorResponseBuilder.build(500, "Empty S3 url file list");
exchange.getMessage().setBody(res);
CommonError error = ErrorResponseBuilder.build(500, "Empty S3 url file list");
exchange.getMessage().setBody(error);
throw new MobidamException("Empty S3 url file list");
} else {
var file = new PresignedUrl();
Expand Down
Loading

0 comments on commit e0768cd

Please sign in to comment.