Revert changes to exception handling in RealmsAdminResource#importRealm

- ModelDuplicateException and ModelIllegalException were wrongfully handled as ModelException, returning wrong status code

Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>

Closes #39753
This commit is contained in:
Stefan Guilhen 2025-05-20 14:07:53 -03:00 committed by Pedro Igor
parent 43a7b27301
commit 75e6d7214a

View File

@ -176,6 +176,12 @@ public class RealmsAdminResource {
} catch (PasswordPolicyNotMetException e) {
logger.error("Password policy not met for user " + e.getUsername(), e);
throw ErrorResponse.error("Password policy not met. See logs for details", Response.Status.BAD_REQUEST);
} catch (ModelIllegalStateException mise) {
logger.error(mise.getMessage(), mise);
throw ErrorResponse.error(mise.getMessage(), Response.Status.INTERNAL_SERVER_ERROR);
} catch (ModelDuplicateException mde) {
logger.error("Conflict detected", mde);
throw ErrorResponse.exists(mde.getMessage());
} catch (ModelException e) {
throw ErrorResponse.error(e.getMessage(), Response.Status.BAD_REQUEST);
}