diff --git a/src/main/kotlin/no/nav/klage/dokument/service/SmartDocumentService.kt b/src/main/kotlin/no/nav/klage/dokument/service/SmartDocumentService.kt index da7a1ef99..ae3a43e1d 100644 --- a/src/main/kotlin/no/nav/klage/dokument/service/SmartDocumentService.kt +++ b/src/main/kotlin/no/nav/klage/dokument/service/SmartDocumentService.kt @@ -2,7 +2,6 @@ package no.nav.klage.dokument.service import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.ObjectMapper -import jakarta.transaction.Transactional import no.nav.klage.dokument.api.mapper.DokumentMapper import no.nav.klage.dokument.api.view.* import no.nav.klage.dokument.clients.kabalsmarteditorapi.model.request.CommentInput @@ -31,6 +30,7 @@ import no.nav.klage.oppgave.util.getSecureLogger import no.nav.klage.oppgave.util.ourJacksonObjectMapper import org.springframework.context.ApplicationEventPublisher import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional import java.time.LocalDateTime import java.util.* diff --git a/src/main/kotlin/no/nav/klage/oppgave/clients/gosysoppgave/GosysOppgaveClient.kt b/src/main/kotlin/no/nav/klage/oppgave/clients/gosysoppgave/GosysOppgaveClient.kt index ecc71eaba..74502bd19 100644 --- a/src/main/kotlin/no/nav/klage/oppgave/clients/gosysoppgave/GosysOppgaveClient.kt +++ b/src/main/kotlin/no/nav/klage/oppgave/clients/gosysoppgave/GosysOppgaveClient.kt @@ -3,6 +3,7 @@ package no.nav.klage.oppgave.clients.gosysoppgave import no.nav.klage.kodeverk.Tema import no.nav.klage.oppgave.clients.gosysoppgave.OppgaveMapperResponse.OppgaveMappe import no.nav.klage.oppgave.config.CacheWithJCacheConfiguration +import no.nav.klage.oppgave.exceptions.GosysOppgaveClientException import no.nav.klage.oppgave.util.TokenUtil import no.nav.klage.oppgave.util.getLogger import no.nav.klage.oppgave.util.getSecureLogger @@ -40,7 +41,7 @@ class GosysOppgaveClient( .header("Nav-Consumer-Id", applicationName) .retrieve() .bodyToMono() - .block() ?: throw OppgaveClientException("Oppgave could not be fetched") + .block() ?: throw RuntimeException("Oppgave could not be fetched") } } @@ -62,7 +63,7 @@ class GosysOppgaveClient( .header("Nav-Consumer-Id", applicationName) .retrieve() .bodyToMono() - .block() ?: throw OppgaveClientException("Oppgave could not be updated") + .block() ?: throw RuntimeException("Oppgave could not be updated") } } @@ -87,7 +88,7 @@ class GosysOppgaveClient( .header("Nav-Consumer-Id", applicationName) .retrieve() .bodyToMono() - .block() ?: throw OppgaveClientException("Could not get mapper for enhet") + .block() ?: throw RuntimeException("Could not get mapper for enhet") } } @@ -110,7 +111,7 @@ class GosysOppgaveClient( .header("Nav-Consumer-Id", applicationName) .retrieve() .bodyToMono() - .block() ?: throw OppgaveClientException("Could not get mapper for enhet") + .block() ?: throw RuntimeException("Could not get mapper for enhet") } } @@ -136,7 +137,7 @@ class GosysOppgaveClient( .header("Nav-Consumer-Id", applicationName) .retrieve() .bodyToMono() - .block() ?: throw OppgaveClientException("Oppgaver could not be fetched") + .block() ?: throw RuntimeException("Oppgaver could not be fetched") } return oppgaveResponse.oppgaver @@ -155,10 +156,10 @@ class GosysOppgaveClient( ex.request?.uri ?: "-", ex.responseBodyAsString ) - throw OppgaveClientException("Caught WebClientResponseException", ex) + throw GosysOppgaveClientException("Caught WebClientResponseException", ex) } catch (rtex: RuntimeException) { logger.warn("Caught RuntimeException", rtex) - throw OppgaveClientException("Caught runtimeexception", rtex) + throw GosysOppgaveClientException("Caught runtimeexception", rtex) } finally { val end: Long = System.currentTimeMillis() logger.info("Method {} took {} millis", methodName, (end - start)) @@ -181,7 +182,7 @@ class GosysOppgaveClient( .header("Nav-Consumer-Id", applicationName) .retrieve() .bodyToMono>() - .block() ?: throw OppgaveClientException("Could not fetch gjelder kodeverk for tema ${tema.navn}") + .block() ?: throw RuntimeException("Could not fetch gjelder kodeverk for tema ${tema.navn}") } return gjelderResponse @@ -203,7 +204,7 @@ class GosysOppgaveClient( .header("Nav-Consumer-Id", applicationName) .retrieve() .bodyToMono>() - .block() ?: throw OppgaveClientException("Could not fetch oppgavetype kodeverk for tema ${tema.navn}") + .block() ?: throw RuntimeException("Could not fetch oppgavetype kodeverk for tema ${tema.navn}") } return oppgavetypeResponse diff --git a/src/main/kotlin/no/nav/klage/oppgave/clients/gosysoppgave/OppgaveApiResponse.kt b/src/main/kotlin/no/nav/klage/oppgave/clients/gosysoppgave/OppgaveApiResponse.kt index 637df84ff..0d35c3c3f 100644 --- a/src/main/kotlin/no/nav/klage/oppgave/clients/gosysoppgave/OppgaveApiResponse.kt +++ b/src/main/kotlin/no/nav/klage/oppgave/clients/gosysoppgave/OppgaveApiResponse.kt @@ -66,12 +66,6 @@ enum class Status(val statusId: Long) { } } -class OppgaveClientException : Exception { - constructor(message: String?) : super(message) - - constructor(message: String?, cause: Throwable?) : super(message, cause) -} - data class OppgaveMapperResponse( val antallTreffTotalt: Int, val mapper: List diff --git a/src/main/kotlin/no/nav/klage/oppgave/eventlisteners/CleanupAfterBehandlingEventListener.kt b/src/main/kotlin/no/nav/klage/oppgave/eventlisteners/CleanupAfterBehandlingEventListener.kt index bc3d05faa..921b34b82 100644 --- a/src/main/kotlin/no/nav/klage/oppgave/eventlisteners/CleanupAfterBehandlingEventListener.kt +++ b/src/main/kotlin/no/nav/klage/oppgave/eventlisteners/CleanupAfterBehandlingEventListener.kt @@ -17,7 +17,10 @@ import no.nav.klage.oppgave.util.getSecureLogger import org.springframework.beans.factory.annotation.Value import org.springframework.context.event.EventListener import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Propagation import org.springframework.transaction.annotation.Transactional +import org.springframework.transaction.event.TransactionPhase +import org.springframework.transaction.event.TransactionalEventListener import java.time.LocalDateTime import java.util.* @@ -50,6 +53,8 @@ class CleanupAfterBehandlingEventListener( } @EventListener + @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) + @Transactional(propagation = Propagation.REQUIRES_NEW) fun cleanupAfterBehandling(behandlingEndretEvent: BehandlingEndretEvent) { val behandling = behandlingEndretEvent.behandling diff --git a/src/main/kotlin/no/nav/klage/oppgave/eventlisteners/SendBehandlingEndretToKafkaEventListener.kt b/src/main/kotlin/no/nav/klage/oppgave/eventlisteners/SendBehandlingEndretToKafkaEventListener.kt index c77ce47f8..9298089dd 100644 --- a/src/main/kotlin/no/nav/klage/oppgave/eventlisteners/SendBehandlingEndretToKafkaEventListener.kt +++ b/src/main/kotlin/no/nav/klage/oppgave/eventlisteners/SendBehandlingEndretToKafkaEventListener.kt @@ -26,7 +26,6 @@ class SendBehandlingEndretToKafkaEventListener( val objectMapper: ObjectMapper = ourJacksonObjectMapper() } - /* This code needs a transaction b/c of lazy loading */ @EventListener @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) @Transactional(propagation = Propagation.REQUIRES_NEW) diff --git a/src/main/kotlin/no/nav/klage/oppgave/eventlisteners/StatistikkTilDVHEventListener.kt b/src/main/kotlin/no/nav/klage/oppgave/eventlisteners/StatistikkTilDVHEventListener.kt index 8ed4d9c2e..1421e7c26 100644 --- a/src/main/kotlin/no/nav/klage/oppgave/eventlisteners/StatistikkTilDVHEventListener.kt +++ b/src/main/kotlin/no/nav/klage/oppgave/eventlisteners/StatistikkTilDVHEventListener.kt @@ -1,6 +1,7 @@ package no.nav.klage.oppgave.eventlisteners import no.nav.klage.oppgave.domain.events.BehandlingEndretEvent +import no.nav.klage.oppgave.service.StatistikkTilDVHService import no.nav.klage.oppgave.util.getLogger import org.springframework.context.event.EventListener import org.springframework.stereotype.Service diff --git a/src/main/kotlin/no/nav/klage/oppgave/eventlisteners/UpdateGosysOppgaveEventListener.kt b/src/main/kotlin/no/nav/klage/oppgave/eventlisteners/UpdateGosysOppgaveEventListener.kt index 9878efacd..4c87fb315 100644 --- a/src/main/kotlin/no/nav/klage/oppgave/eventlisteners/UpdateGosysOppgaveEventListener.kt +++ b/src/main/kotlin/no/nav/klage/oppgave/eventlisteners/UpdateGosysOppgaveEventListener.kt @@ -3,7 +3,6 @@ package no.nav.klage.oppgave.eventlisteners import com.fasterxml.jackson.databind.ObjectMapper import no.nav.klage.oppgave.domain.events.BehandlingEndretEvent import no.nav.klage.oppgave.domain.klage.Felt -import no.nav.klage.oppgave.repositories.BehandlingRepository import no.nav.klage.oppgave.service.GosysOppgaveService import no.nav.klage.oppgave.util.getLogger import no.nav.klage.oppgave.util.ourJacksonObjectMapper @@ -17,7 +16,6 @@ import org.springframework.transaction.event.TransactionalEventListener @Service class UpdateGosysOppgaveEventListener( - private val behandlingRepository: BehandlingRepository, private val gosysOppgaveService: GosysOppgaveService, @Value("\${SYSTEMBRUKER_IDENT}") private val systembrukerIdent: String, ) { @@ -28,7 +26,6 @@ class UpdateGosysOppgaveEventListener( val objectMapper: ObjectMapper = ourJacksonObjectMapper() } - /* This code needs a transaction b/c of lazy loading */ @EventListener @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) @Transactional(propagation = Propagation.REQUIRES_NEW) diff --git a/src/main/kotlin/no/nav/klage/oppgave/exceptions/Exceptions.kt b/src/main/kotlin/no/nav/klage/oppgave/exceptions/Exceptions.kt index bad7ef935..eef8ef2be 100644 --- a/src/main/kotlin/no/nav/klage/oppgave/exceptions/Exceptions.kt +++ b/src/main/kotlin/no/nav/klage/oppgave/exceptions/Exceptions.kt @@ -47,4 +47,9 @@ class EREGOrganizationNotFoundException(msg: String) : RuntimeException(msg) class KodeverkNotFoundException(msg: String) : RuntimeException(msg) -class AttachmentCouldNotBeConvertedException(override val message: String = "FILE_COULD_NOT_BE_CONVERTED") : RuntimeException() \ No newline at end of file +class AttachmentCouldNotBeConvertedException(override val message: String = "FILE_COULD_NOT_BE_CONVERTED") : RuntimeException() + +class GosysOppgaveClientException : RuntimeException { + constructor(message: String?) : super(message) + constructor(message: String?, cause: Throwable?) : super(message, cause) +} \ No newline at end of file diff --git a/src/main/kotlin/no/nav/klage/oppgave/service/AdminService.kt b/src/main/kotlin/no/nav/klage/oppgave/service/AdminService.kt index 83a7c9450..6f7de7eb9 100644 --- a/src/main/kotlin/no/nav/klage/oppgave/service/AdminService.kt +++ b/src/main/kotlin/no/nav/klage/oppgave/service/AdminService.kt @@ -26,8 +26,8 @@ import no.nav.klage.oppgave.domain.kafka.EventType import no.nav.klage.oppgave.domain.kafka.StatistikkTilDVH import no.nav.klage.oppgave.domain.kafka.UtsendingStatus import no.nav.klage.oppgave.domain.klage.* -import no.nav.klage.oppgave.eventlisteners.StatistikkTilDVHService.Companion.TR_ENHET import no.nav.klage.oppgave.repositories.* +import no.nav.klage.oppgave.service.StatistikkTilDVHService.Companion.TR_ENHET import no.nav.klage.oppgave.util.* import org.slf4j.Logger import org.springframework.beans.factory.annotation.Value diff --git a/src/main/kotlin/no/nav/klage/oppgave/service/AnkeITrygderettenbehandlingService.kt b/src/main/kotlin/no/nav/klage/oppgave/service/AnkeITrygderettenbehandlingService.kt index d568a8bc1..dc69bf10c 100644 --- a/src/main/kotlin/no/nav/klage/oppgave/service/AnkeITrygderettenbehandlingService.kt +++ b/src/main/kotlin/no/nav/klage/oppgave/service/AnkeITrygderettenbehandlingService.kt @@ -3,7 +3,6 @@ package no.nav.klage.oppgave.service import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule -import jakarta.transaction.Transactional import no.nav.klage.dokument.api.view.JournalfoertDokumentReference import no.nav.klage.kodeverk.hjemmel.Hjemmel import no.nav.klage.kodeverk.hjemmel.ytelseTilRegistreringshjemlerV2 @@ -21,6 +20,7 @@ import no.nav.klage.oppgave.util.getLogger import org.springframework.beans.factory.annotation.Value import org.springframework.context.ApplicationEventPublisher import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional import java.util.* @Service diff --git a/src/main/kotlin/no/nav/klage/oppgave/service/AnkebehandlingService.kt b/src/main/kotlin/no/nav/klage/oppgave/service/AnkebehandlingService.kt index f9b1ddf78..246fc158b 100644 --- a/src/main/kotlin/no/nav/klage/oppgave/service/AnkebehandlingService.kt +++ b/src/main/kotlin/no/nav/klage/oppgave/service/AnkebehandlingService.kt @@ -1,18 +1,17 @@ package no.nav.klage.oppgave.service -import jakarta.transaction.Transactional import no.nav.klage.dokument.api.view.JournalfoertDokumentReference import no.nav.klage.kodeverk.Type import no.nav.klage.oppgave.clients.kaka.KakaApiGateway import no.nav.klage.oppgave.domain.events.BehandlingEndretEvent import no.nav.klage.oppgave.domain.klage.* import no.nav.klage.oppgave.repositories.AnkebehandlingRepository -import no.nav.klage.oppgave.repositories.BehandlingEtterTrygderettenOpphevetRepository import no.nav.klage.oppgave.repositories.BehandlingRepository import no.nav.klage.oppgave.util.getLogger import org.springframework.beans.factory.annotation.Value import org.springframework.context.ApplicationEventPublisher import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional import java.time.LocalDate import java.time.Period import java.util.* @@ -21,14 +20,11 @@ import java.util.* @Transactional class AnkebehandlingService( private val ankebehandlingRepository: AnkebehandlingRepository, - private val behandlingEtterTrygderettenOpphevetRepository: BehandlingEtterTrygderettenOpphevetRepository, private val behandlingRepository: BehandlingRepository, private val kakaApiGateway: KakaApiGateway, private val dokumentService: DokumentService, private val behandlingService: BehandlingService, private val applicationEventPublisher: ApplicationEventPublisher, - @Value("#{T(java.time.LocalDate).parse('\${KAKA_VERSION_2_DATE}')}") - private val kakaVersion2Date: LocalDate, @Value("\${SYSTEMBRUKER_IDENT}") private val systembrukerIdent: String, ) { diff --git a/src/main/kotlin/no/nav/klage/oppgave/service/BehandlingEtterTrygderettenOpphevetService.kt b/src/main/kotlin/no/nav/klage/oppgave/service/BehandlingEtterTrygderettenOpphevetService.kt index cb1e32550..9daacd481 100644 --- a/src/main/kotlin/no/nav/klage/oppgave/service/BehandlingEtterTrygderettenOpphevetService.kt +++ b/src/main/kotlin/no/nav/klage/oppgave/service/BehandlingEtterTrygderettenOpphevetService.kt @@ -3,7 +3,6 @@ package no.nav.klage.oppgave.service import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule -import jakarta.transaction.Transactional import no.nav.klage.dokument.api.view.JournalfoertDokumentReference import no.nav.klage.kodeverk.Type import no.nav.klage.oppgave.clients.kaka.KakaApiGateway @@ -17,6 +16,7 @@ import no.nav.klage.oppgave.util.getLogger import org.springframework.beans.factory.annotation.Value import org.springframework.context.ApplicationEventPublisher import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional import java.time.LocalDate import java.time.LocalDateTime diff --git a/src/main/kotlin/no/nav/klage/oppgave/service/BehandlingService.kt b/src/main/kotlin/no/nav/klage/oppgave/service/BehandlingService.kt index 2b9593027..a63daa614 100644 --- a/src/main/kotlin/no/nav/klage/oppgave/service/BehandlingService.kt +++ b/src/main/kotlin/no/nav/klage/oppgave/service/BehandlingService.kt @@ -2340,7 +2340,7 @@ class BehandlingService( return if (behandlingList.isEmpty()) { null } else if (behandlingList.size != 1) { - throw Exception("Found more than one behandling for gosysOppgaveId $gosysOppgaveId, investigate") + throw RuntimeException("Found more than one behandling for gosysOppgaveId $gosysOppgaveId, investigate") } else { behandlingList.first().id } diff --git a/src/main/kotlin/no/nav/klage/oppgave/service/GosysOppgaveService.kt b/src/main/kotlin/no/nav/klage/oppgave/service/GosysOppgaveService.kt index 0c146a2bc..140794a7b 100644 --- a/src/main/kotlin/no/nav/klage/oppgave/service/GosysOppgaveService.kt +++ b/src/main/kotlin/no/nav/klage/oppgave/service/GosysOppgaveService.kt @@ -15,6 +15,7 @@ import no.nav.klage.oppgave.domain.kafka.GosysoppgaveEvent import no.nav.klage.oppgave.domain.kafka.InternalBehandlingEvent import no.nav.klage.oppgave.domain.kafka.InternalEventType import no.nav.klage.oppgave.domain.klage.Behandling +import no.nav.klage.oppgave.exceptions.GosysOppgaveClientException import no.nav.klage.oppgave.exceptions.GosysOppgaveNotEditableException import no.nav.klage.oppgave.exceptions.IllegalOperation import no.nav.klage.oppgave.util.getLogger @@ -282,7 +283,7 @@ class GosysOppgaveService( val mappeResponse = gosysOppgaveClient.getMappe(id = id, systemContext = systemContext) if (mappeResponse.id == null) { - throw OppgaveClientException("Mappe did not contain id") + throw GosysOppgaveClientException("Mappe did not contain id") } return GosysOppgaveMappeView( diff --git a/src/main/kotlin/no/nav/klage/oppgave/eventlisteners/StatistikkTilDVHService.kt b/src/main/kotlin/no/nav/klage/oppgave/service/StatistikkTilDVHService.kt similarity index 99% rename from src/main/kotlin/no/nav/klage/oppgave/eventlisteners/StatistikkTilDVHService.kt rename to src/main/kotlin/no/nav/klage/oppgave/service/StatistikkTilDVHService.kt index 7de6ca9f3..1d34f60a6 100644 --- a/src/main/kotlin/no/nav/klage/oppgave/eventlisteners/StatistikkTilDVHService.kt +++ b/src/main/kotlin/no/nav/klage/oppgave/service/StatistikkTilDVHService.kt @@ -1,4 +1,4 @@ -package no.nav.klage.oppgave.eventlisteners +package no.nav.klage.oppgave.service import no.nav.klage.kodeverk.Fagsystem import no.nav.klage.kodeverk.PartIdType diff --git a/src/test/kotlin/no/nav/klage/oppgave/eventlisteners/StatistikkTilDVHServiceTest.kt b/src/test/kotlin/no/nav/klage/oppgave/eventlisteners/StatistikkTilDVHServiceTest.kt index a274e543b..307d5d659 100644 --- a/src/test/kotlin/no/nav/klage/oppgave/eventlisteners/StatistikkTilDVHServiceTest.kt +++ b/src/test/kotlin/no/nav/klage/oppgave/eventlisteners/StatistikkTilDVHServiceTest.kt @@ -8,6 +8,7 @@ import no.nav.klage.kodeverk.Ytelse import no.nav.klage.oppgave.domain.events.BehandlingEndretEvent import no.nav.klage.oppgave.domain.klage.* import no.nav.klage.oppgave.repositories.KafkaEventRepository +import no.nav.klage.oppgave.service.StatistikkTilDVHService import org.junit.jupiter.api.Assertions.assertFalse import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test