Package ome.services.blitz.repo.path
Class ClientFilePathTransformer
- java.lang.Object
-
- ome.services.blitz.repo.path.ClientFilePathTransformer
-
public class ClientFilePathTransformer extends java.lang.Object
Transform client-localFile
to repositoryFsFile
path. Wholly thread-safe.- Since:
- 5.0
-
-
Constructor Summary
Constructors Constructor Description ClientFilePathTransformer(java.util.function.Function<java.lang.String,java.lang.String> pathSanitizer)
Construct a new client-side file path transformer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FsFile
getFsFileFromClientFile(java.io.File clientFile, int depth)
Given a client-localFile
, and a path component depth, returns the corresponding repository path.int
getMinimumDepth(java.util.Collection<java.io.File> files)
Get the smallest path component depth that allows the given set ofFile
s to be disambiguated.java.util.Set<java.util.Collection<java.io.File>>
getTooSimilarFiles(java.util.Set<java.io.File> files)
Get the files that are too similarly named.
-
-
-
Constructor Detail
-
ClientFilePathTransformer
public ClientFilePathTransformer(java.util.function.Function<java.lang.String,java.lang.String> pathSanitizer)
Construct a new client-side file path transformer.- Parameters:
pathSanitizer
- a file-path component string transformer whose behavior corresponds to that passed toServerFilePathTransformer.setPathSanitizer(java.util.function.Function<java.lang.String, java.lang.String>)
server-side.
-
-
Method Detail
-
getFsFileFromClientFile
public FsFile getFsFileFromClientFile(java.io.File clientFile, int depth) throws java.io.IOException
Given a client-localFile
, and a path component depth, returns the corresponding repository path. Must be executed client-side.- Parameters:
clientFile
- a client-localFile
depth
- the path component depth (including filename)- Returns:
- the corresponding repository path, intended to be safe cross-platform
- Throws:
java.io.IOException
- if the absolute path of theFile
could not be found
-
getMinimumDepth
public int getMinimumDepth(java.util.Collection<java.io.File> files) throws java.io.IOException
Get the smallest path component depth that allows the given set ofFile
s to be disambiguated. Must be executed client-side.- Parameters:
files
- a set ofFile
s- Returns:
- the minimum depth for disambiguating the
File
s, no less than 1 - Throws:
java.io.IOException
- if the absolute path of any of theFile
s could not be found
-
getTooSimilarFiles
public java.util.Set<java.util.Collection<java.io.File>> getTooSimilarFiles(java.util.Set<java.io.File> files) throws java.io.IOException
Get the files that are too similarly named.- Parameters:
files
- a set of files- Returns:
- the files grouped by those to which they are too similar,
or
null
if all the files are named sufficiently distinctly - Throws:
java.io.IOException
- if the absolute path of any of theFile
s could not be found
-
-