try { session = requestContext.getSession(); final String bundleName = WebFileUtils.getBundleName(requestContext); log.debug("Trying to get web file bundle '{}' with session user '{}'", bundleName, session.getUserID()); final WebFileBundle webFileBundle = service.getJcrWebFileBundle(session, bundleName);
final String templateFreeMarkerPath = WebFileUtils.webFilePathToJcrPath(componentConfiguration.getRenderPath()); final String webFileTemplateFreeMarkerPath = WebFileUtils.jcrPathToWebFilePath(templateFreeMarkerPath); variantWebFilePaths.add(webFileTemplateFreeMarkerPath); log.debug("Found variant '{}' for '{}'", variant.getPath(), templateFreeMarkerPath); final String variantJcrPath = variant.getPath(); final String variantWebFilePath = WebFileUtils.jcrPathToWebFilePath(variantJcrPath); variantWebFilePaths.add(variantWebFilePath); } else {
public Object findTemplateSource(String templateSource) throws IOException { if (templateSource == null || !templateSource.startsWith(ContainerConstants.FREEMARKER_WEB_FILE_TEMPLATE_PROTOCOL)) { return null; } String absPath = WebFileUtils.webFilePathToJcrPath(templateSource); log.info("Trying to load freemarker template for web file from '{}'", absPath); final RepositorySource repositorySource = getLoadingCache().get(absPath); if (repositorySource == null || !repositorySource.isFound()) { return null; } return repositorySource; }
final String bundleName = WebFileUtils.getBundleName(requestContext); log.debug("Trying to get web file bundle '{}' with session user '{}'", bundleName, session.getUserID()); final WebFileBundle webFileBundle = service.getJcrWebFileBundle(session, bundleName);
final Session session = reqContext.getSession(); final String bundleName = WebFileUtils.getBundleName(reqContext); try { final WebFileBundle webFileBundle = service.getJcrWebFileBundle(session, bundleName);
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; } }