public interface SftpFileSystemAccessor
Modifier and Type | Field and Description |
---|---|
static SftpFileSystemAccessor |
DEFAULT |
static boolean |
DEFAULT_AUTO_SYNC_FILE_ON_CLOSE
Default value for "sftp-auto-fsync-on-close" if none set
|
static List<String> |
DEFAULT_UNIX_VIEW |
static NavigableMap<String,FileInfoExtractor<?>> |
FILEATTRS_RESOLVERS
A case insensitive
NavigableMap of FileInfoExtractor s to be used to complete attributes
that are deemed important enough to warrant an extra effort if not accessible via the file system attributes
views |
static String |
PROP_AUTO_SYNC_FILE_ON_CLOSE
Whether to invoke
FileChannel.force(boolean) on files open for write when closing |
Modifier and Type | Method and Description |
---|---|
default void |
applyExtensionFileAttributes(SftpSubsystemProxy subsystem,
Path file,
Map<String,byte[]> extensions,
LinkOption... options)
Invoked in order to allow processing of custom file attributes
|
default void |
closeDirectory(SftpSubsystemProxy subsystem,
DirectoryHandle dirHandle,
Path dir,
String handle,
DirectoryStream<Path> ds)
Called when a directory stream is no longer required
|
default void |
closeFile(SftpSubsystemProxy subsystem,
FileHandle fileHandle,
Path file,
String handle,
Channel channel,
Set<? extends OpenOption> options)
Called to inform the accessor that it should close the file
|
default void |
copyFile(SftpSubsystemProxy subsystem,
Path src,
Path dst,
Collection<CopyOption> opts) |
default void |
createDirectory(SftpSubsystemProxy subsystem,
Path path) |
default void |
createLink(SftpSubsystemProxy subsystem,
Path link,
Path existing,
boolean symLink)
Invoked in order to create a link to a path
|
default boolean |
noFollow(Collection<?> opts) |
default DirectoryStream<Path> |
openDirectory(SftpSubsystemProxy subsystem,
DirectoryHandle dirHandle,
Path dir,
String handle,
LinkOption... linkOptions)
Called when a new directory stream is requested
|
default SeekableByteChannel |
openFile(SftpSubsystemProxy subsystem,
FileHandle fileHandle,
Path file,
String handle,
Set<? extends OpenOption> options,
FileAttribute<?>... attrs)
Called whenever a new file is opened
|
default void |
putRemoteFileName(SftpSubsystemProxy subsystem,
Path path,
Buffer buf,
String name,
boolean shortName)
Invoked in order to encode the outgoing referenced file name/path
|
default Map<String,?> |
readFileAttributes(SftpSubsystemProxy subsystem,
Path file,
String view,
LinkOption... options)
Invoked when required to retrieve file attributes for a specific file system view
|
default void |
removeFile(SftpSubsystemProxy subsystem,
Path path,
boolean isDirectory) |
default void |
renameFile(SftpSubsystemProxy subsystem,
Path oldPath,
Path newPath,
Collection<CopyOption> opts) |
default LinkOption[] |
resolveFileAccessLinkOptions(SftpSubsystemProxy subsystem,
Path file,
int cmd,
String extension,
boolean followLinks)
Invoked in order to determine the symbolic link follow options
|
default UserPrincipal |
resolveFileOwner(SftpSubsystemProxy subsystem,
Path file,
UserPrincipal name) |
default GroupPrincipal |
resolveGroupOwner(SftpSubsystemProxy subsystem,
Path file,
GroupPrincipal name) |
default String |
resolveLinkTarget(SftpSubsystemProxy subsystem,
Path link) |
default Path |
resolveLocalFilePath(SftpSubsystemProxy subsystem,
Path rootDir,
String remotePath)
Invoked in order to resolve remote file paths reference by the client into ones accessible by the server
|
default NavigableMap<String,Object> |
resolveReportedFileAttributes(SftpSubsystemProxy subsystem,
Path file,
int flags,
NavigableMap<String,Object> attrs,
LinkOption... options)
Invoked in order to allow intervention to the reported file attributes - e.g., add custom/extended properties
|
static SecureDirectoryStream<Path> |
secure(DirectoryStream<Path> ds) |
static SecureDirectoryStream<Path> |
secureResolveDirectoryStream(Path toResolve) |
static SeekableByteChannel |
seekableByteChannelNoLinkFollow(Path src,
Set<? extends OpenOption> opts,
FileAttribute<?>... fileAttributes) |
default void |
setFileAccessControl(SftpSubsystemProxy subsystem,
Path file,
List<AclEntry> acl,
LinkOption... options) |
default void |
setFileAttribute(SftpSubsystemProxy subsystem,
Path file,
String view,
String attribute,
Object value,
LinkOption... options)
Sets a view attribute for a local file
|
default void |
setFileOwner(SftpSubsystemProxy subsystem,
Path file,
Principal value,
LinkOption... options) |
default void |
setFilePermissions(SftpSubsystemProxy subsystem,
Path file,
Set<PosixFilePermission> perms,
LinkOption... options) |
default void |
setGroupOwner(SftpSubsystemProxy subsystem,
Path file,
Principal value,
LinkOption... options) |
default void |
syncFileData(SftpSubsystemProxy subsystem,
FileHandle fileHandle,
Path file,
String handle,
Channel channel)
Called when file meta-data re-synchronization is required
|
default FileLock |
tryLock(SftpSubsystemProxy subsystem,
FileHandle fileHandle,
Path file,
String handle,
Channel channel,
long position,
long size,
boolean shared)
Called when locking a section of a file is requested
|
static final NavigableMap<String,FileInfoExtractor<?>> FILEATTRS_RESOLVERS
NavigableMap
of FileInfoExtractor
s to be used to complete attributes
that are deemed important enough to warrant an extra effort if not accessible via the file system attributes
viewsstatic final String PROP_AUTO_SYNC_FILE_ON_CLOSE
FileChannel.force(boolean)
on files open for write when closingstatic final boolean DEFAULT_AUTO_SYNC_FILE_ON_CLOSE
static final SftpFileSystemAccessor DEFAULT
default Path resolveLocalFilePath(SftpSubsystemProxy subsystem, Path rootDir, String remotePath) throws IOException, InvalidPathException
subsystem
- The SFTP subsystem instance that manages the sessionrootDir
- The default root directory used to resolve relative paths - a.k.a. the
chroot
locationremotePath
- The remote path - separated by '/'Path
IOException
- If failed to resolve the local pathInvalidPathException
- If bad local path specificationSftpSubsystemEnvironment#getDefaultDirectory()
default LinkOption[] resolveFileAccessLinkOptions(SftpSubsystemProxy subsystem, Path file, int cmd, String extension, boolean followLinks) throws IOException
subsystem
- The SFTP subsystem instance that manages the sessionfile
- The referenced filecmd
- The SFTP command that triggered this accessextension
- The SFTP extension that triggered this access - non-empty only for {SSH_FXP_EXTENDED} commandfollowLinks
- Whether to follow symbolic linksLinkOption
-s to use - invokes IoUtils.getLinkOptions(boolean)
by defaultIOException
- if failed to resolve the required optionsdefault NavigableMap<String,Object> resolveReportedFileAttributes(SftpSubsystemProxy subsystem, Path file, int flags, NavigableMap<String,Object> attrs, LinkOption... options) throws IOException
subsystem
- The SFTP subsystem instance that manages the sessionfile
- The referenced fileflags
- A mask of the original required attributesattrs
- The default resolved attributes mapoptions
- The LinkOption
-s that were used to access the file's attributesIOException
- If failed to resolve the attributesdefault void applyExtensionFileAttributes(SftpSubsystemProxy subsystem, Path file, Map<String,byte[]> extensions, LinkOption... options) throws IOException
subsystem
- The SFTP subsystem instance that manages the sessionfile
- The referenced fileextensions
- The received extensions - may be null
/emptyoptions
- The LinkOption
-s that were used to access the file's standard attributesIOException
- If failed to apply the attributesdefault void putRemoteFileName(SftpSubsystemProxy subsystem, Path path, Buffer buf, String name, boolean shortName) throws IOException
subsystem
- The SFTP subsystem instance that manages the sessionpath
- The associated file Path
- Note: might be a symbolic link containerbuf
- The target Buffer
for the encoded stringname
- The string to sendshortName
- If true
then this is the "pure" file name/path, otherwise it also contains
user/group/size/last-modified-time/etc.IOException
- If failed to resolve the remote namedefault SeekableByteChannel openFile(SftpSubsystemProxy subsystem, FileHandle fileHandle, Path file, String handle, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException
subsystem
- The SFTP subsystem instance that manages the sessionfileHandle
- The FileHandle
representing the created channel - may be null
if not invoked
within the context of such a handle (special cases)file
- The requested local file Path
- same one returned by
resolveLocalFilePath
handle
- The assigned file handle through which the remote peer references this file. May be
null
/empty if the request is due to some internal functionality instead of due to
peer requesting a handle to a file.options
- The requested OpenOption
sattrs
- The requested FileAttribute
sSeekableByteChannel
IOException
- If failed to opendefault FileLock tryLock(SftpSubsystemProxy subsystem, FileHandle fileHandle, Path file, String handle, Channel channel, long position, long size, boolean shared) throws IOException
subsystem
- The SFTP subsystem instance that manages the sessionfileHandle
- The FileHandle
representing the created channelfile
- The requested local file Path
- same one returned by
resolveLocalFilePath
handle
- The assigned file handle through which the remote peer references this filechannel
- The original Channel
that was returned by
openFile(SftpSubsystemProxy, FileHandle, Path, String, Set, FileAttribute...)
position
- The position at which the locked region is to start - must be non-negativesize
- The size of the locked region; must be non-negative, and the sum
position + size must be non-negativeshared
- true
to request a shared lock, false
to request an exclusive locknull
if the lock could not be
acquired because another program holds an overlapping lockIOException
- If failed to honor the requestFileChannel.tryLock(long, long, boolean)
default void syncFileData(SftpSubsystemProxy subsystem, FileHandle fileHandle, Path file, String handle, Channel channel) throws IOException
subsystem
- The SFTP subsystem instance that manages the sessionfileHandle
- The FileHandle
representing the created channelfile
- The requested local file Path
- same one returned by
resolveLocalFilePath
handle
- The assigned file handle through which the remote peer references this filechannel
- The original Channel
that was returned by
openFile(SftpSubsystemProxy, FileHandle, Path, String, Set, FileAttribute...)
IOException
- If failed to execute the requestFileChannel.force(boolean)
,
OpenSSH - section
10default void closeFile(SftpSubsystemProxy subsystem, FileHandle fileHandle, Path file, String handle, Channel channel, Set<? extends OpenOption> options) throws IOException
subsystem
- The SFTP subsystem instance that manages the sessionfileHandle
- The FileHandle
representing the created channel - may be null
if not invoked
within the context of such a handle (special cases)file
- The requested local file Path
- same one returned by
resolveLocalFilePath
handle
- The assigned file handle through which the remote peer references this filechannel
- The original Channel
that was returned by
openFile(SftpSubsystemProxy, FileHandle, Path, String, Set, FileAttribute...)
options
- The original options used to open the channelIOException
- If failed to execute the requestdefault DirectoryStream<Path> openDirectory(SftpSubsystemProxy subsystem, DirectoryHandle dirHandle, Path dir, String handle, LinkOption... linkOptions) throws IOException
subsystem
- The SFTP subsystem instance that manages the sessiondirHandle
- The DirectoryHandle
representing the streamdir
- The requested local directory Path
- same one returned by
resolveLocalFilePath
handle
- The assigned directory handle through which the remote peer references this directoryDirectoryStream
IOException
- If failed to opendefault void closeDirectory(SftpSubsystemProxy subsystem, DirectoryHandle dirHandle, Path dir, String handle, DirectoryStream<Path> ds) throws IOException
subsystem
- The SFTP subsystem instance that manages the sessiondirHandle
- The DirectoryHandle
representing the stream - may be null
if not invoked
within the context of such a handle (special cases)dir
- The requested local directory Path
- same one returned by
resolveLocalFilePath
handle
- The assigned directory handle through which the remote peer references this directoryds
- The disposed DirectoryStream
IOException
- If failed to opendefault Map<String,?> readFileAttributes(SftpSubsystemProxy subsystem, Path file, String view, LinkOption... options) throws IOException
subsystem
- The SFTP subsystem instance that manages the sessionfile
- The requested local file Path
- same one returned by
resolveLocalFilePath
view
- The required view nameoptions
- The access LinkOption
-sMap
of all the attributes available for the file in the viewIOException
- If failed to read the attributesFiles.readAttributes(Path, String, LinkOption...)
default void setFileAttribute(SftpSubsystemProxy subsystem, Path file, String view, String attribute, Object value, LinkOption... options) throws IOException
subsystem
- The SFTP subsystem instance that manages the sessionfile
- The requested local file Path
- same one returned by
resolveLocalFilePath
view
- The required view nameattribute
- The attribute namevalue
- The attribute valueoptions
- The access LinkOption
-sIOException
- If failed to set the attributedefault UserPrincipal resolveFileOwner(SftpSubsystemProxy subsystem, Path file, UserPrincipal name) throws IOException
IOException
default void setFileOwner(SftpSubsystemProxy subsystem, Path file, Principal value, LinkOption... options) throws IOException
IOException
default GroupPrincipal resolveGroupOwner(SftpSubsystemProxy subsystem, Path file, GroupPrincipal name) throws IOException
IOException
default void setGroupOwner(SftpSubsystemProxy subsystem, Path file, Principal value, LinkOption... options) throws IOException
IOException
default void setFilePermissions(SftpSubsystemProxy subsystem, Path file, Set<PosixFilePermission> perms, LinkOption... options) throws IOException
IOException
default void setFileAccessControl(SftpSubsystemProxy subsystem, Path file, List<AclEntry> acl, LinkOption... options) throws IOException
IOException
default void createDirectory(SftpSubsystemProxy subsystem, Path path) throws IOException
IOException
default void createLink(SftpSubsystemProxy subsystem, Path link, Path existing, boolean symLink) throws IOException
subsystem
- The SFTP subsystem instance that manages the sessionlink
- The requested link Path
- same one returned by
resolveLocalFilePath
existing
- The existing Path
that the link should referencesymLink
- true
if this should be a symbolic linkIOException
- If failed to create the linkFiles.createLink(Path, Path)
,
Files.createSymbolicLink(Path, Path, FileAttribute...)
default String resolveLinkTarget(SftpSubsystemProxy subsystem, Path link) throws IOException
IOException
default void renameFile(SftpSubsystemProxy subsystem, Path oldPath, Path newPath, Collection<CopyOption> opts) throws IOException
IOException
default void copyFile(SftpSubsystemProxy subsystem, Path src, Path dst, Collection<CopyOption> opts) throws IOException
IOException
static SeekableByteChannel seekableByteChannelNoLinkFollow(Path src, Set<? extends OpenOption> opts, FileAttribute<?>... fileAttributes) throws IOException
IOException
static SecureDirectoryStream<Path> secureResolveDirectoryStream(Path toResolve) throws IOException
IOException
static SecureDirectoryStream<Path> secure(DirectoryStream<Path> ds)
default void removeFile(SftpSubsystemProxy subsystem, Path path, boolean isDirectory) throws IOException
IOException
default boolean noFollow(Collection<?> opts)
Copyright © 2008–2024 The Apache Software Foundation. All rights reserved.