Search in sources :

Example 21 with Theme

use of org.keycloak.theme.Theme 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

Theme (org.keycloak.theme.Theme)21 IOException (java.io.IOException)17 Locale (java.util.Locale)9 Properties (java.util.Properties)7 Test (org.junit.Test)7 HashMap (java.util.HashMap)5 AbstractTestRealmKeycloakTest (org.keycloak.testsuite.AbstractTestRealmKeycloakTest)5 FreeMarkerUtil (org.keycloak.theme.FreeMarkerUtil)5 UriBuilder (javax.ws.rs.core.UriBuilder)4 URI (java.net.URI)3 GET (javax.ws.rs.GET)3 Path (javax.ws.rs.Path)3 WebApplicationException (javax.ws.rs.WebApplicationException)3 Response (javax.ws.rs.core.Response)3 RealmModel (org.keycloak.models.RealmModel)3 InputStream (java.io.InputStream)2 URISyntaxException (java.net.URISyntaxException)2 UnknownHostException (java.net.UnknownHostException)2 Map (java.util.Map)2 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)2