From b3a55af93a80e523ba450228629911a17b6ab5ac Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Thu, 26 Oct 2023 19:06:26 +0200 Subject: [PATCH] Moved generic value classes to separate module --- module-common/common.gradle.kts | 5 + .../de/twomartens/timetable/types}/Hour.kt | 2 +- .../twomartens/timetable/types}/HourAtDay.kt | 2 +- .../timetable/types}/NonEmptyString.kt | 2 +- .../timetable/types}/PositiveInteger.kt | 2 +- module-server/server.gradle.kts | 1 + .../bahnApi/mapper/BahnTimetableMapper.kt | 2 +- .../timetable/bahnApi/model/TaskFactory.kt | 2 +- .../timetable/bahnApi/model/db/BahnStation.kt | 2 +- .../bahnApi/model/db/BahnTimetable.kt | 2 +- .../bahnApi/model/db/ScheduledFetchTask.kt | 2 +- .../bahnApi/model/dto/BahnStations.kt | 2 +- .../bahnApi/model/dto/BahnStopEvent.kt | 30 +-- .../bahnApi/model/dto/BahnTripLabel.kt | 12 +- .../bahnApi/service/BahnApiService.kt | 4 +- .../bahnApi/service/BahnDatabaseService.kt | 2 +- .../bahnApi/service/ScheduledTaskService.kt | 4 +- .../bahnApi/service/TaskScheduler.kt | 2 +- .../bahnApi/tasks/FetchTimetableTask.kt | 2 +- .../bahnApi/tasks/StoreTimetableTask.kt | 2 +- .../configuration/PropertyConfiguration.kt | 2 +- .../controller/TimetableController.kt | 2 +- .../timetable/model/db/CoachCapacity.kt | 2 +- .../timetable/model/db/CountryCode.kt | 2 +- .../de/twomartens/timetable/model/db/Depot.kt | 2 +- .../timetable/model/db/Formation.kt | 2 +- .../timetable/model/db/FormationId.kt | 2 +- .../twomartens/timetable/model/db/Portal.kt | 2 +- .../twomartens/timetable/model/db/Section.kt | 2 +- .../timetable/model/db/StationId.kt | 2 +- .../twomartens/timetable/model/db/TrackId.kt | 2 +- .../twomartens/timetable/model/db/TswRoute.kt | 2 +- .../de/twomartens/timetable/model/db/User.kt | 2 +- .../twomartens/timetable/model/db/UserId.kt | 2 +- .../repository/TswRouteRepository.kt | 2 +- .../configuration/FilterConfiguration.kt | 8 +- .../configuration/InterceptorConfiguration.kt | 16 +- .../configuration/OpenApiConfiguration.kt | 30 +-- .../RestTemplateConfiguration.kt | 18 +- .../configuration/StatusProbeConfiguration.kt | 4 +- .../configuration/WebSecurityConfiguration.kt | 26 +- .../support/controller/ExceptionController.kt | 2 +- .../controller/VersionHtmlController.kt | 3 +- .../support/exception/HttpStatusException.kt | 2 +- .../BufferingClientHttpResponseWrapper.kt | 2 +- .../interceptor/HeaderInterceptorRest.kt | 8 +- .../interceptor/LoggingInterceptorRest.kt | 222 +++++++++--------- .../actuator/AbstractHealthIndicator.kt | 8 +- .../actuator/RestHealthIndicator.kt | 2 +- .../statusprobe/ScheduledStatusProbe.kt | 6 +- .../statusprobe/StatusProbeLogger.kt | 28 +-- .../property/RestTemplateTimeoutProperties.kt | 8 +- .../support/property/StatusProbeProperties.kt | 9 +- .../support/property/TimeProperties.kt | 4 +- settings.gradle.kts | 1 + 55 files changed, 264 insertions(+), 257 deletions(-) create mode 100644 module-common/common.gradle.kts rename {module-server/src/main/kotlin/de/twomartens/timetable/model/base => module-common/src/main/kotlin/de/twomartens/timetable/types}/Hour.kt (86%) rename {module-server/src/main/kotlin/de/twomartens/timetable/model/base => module-common/src/main/kotlin/de/twomartens/timetable/types}/HourAtDay.kt (95%) rename {module-server/src/main/kotlin/de/twomartens/timetable/model/base => module-common/src/main/kotlin/de/twomartens/timetable/types}/NonEmptyString.kt (78%) rename {module-server/src/main/kotlin/de/twomartens/timetable/model/base => module-common/src/main/kotlin/de/twomartens/timetable/types}/PositiveInteger.kt (78%) diff --git a/module-common/common.gradle.kts b/module-common/common.gradle.kts new file mode 100644 index 0000000..7a57b7c --- /dev/null +++ b/module-common/common.gradle.kts @@ -0,0 +1,5 @@ +plugins { + id("twomartens.kotlin") + id("twomartens.java") + kotlin("kapt") +} \ No newline at end of file diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/model/base/Hour.kt b/module-common/src/main/kotlin/de/twomartens/timetable/types/Hour.kt similarity index 86% rename from module-server/src/main/kotlin/de/twomartens/timetable/model/base/Hour.kt rename to module-common/src/main/kotlin/de/twomartens/timetable/types/Hour.kt index 8b252b4..f028e3d 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/model/base/Hour.kt +++ b/module-common/src/main/kotlin/de/twomartens/timetable/types/Hour.kt @@ -1,4 +1,4 @@ -package de.twomartens.timetable.model.base +package de.twomartens.timetable.types @JvmInline value class Hour private constructor(val value: Int) { diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/model/base/HourAtDay.kt b/module-common/src/main/kotlin/de/twomartens/timetable/types/HourAtDay.kt similarity index 95% rename from module-server/src/main/kotlin/de/twomartens/timetable/model/base/HourAtDay.kt rename to module-common/src/main/kotlin/de/twomartens/timetable/types/HourAtDay.kt index 65e5283..fc1aaa0 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/model/base/HourAtDay.kt +++ b/module-common/src/main/kotlin/de/twomartens/timetable/types/HourAtDay.kt @@ -1,4 +1,4 @@ -package de.twomartens.timetable.model.base +package de.twomartens.timetable.types import java.time.LocalDate import java.time.LocalDateTime diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/model/base/NonEmptyString.kt b/module-common/src/main/kotlin/de/twomartens/timetable/types/NonEmptyString.kt similarity index 78% rename from module-server/src/main/kotlin/de/twomartens/timetable/model/base/NonEmptyString.kt rename to module-common/src/main/kotlin/de/twomartens/timetable/types/NonEmptyString.kt index 379a8e7..789f49b 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/model/base/NonEmptyString.kt +++ b/module-common/src/main/kotlin/de/twomartens/timetable/types/NonEmptyString.kt @@ -1,4 +1,4 @@ -package de.twomartens.timetable.model.base +package de.twomartens.timetable.types @JvmInline value class NonEmptyString(val name: String) { diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/model/base/PositiveInteger.kt b/module-common/src/main/kotlin/de/twomartens/timetable/types/PositiveInteger.kt similarity index 78% rename from module-server/src/main/kotlin/de/twomartens/timetable/model/base/PositiveInteger.kt rename to module-common/src/main/kotlin/de/twomartens/timetable/types/PositiveInteger.kt index b25bfb3..8f0fa8a 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/model/base/PositiveInteger.kt +++ b/module-common/src/main/kotlin/de/twomartens/timetable/types/PositiveInteger.kt @@ -1,4 +1,4 @@ -package de.twomartens.timetable.model.base +package de.twomartens.timetable.types @JvmInline value class PositiveInteger(val value: Int) { diff --git a/module-server/server.gradle.kts b/module-server/server.gradle.kts index 28fcea7..89c558c 100644 --- a/module-server/server.gradle.kts +++ b/module-server/server.gradle.kts @@ -5,6 +5,7 @@ plugins { } dependencies { + implementation(project(":common")) implementation(libs.mapstruct.base) implementation(libs.bundles.spring.boot.security) implementation(libs.jaxb.impl) diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/mapper/BahnTimetableMapper.kt b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/mapper/BahnTimetableMapper.kt index 490c5f1..ec2e32d 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/mapper/BahnTimetableMapper.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/mapper/BahnTimetableMapper.kt @@ -1,7 +1,7 @@ package de.twomartens.timetable.bahnApi.mapper import de.twomartens.timetable.bahnApi.model.db.BahnTimetable -import de.twomartens.timetable.model.base.NonEmptyString +import de.twomartens.timetable.types.NonEmptyString import org.mapstruct.* import java.time.LocalDateTime diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/TaskFactory.kt b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/TaskFactory.kt index e1552f4..36a6408 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/TaskFactory.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/TaskFactory.kt @@ -1,7 +1,7 @@ package de.twomartens.timetable.bahnApi.model import de.twomartens.timetable.bahnApi.model.db.ScheduledFetchTask -import de.twomartens.timetable.model.base.HourAtDay +import de.twomartens.timetable.types.HourAtDay import org.springframework.stereotype.Component import java.time.LocalDateTime diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/db/BahnStation.kt b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/db/BahnStation.kt index 3d3bc65..1a513a9 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/db/BahnStation.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/db/BahnStation.kt @@ -1,7 +1,7 @@ package de.twomartens.timetable.bahnApi.model.db import de.twomartens.timetable.bahnApi.model.Eva -import de.twomartens.timetable.model.base.NonEmptyString +import de.twomartens.timetable.types.NonEmptyString import org.bson.types.ObjectId import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.Id diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/db/BahnTimetable.kt b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/db/BahnTimetable.kt index 64fe59a..9cd0ef2 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/db/BahnTimetable.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/db/BahnTimetable.kt @@ -2,7 +2,7 @@ package de.twomartens.timetable.bahnApi.model.db import de.twomartens.timetable.bahnApi.model.Eva import de.twomartens.timetable.bahnApi.model.dto.BahnStationStop -import de.twomartens.timetable.model.base.NonEmptyString +import de.twomartens.timetable.types.NonEmptyString import org.bson.types.ObjectId import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.Id diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/db/ScheduledFetchTask.kt b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/db/ScheduledFetchTask.kt index b553673..1be2ba6 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/db/ScheduledFetchTask.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/db/ScheduledFetchTask.kt @@ -1,7 +1,7 @@ package de.twomartens.timetable.bahnApi.model.db import de.twomartens.timetable.bahnApi.model.Eva -import de.twomartens.timetable.model.base.HourAtDay +import de.twomartens.timetable.types.HourAtDay import org.bson.types.ObjectId import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.Id diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/dto/BahnStations.kt b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/dto/BahnStations.kt index b9a71e8..e864822 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/dto/BahnStations.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/dto/BahnStations.kt @@ -8,7 +8,7 @@ import jakarta.xml.bind.annotation.XmlRootElement @XmlRootElement(name = "stations") @XmlAccessorType(XmlAccessType.FIELD) data class BahnStations( - @field:XmlElement(name = "station") var stations: List + @field:XmlElement(name = "station") var stations: List ) { constructor() : this(listOf()) } diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/dto/BahnStopEvent.kt b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/dto/BahnStopEvent.kt index 2f348e3..7e2c833 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/dto/BahnStopEvent.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/dto/BahnStopEvent.kt @@ -9,22 +9,22 @@ import java.time.LocalDateTime @XmlAccessorType(XmlAccessType.FIELD) data class BahnStopEvent( - @field:XmlAttribute(name = "pde") var plannedDistantEndpoint: String, - @field:XmlAttribute(name = "cde") var changedDistantEndpoint: String, - @field:XmlAttribute(name = "pt") - @field:XmlJavaTypeAdapter(value = LocalDateTimeAdapter::class) - var plannedTime: LocalDateTime?, - @field:XmlAttribute(name = "ct") - @field:XmlJavaTypeAdapter(value = LocalDateTimeAdapter::class) - var changedTime: LocalDateTime?, - @field:XmlAttribute(name = "ppth") var plannedPath: String, - @field:XmlAttribute(name = "cpth") var changedPath: String, - @field:XmlAttribute(name = "pp") var plannedPlatform: String, - @field:XmlAttribute(name = "cp") var changedPlatform: String, - @field:XmlAttribute(name = "wings") var wings: String, - @field:XmlAttribute(name = "l") var line: String + @field:XmlAttribute(name = "pde") var plannedDistantEndpoint: String, + @field:XmlAttribute(name = "cde") var changedDistantEndpoint: String, + @field:XmlAttribute(name = "pt") + @field:XmlJavaTypeAdapter(value = LocalDateTimeAdapter::class) + var plannedTime: LocalDateTime?, + @field:XmlAttribute(name = "ct") + @field:XmlJavaTypeAdapter(value = LocalDateTimeAdapter::class) + var changedTime: LocalDateTime?, + @field:XmlAttribute(name = "ppth") var plannedPath: String, + @field:XmlAttribute(name = "cpth") var changedPath: String, + @field:XmlAttribute(name = "pp") var plannedPlatform: String, + @field:XmlAttribute(name = "cp") var changedPlatform: String, + @field:XmlAttribute(name = "wings") var wings: String, + @field:XmlAttribute(name = "l") var line: String ) { - constructor(): this("", "", + constructor() : this("", "", null, null, "", "", "", "", diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/dto/BahnTripLabel.kt b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/dto/BahnTripLabel.kt index 4ee5197..4522f5f 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/dto/BahnTripLabel.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/dto/BahnTripLabel.kt @@ -6,12 +6,12 @@ import jakarta.xml.bind.annotation.XmlAttribute @XmlAccessorType(XmlAccessType.FIELD) data class BahnTripLabel( - @field:XmlAttribute(name = "c") var category: String, - // S: S-Bahn, N: Nahverkehr, F: Fernverkehr - @field:XmlAttribute(name = "f") var filterFlags: String, - @field:XmlAttribute(name = "n") var trainNumber: String, - @field:XmlAttribute(name = "o") var owner: String, - @field:XmlAttribute(name = "t") var tripType: BahnTripType + @field:XmlAttribute(name = "c") var category: String, + // S: S-Bahn, N: Nahverkehr, F: Fernverkehr + @field:XmlAttribute(name = "f") var filterFlags: String, + @field:XmlAttribute(name = "n") var trainNumber: String, + @field:XmlAttribute(name = "o") var owner: String, + @field:XmlAttribute(name = "t") var tripType: BahnTripType ) { constructor() : this("", "", "", "", BahnTripType.p) } \ No newline at end of file diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/BahnApiService.kt b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/BahnApiService.kt index cca994e..ca6dd58 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/BahnApiService.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/BahnApiService.kt @@ -5,7 +5,7 @@ import de.twomartens.timetable.bahnApi.model.dto.BahnStation import de.twomartens.timetable.bahnApi.model.dto.BahnStations import de.twomartens.timetable.bahnApi.model.dto.BahnTimetable import de.twomartens.timetable.bahnApi.property.BahnApiProperties -import de.twomartens.timetable.model.base.HourAtDay +import de.twomartens.timetable.types.HourAtDay import org.springframework.http.HttpEntity import org.springframework.http.HttpHeaders import org.springframework.http.HttpMethod @@ -23,7 +23,7 @@ class BahnApiService( fun fetchStations(pattern: String): List { val requestEntity = buildRequestEntity() val response = restTemplate.exchange( - "https://apis.deutschebahn.com/db-api-marketplace/apis/timetables/v1/station/${pattern}", + "https://apis.deutschebahn.com/db-api-marketplace/apis/timetables/v1/station/${pattern}", HttpMethod.GET, requestEntity, BahnStations::class.java diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/BahnDatabaseService.kt b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/BahnDatabaseService.kt index 5ebc2dd..2f567b6 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/BahnDatabaseService.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/BahnDatabaseService.kt @@ -6,7 +6,7 @@ import de.twomartens.timetable.bahnApi.model.dto.BahnStation import de.twomartens.timetable.bahnApi.model.dto.BahnTimetable import de.twomartens.timetable.bahnApi.repository.BahnStationRepository import de.twomartens.timetable.bahnApi.repository.BahnTimetableRepository -import de.twomartens.timetable.model.base.HourAtDay +import de.twomartens.timetable.types.HourAtDay import org.mapstruct.factory.Mappers import org.springframework.stereotype.Service diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/ScheduledTaskService.kt b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/ScheduledTaskService.kt index 9eb74ad..0c0e8d4 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/ScheduledTaskService.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/ScheduledTaskService.kt @@ -5,9 +5,9 @@ import de.twomartens.timetable.bahnApi.model.FetchDates import de.twomartens.timetable.bahnApi.model.TaskFactory import de.twomartens.timetable.bahnApi.model.db.ScheduledFetchTask import de.twomartens.timetable.bahnApi.repository.ScheduledFetchTaskRepository -import de.twomartens.timetable.model.base.Hour -import de.twomartens.timetable.model.base.HourAtDay import de.twomartens.timetable.model.db.TswRoute +import de.twomartens.timetable.types.Hour +import de.twomartens.timetable.types.HourAtDay import mu.KotlinLogging import org.springframework.stereotype.Service import java.time.LocalDate diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/TaskScheduler.kt b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/TaskScheduler.kt index 66e10d0..7044699 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/TaskScheduler.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/TaskScheduler.kt @@ -6,8 +6,8 @@ import de.twomartens.timetable.bahnApi.repository.ScheduledFetchTaskRepository import de.twomartens.timetable.bahnApi.tasks.DeleteScheduledTask import de.twomartens.timetable.bahnApi.tasks.FetchTimetableTask import de.twomartens.timetable.bahnApi.tasks.StoreTimetableTask -import de.twomartens.timetable.model.base.HourAtDay import de.twomartens.timetable.property.TimeProperties +import de.twomartens.timetable.types.HourAtDay import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler import org.springframework.stereotype.Service diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/tasks/FetchTimetableTask.kt b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/tasks/FetchTimetableTask.kt index 2e8073b..7f68b6f 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/tasks/FetchTimetableTask.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/tasks/FetchTimetableTask.kt @@ -3,7 +3,7 @@ package de.twomartens.timetable.bahnApi.tasks import de.twomartens.timetable.bahnApi.model.Eva import de.twomartens.timetable.bahnApi.service.BahnApiService import de.twomartens.timetable.bahnApi.service.TaskScheduler -import de.twomartens.timetable.model.base.HourAtDay +import de.twomartens.timetable.types.HourAtDay import mu.KotlinLogging import org.springframework.scheduling.annotation.Async diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/tasks/StoreTimetableTask.kt b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/tasks/StoreTimetableTask.kt index 31dc69e..3738772 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/tasks/StoreTimetableTask.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/tasks/StoreTimetableTask.kt @@ -2,7 +2,7 @@ package de.twomartens.timetable.bahnApi.tasks import de.twomartens.timetable.bahnApi.model.dto.BahnTimetable import de.twomartens.timetable.bahnApi.service.BahnDatabaseService -import de.twomartens.timetable.model.base.HourAtDay +import de.twomartens.timetable.types.HourAtDay import mu.KotlinLogging import org.springframework.scheduling.annotation.Async diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/configuration/PropertyConfiguration.kt b/module-server/src/main/kotlin/de/twomartens/timetable/configuration/PropertyConfiguration.kt index 29fbf88..98da0dd 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/configuration/PropertyConfiguration.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/configuration/PropertyConfiguration.kt @@ -10,5 +10,5 @@ import org.springframework.context.annotation.Configuration @Configuration @EnableConfigurationProperties(RestTemplateTimeoutProperties::class, ServiceProperties::class, - StatusProbeProperties::class, TimeProperties::class, BahnApiProperties::class) + StatusProbeProperties::class, TimeProperties::class, BahnApiProperties::class) open class PropertyConfiguration \ No newline at end of file diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/controller/TimetableController.kt b/module-server/src/main/kotlin/de/twomartens/timetable/controller/TimetableController.kt index e0e05fa..83244bb 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/controller/TimetableController.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/controller/TimetableController.kt @@ -1,9 +1,9 @@ package de.twomartens.timetable.controller import de.twomartens.timetable.bahnApi.service.ScheduledTaskService -import de.twomartens.timetable.model.base.NonEmptyString import de.twomartens.timetable.model.db.UserId import de.twomartens.timetable.repository.TswRouteRepository +import de.twomartens.timetable.types.NonEmptyString import io.swagger.v3.oas.annotations.Operation import io.swagger.v3.oas.annotations.Parameter import io.swagger.v3.oas.annotations.responses.ApiResponse diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/CoachCapacity.kt b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/CoachCapacity.kt index df5ed1e..29516d0 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/CoachCapacity.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/CoachCapacity.kt @@ -1,6 +1,6 @@ package de.twomartens.timetable.model.db -import de.twomartens.timetable.model.base.PositiveInteger +import de.twomartens.timetable.types.PositiveInteger @JvmInline value class CoachCapacity(val capacity: PositiveInteger) diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/CountryCode.kt b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/CountryCode.kt index ffe671c..c1947a6 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/CountryCode.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/CountryCode.kt @@ -1,6 +1,6 @@ package de.twomartens.timetable.model.db -import de.twomartens.timetable.model.base.NonEmptyString +import de.twomartens.timetable.types.NonEmptyString @JvmInline value class CountryCode(val countryCode: NonEmptyString) { diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/Depot.kt b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/Depot.kt index bca4ef9..cf530ad 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/Depot.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/Depot.kt @@ -1,6 +1,6 @@ package de.twomartens.timetable.model.db -import de.twomartens.timetable.model.base.NonEmptyString +import de.twomartens.timetable.types.NonEmptyString import kotlin.time.Duration data class Depot( diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/Formation.kt b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/Formation.kt index 9866d20..3b31d5f 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/Formation.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/Formation.kt @@ -1,6 +1,6 @@ package de.twomartens.timetable.model.db -import de.twomartens.timetable.model.base.NonEmptyString +import de.twomartens.timetable.types.NonEmptyString import org.bson.types.ObjectId import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.Id diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/FormationId.kt b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/FormationId.kt index 61ffd89..11af083 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/FormationId.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/FormationId.kt @@ -1,6 +1,6 @@ package de.twomartens.timetable.model.db -import de.twomartens.timetable.model.base.PositiveInteger +import de.twomartens.timetable.types.PositiveInteger @JvmInline value class FormationId(val id: PositiveInteger) \ No newline at end of file diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/Portal.kt b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/Portal.kt index 3a7232e..ad359c4 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/Portal.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/Portal.kt @@ -1,6 +1,6 @@ package de.twomartens.timetable.model.db -import de.twomartens.timetable.model.base.NonEmptyString +import de.twomartens.timetable.types.NonEmptyString import kotlin.time.Duration data class Portal( diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/Section.kt b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/Section.kt index 2c18c43..5bdde2e 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/Section.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/Section.kt @@ -1,6 +1,6 @@ package de.twomartens.timetable.model.db -import de.twomartens.timetable.model.base.NonEmptyString +import de.twomartens.timetable.types.NonEmptyString @JvmInline value class Section(val name: NonEmptyString) diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/StationId.kt b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/StationId.kt index e34c48c..dabfc23 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/StationId.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/StationId.kt @@ -1,6 +1,6 @@ package de.twomartens.timetable.model.db -import de.twomartens.timetable.model.base.NonEmptyString +import de.twomartens.timetable.types.NonEmptyString @JvmInline value class StationId(val id: NonEmptyString) { diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/TrackId.kt b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/TrackId.kt index 2a3017a..6424aa3 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/TrackId.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/TrackId.kt @@ -1,6 +1,6 @@ package de.twomartens.timetable.model.db -import de.twomartens.timetable.model.base.PositiveInteger +import de.twomartens.timetable.types.PositiveInteger @JvmInline value class TrackId(val id: PositiveInteger) diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/TswRoute.kt b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/TswRoute.kt index 9e0eb69..e763ad0 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/TswRoute.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/TswRoute.kt @@ -1,6 +1,6 @@ package de.twomartens.timetable.model.db -import de.twomartens.timetable.model.base.NonEmptyString +import de.twomartens.timetable.types.NonEmptyString import org.bson.types.ObjectId import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.Id diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/User.kt b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/User.kt index 843b630..d80333e 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/User.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/User.kt @@ -1,6 +1,6 @@ package de.twomartens.timetable.model.db -import de.twomartens.timetable.model.base.NonEmptyString +import de.twomartens.timetable.types.NonEmptyString import org.bson.types.ObjectId import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.Id diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/UserId.kt b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/UserId.kt index 3776a5b..63b7d7f 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/model/db/UserId.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/model/db/UserId.kt @@ -1,6 +1,6 @@ package de.twomartens.timetable.model.db -import de.twomartens.timetable.model.base.NonEmptyString +import de.twomartens.timetable.types.NonEmptyString @JvmInline value class UserId(val id: NonEmptyString) diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/repository/TswRouteRepository.kt b/module-server/src/main/kotlin/de/twomartens/timetable/repository/TswRouteRepository.kt index eeaab46..999e8ba 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/repository/TswRouteRepository.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/repository/TswRouteRepository.kt @@ -1,8 +1,8 @@ package de.twomartens.timetable.repository -import de.twomartens.timetable.model.base.NonEmptyString import de.twomartens.timetable.model.db.TswRoute import de.twomartens.timetable.model.db.UserId +import de.twomartens.timetable.types.NonEmptyString import org.bson.types.ObjectId import org.springframework.data.mongodb.repository.MongoRepository diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/FilterConfiguration.kt b/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/FilterConfiguration.kt index 3f16f62..abc2b29 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/FilterConfiguration.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/FilterConfiguration.kt @@ -6,8 +6,8 @@ import org.springframework.web.filter.ForwardedHeaderFilter @Configuration open class FilterConfiguration { - @Bean - open fun forwardedFilter(): ForwardedHeaderFilter { - return ForwardedHeaderFilter() - } + @Bean + open fun forwardedFilter(): ForwardedHeaderFilter { + return ForwardedHeaderFilter() + } } \ No newline at end of file diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/InterceptorConfiguration.kt b/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/InterceptorConfiguration.kt index 15b8a01..0fe9d29 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/InterceptorConfiguration.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/InterceptorConfiguration.kt @@ -8,13 +8,13 @@ import java.time.Clock @Configuration open class InterceptorConfiguration { - @Bean - open fun loggingInterceptorRest(clock: Clock): LoggingInterceptorRest { - return LoggingInterceptorRest(clock) - } + @Bean + open fun loggingInterceptorRest(clock: Clock): LoggingInterceptorRest { + return LoggingInterceptorRest(clock) + } - @Bean - open fun headerInterceptorRest(): HeaderInterceptorRest { - return HeaderInterceptorRest() - } + @Bean + open fun headerInterceptorRest(): HeaderInterceptorRest { + return HeaderInterceptorRest() + } } \ No newline at end of file diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/OpenApiConfiguration.kt b/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/OpenApiConfiguration.kt index 2d82750..995c587 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/OpenApiConfiguration.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/OpenApiConfiguration.kt @@ -12,28 +12,28 @@ import org.springframework.context.annotation.Configuration @SecurityScheme(name = "bearerAuth", type = SecuritySchemeType.HTTP, scheme = "bearer", bearerFormat = "JWT") @SecurityScheme( - name = "oauth2", - type = SecuritySchemeType.OAUTH2, - flows = OAuthFlows( - implicit = OAuthFlow( - authorizationUrl = "https://id.2martens.de/realms/2martens/protocol/openid-connect/auth", - tokenUrl = "https://id.2martens.de/realms/2martens/protocol/openid-connect/token" + name = "oauth2", + type = SecuritySchemeType.OAUTH2, + flows = OAuthFlows( + implicit = OAuthFlow( + authorizationUrl = "https://id.2martens.de/realms/2martens/protocol/openid-connect/auth", + tokenUrl = "https://id.2martens.de/realms/2martens/protocol/openid-connect/token" + ) ) - ) ) @Configuration open class OpenApiConfiguration { @Bean open fun customOpenAPI( - @Value("\${openapi.description}") apiDescription: String, - @Value("\${openapi.version}") apiVersion: String, @Value("\${openapi.title}") apiTitle: String + @Value("\${openapi.description}") apiDescription: String, + @Value("\${openapi.version}") apiVersion: String, @Value("\${openapi.title}") apiTitle: String ): OpenAPI { return OpenAPI() - .info( - Info() - .title(apiTitle) - .version(apiVersion) - .description(apiDescription) - ) + .info( + Info() + .title(apiTitle) + .version(apiVersion) + .description(apiDescription) + ) } } diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/RestTemplateConfiguration.kt b/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/RestTemplateConfiguration.kt index c5dd219..623c0d1 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/RestTemplateConfiguration.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/RestTemplateConfiguration.kt @@ -1,8 +1,8 @@ package de.twomartens.timetable.support.configuration +import de.twomartens.timetable.property.RestTemplateTimeoutProperties import de.twomartens.timetable.support.interceptor.HeaderInterceptorRest import de.twomartens.timetable.support.interceptor.LoggingInterceptorRest -import de.twomartens.timetable.property.RestTemplateTimeoutProperties import org.springframework.boot.web.client.RestTemplateBuilder import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @@ -17,10 +17,10 @@ open class RestTemplateConfiguration { restTemplateTimeoutProperties: RestTemplateTimeoutProperties ): RestTemplate { return RestTemplateBuilder() - .additionalInterceptors(headerInterceptorRest, loggingInterceptor) - .setConnectTimeout(restTemplateTimeoutProperties.connectionRestTemplateTimeoutInMillis) - .setReadTimeout(restTemplateTimeoutProperties.readTimeoutRestTemplateInMillis) - .build() + .additionalInterceptors(headerInterceptorRest, loggingInterceptor) + .setConnectTimeout(restTemplateTimeoutProperties.connectionRestTemplateTimeoutInMillis) + .setReadTimeout(restTemplateTimeoutProperties.readTimeoutRestTemplateInMillis) + .build() } @Bean("restTemplateRestHealthIndicator") @@ -29,9 +29,9 @@ open class RestTemplateConfiguration { restTemplateTimeoutProperties: RestTemplateTimeoutProperties ): RestTemplate { return RestTemplateBuilder() - .additionalInterceptors(headerInterceptorRest) - .setConnectTimeout(restTemplateTimeoutProperties.connectionRestHealthIndicatorTimeoutInMillis) - .setReadTimeout(restTemplateTimeoutProperties.readTimeoutRestHealthIndicatorInMillis) - .build() + .additionalInterceptors(headerInterceptorRest) + .setConnectTimeout(restTemplateTimeoutProperties.connectionRestHealthIndicatorTimeoutInMillis) + .setReadTimeout(restTemplateTimeoutProperties.readTimeoutRestHealthIndicatorInMillis) + .build() } } \ No newline at end of file diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/StatusProbeConfiguration.kt b/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/StatusProbeConfiguration.kt index f48b491..9a63847 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/StatusProbeConfiguration.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/StatusProbeConfiguration.kt @@ -18,8 +18,8 @@ open class StatusProbeConfiguration(private val clock: Clock) { @Bean open fun testStatusProbe(statusProbeLogger: StatusProbeLogger): StatusProbe { return CountBasedStatusProbe( - 1, - clock, StatusProbeCriticality.K1, "testStatusProbe", statusProbeLogger + 1, + clock, StatusProbeCriticality.K1, "testStatusProbe", statusProbeLogger ) } } \ No newline at end of file diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/WebSecurityConfiguration.kt b/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/WebSecurityConfiguration.kt index aafeda9..0263eec 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/WebSecurityConfiguration.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/support/configuration/WebSecurityConfiguration.kt @@ -34,12 +34,12 @@ open class WebSecurityConfiguration { @Throws(Exception::class) open fun securityFilterChain(http: HttpSecurity): SecurityFilterChain { http - .csrf { it.disable() } - .authorizeHttpRequests { it.requestMatchers(*PERMITTED_PATHS.toTypedArray()).permitAll() } - .authorizeHttpRequests { it.requestMatchers(HttpMethod.OPTIONS).permitAll() } - .authorizeHttpRequests { it.anyRequest().authenticated() } - .oauth2ResourceServer { obj: OAuth2ResourceServerConfigurer -> obj.jwt(Customizer.withDefaults()) } - .addFilterAfter(createPolicyEnforcerFilter(), BearerTokenAuthenticationFilter::class.java) + .csrf { it.disable() } + .authorizeHttpRequests { it.requestMatchers(*PERMITTED_PATHS.toTypedArray()).permitAll() } + .authorizeHttpRequests { it.requestMatchers(HttpMethod.OPTIONS).permitAll() } + .authorizeHttpRequests { it.anyRequest().authenticated() } + .oauth2ResourceServer { obj: OAuth2ResourceServerConfigurer -> obj.jwt(Customizer.withDefaults()) } + .addFilterAfter(createPolicyEnforcerFilter(), BearerTokenAuthenticationFilter::class.java) return http.build() } @@ -53,7 +53,7 @@ open class WebSecurityConfiguration { override fun resolve(request: HttpRequest): PolicyEnforcerConfig { return try { val policyEnforcerConfig = JsonSerialization.readValue( - javaClass.getResourceAsStream("/policy-enforcer.json"), PolicyEnforcerConfig::class.java + javaClass.getResourceAsStream("/policy-enforcer.json"), PolicyEnforcerConfig::class.java ) policyEnforcerConfig.credentials = mapOf(Pair("secret", clientSecret)) if (request.method == HttpMethod.OPTIONS.name()) { @@ -72,12 +72,12 @@ open class WebSecurityConfiguration { companion object { private val PERMITTED_PATHS: Collection = listOf( - "/timetable/v1/healthCheck", - "/actuator/**", - "/timetable/v1/doc/**", - "/timetable/v1/api-docs/**", - "/error", - "/timetable/version", + "/timetable/v1/healthCheck", + "/actuator/**", + "/timetable/v1/doc/**", + "/timetable/v1/api-docs/**", + "/error", + "/timetable/version", ) private val PATHS = buildPathConfigs() diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/support/controller/ExceptionController.kt b/module-server/src/main/kotlin/de/twomartens/timetable/support/controller/ExceptionController.kt index c87986f..ff9f1cc 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/support/controller/ExceptionController.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/support/controller/ExceptionController.kt @@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RestController import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler @ControllerAdvice(annotations = [RestController::class]) -class ExceptionController: ResponseEntityExceptionHandler() { +class ExceptionController : ResponseEntityExceptionHandler() { @ExceptionHandler(HttpStatusException::class) fun handleException(e: HttpStatusException): ResponseEntity { if (e.cause != null) { diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/support/controller/VersionHtmlController.kt b/module-server/src/main/kotlin/de/twomartens/timetable/support/controller/VersionHtmlController.kt index bdc2bee..cfb482f 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/support/controller/VersionHtmlController.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/support/controller/VersionHtmlController.kt @@ -65,7 +65,8 @@ class VersionHtmlController { JarFile(jarFileName).use { jarFile -> val entry = jarFile.getEntry(JarFile.MANIFEST_NAME) jarFile.getInputStream(entry).use { `in` -> - return String(`in`.readAllBytes(), StandardCharsets.UTF_8).lines().toList() } + return String(`in`.readAllBytes(), StandardCharsets.UTF_8).lines().toList() + } } } catch (ignored: FileNotFoundException) { // do nothing if manifest file is not available diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/support/exception/HttpStatusException.kt b/module-server/src/main/kotlin/de/twomartens/timetable/support/exception/HttpStatusException.kt index 99607f1..2a2ac4c 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/support/exception/HttpStatusException.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/support/exception/HttpStatusException.kt @@ -2,5 +2,5 @@ package de.twomartens.timetable.support.exception import org.springframework.http.HttpStatus -class HttpStatusException(val status: HttpStatus, message: String, cause: Throwable?): +class HttpStatusException(val status: HttpStatus, message: String, cause: Throwable?) : RuntimeException(message, cause) \ No newline at end of file diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/support/interceptor/BufferingClientHttpResponseWrapper.kt b/module-server/src/main/kotlin/de/twomartens/timetable/support/interceptor/BufferingClientHttpResponseWrapper.kt index 2a39f1a..5b81ea8 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/support/interceptor/BufferingClientHttpResponseWrapper.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/support/interceptor/BufferingClientHttpResponseWrapper.kt @@ -8,7 +8,7 @@ import java.io.ByteArrayInputStream import java.io.IOException import java.io.InputStream -class BufferingClientHttpResponseWrapper(private val response: ClientHttpResponse): ClientHttpResponse { +class BufferingClientHttpResponseWrapper(private val response: ClientHttpResponse) : ClientHttpResponse { private var body: ByteArray? = null @Throws(IOException::class) diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/support/interceptor/HeaderInterceptorRest.kt b/module-server/src/main/kotlin/de/twomartens/timetable/support/interceptor/HeaderInterceptorRest.kt index 10a4169..f2599c9 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/support/interceptor/HeaderInterceptorRest.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/support/interceptor/HeaderInterceptorRest.kt @@ -44,8 +44,8 @@ class HeaderInterceptorRest : HeaderInterceptor(), HandlerInterceptor, ClientHtt // ClientHttpRequestInterceptor @Throws(IOException::class) override fun intercept( - request: HttpRequest, body: ByteArray, - execution: ClientHttpRequestExecution + request: HttpRequest, body: ByteArray, + execution: ClientHttpRequestExecution ): ClientHttpResponse { request.headers.add(HEADER_FIELD_TRACE_ID, getTraceId()) val requestType = getRequestType() @@ -63,8 +63,8 @@ class HeaderInterceptorRest : HeaderInterceptor(), HandlerInterceptor, ClientHtt // HandlerInterceptor override fun preHandle( - request: HttpServletRequest, response: HttpServletResponse, - handler: Any + request: HttpServletRequest, response: HttpServletResponse, + handler: Any ): Boolean { val traceId = extractTraceId(request) val requestType = extractRequestType(request) diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/support/interceptor/LoggingInterceptorRest.kt b/module-server/src/main/kotlin/de/twomartens/timetable/support/interceptor/LoggingInterceptorRest.kt index 7746561..8674864 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/support/interceptor/LoggingInterceptorRest.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/support/interceptor/LoggingInterceptorRest.kt @@ -35,14 +35,14 @@ class LoggingInterceptorRest( @Throws(IOException::class, ServletException::class) override fun doFilter( - request: ServletRequest, response: ServletResponse, - chain: FilterChain + request: ServletRequest, response: ServletResponse, + chain: FilterChain ) { val requestTime = ZonedDateTime.now(clock) val httpRequest = request as HttpServletRequest val requestWrapper = ContentCachingRequestWrapper(httpRequest) val responseWrapper = ContentCachingResponseWrapper( - (response as HttpServletResponse) + (response as HttpServletResponse) ) var fullResponseBytes: ByteArray? = null var throwable: Throwable? = null @@ -51,8 +51,8 @@ class LoggingInterceptorRest( try { try { chain.doFilter( - if (requestLogBehaviour != FieldLogBehaviour.NEVER) requestWrapper else httpRequest, - responseWrapper + if (requestLogBehaviour != FieldLogBehaviour.NEVER) requestWrapper else httpRequest, + responseWrapper ) if (responseLogBehaviour != FieldLogBehaviour.NEVER) { fullResponseBytes = responseWrapper.contentAsByteArray @@ -68,58 +68,58 @@ class LoggingInterceptorRest( try { val responseSize = responseWrapper.contentSize val responseHeaders = extractHeaders( - headerNames = responseWrapper.headerNames.iterator() + headerNames = responseWrapper.headerNames.iterator() ) { responseWrapper.getHeaders(it).iterator() } if ( - (responseLogBehaviour == FieldLogBehaviour.ONLY_ON_ERROR && isError(httpStatusCode) - || responseLogBehaviour == FieldLogBehaviour.ALWAYS) - && fullResponseBytes != null + (responseLogBehaviour == FieldLogBehaviour.ONLY_ON_ERROR && isError(httpStatusCode) + || responseLogBehaviour == FieldLogBehaviour.ALWAYS) + && fullResponseBytes != null ) { responseBody = String( - fullResponseBytes, - determineResponseEncoding() + fullResponseBytes, + determineResponseEncoding() ) } val query = if (httpRequest.queryString != null) "?${httpRequest.queryString}" else "" val requestUrl = URL("${httpRequest.requestURL}$query") val requestHeaders = extractHeaders( - headerNames = httpRequest.headerNames.asIterator(), - ignoreList = listOf("authorization")) { + headerNames = httpRequest.headerNames.asIterator(), + ignoreList = listOf("authorization")) { httpRequest.getHeaders(it).asIterator() } var requestBody: String? = null var businessType: String? = null if (requestLogBehaviour == FieldLogBehaviour.ONLY_ON_ERROR && isError(httpStatusCode) - || requestLogBehaviour == FieldLogBehaviour.ALWAYS + || requestLogBehaviour == FieldLogBehaviour.ALWAYS ) { val fullRequestBytes = requestWrapper.contentAsByteArray requestBody = String(fullRequestBytes, determineRequestEncoding()) businessType = determineBusinessType() } log( - LogMessage( - requestHeaders = requestHeaders, - responseHeaders = responseHeaders, - url = requestUrl, - method = httpRequest.method, - requestMimeType = typeToString(request.getContentType()), - responseMimeType = typeToString(response.getContentType()), - requestBody = requestBody, - responseBody = responseBody, - requestSize = httpRequest.contentLength, - responseSize = responseSize, - httpStatus = httpStatusCode, - direction = DIRECTION_IN, - requestTime = requestTime, - responseTime = ZonedDateTime.now(clock), - traceId = HeaderInterceptor.getTraceId(), - requestType = HeaderInterceptor.getRequestType(), - businessType = businessType, - throwable = throwable - ) + LogMessage( + requestHeaders = requestHeaders, + responseHeaders = responseHeaders, + url = requestUrl, + method = httpRequest.method, + requestMimeType = typeToString(request.getContentType()), + responseMimeType = typeToString(response.getContentType()), + requestBody = requestBody, + responseBody = responseBody, + requestSize = httpRequest.contentLength, + responseSize = responseSize, + httpStatus = httpStatusCode, + direction = DIRECTION_IN, + requestTime = requestTime, + responseTime = ZonedDateTime.now(clock), + traceId = HeaderInterceptor.getTraceId(), + requestType = HeaderInterceptor.getRequestType(), + businessType = businessType, + throwable = throwable + ) ) val interceptorCloseables = - request.getAttribute(HeaderInterceptorRest.CLASS_NAME) as HeaderInterceptor.InterceptorCloseables + request.getAttribute(HeaderInterceptorRest.CLASS_NAME) as HeaderInterceptor.InterceptorCloseables interceptorCloseables.close() } catch (e: java.lang.RuntimeException) { log.error(e.toString(), e) @@ -133,8 +133,8 @@ class LoggingInterceptorRest( @Throws(IOException::class) override fun intercept( - request: HttpRequest, - requestBytes: ByteArray, execution: ClientHttpRequestExecution + request: HttpRequest, + requestBytes: ByteArray, execution: ClientHttpRequestExecution ): ClientHttpResponse { val requestTime = ZonedDateTime.now(clock) var responseSize = 0 @@ -147,7 +147,7 @@ class LoggingInterceptorRest( var businessType: String? = null return try { val result = BufferingClientHttpResponseWrapper( - execution.execute(request, requestBytes) + execution.execute(request, requestBytes) ) val responseBytes = StreamUtils.copyToByteArray(result.getBody()) responseSize = responseBytes.size @@ -155,11 +155,11 @@ class LoggingInterceptorRest( responseMediaType = result.headers.getContentType() httpStatusCode = result.statusCode.value() if (responseLogBehaviour == FieldLogBehaviour.ONLY_ON_ERROR && isError(httpStatusCode) - || responseLogBehaviour == FieldLogBehaviour.ALWAYS + || responseLogBehaviour == FieldLogBehaviour.ALWAYS ) { responseBody = String( - responseBytes, - determineRequestEncoding() + responseBytes, + determineRequestEncoding() ) } result @@ -171,35 +171,35 @@ class LoggingInterceptorRest( val url = request.uri.toURL() val requestHeaders: Map> = extractHeaders(request.headers) if (requestLogBehaviour == FieldLogBehaviour.ONLY_ON_ERROR && isError(httpStatusCode) - || requestLogBehaviour == FieldLogBehaviour.ALWAYS + || requestLogBehaviour == FieldLogBehaviour.ALWAYS ) { requestBody = String( - requestBytes, - determineRequestEncoding() + requestBytes, + determineRequestEncoding() ) businessType = determineBusinessType() } log( - LogMessage( - requestHeaders = requestHeaders, - responseHeaders = responseHeaders, - url = url, - method = request.method.name(), - requestMimeType = typeToString(request.headers.getContentType()), - requestBody = requestBody, - responseBody = responseBody, - responseMimeType = typeToString(responseMediaType!!), - requestSize = requestBytes.size, - responseSize = responseSize, - httpStatus = httpStatusCode, - direction = DIRECTION_OUT, - requestTime = requestTime, - responseTime = ZonedDateTime.now(clock), - businessType = businessType, - throwable = throwable, - traceId = HeaderInterceptorRest.extractTraceId(request), - requestType = HeaderInterceptorRest.extractRequestType(request), - ) + LogMessage( + requestHeaders = requestHeaders, + responseHeaders = responseHeaders, + url = url, + method = request.method.name(), + requestMimeType = typeToString(request.headers.getContentType()), + requestBody = requestBody, + responseBody = responseBody, + responseMimeType = typeToString(responseMediaType!!), + requestSize = requestBytes.size, + responseSize = responseSize, + httpStatus = httpStatusCode, + direction = DIRECTION_OUT, + requestTime = requestTime, + responseTime = ZonedDateTime.now(clock), + businessType = businessType, + throwable = throwable, + traceId = HeaderInterceptorRest.extractTraceId(request), + requestType = HeaderInterceptorRest.extractRequestType(request), + ) ) } catch (e: java.lang.RuntimeException) { log.error(e.toString(), e) @@ -210,18 +210,18 @@ class LoggingInterceptorRest( private fun log(logMessage: LogMessage) { val stringMapMessage = StringMapMessage() addLogString( - stringMapMessage, PARAM_REQUEST_HEADERS, - toHeaderString(logMessage.requestHeaders) + stringMapMessage, PARAM_REQUEST_HEADERS, + toHeaderString(logMessage.requestHeaders) ) addLogString( - stringMapMessage, PARAM_RESPONSE_HEADERS, - toHeaderString(logMessage.responseHeaders) + stringMapMessage, PARAM_RESPONSE_HEADERS, + toHeaderString(logMessage.responseHeaders) ) addLogString(stringMapMessage, PARAM_URL_FULL, logMessage.url.toString()) addLogString(stringMapMessage, PARAM_URL_DOMAIN, logMessage.url.host) addLogString( - stringMapMessage, PARAM_URL_EXTENSION, - extractExtension(logMessage.url.path) + stringMapMessage, PARAM_URL_EXTENSION, + extractExtension(logMessage.url.path) ) addLogString(stringMapMessage, PARAM_URL_PATH, logMessage.url.path) addLogString(stringMapMessage, PARAM_URL_PORT, logMessage.url.port.toString()) @@ -229,8 +229,8 @@ class LoggingInterceptorRest( addLogString(stringMapMessage, PARAM_URL_QUERY, logMessage.url.query) addLogString(stringMapMessage, PARAM_REQUEST_METHOD, logMessage.method) addLogString( - stringMapMessage, PARAM_REQUEST_REFERER, - getHeader(logMessage.requestHeaders, HttpHeaders.REFERER) + stringMapMessage, PARAM_REQUEST_REFERER, + getHeader(logMessage.requestHeaders, HttpHeaders.REFERER) ) addLogString(stringMapMessage, PARAM_REQUEST_MIMETYPE, logMessage.requestMimeType) addLogString(stringMapMessage, PARAM_RESPONSE_MIMETYPE, logMessage.responseMimeType) @@ -240,21 +240,21 @@ class LoggingInterceptorRest( addLogString(stringMapMessage, PARAM_DIRECTION, logMessage.direction) addLogString(stringMapMessage, PARAM_PROTOCOL, PROTOCOL_NAME) addLogString( - stringMapMessage, PARAM_REQUEST_TIME, - logMessage.requestTime.format(DATE_TIME_FORMATTER) + stringMapMessage, PARAM_REQUEST_TIME, + logMessage.requestTime.format(DATE_TIME_FORMATTER) ) addLogString( - stringMapMessage, PARAM_RESPONSE_TIME, - logMessage.responseTime.format(DATE_TIME_FORMATTER) + stringMapMessage, PARAM_RESPONSE_TIME, + logMessage.responseTime.format(DATE_TIME_FORMATTER) ) addLogString( - stringMapMessage, - PARAM_DURATION, - getDurationBetweenRequestAndResponseTime(logMessage).toNanos().toString() + stringMapMessage, + PARAM_DURATION, + getDurationBetweenRequestAndResponseTime(logMessage).toNanos().toString() ) addLogString( - stringMapMessage, PARAM_USER_AGENT, - getHeader(logMessage.requestHeaders, HttpHeaders.USER_AGENT) + stringMapMessage, PARAM_USER_AGENT, + getHeader(logMessage.requestHeaders, HttpHeaders.USER_AGENT) ) addLogString(stringMapMessage, HeaderInterceptor.LOGGER_TRACE_ID, logMessage.traceId) addLogString(stringMapMessage, HeaderInterceptor.LOGGER_REQTYPE_ID, logMessage.requestType) @@ -270,9 +270,9 @@ class LoggingInterceptorRest( private fun getHeader(headers: Map>, headerKey: String): String? { return headers.entries.asSequence() - .filter { it.key.equals(headerKey, ignoreCase = true) } - .flatMap { it.value.asSequence() } - .firstOrNull() + .filter { it.key.equals(headerKey, ignoreCase = true) } + .flatMap { it.value.asSequence() } + .firstOrNull() } private fun addLogString(stringMapMessage: StringMapMessage, key: String, value: String?) { @@ -340,9 +340,9 @@ class LoggingInterceptorRest( const val PARAM_PROTOCOL = "network.protocol" private fun extractHeaders( - headerNames: Iterator, - ignoreList: List = emptyList(), - headerValuesSupplier: Function> + headerNames: Iterator, + ignoreList: List = emptyList(), + headerValuesSupplier: Function> ): Map> { val requestHeaders: MutableMap> = mutableMapOf() while (headerNames.hasNext()) { @@ -367,12 +367,12 @@ class LoggingInterceptorRest( private fun toHeaderString(headerMap: Map>): String { return headerMap.entries.asSequence() - .flatMap { entry -> - val key = entry.key - entry.value.asSequence().map { Pair(key, it) } - } - .map { "${it.first}=${it.second}" } - .joinToString(separator = ",") + .flatMap { entry -> + val key = entry.key + entry.value.asSequence().map { Pair(key, it) } + } + .map { "${it.first}=${it.second}" } + .joinToString(separator = ",") } private fun typeToString(contentType: String?): String? { @@ -408,24 +408,24 @@ class LoggingInterceptorRest( } private data class LogMessage( - val requestHeaders: Map>, - val responseHeaders: Map>, - val url: URL, - val method: String, - val requestMimeType: String?, - val responseMimeType: String?, - val requestBody: String?, - val responseBody: String?, - val requestSize: Int, - val responseSize: Int, - val httpStatus: Int, - val direction: String, - val requestTime: ZonedDateTime, - val responseTime: ZonedDateTime, - val traceId: String?, - val requestType: String?, - val businessType: String?, - val throwable: Throwable? + val requestHeaders: Map>, + val responseHeaders: Map>, + val url: URL, + val method: String, + val requestMimeType: String?, + val responseMimeType: String?, + val requestBody: String?, + val responseBody: String?, + val requestSize: Int, + val responseSize: Int, + val httpStatus: Int, + val direction: String, + val requestTime: ZonedDateTime, + val responseTime: ZonedDateTime, + val traceId: String?, + val requestType: String?, + val businessType: String?, + val throwable: Throwable? ) enum class FieldLogBehaviour { diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/support/monitoring/actuator/AbstractHealthIndicator.kt b/module-server/src/main/kotlin/de/twomartens/timetable/support/monitoring/actuator/AbstractHealthIndicator.kt index e3cc29d..e203d08 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/support/monitoring/actuator/AbstractHealthIndicator.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/support/monitoring/actuator/AbstractHealthIndicator.kt @@ -11,8 +11,8 @@ import java.time.Duration import java.util.* abstract class AbstractHealthIndicator( - private val clock: Clock, - private val preparable: Preparable + private val clock: Clock, + private val preparable: Preparable ) : HealthIndicator { private val logStatusDownMessage = "health indicator '${indicatorName()}' invoked with status '${Status.DOWN.code}'" @@ -67,8 +67,8 @@ abstract class AbstractHealthIndicator( private fun indicatorName(): String { return this.javaClass.getSimpleName() - .replace("HealthIndicator", "") - .lowercase(Locale.getDefault()) + .replace("HealthIndicator", "") + .lowercase(Locale.getDefault()) } companion object { diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/support/monitoring/actuator/RestHealthIndicator.kt b/module-server/src/main/kotlin/de/twomartens/timetable/support/monitoring/actuator/RestHealthIndicator.kt index 3a54d04..980bf53 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/support/monitoring/actuator/RestHealthIndicator.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/support/monitoring/actuator/RestHealthIndicator.kt @@ -1,7 +1,7 @@ package de.twomartens.timetable.support.monitoring.actuator -import de.twomartens.timetable.support.interceptor.HeaderInterceptorRest import de.twomartens.timetable.property.ServiceProperties +import de.twomartens.timetable.support.interceptor.HeaderInterceptorRest import org.springframework.boot.actuate.health.Health import org.springframework.boot.actuate.health.HealthIndicator import org.springframework.boot.actuate.health.Status diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/support/monitoring/statusprobe/ScheduledStatusProbe.kt b/module-server/src/main/kotlin/de/twomartens/timetable/support/monitoring/statusprobe/ScheduledStatusProbe.kt index bd87d22..abc6b29 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/support/monitoring/statusprobe/ScheduledStatusProbe.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/support/monitoring/statusprobe/ScheduledStatusProbe.kt @@ -7,11 +7,11 @@ import java.time.Duration interface ScheduledStatusProbe { fun runScheduledTask() fun scheduleTask( - threadPoolTaskScheduler: ThreadPoolTaskScheduler, - schedulePeriod: Duration + threadPoolTaskScheduler: ThreadPoolTaskScheduler, + schedulePeriod: Duration ) { val periodicTrigger = PeriodicTrigger( - Duration.ofSeconds(schedulePeriod.toSeconds()) + Duration.ofSeconds(schedulePeriod.toSeconds()) ) threadPoolTaskScheduler.schedule(periodicTrigger) { runScheduledTask() } } diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/support/monitoring/statusprobe/StatusProbeLogger.kt b/module-server/src/main/kotlin/de/twomartens/timetable/support/monitoring/statusprobe/StatusProbeLogger.kt index c34afad..3de90d6 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/support/monitoring/statusprobe/StatusProbeLogger.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/support/monitoring/statusprobe/StatusProbeLogger.kt @@ -19,8 +19,8 @@ class StatusProbeLogger internal constructor(private val clock: Clock, private v } fun logStatusChange( - name: String, message: String?, status: Status, lastStatusChange: ZonedDateTime?, - throwable: Throwable? + name: String, message: String?, status: Status, lastStatusChange: ZonedDateTime?, + throwable: Throwable? ) { var probeIdent = getProbeIdent(name) if (probeIdent == null) { @@ -32,8 +32,8 @@ class StatusProbeLogger internal constructor(private val clock: Clock, private v private fun getProbeIdent(name: String): ProbeIdent? { return statusProbeToStatus.keys.asSequence() - .filter { it.name == name } - .firstOrNull() + .filter { it.name == name } + .firstOrNull() } private fun createLog(message: String?, lastStatusChange: ZonedDateTime?, throwable: Throwable?) { @@ -42,7 +42,7 @@ class StatusProbeLogger internal constructor(private val clock: Clock, private v val criticality = overallCriticality if (Status.UP == overallStatus) { commLog.info( - MARKER, StringMapMessage() + MARKER, StringMapMessage() .with(LABEL_CRITICALITY, criticality) .with(LABEL_STATUS, overallStatus) .with(LABEL_MESSAGE, cleanedMessage) @@ -50,7 +50,7 @@ class StatusProbeLogger internal constructor(private val clock: Clock, private v ) } else { commLog.error( - MARKER, StringMapMessage() + MARKER, StringMapMessage() .with(LABEL_CRITICALITY, criticality) .with(LABEL_STATUS, overallStatus) .with(LABEL_MESSAGE, cleanedMessage) @@ -63,8 +63,8 @@ class StatusProbeLogger internal constructor(private val clock: Clock, private v private val overallCriticality: StatusProbeCriticality get() { val crits = statusProbeToStatus.keys.asSequence() - .map { it.criticality } - .toList() + .map { it.criticality } + .toList() return if (crits.contains(StatusProbeCriticality.K1)) StatusProbeCriticality.K1 else if (crits.contains(StatusProbeCriticality.K2)) StatusProbeCriticality.K2 else StatusProbeCriticality.K3 @@ -77,9 +77,9 @@ class StatusProbeLogger internal constructor(private val clock: Clock, private v private val reason: String get() { val probesDown = statusProbeToStatus.entries.asSequence() - .filter { it.value == Status.DOWN } - .map { it.key } - .toList() + .filter { it.value == Status.DOWN } + .map { it.key } + .toList() val reasonK1 = getDownStatusProbes(probesDown, StatusProbeCriticality.K1) val reasonK2 = getDownStatusProbes(probesDown, StatusProbeCriticality.K2) val reasonK3 = getDownStatusProbes(probesDown, StatusProbeCriticality.K3) @@ -88,9 +88,9 @@ class StatusProbeLogger internal constructor(private val clock: Clock, private v private fun getDownStatusProbes(probesDown: List, criticality: StatusProbeCriticality): String { val downProbeNames = probesDown.asSequence() - .filter { it.criticality == criticality } - .map { it.name } - .toList() + .filter { it.criticality == criticality } + .map { it.name } + .toList() return if (downProbeNames.isNotEmpty()) { "$criticality failed: ${downProbeNames.joinToString(separator = ",")}\n" } else "" diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/support/property/RestTemplateTimeoutProperties.kt b/module-server/src/main/kotlin/de/twomartens/timetable/support/property/RestTemplateTimeoutProperties.kt index 53f17b6..e4f1c0f 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/support/property/RestTemplateTimeoutProperties.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/support/property/RestTemplateTimeoutProperties.kt @@ -8,8 +8,8 @@ import java.time.temporal.ChronoUnit @ConfigurationProperties(prefix = "resttemplate.timeout") data class RestTemplateTimeoutProperties @ConstructorBinding constructor( - @DurationUnit(ChronoUnit.MILLIS) val readTimeoutRestHealthIndicatorInMillis: Duration, - @DurationUnit(ChronoUnit.MILLIS) val connectionRestHealthIndicatorTimeoutInMillis: Duration, - @DurationUnit(ChronoUnit.MILLIS) val readTimeoutRestTemplateInMillis: Duration, - @DurationUnit(ChronoUnit.MILLIS) val connectionRestTemplateTimeoutInMillis: Duration + @DurationUnit(ChronoUnit.MILLIS) val readTimeoutRestHealthIndicatorInMillis: Duration, + @DurationUnit(ChronoUnit.MILLIS) val connectionRestHealthIndicatorTimeoutInMillis: Duration, + @DurationUnit(ChronoUnit.MILLIS) val readTimeoutRestTemplateInMillis: Duration, + @DurationUnit(ChronoUnit.MILLIS) val connectionRestTemplateTimeoutInMillis: Duration ) \ No newline at end of file diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/support/property/StatusProbeProperties.kt b/module-server/src/main/kotlin/de/twomartens/timetable/support/property/StatusProbeProperties.kt index 5f2ca08..ee667ff 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/support/property/StatusProbeProperties.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/support/property/StatusProbeProperties.kt @@ -5,7 +5,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties import org.springframework.boot.context.properties.bind.ConstructorBinding import org.springframework.boot.convert.DurationUnit import org.springframework.cloud.context.config.annotation.RefreshScope -import org.springframework.context.annotation.Configuration import java.time.Duration import java.time.temporal.ChronoUnit @@ -13,8 +12,8 @@ import java.time.temporal.ChronoUnit @ConfigurationProperties(prefix = "de.twomartens.timetable.statusprobe") @Schema(description = "Properties, to configure this Application") data class StatusProbeProperties @ConstructorBinding constructor( - @DurationUnit(ChronoUnit.SECONDS) val scheduleDuration: Duration, - @DurationUnit(ChronoUnit.MINUTES) val maxKafkaFailureDuration: Duration, - val maxBlobFailureCount: Int, - val maxFailurePercent: Int + @DurationUnit(ChronoUnit.SECONDS) val scheduleDuration: Duration, + @DurationUnit(ChronoUnit.MINUTES) val maxKafkaFailureDuration: Duration, + val maxBlobFailureCount: Int, + val maxFailurePercent: Int ) diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/support/property/TimeProperties.kt b/module-server/src/main/kotlin/de/twomartens/timetable/support/property/TimeProperties.kt index d5b7501..b0fb344 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/support/property/TimeProperties.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/support/property/TimeProperties.kt @@ -9,6 +9,6 @@ import java.time.ZoneId @RefreshScope @ConfigurationProperties(prefix = "time") @Schema(description = "Properties to configure time") -data class TimeProperties @ConstructorBinding constructor( - val defaultTimeZone: ZoneId +data class TimeProperties @ConstructorBinding constructor( + val defaultTimeZone: ZoneId ) diff --git a/settings.gradle.kts b/settings.gradle.kts index 91511eb..dc4096a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,6 +1,7 @@ val projectname: String = providers.gradleProperty("projectname").get() rootProject.name = projectname +include("common") include("server") include("deploy")