Class SftpFileSystem
- java.lang.Object
-
- org.apache.commons.vfs2.provider.AbstractVfsComponent
-
- org.apache.commons.vfs2.provider.AbstractFileSystem
-
- org.apache.commons.vfs2.provider.sftp.SftpFileSystem
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,FileSystem,VfsComponent
public class SftpFileSystem extends AbstractFileSystem
Represents the files on an SFTP server.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSftpFileSystem(GenericFileName rootName, com.jcraft.jsch.Session session, FileSystemOptions fileSystemOptions)Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddCapabilities(java.util.Collection<Capability> caps)Adds the capabilities of this file system.protected FileObjectcreateFile(AbstractFileName name)Creates a file object.protected voiddoCloseCommunicationLink()Closes the underlying link used to access the files.protected com.jcraft.jsch.ChannelSftpgetChannel()Returns an SFTP channel to the server.int[]getGroupsIds()Gets the (numeric) group IDs.doublegetLastModTimeAccuracy()Last modification time is only an int and in seconds, thus can be off by 999.intgetUId()Gets the (numeric) group IDs.booleanisExecDisabled()Tests whether the exec channel is disabled.protected voidputChannel(com.jcraft.jsch.ChannelSftp channelSftp)Returns a channel to the pool.-
Methods inherited from class org.apache.commons.vfs2.provider.AbstractFileSystem
addJunction, addListener, close, closeCommunicationLink, decorateFileObject, doReplicateFile, fireFileChanged, fireFileCreated, fireFileDeleted, getAttribute, getFileFromCache, getFileSystemManager, getFileSystemOptions, getParentLayer, getRoot, getRootName, getRootURI, hasCapability, init, isOpen, isReleaseable, notifyAllStreamsClosed, putFileToCache, removeFileFromCache, removeJunction, removeListener, replicateFile, resolveFile, resolveFile, setAttribute
-
Methods inherited from class org.apache.commons.vfs2.provider.AbstractVfsComponent
getContext, getLogger, setContext, setLogger
-
-
-
-
Constructor Detail
-
SftpFileSystem
protected SftpFileSystem(GenericFileName rootName, com.jcraft.jsch.Session session, FileSystemOptions fileSystemOptions)
Constructs a new instance.- Parameters:
rootName- The root file name of this file system.session- The session.fileSystemOptions- Options to build this file system.
-
-
Method Detail
-
addCapabilities
protected void addCapabilities(java.util.Collection<Capability> caps)
Adds the capabilities of this file system.- Specified by:
addCapabilitiesin classAbstractFileSystem- Parameters:
caps- collections of Capabilities, can be immutable.
-
createFile
protected FileObject createFile(AbstractFileName name) throws FileSystemException
Creates a file object. This method is called only if the requested file is not cached.- Specified by:
createFilein classAbstractFileSystem- Parameters:
name- name referencing the new file.- Returns:
- new created FileObject.
- Throws:
FileSystemException
-
doCloseCommunicationLink
protected void doCloseCommunicationLink()
Description copied from class:AbstractFileSystemCloses the underlying link used to access the files.- Overrides:
doCloseCommunicationLinkin classAbstractFileSystem
-
getChannel
protected com.jcraft.jsch.ChannelSftp getChannel() throws java.io.IOException
Returns an SFTP channel to the server.- Returns:
- new or reused channel, never null.
- Throws:
FileSystemException- if a session cannot be created.java.io.IOException- if an I/O error is detected.
-
getGroupsIds
public int[] getGroupsIds() throws com.jcraft.jsch.JSchException, java.io.IOException
Gets the (numeric) group IDs.- Returns:
- the (numeric) group IDs.
- Throws:
com.jcraft.jsch.JSchException- If a problem occurs while retrieving the group IDs.java.io.IOException- if an I/O error is detected.- Since:
- 2.1
-
getLastModTimeAccuracy
public double getLastModTimeAccuracy()
Last modification time is only an int and in seconds, thus can be off by 999.- Specified by:
getLastModTimeAccuracyin interfaceFileSystem- Overrides:
getLastModTimeAccuracyin classAbstractFileSystem- Returns:
- 1000
-
getUId
public int getUId() throws com.jcraft.jsch.JSchException, java.io.IOException
Gets the (numeric) group IDs.- Returns:
- The numeric user ID
- Throws:
com.jcraft.jsch.JSchException- If a problem occurs while retrieving the group ID.java.io.IOException- if an I/O error is detected.- Since:
- 2.1
-
isExecDisabled
public boolean isExecDisabled()
Tests whether the exec channel is disabled.- Returns:
- Whether the exec channel is disabled.
- See Also:
execDisabled
-
putChannel
protected void putChannel(com.jcraft.jsch.ChannelSftp channelSftp)
Returns a channel to the pool.- Parameters:
channelSftp- the SFTP channel.
-
-