Class ClientFilePathTransformer


  • public class ClientFilePathTransformer
    extends java.lang.Object
    Transform client-local File to repository FsFile 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-local File, 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 of Files 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getFsFileFromClientFile

        public FsFile getFsFileFromClientFile​(java.io.File clientFile,
                                              int depth)
                                       throws java.io.IOException
        Given a client-local File, and a path component depth, returns the corresponding repository path. Must be executed client-side.
        Parameters:
        clientFile - a client-local File
        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 the File 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 of Files to be disambiguated. Must be executed client-side.
        Parameters:
        files - a set of Files
        Returns:
        the minimum depth for disambiguating the Files, no less than 1
        Throws:
        java.io.IOException - if the absolute path of any of the Files 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 the Files could not be found