diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6b3da8a..290e2ef 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -120,17 +120,18 @@ jobs: VARS: .nais/q2.yaml PRINT_PAYLOAD: true - prod: - name: 'Deploy to prod' - runs-on: ubuntu-latest - needs: [build, deploy-q1, deploy-q2] - steps: - - uses: actions/checkout@v4 - - name: 'Calling nais deploy action for prod' - uses: nais/deploy/actions/deploy@v2 - env: - CLUSTER: prod-gcp - RESOURCE: .nais/nais.yaml - VAR: image=${{ needs.build.outputs.docker-image }} - VARS: .nais/prod.yaml - PRINT_PAYLOAD: true +# Endret feilhåndtering, avventer litt produksjon +# prod: +# name: 'Deploy to prod' +# runs-on: ubuntu-latest +# needs: [build, deploy-q1, deploy-q2] +# steps: +# - uses: actions/checkout@v4 +# - name: 'Calling nais deploy action for prod' +# uses: nais/deploy/actions/deploy@v2 +# env: +# CLUSTER: prod-gcp +# RESOURCE: .nais/nais.yaml +# VAR: image=${{ needs.build.outputs.docker-image }} +# VARS: .nais/prod.yaml +# PRINT_PAYLOAD: true diff --git a/eux-journal-integration/pom.xml b/eux-journal-integration/pom.xml index 111ce09..d2e7b12 100644 --- a/eux-journal-integration/pom.xml +++ b/eux-journal-integration/pom.xml @@ -72,14 +72,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - org.apache.maven.plugins - maven-failsafe-plugin - diff --git a/eux-journal-integration/src/main/kotlin/no/nav/eux/journal/integration/client/eux/navrinasak/EuxNavRinasakClient.kt b/eux-journal-integration/src/main/kotlin/no/nav/eux/journal/integration/client/eux/navrinasak/EuxNavRinasakClient.kt index 8d3c5b4..bd28ef3 100644 --- a/eux-journal-integration/src/main/kotlin/no/nav/eux/journal/integration/client/eux/navrinasak/EuxNavRinasakClient.kt +++ b/eux-journal-integration/src/main/kotlin/no/nav/eux/journal/integration/client/eux/navrinasak/EuxNavRinasakClient.kt @@ -2,7 +2,6 @@ package no.nav.eux.journal.integration.client.eux.navrinasak import no.nav.eux.journal.integration.config.get import org.springframework.beans.factory.annotation.Value -import org.springframework.http.ResponseEntity import org.springframework.stereotype.Component import org.springframework.web.client.RestTemplate import org.springframework.web.client.toEntity @@ -14,14 +13,10 @@ class EuxNavRinasakClient( val euxNavRinasakRestTemplate: RestTemplate ) { - fun finn(rinasakId: Int): EuxNavRinasak { - val entity: ResponseEntity = euxNavRinasakRestTemplate - .get() - .uri("${euxNavRinasakUrl}/api/v1/rinasaker/${rinasakId}") - .retrieve() - .toEntity() - if (!entity.statusCode.is2xxSuccessful) - throw RuntimeException("Fant ikke rinasak $rinasakId på: $euxNavRinasakUrl") - return entity.body!! - } + fun finn(rinasakId: Int): EuxNavRinasak = euxNavRinasakRestTemplate + .get() + .uri("${euxNavRinasakUrl}/api/v1/rinasaker/${rinasakId}") + .retrieve() + .toEntity() + .body!! } diff --git a/eux-journal-integration/src/main/kotlin/no/nav/eux/journal/integration/client/saf/SafClient.kt b/eux-journal-integration/src/main/kotlin/no/nav/eux/journal/integration/client/saf/SafClient.kt index 3359cf4..9a8b897 100644 --- a/eux-journal-integration/src/main/kotlin/no/nav/eux/journal/integration/client/saf/SafClient.kt +++ b/eux-journal-integration/src/main/kotlin/no/nav/eux/journal/integration/client/saf/SafClient.kt @@ -5,7 +5,7 @@ import org.springframework.beans.factory.annotation.Value import org.springframework.http.MediaType.APPLICATION_JSON import org.springframework.stereotype.Component import org.springframework.web.client.RestTemplate -import org.springframework.web.client.toEntity +import org.springframework.web.client.body @Component class SafClient( @@ -14,7 +14,7 @@ class SafClient( val safRestTemplate: RestTemplate ) { - fun safSakerRoot(fnr: String): SafSakerRoot = + fun safSakerRoot(fnr: String): List = safRestTemplate .post() .uri("$safUrl/graphql") @@ -22,10 +22,11 @@ class SafClient( .contentType(APPLICATION_JSON) .accept(APPLICATION_JSON) .retrieve() - .toEntity() - .body!! + .body>() + .safData() + .saker - fun safJournalpost(journalpostId: String): SafJournalpostRoot = + fun safJournalpost(journalpostId: String): SafJournalpost = safRestTemplate .post() .uri("$safUrl/graphql") @@ -33,16 +34,15 @@ class SafClient( .contentType(APPLICATION_JSON) .accept(APPLICATION_JSON) .retrieve() - .toEntity() - .body!! + .body>() + .safData() + .journalpost fun firstTilknyttetJournalpostOrNull(dokumentInfoId: String): SafJournalpost? = tilknyttedeJournalposterRoot(dokumentInfoId) - .data - .tilknyttedeJournalposter .firstOrNull() - fun tilknyttedeJournalposterRoot(dokumentInfoId: String): SafTilknyttedeJournalposterRoot = + fun tilknyttedeJournalposterRoot(dokumentInfoId: String): List = safRestTemplate .post() .uri("$safUrl/graphql") @@ -50,8 +50,18 @@ class SafClient( .contentType(APPLICATION_JSON) .accept(APPLICATION_JSON) .retrieve() - .toEntity() - .body!! + .body>() + .safData() + .tilknyttedeJournalposter + + fun SafRoot?.safData(): T = + when (this!!.data) { + null -> throw SafErrorException( + "Feil fra SAF: ${errors?.joinToString { it.message }}", + errors ?: emptyList() + ) + else -> data!! + } } fun journalpostQuery(journalpostId: String) = GraphQlQuery( diff --git a/eux-journal-integration/src/main/kotlin/no/nav/eux/journal/integration/client/saf/SafRootData.kt b/eux-journal-integration/src/main/kotlin/no/nav/eux/journal/integration/client/saf/SafRootData.kt index 74fd16b..16d7f7e 100644 --- a/eux-journal-integration/src/main/kotlin/no/nav/eux/journal/integration/client/saf/SafRootData.kt +++ b/eux-journal-integration/src/main/kotlin/no/nav/eux/journal/integration/client/saf/SafRootData.kt @@ -1,8 +1,20 @@ package no.nav.eux.journal.integration.client.saf -data class SafJournalpostRoot(val data: SafJournalpostData) +data class SafRoot( + val data: T?, + val errors: List?, +) data class SafJournalpostData(val journalpost: SafJournalpost) -data class SafSakerRoot(val data: SafSakerData) data class SafSakerData(val saker: List) -data class SafTilknyttedeJournalposterRoot(val data: SafTilknyttedeJournalposterData) data class SafTilknyttedeJournalposterData(val tilknyttedeJournalposter: List) +data class SafDokumentoversiktBrukerData(val dokumentoversiktBruker: SafDokumentoversiktBruker) +data class SafDokumentoversiktBruker(val journalposter: List) + +data class SafError ( + val message: String, +) + +class SafErrorException( + message: String, + val errors: List +) : RuntimeException(message) diff --git a/eux-journal-persistence/pom.xml b/eux-journal-persistence/pom.xml index 8c17d50..50446e7 100644 --- a/eux-journal-persistence/pom.xml +++ b/eux-journal-persistence/pom.xml @@ -82,14 +82,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - org.apache.maven.plugins - maven-failsafe-plugin - diff --git a/eux-journal-service/pom.xml b/eux-journal-service/pom.xml index e8b01a2..d8ad2f1 100644 --- a/eux-journal-service/pom.xml +++ b/eux-journal-service/pom.xml @@ -91,14 +91,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - org.apache.maven.plugins - maven-failsafe-plugin - \ No newline at end of file diff --git a/eux-journal-webapp/pom.xml b/eux-journal-webapp/pom.xml index 04c0335..ec39dcd 100644 --- a/eux-journal-webapp/pom.xml +++ b/eux-journal-webapp/pom.xml @@ -176,6 +176,7 @@ org.apache.maven.plugins maven-surefire-plugin + -XX:+EnableDynamicAgentLoading false diff --git a/eux-journal-webapp/src/main/kotlin/no/nav/eux/journal/advice/SafErrorExceptionAdvice.kt b/eux-journal-webapp/src/main/kotlin/no/nav/eux/journal/advice/SafErrorExceptionAdvice.kt new file mode 100644 index 0000000..d51b798 --- /dev/null +++ b/eux-journal-webapp/src/main/kotlin/no/nav/eux/journal/advice/SafErrorExceptionAdvice.kt @@ -0,0 +1,30 @@ +package no.nav.eux.journal.advice + +import no.nav.eux.journal.integration.client.saf.SafErrorException +import org.springframework.http.HttpStatus.BAD_REQUEST +import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.ExceptionHandler +import org.springframework.web.bind.annotation.RestControllerAdvice +import org.springframework.web.context.request.WebRequest +import java.time.LocalDateTime +import java.time.LocalDateTime.now + +@RestControllerAdvice +class SafErrorExceptionAdvice { + + @ExceptionHandler(value = [SafErrorException::class]) + fun handleMethodArgumentValidationExceptions( + exception: SafErrorException, + webRequest: WebRequest + ) = ResponseEntity + .status(BAD_REQUEST) + .body(exception.safError) + + val SafErrorException.safError + get() = SafError(errors = errors.map { it.message }) + + data class SafError( + val timestamp: LocalDateTime = now(), + val errors: List + ) +} diff --git a/pom.xml b/pom.xml index 4b5c6f7..11298fe 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ no.nav.eux parent-pom - 1.0.13 + 1.0.16