From d3e6aa5821c84c836f582d6087963d8841ae48f4 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Mon, 25 Aug 2025 12:13:44 +0200 Subject: fix: mime type representation in kafka header (#139) --- .../kotlin/dev/dnpm/etl/processor/input/KafkaInputListener.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/main/kotlin/dev/dnpm/etl/processor') diff --git a/src/main/kotlin/dev/dnpm/etl/processor/input/KafkaInputListener.kt b/src/main/kotlin/dev/dnpm/etl/processor/input/KafkaInputListener.kt index 4ac9f2d..d53eb7e 100644 --- a/src/main/kotlin/dev/dnpm/etl/processor/input/KafkaInputListener.kt +++ b/src/main/kotlin/dev/dnpm/etl/processor/input/KafkaInputListener.kt @@ -31,6 +31,7 @@ import org.apache.kafka.clients.consumer.ConsumerRecord import org.slf4j.LoggerFactory import org.springframework.http.MediaType import org.springframework.kafka.listener.MessageListener +import java.nio.charset.Charset class KafkaInputListener( private val requestProcessor: RequestProcessor, @@ -49,19 +50,16 @@ class KafkaInputListener( } } - private fun guessMimeType(record: ConsumerRecord): String { + private fun guessMimeType(record: ConsumerRecord): String? { if (record.headers().headers("contentType").toList().isEmpty()) { // Fallback if no contentType set (old behavior) return MediaType.APPLICATION_JSON_VALUE } - return record.headers().headers("contentType")?.firstOrNull()?.value().contentToString() + return record.headers().headers("contentType")?.firstOrNull()?.value()?.toString(Charset.forName("UTF-8")) } private fun handleDnpmV2Message(record: ConsumerRecord) { - // Do not handle DNPM-V2 for now - logger.warn("Ignoring MTB File in DNPM V2 format: Not implemented yet") - val mtbFile = objectMapper.readValue(record.value(), Mtb::class.java) val patientId = PatientId(mtbFile.patient.id) val firstRequestIdHeader = record.headers().headers("requestId")?.firstOrNull() -- cgit v1.2.3