Class SFTPRepository

  • All Implemented Interfaces:
    Repository

    public class SFTPRepository
    extends AbstractSshBasedRepository
    SFTP Repository, allow to use a repository accessed by sftp protocol. It supports all operations: get, put and list. It relies on jsch for sftp handling, and thus is compatible with sftp version 0, 1, 2 and 3
    • Constructor Detail

      • SFTPRepository

        public SFTPRepository()
    • Method Detail

      • getResource

        public Resource getResource​(java.lang.String source)
        Description copied from interface: Repository
        Return the resource associated with a specified identifier. If the resource does not exist, it should return a Resource with exists() returning false. An IOException should only be thrown when a real IO problem occurs, like the impossibility to connect to a server.
        Parameters:
        source - A string identifying the resource.
        Returns:
        The resource associated with the resource identifier.
      • resolveResource

        public Resource resolveResource​(java.lang.String path)
        This method is similar to getResource, except that the returned resource is fully initialized (resolved in the sftp repository), and that the given string is a full remote path
        Parameters:
        path - the full remote path in the repository of the resource
        Returns:
        a fully initialized resource, able to answer to all its methods without needing any further connection
      • openStream

        public java.io.InputStream openStream​(SFTPResource resource)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • get

        public void get​(java.lang.String source,
                        java.io.File destination)
                 throws java.io.IOException
        Description copied from interface: Repository
        Fetch a resource from the repository.
        Parameters:
        source - A string identifying the resource to be fetched.
        destination - Where to place the fetched resource.
        Throws:
        java.io.IOException - On retrieval failure.
      • put

        public void put​(java.io.File source,
                        java.lang.String destination,
                        boolean overwrite)
                 throws java.io.IOException
        Overrides:
        put in class AbstractRepository
        Throws:
        java.io.IOException
      • list

        public java.util.List list​(java.lang.String parent)
                            throws java.io.IOException
        Description copied from interface: Repository
        Return a listing of resources names
        Parameters:
        parent - The parent directory from which to generate the listing.
        Returns:
        A listing of the parent directory's file content, as a List of String.
        Throws:
        java.io.IOException - On listing failure.