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

Update to Spring-boot 3.2.1 #28

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
33 changes: 33 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,36 @@ build/

/Krankenkassenverzeichnis_DiGA.xml
/.gradle/

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# build stage to build the diga-api-service.jar
FROM maven:3-jdk-11-slim as build
FROM maven:3-openjdk-17-slim as build

WORKDIR /usr/src/app

Expand Down
39 changes: 35 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.0</version>
<version>3.2.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand All @@ -26,8 +26,8 @@
</licenses>

<properties>
<java.version>11</java.version>
<kotlin.version>1.5.10</kotlin.version>
<java.version>17</java.version>
<kotlin.version>1.9.22</kotlin.version>
</properties>

<dependencies>
Expand All @@ -49,7 +49,7 @@
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<artifactId>kotlin-stdlib</artifactId>
</dependency>

<dependency>
Expand All @@ -75,6 +75,16 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.9</version>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -133,4 +143,25 @@
</plugins>
</build>

<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

</project>
8 changes: 3 additions & 5 deletions src/main/kotlin/dev/gtuk/diga/AppConfig.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package dev.gtuk.diga

import jakarta.validation.constraints.Email
import jakarta.validation.constraints.NotEmpty
import jakarta.validation.constraints.Size
import java.math.BigDecimal
import javax.validation.constraints.Email
import javax.validation.constraints.NotEmpty
import javax.validation.constraints.Size
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.context.properties.ConstructorBinding
import org.springframework.validation.annotation.Validated

@ConfigurationProperties("app")
@ConstructorBinding
@Validated
data class AppConfig(
val disableTestcodes: Boolean,
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/dev/gtuk/diga/AppController.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.gtuk.diga

import dev.gtuk.diga.dtos.BillingRequest
import javax.validation.Valid
import jakarta.validation.Valid
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.GetMapping
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/dev/gtuk/diga/AppExceptionHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package dev.gtuk.diga
import dev.gtuk.diga.exceptions.BillingException
import dev.gtuk.diga.exceptions.TestCodesDisabledException
import dev.gtuk.diga.exceptions.ValidationException
import javax.servlet.http.HttpServletResponse
import jakarta.servlet.http.HttpServletResponse
import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.ControllerAdvice
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.RestControllerAdvice

@ControllerAdvice
@RestControllerAdvice
class AppExceptionHandler {

@ExceptionHandler(ValidationException::class)
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/dev/gtuk/diga/Application.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package dev.gtuk.diga

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.runApplication

@SpringBootApplication
@SpringBootApplication(exclude = [ErrorMvcAutoConfiguration::class])
@EnableConfigurationProperties(AppConfig::class)
class Application

Expand Down
15 changes: 7 additions & 8 deletions src/main/kotlin/dev/gtuk/diga/DigaService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import dev.gtuk.diga.exceptions.BillingException
import dev.gtuk.diga.exceptions.TestCodesDisabledException
import dev.gtuk.diga.exceptions.ValidationException
import java.io.FileInputStream
import kotlin.jvm.Throws
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service

Expand All @@ -23,7 +22,7 @@ class DigaService(private val appConfig: AppConfig) {

private val logger = LoggerFactory.getLogger(javaClass)

private var apiClient: DigaApiClient
private lateinit var apiClient: DigaApiClient

init {
val apiClientSettings = DigaApiClientSettings.builder()
Expand Down Expand Up @@ -85,8 +84,8 @@ class DigaService(private val appConfig: AppConfig) {
}

// If response has errors unwrap them
if (response.isHasError()) {
val errors: String = unwrapErrors(response.getErrors()).joinToString(separator = ", ")
if (response.isHasError) {
val errors: String = unwrapErrors(response.errors).joinToString(separator = ", ")
logger.error("Validation errors", errors)

throw ValidationException(errors)
Expand Down Expand Up @@ -128,11 +127,11 @@ class DigaService(private val appConfig: AppConfig) {
}

// If response has errors unwrap them
if (response.isHasError()) {
val errors: String = unwrapErrors(response.getErrors()).joinToString(separator = ", ")
if (response.isHasError) {
val errors: String = unwrapErrors(response.errors).joinToString(separator = ", ")
logger.error("Billing errors", errors)

throw BillingException(unwrapErrors(response.getErrors()).joinToString(separator = ", "))
throw BillingException(unwrapErrors(response.errors).joinToString(separator = ", "))
}

return BillingResponse(
Expand All @@ -146,7 +145,7 @@ class DigaService(private val appConfig: AppConfig) {
private fun unwrapErrors(responseErrors: List<DigaApiResponseError>): List<String> {
val errors: MutableList<String> = ArrayList()
for (error: DigaApiResponseError in responseErrors) {
errors.add(error.getError())
errors.add(error.error)
}

return errors
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/dev/gtuk/diga/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package dev.gtuk.diga

import com.alextherapeutics.diga.model.DigaApiTestCode
import dev.gtuk.diga.exceptions.CodeValidationException
import kotlin.jvm.Throws

class Utils {

Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/dev/gtuk/diga/dtos/BillingRequest.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dev.gtuk.diga.dtos

import jakarta.validation.constraints.NotEmpty
import jakarta.validation.constraints.Size
import java.util.Date
import javax.validation.constraints.NotEmpty
import javax.validation.constraints.Size

data class BillingRequest(
@get:NotEmpty @get:Size(min = 16, max = 16) val code: String,
Expand Down
Loading