} 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) {
logger.warn("File {} does not have suitable content", file);
return SKIP_BODY;
}
fileContent = file.getContent(contentLanguage);
} catch (ContentRepositoryException e) {
logger.warn("Error trying to load file " + uri + ": " + e.getMessage(), e);
return SKIP_BODY;
}
// TODO: Check the permissions
// Store the file and the file content in the request
stashAndSetAttribute(FileResourceTagExtraInfo.FILE, file);
stashAndSetAttribute(FileResourceTagExtraInfo.FILE_CONTENT, fileContent);
// Add cache tags to response
response.addTag(CacheTag.Resource, file.getURI().getIdentifier());
response.addTag(CacheTag.Url, file.getURI().getPath());
return EVAL_BODY_INCLUDE;
}