Package org.ametys.site
Class SiteCacheHelper
java.lang.Object
org.ametys.site.SiteCacheHelper
Class providing helper methods for cache files.
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
getHashedFilePath
(File file) Get a hashed file path for the given file.static String
getHashedFilePath
(File file, boolean encode) Get a hashed file path for the given file.static String
getHashedFilePath
(String filePath) Get a hashed version of the given file path.static String
getHashedFilePath
(String filePath, boolean encode) Get a hashed version of the given file path.static Source
getHashedFileSource
(SourceResolver resolver, FileSource source) Release the given file source and resolve a hashed version of the file to replace it.static File
Return the root cache filestatic boolean
Test if a file is valid.static boolean
isValid
(FileSource fileSource) Test if a file source is valid.
-
Method Details
-
getRootCache
Return the root cache file- Returns:
- The root cache File
-
isValid
Test if a file is valid.- Parameters:
file
- the file to test.- Returns:
- true if the file is valid, false otherwise.
-
isValid
Test if a file source is valid.- Parameters:
fileSource
- the file source to test.- Returns:
- true if the file is valid, false otherwise.
-
getHashedFilePath
Get a hashed file path for the given file.- Parameters:
file
- the original resource file.- Returns:
- the hashed file path.
-
getHashedFilePath
Get a hashed file path for the given file.- Parameters:
file
- the original resource file.encode
- true to encode the folder parts, false otherwise.- Returns:
- the hashed file path.
-
getHashedFilePath
Get a hashed version of the given file path.- Parameters:
filePath
- the original file path.- Returns:
- the hashed file path.
-
getHashedFilePath
Get a hashed version of the given file path.- Parameters:
filePath
- the original file path.encode
- true to encode the folder parts, false otherwise.- Returns:
- the hashed file path.
-
getHashedFileSource
public static Source getHashedFileSource(SourceResolver resolver, FileSource source) throws IOException, ProcessingException Release the given file source and resolve a hashed version of the file to replace it.- Parameters:
resolver
- the source resolver.source
- the invalid file source to hash.- Returns:
- the hashed file source.
- Throws:
IOException
- if an IO error occurs.ProcessingException
- if the new source couldn't be resolved.
-