feat(fullstack): Add notifications, user is now an entity, add testcontainers, rework custom permissions, get user from JWT in endpoints
This commit is contained in:
@@ -16,7 +16,7 @@ class ExceptionHandler {
|
||||
var logger = LoggerFactory.getLogger(ExceptionHandler::class.java)
|
||||
|
||||
@ResponseBody
|
||||
@ExceptionHandler(ApplicationFormNotFoundException::class)
|
||||
@ExceptionHandler(ApplicationFormNotFoundException::class, UserNotFoundException::class)
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
fun handleNotFoundError(e: Exception): ResponseEntity<ProblemDetails> {
|
||||
logger.warn(e.message, e)
|
||||
@@ -47,6 +47,22 @@ class ExceptionHandler {
|
||||
)
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ExceptionHandler(UserAlreadyExistsException::class)
|
||||
@ResponseStatus(HttpStatus.CONFLICT)
|
||||
fun handleUserAlreadyExistsError(e: UserAlreadyExistsException): ResponseEntity<ProblemDetails> {
|
||||
logger.warn(e.message, e)
|
||||
return ResponseEntity.status(HttpStatus.CONFLICT).contentType(MediaType.APPLICATION_PROBLEM_JSON)
|
||||
.body(
|
||||
ProblemDetails(
|
||||
title = "Conflict",
|
||||
status = HttpStatus.CONFLICT.value(),
|
||||
type = URI.create("about:blank"),
|
||||
detail = e.message ?: "Resource already exists"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ExceptionHandler(
|
||||
ApplicationFormNotCreatedException::class,
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.betriebsratkanzlei.legalconsenthub.error
|
||||
|
||||
class UserAlreadyExistsException(id: String): RuntimeException("User with ID $id already exists")
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.betriebsratkanzlei.legalconsenthub.error
|
||||
|
||||
class UserNotFoundException(id: String): RuntimeException("Couldn't find user with ID: $id")
|
||||
Reference in New Issue
Block a user