Merge pull request #432 from stianst/master

Fix themes displayed multiple times in admin console
This commit is contained in:
Stian Thorgersen 2014-05-29 10:28:22 +01:00
commit 2a2e57467d

View file

@ -1,6 +1,7 @@
package org.keycloak.services.resources.admin; package org.keycloak.services.resources.admin;
import org.keycloak.audit.AuditListener; import org.keycloak.audit.AuditListener;
import org.keycloak.freemarker.ExtendingThemeManager;
import org.keycloak.freemarker.Theme; import org.keycloak.freemarker.Theme;
import org.keycloak.freemarker.ThemeProvider; import org.keycloak.freemarker.ThemeProvider;
import org.keycloak.provider.ProviderSession; import org.keycloak.provider.ProviderSession;
@ -13,6 +14,7 @@ import javax.ws.rs.GET;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -42,14 +44,13 @@ public class ServerInfoAdminResource {
} }
private void setThemes(ServerInfoRepresentation info) { private void setThemes(ServerInfoRepresentation info) {
Set<ThemeProvider> themeProviders = providers.getAllProviders(ThemeProvider.class); ExtendingThemeManager themeManager = new ExtendingThemeManager(providers);
info.themes = new HashMap<String, List<String>>(); info.themes = new HashMap<String, List<String>>();
for (Theme.Type type : Theme.Type.values()) { for (Theme.Type type : Theme.Type.values()) {
List<String> themes = new LinkedList<String>(); List<String> themes = new LinkedList<String>(themeManager.nameSet(type));
for (ThemeProvider p : themeProviders) {
themes.addAll(p.nameSet(type));
}
Collections.sort(themes); Collections.sort(themes);
info.themes.put(type.toString().toLowerCase(), themes); info.themes.put(type.toString().toLowerCase(), themes);
} }
} }