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

Tsystems 196 upgrade spring boot to 3.2.x message service #161

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
6 changes: 3 additions & 3 deletions .github/workflows/dockerImageSkipTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
- name: Maven Package
run: mvn -B -Pprod clean package -DskipTests
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: targetfiles
path: target/*.jar
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Download buildfiles artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: targetfiles
- name: Get current time
Expand Down Expand Up @@ -179,4 +179,4 @@ jobs:
value: ${{ env.DOCKER_IMAGE_TAG }}
custom-actions: |
- text: View CI
url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
59 changes: 33 additions & 26 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.13</version>
<version>3.3.8</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand All @@ -31,13 +31,14 @@
<openapi.generator.maven.version>6.4.0</openapi.generator.maven.version>
<liquibase-core.version>4.23.2</liquibase-core.version>
<liquibase-maven-plugin.version>4.23.2</liquibase-maven-plugin.version>
<spring-security.version>6.3.4</spring-security.version>
<springfox-boot-starter.version>3.0.0</springfox-boot-starter.version>
<spring-security-test.version>6.0.5</spring-security-test.version>
<spring-security-test.version>6.0.8</spring-security-test.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<commons-lang3.version>3.11</commons-lang3.version>
<commons-collections4.version>4.4</commons-collections4.version>
<commons-codec.version>1.15</commons-codec.version>
<commons-codec.version>1.17.2</commons-codec.version>
<spring-security-oauth2-test-webmvc-addons.version>3.0.1</spring-security-oauth2-test-webmvc-addons.version>
</properties>

Expand Down Expand Up @@ -66,17 +67,14 @@
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${spring-security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${spring-security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${spring-security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -85,11 +83,6 @@
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>8.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.sonatype.plexus</groupId>
Expand Down Expand Up @@ -143,7 +136,7 @@
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.4.0</version>
<version>2.6.0</version>
</dependency>

<!-- Keycloak dependencies -->
Expand All @@ -163,9 +156,8 @@
<version>${keycloak.version}</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.1.1</version>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
</dependency>

<!-- Lombok dependencies -->
Expand All @@ -179,7 +171,6 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>

<dependency>
Expand All @@ -199,7 +190,6 @@
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>${commons-codec.version}</version>
</dependency>

<!-- Liquibase -->
Expand All @@ -212,7 +202,6 @@
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>${liquibase-core.version}</version>
</dependency>

<dependency>
Expand All @@ -223,22 +212,18 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>2.0</version>
</dependency>

<dependency>
Expand All @@ -249,7 +234,6 @@
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<version>${spring-security-test.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -275,6 +259,12 @@
<artifactId>concurrent-junit</artifactId>
<version>1.0.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.fridujo</groupId>
Expand Down Expand Up @@ -442,7 +432,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.3.0</version>
<version>3.6.0</version>
<executions>
<execution>
<id>validate</id>
Expand All @@ -466,9 +456,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>17</source>
<target>17</target>
<compilerArgs>--enable-preview</compilerArgs>
<release>${java.version}</release>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -508,6 +497,24 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>6.0.4</version>
<configuration>
<exportDatatables>true</exportDatatables>
<activeRecipes>
<recipe>org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3</recipe>
</activeRecipes>
</configuration>
<dependencies>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-spring</artifactId>
<version>6.0.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<profiles>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/caritas/cob/messageservice/Messenger.java
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public boolean patchEventMessage(String rcToken, String rcUserId, String message
}

if (!message.isA(MessageType.REASSIGN_CONSULTANT)) {
var errorMessage = String.format("Message (%s) is not a reassignment.", messageId);
var errorMessage = "Message (%s) is not a reassignment.".formatted(messageId);
throw new BadRequestException(errorMessage, LogService::logBadRequest);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import de.caritas.cob.messageservice.api.service.MessageMapper;
import de.caritas.cob.messageservice.api.service.RocketChatService;
import de.caritas.cob.messageservice.generated.api.controller.MessagesApi;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.time.Instant;
import java.util.Optional;
import jakarta.validation.Valid;
Expand All @@ -41,8 +41,8 @@
* Controller for message requests.
*/
@RestController
@Tag(name = "message-controller")
@RequiredArgsConstructor
@Api(tags = "message-controller")
public class MessageController implements MessagesApi {

private final @NonNull RocketChatService rocketChatService;
Expand Down Expand Up @@ -245,19 +245,19 @@ public ResponseEntity<MessageResponseDTO> saveAliasOnlyMessage(String rcGroupId,
var aliasArgs = aliasOnlyMessageDTO.getArgs();

if (type.equals(MessageType.USER_MUTED) || type.equals(MessageType.USER_UNMUTED)) {
var message = String.format("Message type (%s) is protected.", type);
var message = "Message type (%s) is protected.".formatted(type);
throw new BadRequestException(message, LogService::logBadRequest);
}

if (nonNull(aliasArgs) && type != MessageType.REASSIGN_CONSULTANT) {
var message = String.format("Alias args are not supported by type (%s).", type);
var message = "Alias args are not supported by type (%s).".formatted(type);
throw new BadRequestException(message, LogService::logBadRequest);
}

if (type == MessageType.REASSIGN_CONSULTANT && hasMissingMandatoryAliasArgForReassignment(
aliasArgs)) {
var errorFormat = "toConsultantId is required during reassignment creation (%s).";
var message = String.format(errorFormat, MessageType.REASSIGN_CONSULTANT);
var message = errorFormat.formatted(MessageType.REASSIGN_CONSULTANT);
throw new BadRequestException(message, LogService::logBadRequest);
}

Expand Down Expand Up @@ -290,7 +290,7 @@ public ResponseEntity<Void> patchMessage(String rcToken, String rcUserId, String
AliasArgs aliasArgs) {
var reassignStatus = aliasArgs.getStatus();
if (reassignStatus == ReassignStatus.REQUESTED) {
var message = String.format("Updating to status (%s) is not supported.", reassignStatus);
var message = "Updating to status (%s) is not supported.".formatted(reassignStatus);
throw new BadRequestException(message, LogService::logBadRequest);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package de.caritas.cob.messageservice.api.exception;

import java.io.Serial;

public class CustomCryptoException extends Exception {

@Serial
private static final long serialVersionUID = 1232112575979020932L;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package de.caritas.cob.messageservice.api.exception;

import java.io.Serial;

public class HelperException extends RuntimeException {
@Serial
private static final long serialVersionUID = -1321906171569622899L;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package de.caritas.cob.messageservice.api.exception;

import java.io.Serial;

public class KeycloakException extends RuntimeException {

@Serial
private static final long serialVersionUID = -5083156826149548581L;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package de.caritas.cob.messageservice.api.exception;

import java.io.Serial;

public class NoMasterKeyException extends RuntimeException {

@Serial
private static final long serialVersionUID = 362702101121444833L;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package de.caritas.cob.messageservice.api.exception;

import java.io.Serial;
import java.util.function.Consumer;

public class RocketChatBadRequestException extends CustomLoggableResponseException {

@Serial
private static final long serialVersionUID = 362702101121444833L;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package de.caritas.cob.messageservice.api.exception;

import java.io.Serial;

public class RocketChatLoginException extends RuntimeException {

@Serial
private static final long serialVersionUID = 5198347832036308397L;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package de.caritas.cob.messageservice.api.exception;

import java.io.Serial;

public class RocketChatPostMarkGroupAsReadException extends RuntimeException {

@Serial
private static final long serialVersionUID = -5666387091852981692L;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package de.caritas.cob.messageservice.api.exception;

import java.io.Serial;

public class RocketChatSendMessageException extends RuntimeException {

@Serial
private static final long serialVersionUID = 1232112575979020931L;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private String base32EncodeUsername(String username) {
.replace(BASE32_PLACEHOLDER, BASE32_PLACEHOLDER_REPLACE_STRING);
} catch (Exception exception) {
// Catch generic exception because of lack of base32 documentation
throw new HelperException(String.format("Could not encode username %s", username), exception);
throw new HelperException("Could not encode username %s".formatted(username), exception);
}
}

Expand All @@ -43,7 +43,7 @@ private String base32DecodeUsername(String username) {
.toUpperCase().replace(BASE32_PLACEHOLDER_REPLACE_STRING, BASE32_PLACEHOLDER)));
} catch (Exception exception) {
// Catch generic exception because of lack of base32 documentation
throw new HelperException(String.format("Could not decode username %s", username), exception);
throw new HelperException("Could not decode username %s".formatted(username), exception);
}
}

Expand Down
Loading
Loading