public interface ScpFileOpener
Modifier and Type | Method and Description |
---|---|
default void |
closeRead(Session session,
java.nio.file.Path file,
long size,
java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions,
java.io.InputStream stream)
Called when the stream obtained from
openRead is no
longer required since data has been successfully copied. |
default void |
closeWrite(Session session,
java.nio.file.Path file,
long size,
java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions,
java.io.OutputStream os)
Called when output stream obtained from
openWrite is
no longer needed since data copying has been successfully completed. |
ScpSourceStreamResolver |
createScpSourceStreamResolver(Session session,
java.nio.file.Path path) |
ScpTargetStreamResolver |
createScpTargetStreamResolver(Session session,
java.nio.file.Path path) |
default java.nio.file.attribute.BasicFileAttributes |
getLocalBasicFileAttributes(Session session,
java.nio.file.Path path,
java.nio.file.LinkOption... options) |
default java.util.Set<java.nio.file.attribute.PosixFilePermission> |
getLocalFilePermissions(Session session,
java.nio.file.Path path,
java.nio.file.LinkOption... options) |
default java.nio.file.DirectoryStream<java.nio.file.Path> |
getLocalFolderChildren(Session session,
java.nio.file.Path path)
Invoked when required to send all children of a local directory
|
default java.lang.Iterable<java.nio.file.Path> |
getMatchingFilesToSend(Session session,
java.nio.file.Path basedir,
java.lang.String pattern)
Invoked when required to send a pattern of files
|
java.io.InputStream |
openRead(Session session,
java.nio.file.Path file,
long size,
java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions,
java.nio.file.OpenOption... options)
Create an input stream to read from a file
|
java.io.OutputStream |
openWrite(Session session,
java.nio.file.Path file,
long size,
java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions,
java.nio.file.OpenOption... options)
Create an output stream to write to a file
|
default java.nio.file.Path |
resolveIncomingFilePath(Session session,
java.nio.file.Path localPath,
java.lang.String name,
boolean preserve,
java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions,
ScpTimestampCommandDetails time)
Invoked when receiving a new file to via a directory command
|
default java.nio.file.Path |
resolveIncomingReceiveLocation(Session session,
java.nio.file.Path path,
boolean recursive,
boolean shouldBeDir,
boolean preserve)
Invoked when a request to receive something is processed
|
default java.nio.file.Path |
resolveLocalPath(Session session,
java.nio.file.FileSystem fileSystem,
java.lang.String commandPath) |
default java.nio.file.Path |
resolveOutgoingFilePath(Session session,
java.nio.file.Path localPath,
java.nio.file.LinkOption... options)
Called when there is a candidate file/folder for sending
|
default boolean |
sendAsDirectory(Session session,
java.nio.file.Path path,
java.nio.file.LinkOption... options)
Invoked on a local path in order to decide whether it should be sent as a file or as a directory
|
default boolean |
sendAsRegularFile(Session session,
java.nio.file.Path path,
java.nio.file.LinkOption... options)
Invoked on a local path in order to decide whether it should be sent as a file or as a directory
|
static void |
updateFileProperties(java.nio.file.Path file,
java.util.Set<java.nio.file.attribute.PosixFilePermission> perms,
ScpTimestampCommandDetails time) |
default java.nio.file.Path resolveIncomingFilePath(Session session, java.nio.file.Path localPath, java.lang.String name, boolean preserve, java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions, ScpTimestampCommandDetails time) throws java.io.IOException
session
- The client/server Session
through which the transfer is being executedlocalPath
- The target local pathname
- The target file namepreserve
- Whether requested to preserve the permissions and timestamppermissions
- The requested file permissionstime
- The requested ScpTimestampCommandDetails
- may be null
if nothing to updatejava.io.IOException
- If failed to resolve the file pathupdateFileProperties
default java.lang.Iterable<java.nio.file.Path> getMatchingFilesToSend(Session session, java.nio.file.Path basedir, java.lang.String pattern) throws java.io.IOException
session
- The client/server Session
through which the transfer is being executedbasedir
- The base directory - may be null
/empty to indicate CWDpattern
- The required pattern - ignored if null
/empty - returns empty resultjava.io.IOException
- If failed to scan the directorydefault boolean sendAsRegularFile(Session session, java.nio.file.Path path, java.nio.file.LinkOption... options) throws java.io.IOException
session
- The client/server Session
through which the transfer is being executedpath
- The local Path
options
- The LinkOption
-sfalse
then the
sendAsDirectory(Session, Path, LinkOption...)
is consulted.java.io.IOException
- If failed to decidedefault boolean sendAsDirectory(Session session, java.nio.file.Path path, java.nio.file.LinkOption... options) throws java.io.IOException
session
- The client/server Session
through which the transfer is being executedpath
- The local Path
options
- The LinkOption
-strue
then
getLocalFolderChildren(Session, Path)
is consultedjava.io.IOException
- If failed to decidedefault java.nio.file.DirectoryStream<java.nio.file.Path> getLocalFolderChildren(Session session, java.nio.file.Path path) throws java.io.IOException
session
- The client/server Session
through which the transfer is being executedpath
- The local folder Path
DirectoryStream
of children to send - Note: for each child the decision
whether to send it as a file or a directory will be reached by consulting the respective
sendAsRegularFile
and
sendAsDirectory
methodsjava.io.IOException
- If failed to provide the children streamsendAsDirectory
default java.nio.file.attribute.BasicFileAttributes getLocalBasicFileAttributes(Session session, java.nio.file.Path path, java.nio.file.LinkOption... options) throws java.io.IOException
java.io.IOException
default java.util.Set<java.nio.file.attribute.PosixFilePermission> getLocalFilePermissions(Session session, java.nio.file.Path path, java.nio.file.LinkOption... options) throws java.io.IOException
java.io.IOException
default java.nio.file.Path resolveLocalPath(Session session, java.nio.file.FileSystem fileSystem, java.lang.String commandPath) throws java.io.IOException, java.nio.file.InvalidPathException
session
- The client/server Session
through which the transfer is being executedfileSystem
- The local FileSystem
on which local file should residecommandPath
- The command path using the local file separatorPath
java.io.IOException
- If failed to resolve the pathjava.nio.file.InvalidPathException
- If invalid local path valuedefault java.nio.file.Path resolveIncomingReceiveLocation(Session session, java.nio.file.Path path, boolean recursive, boolean shouldBeDir, boolean preserve) throws java.io.IOException
session
- The client/server Session
through which the transfer is being executedpath
- The local target Path
of the requestrecursive
- Whether the request is recursiveshouldBeDir
- Whether target path is expected to be a directorypreserve
- Whether target path is expected to preserve attributes (permissions, times)java.io.IOException
- If failed to resolve target locationdefault java.nio.file.Path resolveOutgoingFilePath(Session session, java.nio.file.Path localPath, java.nio.file.LinkOption... options) throws java.io.IOException
session
- The client/server Session
through which the transfer is being executedlocalPath
- The original file/folder Path
for sendingoptions
- The LinkOption
-s to use for validationjava.io.IOException
- If failed to resolvejava.io.InputStream openRead(Session session, java.nio.file.Path file, long size, java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions, java.nio.file.OpenOption... options) throws java.io.IOException
session
- The Session
requesting the accessfile
- The requested local file Path
size
- The expected transfer bytes countpermissions
- The requested file permissionsoptions
- The OpenOption
s - may be null
/emptyInputStream
never null
java.io.IOException
- If failed to open the filedefault void closeRead(Session session, java.nio.file.Path file, long size, java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions, java.io.InputStream stream) throws java.io.IOException
openRead
is no
longer required since data has been successfully copied.session
- The Session
requesting the accessfile
- The requested local file Path
size
- The expected transfer bytes countpermissions
- The requested file permissionsstream
- The InputStream
to closejava.io.IOException
- If failed to close the stream - Note: stream will be closed regardless of whether this
method throws an exception or not.ScpSourceStreamResolver createScpSourceStreamResolver(Session session, java.nio.file.Path path) throws java.io.IOException
java.io.IOException
java.io.OutputStream openWrite(Session session, java.nio.file.Path file, long size, java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions, java.nio.file.OpenOption... options) throws java.io.IOException
session
- The Session
requesting the accessfile
- The requested local file Path
size
- The expected transfer byte countpermissions
- The requested file permissionsoptions
- The OpenOption
s - may be null
/emptyOutputStream
never null
java.io.IOException
- If failed to open the filedefault void closeWrite(Session session, java.nio.file.Path file, long size, java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions, java.io.OutputStream os) throws java.io.IOException
openWrite
is
no longer needed since data copying has been successfully completed.session
- The Session
requesting the accessfile
- The requested local file Path
size
- The expected transfer byte countpermissions
- The requested file permissionsos
- The opened OutputStream
java.io.IOException
- If failed to close the stream - Note: stream will be closed regardless of whether this
method throws an exception or not.ScpTargetStreamResolver createScpTargetStreamResolver(Session session, java.nio.file.Path path) throws java.io.IOException
java.io.IOException
static void updateFileProperties(java.nio.file.Path file, java.util.Set<java.nio.file.attribute.PosixFilePermission> perms, ScpTimestampCommandDetails time) throws java.io.IOException
java.io.IOException