Package org.apache.sshd.sftp.server
Class AbstractSftpEventListenerAdapter
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.sftp.server.AbstractSftpEventListenerAdapter
- All Implemented Interfaces:
EventListener,SshdEventListener,SftpEventListener
public abstract class AbstractSftpEventListenerAdapter
extends AbstractLoggingBean
implements SftpEventListener
A no-op implementation of
SftpEventListener for those who wish to implement only a small number of methods.
By default, all non-overridden methods simply log at TRACE level their invocation parameters-
Field Summary
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidblocked(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, long length, int mask, Throwable thrown) Called after blocking a file sectionvoidblocking(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, long length, int mask) Called prior to blocking a file sectionvoidclosed(ServerSession session, String remoteHandle, Handle localHandle, Throwable thrown) Specified file / directory has been closedvoidclosing(ServerSession session, String remoteHandle, Handle localHandle) Specified file / directory about to be closedvoidCalled after creating a directoryvoidcreating(ServerSession session, Path path, Map<String, ?> attrs) Called prior to creating a directoryvoiddestroying(ServerSession session) Called when subsystem is destroyed since it was closedvoidexiting(ServerSession session, Handle handle) Called when subsystem is exiting due to being destroyedvoidinitialized(ServerSession session, int version) Called when the SFTP protocol has been initializedvoidlinked(ServerSession session, Path source, Path target, boolean symLink, Throwable thrown) Called after creating a linkvoidlinking(ServerSession session, Path source, Path target, boolean symLink) Called prior to creating a linkvoidmodifiedAttributes(ServerSession session, Path path, Map<String, ?> attrs, Throwable thrown) Called after modifying the attributes of a file / directoryvoidmodifyingAttributes(ServerSession session, Path path, Map<String, ?> attrs) Called prior to modifying the attributes of a file / directoryvoidmoved(ServerSession session, Path srcPath, Path dstPath, Collection<CopyOption> opts, Throwable thrown) Called after renaming a file / directoryvoidmoving(ServerSession session, Path srcPath, Path dstPath, Collection<CopyOption> opts) Called prior to renaming a file / directoryvoidopen(ServerSession session, String remoteHandle, Handle localHandle) Specified file / directory has been openedvoidopenFailed(ServerSession session, String remotePath, Path localPath, boolean isDirectory, Throwable thrown) Specified file / directory could not be opened - Note: this call may occur withoutSftpEventListener.opening(ServerSession, String, Handle)ever having been calledvoidopening(ServerSession session, String remoteHandle, Handle localHandle) Specified file / directory is being openedvoidread(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen, int readLen, Throwable thrown) Result of reading from a filevoidreadEntries(ServerSession session, String remoteHandle, DirectoryHandle localHandle, Map<String, Path> entries) Result of reading entries from a directory - Note: it may be a partial result if the directory contains more entries than can be accommodated in the responsevoidreading(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen) Preparing to read from a filevoidreadingEntries(ServerSession session, String remoteHandle, DirectoryHandle localHandle) About to read entries from a directory - Note: might not be the 1st time it is called for the directory in case several iterations are required in order to go through all the entries in the directoryvoidreceivedExtension(ServerSession session, String extension, int id) Called when a SFTP extension requestSftpConstants.SSH_FXP_EXTENDEDhas been received before it is processed.voidremoved(ServerSession session, Path path, boolean isDirectory, Throwable thrown) Called after a file has been removedvoidremoving(ServerSession session, Path path, boolean isDirectory) Called prior to removing a filevoidunblocked(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, long length, Throwable thrown) Called prior to un-blocking a file sectionvoidunblocking(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, long length) Called prior to un-blocking a file sectionvoidwriting(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen) Preparing to write to filevoidwritten(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen, Throwable thrown) Finished to writing to fileMethods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warnMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.sshd.sftp.server.SftpEventListener
received
-
Constructor Details
-
AbstractSftpEventListenerAdapter
protected AbstractSftpEventListenerAdapter()
-
-
Method Details
-
receivedExtension
Description copied from interface:SftpEventListenerCalled when a SFTP extension requestSftpConstants.SSH_FXP_EXTENDEDhas been received before it is processed.- Specified by:
receivedExtensionin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was receivedextension- The extension request received; one of theSSH_EXT_*constants fromSftpConstantsid- The id received with the request- Throws:
IOException- If the request shall generate an error response.
-
initialized
Description copied from interface:SftpEventListenerCalled when the SFTP protocol has been initialized- Specified by:
initializedin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledversion- The negotiated SFTP version- Throws:
IOException- If failed to handle the call
-
destroying
Description copied from interface:SftpEventListenerCalled when subsystem is destroyed since it was closed- Specified by:
destroyingin interfaceSftpEventListener- Parameters:
session- The associatedServerSession- Throws:
IOException- If failed to handle the call
-
opening
public void opening(ServerSession session, String remoteHandle, Handle localHandle) throws IOException Description copied from interface:SftpEventListenerSpecified file / directory is being opened- Specified by:
openingin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the file / directorylocalHandle- The associated file / directoryHandle- Throws:
IOException- If failed to handle the call
-
openFailed
public void openFailed(ServerSession session, String remotePath, Path localPath, boolean isDirectory, Throwable thrown) throws IOException Description copied from interface:SftpEventListenerSpecified file / directory could not be opened - Note: this call may occur withoutSftpEventListener.opening(ServerSession, String, Handle)ever having been called- Specified by:
openFailedin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledremotePath- The path that was specified in the commandlocalPath- The matching resolved local pathisDirectory- Whether this was a folder or a filethrown- Non-nullreason for the failure- Throws:
IOException- If failed to handle the call
-
open
Description copied from interface:SftpEventListenerSpecified file / directory has been opened- Specified by:
openin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the file / directorylocalHandle- The associated file / directoryHandle- Throws:
IOException- If failed to handle the call
-
readingEntries
public void readingEntries(ServerSession session, String remoteHandle, DirectoryHandle localHandle) throws IOException Description copied from interface:SftpEventListenerAbout to read entries from a directory - Note: might not be the 1st time it is called for the directory in case several iterations are required in order to go through all the entries in the directory- Specified by:
readingEntriesin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the directorylocalHandle- The associatedDirectoryHandle- Throws:
IOException- If failed to handle the call- See Also:
-
readEntries
public void readEntries(ServerSession session, String remoteHandle, DirectoryHandle localHandle, Map<String, Path> entries) throws IOExceptionDescription copied from interface:SftpEventListenerResult of reading entries from a directory - Note: it may be a partial result if the directory contains more entries than can be accommodated in the response- Specified by:
readEntriesin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the directorylocalHandle- The associatedDirectoryHandleentries- AMapof the listed entries - key = short name, value =Pathof the sub-entry- Throws:
IOException- If failed to handle the call
-
reading
public void reading(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen) throws IOException Description copied from interface:SftpEventListenerPreparing to read from a file- Specified by:
readingin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the filelocalHandle- The associatedFileHandleoffset- Offset in file from which to readdata- Buffer holding the read datadataOffset- Offset of read data in bufferdataLen- Requested read length- Throws:
IOException- If failed to handle the call
-
read
public void read(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen, int readLen, Throwable thrown) throws IOException Description copied from interface:SftpEventListenerResult of reading from a file- Specified by:
readin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the filelocalHandle- The associatedFileHandleoffset- Offset in file from which to readdata- Buffer holding the read datadataOffset- Offset of read data in bufferdataLen- Requested read lengthreadLen- Actual read length - negative if thrown exception providedthrown- Non-nullif read failed due to this exception- Throws:
IOException- If failed to handle the call
-
writing
public void writing(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen) throws IOException Description copied from interface:SftpEventListenerPreparing to write to file- Specified by:
writingin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the filelocalHandle- The associatedFileHandleoffset- Offset in file to which to writedata- Buffer holding the written datadataOffset- Offset of write data in bufferdataLen- Requested write length- Throws:
IOException- If failed to handle the call
-
written
public void written(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, byte[] data, int dataOffset, int dataLen, Throwable thrown) throws IOException Description copied from interface:SftpEventListenerFinished to writing to file- Specified by:
writtenin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the filelocalHandle- The associatedFileHandleoffset- Offset in file to which to writedata- Buffer holding the written datadataOffset- Offset of write data in bufferdataLen- Requested write lengththrown- The reason for failing to write -nullif successful- Throws:
IOException- If failed to handle the call
-
blocking
public void blocking(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, long length, int mask) throws IOException Description copied from interface:SftpEventListenerCalled prior to blocking a file section- Specified by:
blockingin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the filelocalHandle- The associatedFileHandleoffset- Offset in file for lockinglength- Section size for lockingmask- Lock mask flags - seeSSH_FXP_BLOCKmessage- Throws:
IOException- If failed to handle the call- See Also:
-
blocked
public void blocked(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, long length, int mask, Throwable thrown) throws IOException Description copied from interface:SftpEventListenerCalled after blocking a file section- Specified by:
blockedin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the filelocalHandle- The associatedFileHandleoffset- Offset in file for lockinglength- Section size for lockingmask- Lock mask flags - seeSSH_FXP_BLOCKmessagethrown- If not-nullthen the reason for the failure to execute- Throws:
IOException- If failed to handle the call
-
unblocking
public void unblocking(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, long length) throws IOException Description copied from interface:SftpEventListenerCalled prior to un-blocking a file section- Specified by:
unblockingin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the filelocalHandle- The associatedFileHandleoffset- Offset in file for un-lockinglength- Section size for un-locking- Throws:
IOException- If failed to handle the call
-
unblocked
public void unblocked(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, long length, Throwable thrown) throws IOException Description copied from interface:SftpEventListenerCalled prior to un-blocking a file section- Specified by:
unblockedin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the filelocalHandle- The associatedFileHandleoffset- Offset in file for un-lockinglength- Section size for un-lockingthrown- If not-nullthen the reason for the failure to execute- Throws:
IOException- If failed to handle the call
-
closing
public void closing(ServerSession session, String remoteHandle, Handle localHandle) throws IOException Description copied from interface:SftpEventListenerSpecified file / directory about to be closed- Specified by:
closingin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the file / directorylocalHandle- The associated file / directoryHandle- Throws:
IOException- If failed to handle the call
-
closed
public void closed(ServerSession session, String remoteHandle, Handle localHandle, Throwable thrown) throws IOException Description copied from interface:SftpEventListenerSpecified file / directory has been closed- Specified by:
closedin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledremoteHandle- The (opaque) assigned handle for the file / directorylocalHandle- The associated file / directoryHandlethrown- If not-nullthen the reason for the failure to execute- Throws:
IOException- If failed to handle the call
-
creating
Description copied from interface:SftpEventListenerCalled prior to creating a directory- Specified by:
creatingin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledpath- DirectoryPathto be createdattrs- Requested associated attributes to set- Throws:
IOException- If failed to handle the call- See Also:
-
created
public void created(ServerSession session, Path path, Map<String, ?> attrs, Throwable thrown) throws IOExceptionDescription copied from interface:SftpEventListenerCalled after creating a directory- Specified by:
createdin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledpath- DirectoryPathto be createdattrs- Requested associated attributes to setthrown- If not-nullthen the reason for the failure to execute- Throws:
IOException- If failed to handle the call
-
moving
public void moving(ServerSession session, Path srcPath, Path dstPath, Collection<CopyOption> opts) throws IOException Description copied from interface:SftpEventListenerCalled prior to renaming a file / directory- Specified by:
movingin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledsrcPath- The sourcePathdstPath- The targetPathopts- The resolved renaming options- Throws:
IOException- If failed to handle the call- See Also:
-
moved
public void moved(ServerSession session, Path srcPath, Path dstPath, Collection<CopyOption> opts, Throwable thrown) throws IOException Description copied from interface:SftpEventListenerCalled after renaming a file / directory- Specified by:
movedin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledsrcPath- The sourcePathdstPath- The targetPathopts- The resolved renaming optionsthrown- If not-nullthen the reason for the failure to execute- Throws:
IOException- If failed to handle the call
-
removing
Description copied from interface:SftpEventListenerCalled prior to removing a file- Specified by:
removingin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledpath- ThePathabout to be removedisDirectory- Whether this is a folder or a file- Throws:
IOException- If failed to handle the call- See Also:
-
removed
public void removed(ServerSession session, Path path, boolean isDirectory, Throwable thrown) throws IOException Description copied from interface:SftpEventListenerCalled after a file has been removed- Specified by:
removedin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledpath- ThePathto be removedisDirectory- Whether this was a folder or a filethrown- If not-nullthen the reason for the failure to execute- Throws:
IOException- If failed to handle the call
-
linking
public void linking(ServerSession session, Path source, Path target, boolean symLink) throws IOException Description copied from interface:SftpEventListenerCalled prior to creating a link- Specified by:
linkingin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledsource- The sourcePathtarget- The targetPathsymLink-true= symbolic link- Throws:
IOException- If failed to handle the call- See Also:
-
linked
public void linked(ServerSession session, Path source, Path target, boolean symLink, Throwable thrown) throws IOException Description copied from interface:SftpEventListenerCalled after creating a link- Specified by:
linkedin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledsource- The sourcePathtarget- The targetPathsymLink-true= symbolic linkthrown- If not-nullthen the reason for the failure to execute- Throws:
IOException- If failed to handle the call
-
modifyingAttributes
public void modifyingAttributes(ServerSession session, Path path, Map<String, ?> attrs) throws IOExceptionDescription copied from interface:SftpEventListenerCalled prior to modifying the attributes of a file / directory- Specified by:
modifyingAttributesin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledpath- The file / directoryPathto be modifiedattrs- The attributesMap- names and values depend on the O/S, view, type, etc...- Throws:
IOException- If failed to handle the call- See Also:
-
modifiedAttributes
public void modifiedAttributes(ServerSession session, Path path, Map<String, ?> attrs, Throwable thrown) throws IOExceptionDescription copied from interface:SftpEventListenerCalled after modifying the attributes of a file / directory- Specified by:
modifiedAttributesin interfaceSftpEventListener- Parameters:
session- TheServerSessionthrough which the request was handledpath- The file / directoryPathto be modifiedattrs- The attributesMap- names and values depend on the O/S, view, type, etc...thrown- If not-nullthen the reason for the failure to execute- Throws:
IOException- If failed to handle the call
-
exiting
Description copied from interface:SftpEventListenerCalled when subsystem is exiting due to being destroyed- Specified by:
exitingin interfaceSftpEventListener- Parameters:
session- The associatedServerSessionhandle- The file / directoryHandlebeing closed due to the exit- Throws:
IOException- If failed to handle the call
-