if (RequestUtils.isPrecompileRequest(request))
return SKIP_BODY;
Site site = request.getSite();
ContentRepository repository = site.getContentRepository();
if (repository == null) {
logger.debug("Unable to load content repository for site '{}'", site);
response.invalidate();
return SKIP_BODY;
}
// Create the file uri, either from the id or the path. If none is
// specified, issue a warning
ResourceURI uri = null;
if (StringUtils.isNotBlank(fileId)) {
uri = new FileResourceURIImpl(site, null, fileId);
} else if (StringUtils.isNotBlank(filePath)) {
uri = new FileResourceURIImpl(site, filePath, null);
} else {
throw new JspException("Neither resource id nor resource path were specified");
}
// Try to load the file from the content repository
try {
if (!repository.exists(uri)) {
logger.warn("Non existing file {} requested on {}", uri, request.getUrl());
return SKIP_BODY;
}
} catch (ContentRepositoryException e) {
logger.error("Error trying to look up file {} from {}", fileId, repository);
return SKIP_BODY;
}
FileResource file = null;
FileContent fileContent = null;
// Determine the languages
Language language = request.getLanguage();
// Store the result in the jsp page context
try {
file = (FileResource) repository.get(uri);
file.switchTo(language);
Language contentLanguage = null;
contentLanguage = LanguageUtils.getPreferredContentLanguage(file, request, site);
if (contentLanguage == null) {