Package org.nuxeo.ecm.core.blob
Class PathStrategy
- java.lang.Object
-
- org.nuxeo.ecm.core.blob.PathStrategy
-
- Direct Known Subclasses:
PathStrategyFlat
,PathStrategyShortened
,PathStrategySubDirs
public abstract class PathStrategy extends Object
Decides at what path a given key is stored.- Since:
- 11.1
-
-
Constructor Summary
Constructors Constructor Description PathStrategy(Path dir)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static void
atomicCopy(Path source, Path dest)
Does an atomic copy from source to dest.static void
atomicMove(Path source, Path dest)
Does an atomic move from source to dest.Path
createTempFile()
Creates a temporary file in a location suitable for efficient move to the final path for any key.String
getKeyForPath(String path)
Gets the key for a given storage path.abstract Path
getPathForKey(String key)
Gets the storage path for a given key.boolean
isTempFile(Path path)
Checks if the given file is a temporary fileprotected String
safePath(String key)
Converts a key to a safe path.protected String
safePathInverse(String path)
Inverse ofsafePath(java.lang.String)
.
-
-
-
Constructor Detail
-
PathStrategy
public PathStrategy(Path dir)
-
-
Method Detail
-
safePath
protected String safePath(String key)
Converts a key to a safe path.Different keys always map to different safe paths (no collision).
- Parameters:
key
- the key- Returns:
- the safe path
- Since:
- 11.5
-
safePathInverse
protected String safePathInverse(String path)
Inverse ofsafePath(java.lang.String)
.- Parameters:
path
- the safe path- Returns:
- the key, or
null
if the safe path is invalid - Since:
- 2021.8
-
createTempFile
public Path createTempFile()
Creates a temporary file in a location suitable for efficient move to the final path for any key.- Returns:
- the temporary file
-
isTempFile
public boolean isTempFile(Path path)
Checks if the given file is a temporary file- Parameters:
path
- the file- Returns:
true
if the file is a temporary file- Since:
- 11.5
-
getPathForKey
public abstract Path getPathForKey(String key)
Gets the storage path for a given key.- Parameters:
key
- the key- Returns:
- the file for this key
-
getKeyForPath
public String getKeyForPath(String path)
Gets the key for a given storage path.- Parameters:
path
- the path- Returns:
- the key
-
atomicMove
public static void atomicMove(Path source, Path dest) throws IOException
Does an atomic move from source to dest.- Parameters:
source
- the sourcedest
- the destination- Throws:
IOException
-
atomicCopy
public static void atomicCopy(Path source, Path dest) throws IOException
Does an atomic copy from source to dest.- Parameters:
source
- the sourcedest
- the destination- Throws:
IOException
- Since:
- 11.5
-
-