@Override public ThemeResource getResource(String name, Optional<Breakpoint> breakpoint) { try { ThemeResource result = getResource(getActiveTheme(), name, breakpoint); return result; } catch (IOException e) { this.logger.warn("I/O Exception while resolving resource [{}]", name, e); return null; } }
/** * Tries to get template content for a certain theme and breakpoint. Tries in order : - tenant theme folder in * persistent directory (example : data/tenants/thetenant/themes/thetheme/[breakpoint/]filename - global theme * folder in persistent directory (example : data/themes/thetheme/[breakpoint/]filename) - classpath (example uri : * /themes/thetheme/[breakpoint/]filename) For each step, checks the breakpoint (if set) and fallback on the * no-breakpoint file * * @param theme the theme for which to try and get the template content * @param name the name of the template to get * @param breakpoint the breakpoint for which to get the template content * @return the content of the template, or null if not found * @throws IOException when there is an IO exception getting the content */ private String getTemplateContent(Theme theme, String name, Optional<Breakpoint> breakpoint) throws IOException { ThemeResource resource = this.getResource(theme, name, breakpoint); if (resource == null) { return null; } switch (resource.getType()) { default: case FILE: return Files.toString(resource.getPath().toFile(), Charsets.UTF_8); case CLASSPATH_RESOURCE: return Resources.toString(Resources.getResource(resource.getPath().toString()), Charsets.UTF_8); } }
return getResource(theme, name, Optional.<Breakpoint>absent()); return getResource(theme.getParent(), name, breakpoint);