summaryrefslogtreecommitdiff
path: root/src/main/kotlin/dev/dnpm
diff options
context:
space:
mode:
authorPaul-Christian Volkmer2025-03-23 12:09:34 +0100
committerGitHub2025-03-23 12:09:34 +0100
commit56a63b276e17412adb5253e9e34d830228a24583 (patch)
treed229a8717f144af19fee45f0741f9c80f72c3b74 /src/main/kotlin/dev/dnpm
parentc0ea5fcd513f9a63b6390065ae07a7a41e8c7263 (diff)
Code cleanup (#87)
* refactor: Replace usage of Void with Kotlins Unit * refactor: make ConnectionCheckService a functional interface * refactor: ignore unused exception * refactor: use property access syntax * refactor: use const value for login path
Diffstat (limited to 'src/main/kotlin/dev/dnpm')
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/config/AppSecurityConfiguration.kt10
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/input/MtbFileRestController.kt4
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/monitoring/ConnectionCheckService.kt8
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/output/RestMtbFileSender.kt2
4 files changed, 13 insertions, 11 deletions
diff --git a/src/main/kotlin/dev/dnpm/etl/processor/config/AppSecurityConfiguration.kt b/src/main/kotlin/dev/dnpm/etl/processor/config/AppSecurityConfiguration.kt
index 6b063bd..ddcf202 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/config/AppSecurityConfiguration.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/config/AppSecurityConfiguration.kt
@@ -44,6 +44,8 @@ import org.springframework.security.web.SecurityFilterChain
import java.util.*
+private const val LOGIN_PATH = "/login"
+
@Configuration
@EnableConfigurationProperties(
value = [
@@ -104,15 +106,15 @@ class AppSecurityConfiguration(
realmName = "ETL-Processor"
}
formLogin {
- loginPage = "/login"
+ loginPage = LOGIN_PATH
}
oauth2Login {
- loginPage = "/login"
+ loginPage = LOGIN_PATH
}
sessionManagement {
sessionConcurrency {
maximumSessions = 1
- expiredUrl = "/login?expired"
+ expiredUrl = "$LOGIN_PATH?expired"
}
sessionFixation {
newSession()
@@ -155,7 +157,7 @@ class AppSecurityConfiguration(
realmName = "ETL-Processor"
}
formLogin {
- loginPage = "/login"
+ loginPage = LOGIN_PATH
}
csrf { disable() }
}
diff --git a/src/main/kotlin/dev/dnpm/etl/processor/input/MtbFileRestController.kt b/src/main/kotlin/dev/dnpm/etl/processor/input/MtbFileRestController.kt
index 9e282c2..ded485c 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/input/MtbFileRestController.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/input/MtbFileRestController.kt
@@ -41,7 +41,7 @@ class MtbFileRestController(
}
@PostMapping
- fun mtbFile(@RequestBody mtbFile: MtbFile): ResponseEntity<Void> {
+ fun mtbFile(@RequestBody mtbFile: MtbFile): ResponseEntity<Unit> {
if (mtbFile.consent.status == Consent.Status.ACTIVE) {
logger.debug("Accepted MTB File for processing")
requestProcessor.processMtbFile(mtbFile)
@@ -54,7 +54,7 @@ class MtbFileRestController(
}
@DeleteMapping(path = ["{patientId}"])
- fun deleteData(@PathVariable patientId: String): ResponseEntity<Void> {
+ fun deleteData(@PathVariable patientId: String): ResponseEntity<Unit> {
logger.debug("Accepted patient ID to process deletion")
requestProcessor.processDeletion(PatientId(patientId))
return ResponseEntity.accepted().build()
diff --git a/src/main/kotlin/dev/dnpm/etl/processor/monitoring/ConnectionCheckService.kt b/src/main/kotlin/dev/dnpm/etl/processor/monitoring/ConnectionCheckService.kt
index 9d96654..b845e21 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/monitoring/ConnectionCheckService.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/monitoring/ConnectionCheckService.kt
@@ -35,7 +35,7 @@ import java.time.Instant
import kotlin.time.Duration.Companion.seconds
import kotlin.time.toJavaDuration
-interface ConnectionCheckService {
+fun interface ConnectionCheckService {
fun connectionAvailable(): ConnectionCheckResult
@@ -88,7 +88,7 @@ class KafkaConnectionCheckService(
Instant.now(),
if (result.available == available) { result.lastChange } else { Instant.now() }
)
- } catch (e: TimeoutException) {
+ } catch (_: TimeoutException) {
ConnectionCheckResult.KafkaConnectionCheckResult(
false,
Instant.now(),
@@ -138,7 +138,7 @@ class RestConnectionCheckService(
Instant.now(),
if (result.available == available) { result.lastChange } else { Instant.now() }
)
- } catch (e: Exception) {
+ } catch (_: Exception) {
ConnectionCheckResult.RestConnectionCheckResult(
false,
Instant.now(),
@@ -191,7 +191,7 @@ class GPasConnectionCheckService(
Instant.now(),
if (result.available == available) { result.lastChange } else { Instant.now() }
)
- } catch (e: Exception) {
+ } catch (_: Exception) {
ConnectionCheckResult.GPasConnectionCheckResult(
false,
Instant.now(),
diff --git a/src/main/kotlin/dev/dnpm/etl/processor/output/RestMtbFileSender.kt b/src/main/kotlin/dev/dnpm/etl/processor/output/RestMtbFileSender.kt
index 5ea42e3..016981c 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/output/RestMtbFileSender.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/output/RestMtbFileSender.kt
@@ -103,7 +103,7 @@ abstract class RestMtbFileSender(
val username = restTargetProperties.username
val password = restTargetProperties.password
val headers = HttpHeaders()
- headers.setContentType(MediaType.APPLICATION_JSON)
+ headers.contentType = MediaType.APPLICATION_JSON
if (username.isNullOrBlank() || password.isNullOrBlank()) {
return headers