From 8c72ef2980d6f0e33f11b903f6fec849a962f677 Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Wed, 14 Oct 2015 07:22:56 +0200 Subject: [PATCH] KEYCLOAK-1877 Empty bubble in admin event types select box --- .../admin/resources/partials/realm-events-config.html | 2 +- .../keycloak/models/utils/ModelToRepresentation.java | 4 ++-- .../org/keycloak/services/managers/RealmManager.java | 4 ++-- .../services/resources/admin/RealmAdminResource.java | 11 ++++++++++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/realm-events-config.html b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/realm-events-config.html index 5c337d3960..b0d8797aaf 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/realm-events-config.html +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/realm-events-config.html @@ -46,7 +46,7 @@ - +
diff --git a/model/api/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java b/model/api/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java index 6b1960642c..de062d58b5 100755 --- a/model/api/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java +++ b/model/api/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java @@ -250,11 +250,11 @@ public class ModelToRepresentation { } if (realm.getEventsListeners() != null) { - rep.setEventsListeners(new LinkedList(realm.getEventsListeners())); + rep.setEventsListeners(new LinkedList<>(realm.getEventsListeners())); } if(realm.getEnabledEventTypes() != null) { - rep.setEnabledEventTypes(new LinkedList(realm.getEnabledEventTypes())); + rep.setEnabledEventTypes(new LinkedList<>(realm.getEnabledEventTypes())); } rep.setAdminEventsEnabled(realm.isAdminEventsEnabled()); diff --git a/services/src/main/java/org/keycloak/services/managers/RealmManager.java b/services/src/main/java/org/keycloak/services/managers/RealmManager.java index 06c19ac369..749c8d83d3 100755 --- a/services/src/main/java/org/keycloak/services/managers/RealmManager.java +++ b/services/src/main/java/org/keycloak/services/managers/RealmManager.java @@ -210,10 +210,10 @@ public class RealmManager implements RealmImporter { realm.setEventsEnabled(rep.isEventsEnabled()); realm.setEventsExpiration(rep.getEventsExpiration() != null ? rep.getEventsExpiration() : 0); if (rep.getEventsListeners() != null) { - realm.setEventsListeners(new HashSet(rep.getEventsListeners())); + realm.setEventsListeners(new HashSet<>(rep.getEventsListeners())); } if(rep.getEnabledEventTypes() != null) { - realm.setEnabledEventTypes(new HashSet(rep.getEnabledEventTypes())); + realm.setEnabledEventTypes(new HashSet<>(rep.getEnabledEventTypes())); } realm.setAdminEventsEnabled(rep.isAdminEventsEnabled()); 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 82dc0bd595..bd11684e30 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java @@ -368,7 +368,16 @@ public class RealmAdminResource { public RealmEventsConfigRepresentation getRealmEventsConfig() { auth.init(RealmAuth.Resource.EVENTS).requireView(); - return ModelToRepresentation.toEventsConfigReprensetation(realm); + RealmEventsConfigRepresentation config = ModelToRepresentation.toEventsConfigReprensetation(realm); + if (config.getEnabledEventTypes() == null || config.getEnabledEventTypes().isEmpty()) { + config.setEnabledEventTypes(new LinkedList()); + for (EventType e : EventType.values()) { + if (e.isSaveByDefault()) { + config.getEnabledEventTypes().add(e.name()); + } + } + } + return config; } /**