Package ome.services.blitz.repo.path
Class ServerFilePathTransformer
- java.lang.Object
-
- ome.services.blitz.repo.path.ServerFilePathTransformer
-
public class ServerFilePathTransformer extends java.lang.Object
Transform between repositoryFsFile
path and server-localFile
.- Since:
- 5.0
-
-
Constructor Summary
Constructors Constructor Description ServerFilePathTransformer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FsFile
getFsFileFromServerFile(java.io.File serverFile)
Given a server-localFile
, 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-localFile
.boolean
isLegalFsFile(FsFile fsFile)
Test if the givenFsFile
has been properly sanitized by the client.void
setBaseDirFile(java.io.File baseDirFile)
Set the repository root directory, to whichFsFile
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.
-
-
-
Method Detail
-
getServerFileFromFsFile
public java.io.File getServerFileFromFsFile(FsFile fsFile)
Given a repository path, returns the corresponding server-localFile
. 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-localFile
, returns the corresponding repository path. Must be executed server-side.- Parameters:
serverFile
- a server-localFile
within the repository- Returns:
- the corresponding repository path
-
isLegalFsFile
public boolean isLegalFsFile(FsFile fsFile)
Test if the givenFsFile
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 whichFsFile
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 foundjava.lang.IllegalArgumentException
- if the root directory does not exist
-
-