throws ResourceNotFoundException {
mLogger.debug("Looking up resource named ... "+name);
if (name == null || name.length() < 1) {
throw new ResourceNotFoundException("Need to specify a template name!");
}
try {
// parse the name ... theme templates name are <theme>:<template>
String[] split = name.split(":", 2);
if(split.length < 2)
throw new ResourceNotFoundException("Invalid ThemeRL key "+name);
// lookup the template from the proper theme
ThemeManager themeMgr = RollerFactory.getRoller().getThemeManager();
Theme theme = themeMgr.getTheme(split[0]);
ThemeTemplate template = theme.getTemplate(split[1]);
if(template == null)
throw new ResourceNotFoundException("Template ["+split[1]+
"] doesn't seem to be part of theme ["+split[0]+"]");
mLogger.debug("Resource found!");
// return the input stream
return new ByteArrayInputStream(template.getContents().getBytes("UTF-8"));
} catch (UnsupportedEncodingException uex) {
// We expect UTF-8 in all JRE installation.
// This rethrows as a Runtime exception after logging.
mLogger.error(uex);
throw new RuntimeException(uex);
} catch (ThemeNotFoundException tnfe) {
String msg = "ThemeResourceLoader Error: " + tnfe.getMessage();
mLogger.error(msg, tnfe);
throw new ResourceNotFoundException(msg);
} catch (RollerException re) {
String msg = "RollerResourceLoader Error: " + re.getMessage();
mLogger.error( msg, re );
throw new ResourceNotFoundException(msg);
}
}