Package ome.services.blitz.repo.path
Class ClientFilePathTransformer
- java.lang.Object
-
- ome.services.blitz.repo.path.ClientFilePathTransformer
-
public class ClientFilePathTransformer extends java.lang.ObjectTransform client-localFileto repositoryFsFilepath. 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 FsFilegetFsFileFromClientFile(java.io.File clientFile, int depth)Given a client-localFile, and a path component depth, returns the corresponding repository path.intgetMinimumDepth(java.util.Collection<java.io.File> files)Get the smallest path component depth that allows the given set ofFiles 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-localFiledepth- 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 theFilecould not be found
-
getMinimumDepth
public int getMinimumDepth(java.util.Collection<java.io.File> files) throws java.io.IOExceptionGet the smallest path component depth that allows the given set ofFiles to be disambiguated. Must be executed client-side.- Parameters:
files- a set ofFiles- Returns:
- the minimum depth for disambiguating the
Files, no less than 1 - Throws:
java.io.IOException- if the absolute path of any of theFiles 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.IOExceptionGet 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
nullif all the files are named sufficiently distinctly - Throws:
java.io.IOException- if the absolute path of any of theFiles could not be found
-
-