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.* import java.util.*
private const val LOGIN_PATH = "/login"
@Configuration @Configuration
@EnableConfigurationProperties( @EnableConfigurationProperties(
value = [ value = [
@ -104,15 +106,15 @@ class AppSecurityConfiguration(
realmName = "ETL-Processor" realmName = "ETL-Processor"
} }
formLogin { formLogin {
loginPage = "/login" loginPage = LOGIN_PATH
} }
oauth2Login { oauth2Login {
loginPage = "/login" loginPage = LOGIN_PATH
} }
sessionManagement { sessionManagement {
sessionConcurrency { sessionConcurrency {
maximumSessions = 1 maximumSessions = 1
expiredUrl = "/login?expired" expiredUrl = "$LOGIN_PATH?expired"
} }
sessionFixation { sessionFixation {
newSession() newSession()
@ -155,7 +157,7 @@ class AppSecurityConfiguration(
realmName = "ETL-Processor" realmName = "ETL-Processor"
} }
formLogin { formLogin {
loginPage = "/login" loginPage = LOGIN_PATH
} }
csrf { disable() } csrf { disable() }
} }

View File

@ -41,7 +41,7 @@ class MtbFileRestController(
} }
@PostMapping @PostMapping
fun mtbFile(@RequestBody mtbFile: MtbFile): ResponseEntity<Void> { fun mtbFile(@RequestBody mtbFile: MtbFile): ResponseEntity<Unit> {
if (mtbFile.consent.status == Consent.Status.ACTIVE) { if (mtbFile.consent.status == Consent.Status.ACTIVE) {
logger.debug("Accepted MTB File for processing") logger.debug("Accepted MTB File for processing")
requestProcessor.processMtbFile(mtbFile) requestProcessor.processMtbFile(mtbFile)
@ -54,7 +54,7 @@ class MtbFileRestController(
} }
@DeleteMapping(path = ["{patientId}"]) @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") logger.debug("Accepted patient ID to process deletion")
requestProcessor.processDeletion(PatientId(patientId)) requestProcessor.processDeletion(PatientId(patientId))
return ResponseEntity.accepted().build() return ResponseEntity.accepted().build()

View File

@ -35,7 +35,7 @@ import java.time.Instant
import kotlin.time.Duration.Companion.seconds import kotlin.time.Duration.Companion.seconds
import kotlin.time.toJavaDuration import kotlin.time.toJavaDuration
interface ConnectionCheckService { fun interface ConnectionCheckService {
fun connectionAvailable(): ConnectionCheckResult fun connectionAvailable(): ConnectionCheckResult
@ -88,7 +88,7 @@ class KafkaConnectionCheckService(
Instant.now(), Instant.now(),
if (result.available == available) { result.lastChange } else { Instant.now() } if (result.available == available) { result.lastChange } else { Instant.now() }
) )
} catch (e: TimeoutException) { } catch (_: TimeoutException) {
ConnectionCheckResult.KafkaConnectionCheckResult( ConnectionCheckResult.KafkaConnectionCheckResult(
false, false,
Instant.now(), Instant.now(),
@ -138,7 +138,7 @@ class RestConnectionCheckService(
Instant.now(), Instant.now(),
if (result.available == available) { result.lastChange } else { Instant.now() } if (result.available == available) { result.lastChange } else { Instant.now() }
) )
} catch (e: Exception) { } catch (_: Exception) {
ConnectionCheckResult.RestConnectionCheckResult( ConnectionCheckResult.RestConnectionCheckResult(
false, false,
Instant.now(), Instant.now(),
@ -191,7 +191,7 @@ class GPasConnectionCheckService(
Instant.now(), Instant.now(),
if (result.available == available) { result.lastChange } else { Instant.now() } if (result.available == available) { result.lastChange } else { Instant.now() }
) )
} catch (e: Exception) { } catch (_: Exception) {
ConnectionCheckResult.GPasConnectionCheckResult( ConnectionCheckResult.GPasConnectionCheckResult(
false, false,
Instant.now(), Instant.now(),

View File

@ -103,7 +103,7 @@ abstract class RestMtbFileSender(
val username = restTargetProperties.username val username = restTargetProperties.username
val password = restTargetProperties.password val password = restTargetProperties.password
val headers = HttpHeaders() val headers = HttpHeaders()
headers.setContentType(MediaType.APPLICATION_JSON) headers.contentType = MediaType.APPLICATION_JSON
if (username.isNullOrBlank() || password.isNullOrBlank()) { if (username.isNullOrBlank() || password.isNullOrBlank()) {
return headers return headers