Search in sources :

Example 1 with ThemeInfoRepresentation

use of org.keycloak.representations.info.ThemeInfoRepresentation in project keycloak by keycloak.

the class ServerInfoAdminResource method setThemes.

private void setThemes(ServerInfoRepresentation info) {
    info.setThemes(new HashMap<>());
    for (Theme.Type type : Theme.Type.values()) {
        List<String> themeNames = filterThemes(type, new LinkedList<>(session.theme().nameSet(type)));
        Collections.sort(themeNames);
        List<ThemeInfoRepresentation> themes = new LinkedList<>();
        info.getThemes().put(type.toString().toLowerCase(), themes);
        for (String name : themeNames) {
            try {
                Theme theme = session.theme().getTheme(name, type);
                ThemeInfoRepresentation ti = new ThemeInfoRepresentation();
                ti.setName(name);
                String locales = theme.getProperties().getProperty("locales");
                if (locales != null) {
                    ti.setLocales(locales.replaceAll(" ", "").split(","));
                }
                themes.add(ti);
            } catch (IOException e) {
                throw new WebApplicationException("Failed to load themes", e);
            }
        }
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) ThemeInfoRepresentation(org.keycloak.representations.info.ThemeInfoRepresentation) Theme(org.keycloak.theme.Theme) IOException(java.io.IOException) LinkedList(java.util.LinkedList)

Aggregations

IOException (java.io.IOException)1 LinkedList (java.util.LinkedList)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 ThemeInfoRepresentation (org.keycloak.representations.info.ThemeInfoRepresentation)1 Theme (org.keycloak.theme.Theme)1