1
0
mirror of https://github.com/pcvolkmer/etl-processor.git synced 2025-04-19 17:26:51 +00:00

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
This commit is contained in:
Paul-Christian Volkmer 2025-03-23 12:09:34 +01:00 committed by GitHub
parent c0ea5fcd51
commit 56a63b276e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 13 additions and 11 deletions

View File

@ -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() }
}

View File

@ -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()

View File

@ -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(),

View File

@ -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