feat(fullstack): Add application form status, add submissions of forms, update DB schema
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package com.betriebsratkanzlei.legalconsenthub.error
|
||||
|
||||
import com.betriebsratkanzlei.legalconsenthub_api.model.ApplicationFormStatus
|
||||
import java.util.UUID
|
||||
|
||||
class ApplicationFormInvalidStateException(
|
||||
val applicationFormId: UUID,
|
||||
val currentState: ApplicationFormStatus,
|
||||
val expectedState: ApplicationFormStatus,
|
||||
val operation: String
|
||||
) : RuntimeException("Cannot $operation application form with ID $applicationFormId. Current state: $currentState, expected state: $expectedState")
|
||||
@@ -31,6 +31,22 @@ class ExceptionHandler {
|
||||
)
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ExceptionHandler(ApplicationFormInvalidStateException::class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
fun handleInvalidStateError(e: ApplicationFormInvalidStateException): ResponseEntity<ProblemDetails> {
|
||||
logger.warn(e.message, e)
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).contentType(MediaType.APPLICATION_PROBLEM_JSON)
|
||||
.body(
|
||||
ProblemDetails(
|
||||
title = "Invalid State",
|
||||
status = HttpStatus.BAD_REQUEST.value(),
|
||||
type = URI.create("about:blank"),
|
||||
detail = e.message ?: "Operation not allowed in current state"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ExceptionHandler(
|
||||
ApplicationFormNotCreatedException::class,
|
||||
|
||||
Reference in New Issue
Block a user