Skip to content

Commit

Permalink
f - Henter gjenny saktype og oppretter journalpost med riktig tema
Browse files Browse the repository at this point in the history
Co-authored-by: [email protected]
  • Loading branch information
MariamPervez committed Dec 12, 2023
1 parent 629c358 commit 8fb013f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/main/kotlin/no/nav/eessi/pensjon/gcp/GcpStorageService.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package no.nav.eessi.pensjon.gcp

import com.google.cloud.storage.Blob
import com.google.cloud.storage.BlobId
import com.google.cloud.storage.Storage
import org.slf4j.LoggerFactory
Expand Down Expand Up @@ -36,6 +37,20 @@ class GcpStorageService(
return false
}

fun hent(storageKey: String): String? {
val jsonHendelse: Blob
try {
jsonHendelse = gcpStorage.get(BlobId.of(bucketname, storageKey))
if(jsonHendelse.exists()){
logger.info("Blob med key:$storageKey funnet")
return jsonHendelse.getContent().decodeToString()
}
} catch ( ex: Exception) {
logger.warn("En feil oppstod under henting av objekt: $storageKey i bucket")
}
return null
}

fun list(keyPrefix: String) : List<String> {
return gcpStorage.list(bucketname , Storage.BlobListOption.prefix(keyPrefix))?.values?.map { v -> v.name} ?: emptyList()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,8 @@ class JournalforingService(
euxCaseId: String
) : Tema {
return if (gcpStorageService.eksisterer(euxCaseId)) {
if (saktype == SakType.BARNEP) EYBARNEP else OMSTILLING
val blob = gcpStorageService.hent(euxCaseId)
if (blob?.contains("BARNEP") == true) EYBARNEP else OMSTILLING
} else {
val ufoereAlder = if (fnr != null && !fnr.erNpid) Period.between(fnr.getBirthDate(), LocalDate.now()).years in 19..61 else false
if (saktype == SakType.UFOREP || bucType == P_BUC_03 && saktype == null) UFORETRYGD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class JournalpostService(private val journalpostKlient: JournalpostKlient) {
| tittel: ${request.tittel},
| dokumenter.str: ${request.dokumenter.length},
| avsenderMottaker: ${request.avsenderMottaker},
| bruker: ${if (vasketFnr) "*******" else "Mangler fnr"},
| bruker: ${if (vasketFnr == true) "*******" else "Mangler fnr"},
| journalfoerendeEnhet: ${request.journalfoerendeEnhet}""".trimMargin()

}
Expand Down

0 comments on commit 8fb013f

Please sign in to comment.