-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
90 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 15 additions & 3 deletions
18
...rnal-integration/src/main/kotlin/no/nav/eux/journal/integration/client/saf/SafRootData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
package no.nav.eux.journal.integration.client.saf | ||
|
||
data class SafJournalpostRoot(val data: SafJournalpostData) | ||
data class SafRoot<T>( | ||
val data: T?, | ||
val errors: List<SafError>?, | ||
) | ||
data class SafJournalpostData(val journalpost: SafJournalpost) | ||
data class SafSakerRoot(val data: SafSakerData) | ||
data class SafSakerData(val saker: List<SafSak>) | ||
data class SafTilknyttedeJournalposterRoot(val data: SafTilknyttedeJournalposterData) | ||
data class SafTilknyttedeJournalposterData(val tilknyttedeJournalposter: List<SafJournalpost>) | ||
data class SafDokumentoversiktBrukerData(val dokumentoversiktBruker: SafDokumentoversiktBruker) | ||
data class SafDokumentoversiktBruker(val journalposter: List<SafJournalpost>) | ||
|
||
data class SafError ( | ||
val message: String, | ||
) | ||
|
||
class SafErrorException( | ||
message: String, | ||
val errors: List<SafError> | ||
) : RuntimeException(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
eux-journal-webapp/src/main/kotlin/no/nav/eux/journal/advice/SafErrorExceptionAdvice.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters