Class ServerFilePathTransformer


  • public class ServerFilePathTransformer
    extends java.lang.Object
    Transform between repository FsFile path and server-local File.
    Since:
    5.0
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      FsFile getFsFileFromServerFile​(java.io.File serverFile)
      Given a server-local File, returns the corresponding repository path.
      java.util.function.Function<java.lang.String,​java.lang.String> getPathSanitizer()
      Get the string transformer that is used to make file-path components safe across platforms.
      java.io.File getServerFileFromFsFile​(FsFile fsFile)
      Given a repository path, returns the corresponding server-local File.
      boolean isLegalFsFile​(FsFile fsFile)
      Test if the given FsFile has been properly sanitized by the client.
      void setBaseDirFile​(java.io.File baseDirFile)
      Set the repository root directory, to which FsFile instances are considered to be relative.
      void setPathSanitizer​(java.util.function.Function<java.lang.String,​java.lang.String> pathSanitizer)
      Set the string transformer that is used to make file-path components safe across platforms.
      • Methods inherited from class java.lang.Object

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

      • ServerFilePathTransformer

        public ServerFilePathTransformer()
    • Method Detail

      • getServerFileFromFsFile

        public java.io.File getServerFileFromFsFile​(FsFile fsFile)
        Given a repository path, returns the corresponding server-local File. Must be executed server-side.
        Parameters:
        fsFile - a repository path
        Returns:
        the corresponding server-local File
      • getFsFileFromServerFile

        public FsFile getFsFileFromServerFile​(java.io.File serverFile)
        Given a server-local File, returns the corresponding repository path. Must be executed server-side.
        Parameters:
        serverFile - a server-local File within the repository
        Returns:
        the corresponding repository path
      • isLegalFsFile

        public boolean isLegalFsFile​(FsFile fsFile)
        Test if the given FsFile has been properly sanitized by the client.
        Parameters:
        fsFile - a repository path
        Returns:
        if the path is sanitary
      • getPathSanitizer

        public java.util.function.Function<java.lang.String,​java.lang.String> getPathSanitizer()
        Get the string transformer that is used to make file-path components safe across platforms.
        Returns:
        the file-path component string transformer
      • setPathSanitizer

        public void setPathSanitizer​(java.util.function.Function<java.lang.String,​java.lang.String> pathSanitizer)
        Set the string transformer that is used to make file-path components safe across platforms. This is not required to be an injective function; two different components may transform to the same.
        Parameters:
        pathSanitizer - the file-path component string transformer
      • setBaseDirFile

        public void setBaseDirFile​(java.io.File baseDirFile)
        Set the repository root directory, to which FsFile instances are considered to be relative.
        Parameters:
        baseDirFile - the repository root directory
        Throws:
        java.io.IOException - if the absolute path of the root directory could not be found
        java.lang.IllegalArgumentException - if the root directory does not exist