Changeset 2523


Ignore:
Timestamp:
Jun 25, 2014, 1:46:13 PM (9 years ago)
Author:
Nicklas Nordborg
Message:

References #305: Create package for supporting external files on FTP servers

Implement support for ResumableConnectionManager.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.xfiles/trunk/src/net/sf/basedb/xfiles/ftp/FtpConnectionManager.java

    r2521 r2523  
    3737import net.sf.basedb.util.uri.CloseResourceInputStream;
    3838import net.sf.basedb.util.uri.ConnectionParameters;
    39 import net.sf.basedb.util.uri.ConnectionManager;
     39import net.sf.basedb.util.uri.ResumableConnectionManager;
    4040import net.sf.basedb.util.uri.UriMetadata;
    4141import net.sf.basedb.xfiles.MultiCloseable;
     
    5050*/
    5151public class FtpConnectionManager
    52   implements ConnectionManager
     52  implements ResumableConnectionManager
    5353{
    5454
     
    6464 
    6565  /*
    66     From the UriHandler interface
    67     -----------------------------
     66    From the ResumableConnectionManager interface
     67    ---------------------------------------------
    6868  */
    6969  @Override
     
    7575  @Override
    7676  public InputStream getInputStream()
     77    throws IOException
     78  {
     79    return getInputStream(0);
     80  }
     81 
     82  @Override
     83  public InputStream getInputStream(long offset)
    7784    throws IOException
    7885  {
     
    8390    {
    8491      ftp = connect(uri, parameters);
    85       stream = new CloseResourceInputStream(startDownload(ftp, uri.getPath()), new FTPClientCloseable(ftp));
     92      stream = new CloseResourceInputStream(startDownload(ftp, uri.getPath(), offset), new FTPClientCloseable(ftp));
    8693    }
    8794    finally
     
    207214    reading it. The download is started in a separate thread.
    208215  */
    209   private InputStream startDownload(final FTPClient ftp, final String file)
     216  private InputStream startDownload(final FTPClient ftp, final String file, final long offset)
    210217  {
    211218    final PipedInputStream in = new PipedInputStream(XFiles.DEFAULT_BUFFER_SIZE);
     
    218225        {
    219226          OutputStream out = new PipedOutputStream(in);
    220           ftp.download(file, out, 0, null);
     227          ftp.download(file, out, offset, null);
    221228        }
    222229        catch (Exception ex)
Note: See TracChangeset for help on using the changeset viewer.