Package org.ametys.site
Class SiteCacheHelper
- java.lang.Object
-
- org.ametys.site.SiteCacheHelper
-
public final class SiteCacheHelper extends Object
Class providing helper methods for cache files.
-
-
Field Summary
Fields Modifier and Type Field Description private static String
__MD5_PREFIX
-
Constructor Summary
Constructors Modifier Constructor Description private
SiteCacheHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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
getRootCache()
Return the root cache fileprivate static String
hashPath(String path, boolean encode)
Hash the resource pathstatic boolean
isValid(File file)
Test if a file is valid.static boolean
isValid(FileSource fileSource)
Test if a file source is valid.
-
-
-
Field Detail
-
__MD5_PREFIX
private static final String __MD5_PREFIX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SiteCacheHelper
private SiteCacheHelper()
-
-
Method Detail
-
getRootCache
public static File getRootCache()
Return the root cache file- Returns:
- The root cache File
-
isValid
public static boolean isValid(File file)
Test if a file is valid.- Parameters:
file
- the file to test.- Returns:
- true if the file is valid, false otherwise.
-
isValid
public static boolean isValid(FileSource fileSource)
Test if a file source is valid.- Parameters:
fileSource
- the file source to test.- Returns:
- true if the file is valid, false otherwise.
-
getHashedFilePath
public static String getHashedFilePath(File file)
Get a hashed file path for the given file.- Parameters:
file
- the original resource file.- Returns:
- the hashed file path.
-
getHashedFilePath
public static String getHashedFilePath(File file, boolean encode)
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
public static String getHashedFilePath(String filePath)
Get a hashed version of the given file path.- Parameters:
filePath
- the original file path.- Returns:
- the hashed file path.
-
getHashedFilePath
public static String getHashedFilePath(String filePath, boolean encode)
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.
-
-