private WhitelistReader getWhitelistReader(final HstRequestContext requestContext)
throws ContainerException, RepositoryException, WebFileException, IOException {
final String bundleName = WebFileUtils.getBundleName(requestContext);
final String version = getVersion(requestContext);
final String cacheKey= WebFilesService.JCR_ROOT_PATH + "/" + bundleName + WHITE_LIST_CONTENT_PATH;
try {
final CacheElement cacheElement = webFileCache.get(cacheKey);
if (cacheElement != null && cacheElement.getContent() instanceof WhitelistReader) {
return (WhitelistReader)cacheElement.getContent();
}
final WebFilesService service = getWebFilesService();
final Session session = requestContext.getSession();
final WebFileBundle webFileBundle = service.getJcrWebFileBundle(session, bundleName);
final WebFile webFile = getWebFileFromBundle(webFileBundle, WHITE_LIST_CONTENT_PATH, version);
final WhitelistReader whiteListReader = new WhitelistReader(webFile.getBinary().getStream());
final CacheElement whiteListReaderElement = webFileCache.createElement(cacheKey, whiteListReader);
webFileCache.put(whiteListReaderElement);
return whiteListReader;
} catch (Exception e) {
if (e instanceof WebFileNotFoundException) {
log.info("No '{}' configured in web files for '{}'. All web files will be whitelisted. In the next PATCH version " +
"(HST 3.1.1) all web files will be blacklisted if there is no '{}' configured in web files.",
WHITE_LIST_CONTENT_PATH, bundleName, WHITE_LIST_CONTENT_PATH);
}
clearBlockingLock(cacheKey);
throw e;
}
}