Skip to content

Commit

Permalink
lagre state
Browse files Browse the repository at this point in the history
  • Loading branch information
vegardlu committed Feb 17, 2024
1 parent 003bdde commit d02a0ab
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 26 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package no.nav.eux.journal.model.entity

import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.Id
import java.time.LocalDateTime
import java.util.*
import java.util.UUID.randomUUID

@Entity
data class Feilregistrering(
@Id
val feilregistreringUuid: UUID = randomUUID(),
val feilregistreringStatus: FeilregistreringStatus,
val beskrivelse: String,
val dokumentInfoId: String,
val journalpostId: String,
@Column(updatable = false)
val opprettetBruker: String,
@Column(updatable = false)
val opprettetTidspunkt: LocalDateTime = LocalDateTime.now(),
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.nav.eux.journal.model
package no.nav.eux.journal.model.entity

enum class FeilregistreringStatus {
SATT_TIL_STATUS_AVBRYT,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package no.nav.eux.journal.persistence

import no.nav.eux.journal.model.entity.Feilregistrering
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.stereotype.Repository
import java.util.*

@Repository
interface FeilregistreringRepository : JpaRepository<Feilregistrering, UUID>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
create table feilregistrering
(
feilregistrering_uuid uuid primary key not null,
feilregistrering_status text not null,
beskrivelse text not null,
dokument_info_id text not null,
journalpost_id text not null,
opprettet_bruker text not null,
opprettet_tidspunkt timestamp not null
);
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ import no.nav.eux.journal.integration.client.saf.SafClient
import no.nav.eux.journal.integration.client.saf.SafJournalpost
import no.nav.eux.journal.integration.client.saf.SafJournalposttype.I
import no.nav.eux.journal.integration.client.saf.SafJournalposttype.U
import no.nav.eux.journal.model.Feilregistrering
import no.nav.eux.journal.model.FeilregistreringStatus.*
import no.nav.eux.journal.model.entity.Feilregistrering
import no.nav.eux.journal.model.entity.FeilregistreringStatus.*
import no.nav.eux.journal.persistence.FeilregistreringRepository
import org.springframework.stereotype.Component

@Component
class FeilregistrerJournalpostService(
val dokarkivClient: DokarkivClient,
val safClient: SafClient,
val euxOppgaveClient: EuxOppgaveClient,
val euxNavRinasakClient: EuxNavRinasakClient
val euxNavRinasakClient: EuxNavRinasakClient,
val repository: FeilregistreringRepository,
val context: TokenContextService
) {

val log = logger {}
Expand All @@ -34,11 +37,12 @@ class FeilregistrerJournalpostService(

fun DokumentPair.feilregistrer(): Feilregistrering {
log.info { "Feilregistrerer dokument." }
return when (journalpost.journalposttype) {
val feilregistrering = when (journalpost.journalposttype) {
I -> settStatusAvbryt()
U -> tildelEnhetsnr()
else -> ukjentJournalposttype()
}
return repository.save(feilregistrering)
}

fun DokumentPair.settStatusAvbryt() =
Expand All @@ -50,7 +54,8 @@ class FeilregistrerJournalpostService(
feilregistreringStatus = SATT_TIL_STATUS_AVBRYT,
beskrivelse = beskrivelse,
dokumentInfoId = dokument.dokumentInfoId,
journalpostId = journalpost.journalpostId
journalpostId = journalpost.journalpostId,
opprettetBruker = context.navIdent
)
} catch (e: RuntimeException) {
val beskrivelse = "Kunne ikke sette til status avbryt"
Expand All @@ -59,7 +64,8 @@ class FeilregistrerJournalpostService(
feilregistreringStatus = FEILREGISTRERING_FEILET,
beskrivelse = beskrivelse,
dokumentInfoId = dokument.dokumentInfoId,
journalpostId = journalpost.journalpostId
journalpostId = journalpost.journalpostId,
opprettetBruker = context.navIdent
)
}

Expand All @@ -75,7 +81,8 @@ class FeilregistrerJournalpostService(
feilregistreringStatus = OPPGAVE_FLYTTET,
beskrivelse = beskrivelse,
dokumentInfoId = dokument.dokumentInfoId,
journalpostId = journalpost.journalpostId
journalpostId = journalpost.journalpostId,
opprettetBruker = context.navIdent
)
} catch (e: RuntimeException) {
val beskrivelse = "Kunne ikke flytte oppgave"
Expand All @@ -84,7 +91,8 @@ class FeilregistrerJournalpostService(
feilregistreringStatus = OPPGAVEFLYTT_FEILET,
beskrivelse = beskrivelse,
dokumentInfoId = dokument.dokumentInfoId,
journalpostId = journalpost.journalpostId
journalpostId = journalpost.journalpostId,
opprettetBruker = context.navIdent
)
}

Expand All @@ -95,7 +103,8 @@ class FeilregistrerJournalpostService(
feilregistreringStatus = FEILREGISTRERING_FEILET,
beskrivelse = beskrivelse,
dokumentInfoId = dokument.dokumentInfoId,
journalpostId = journalpost.journalpostId
journalpostId = journalpost.journalpostId,
opprettetBruker = context.navIdent
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package no.nav.eux.journal.service

import no.nav.security.token.support.core.context.TokenValidationContextHolder
import org.springframework.stereotype.Service

@Service
class TokenContextService(
val tokenValidationContextHolder: TokenValidationContextHolder
) {
val navIdent
get() = tokenValidationContextHolder
.getTokenValidationContext()
.firstValidToken
?.jwtTokenClaims
?.get("NAVident")
?.toString()
?: "ukjent"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package no.nav.eux.journal.webapp

import no.nav.eux.journal.model.Feilregistrering
import no.nav.eux.journal.model.entity.Feilregistrering
import no.nav.eux.journal.model.common.toEnum
import no.nav.eux.journal.openapi.model.RinasakFeilregistrerJournalposterResponsOpenApiType
import no.nav.eux.journal.openapi.model.RinasakFeilregistreringOpenApiType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ fun tildelEnhetsnrResponse(body: String): MockResponse {
.readTree(body)
.findValue("tildeltEnhetsnr")
.asText()
if (listOf("453802638", "453802639").contains(journalpostId) && tildeltEnhetsnr == "2950") {
println("Det ble utført tildeling av enhetsnr $tildeltEnhetsnr for journalpostId $journalpostId")
return MockResponse().apply {
println("Det ble utført tildeling av enhetsnr $tildeltEnhetsnr for journalpostId $journalpostId")
return if (listOf("453802638", "453802639").contains(journalpostId) && tildeltEnhetsnr == "2950") {
MockResponse().apply {
setResponseCode(200)
}
} else {
println("Det ble utført tildeling av enhetsnr $tildeltEnhetsnr for journalpostId $journalpostId")
return MockResponse().apply {
MockResponse().apply {
setResponseCode(500)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ fun getOppgaverResponse() =
setBody(getOppgaverResponse)
}

val oppgaverResponse = object {}.javaClass.getResource("/dataset/oppgave/oppgave.json")!!.readText()
val oppgaverResponse = object {}.javaClass.getResource("/dataset/eux-oppgave/oppgave.json")!!.readText()

val getOppgaverResponse = object {}.javaClass.getResource("/dataset/oppgave/oppgaver.json")!!.readText()
val getOppgaverResponse = object {}.javaClass.getResource("/dataset/eux-oppgave/oppgaver.json")!!.readText()

const val getOppgaverUri = "/api/v1/oppgaver" +
"?journalpostId=1234&statuskategori=AAPEN&oppgavetype=JFR&oppgavetype=FDR"

0 comments on commit d02a0ab

Please sign in to comment.