From 2694e003c4d1c83bfb4aa30d85e0514d8522e2d6 Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Thu, 7 Apr 2016 06:00:31 +0200 Subject: [PATCH] KEYCLOAK-2759 Fix error message when renaming realm to name that exists --- .../keycloak/services/resources/admin/RealmAdminResource.java | 2 +- .../keycloak/services/resources/admin/RealmsAdminResource.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java index b434cdfe04..058b6e4c46 100644 --- a/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java @@ -266,7 +266,7 @@ public class RealmAdminResource { } catch (PatternSyntaxException e) { return ErrorResponse.error("Specified regex pattern(s) is invalid.", Response.Status.BAD_REQUEST); } catch (ModelDuplicateException e) { - throw e; + return ErrorResponse.exists("Realm with same name exists"); } catch (Exception e) { logger.error(e.getMessage(), e); return ErrorResponse.error("Failed to update realm", Response.Status.INTERNAL_SERVER_ERROR); diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RealmsAdminResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RealmsAdminResource.java index 1a48fe7cc4..939e61636d 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/RealmsAdminResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/RealmsAdminResource.java @@ -151,7 +151,7 @@ public class RealmsAdminResource { return Response.created(location).build(); } catch (ModelDuplicateException e) { - return ErrorResponse.exists("Realm " + rep.getRealm() + " already exists"); + return ErrorResponse.exists("Realm with same name exists"); } }