Class ExtendedFTPRemoteFile

  • All Implemented Interfaces:
    RemoteFile, Serializable

    public class ExtendedFTPRemoteFile
    extends Object
    implements RemoteFile
    This class extends the functionality of FTPRemoteFile by allowing local input to be taken from an ArchiveRecord. It has factory methods which return an instance of FTPRemoteFile when a File is used as input so that behavior is effectively delegated to that class when required.
    See Also:
    Serialized Form
    • Method Detail

      • getInstance

        public static RemoteFile getInstance​(org.archive.io.ArchiveRecord record)
        Create an instance of this class connected to an ARC or WARC record. Unfortunately the reflection we use to find the factory method cannot find this method directly because the runtime-class of the parameter is not ArchiveRecord. Therefore we also define the two specific overloaded factory methods for ARCRecords and WARCRecord.
        Parameters:
        record - the record
        Returns:
        the instance
      • getInstance

        public static RemoteFile getInstance​(org.archive.io.arc.ARCRecord record)
        Create an instance of this class connected to an ARCRecord.
        Parameters:
        record - the record
        Returns:
        the instance
      • getInstance

        public static RemoteFile getInstance​(org.archive.io.warc.WARCRecord record)
        Create an instance of this class connected to a WARCRecord.
        Parameters:
        record - the record
        Returns:
        the instance
      • getInstance

        public static RemoteFile getInstance​(File localFile,
                                             Boolean useChecksums,
                                             Boolean fileDeletable,
                                             Boolean multipleDownloads)
                                      throws IOFailure
        This method returns an instance of FTPRemoteFile using the factory method with the same signature in that class.
        Parameters:
        localFile - File object for the remote file
        useChecksums - If true, checksums will be used to check transfers.
        fileDeletable - If true, this file will be deleted after upload to FTP.
        multipleDownloads - If true, the file will not be removed from FTP server automatically after first download.
        Returns:
        FTPRemoteFile object
        Throws:
        IOFailure - if FTPRemoteFile creation fails
      • getInstance

        public static RemoteFile getInstance​(File localFile,
                                             Boolean useChecksums,
                                             Boolean fileDeletable,
                                             Boolean multipleDownloads,
                                             RemoteFileSettings connectionParams)
                                      throws IOFailure
        This method returns an instance of FTPRemoteFile using the factory method with the same signature in that class.
        Parameters:
        localFile - File object for the remote file
        useChecksums - If true, checksums will be used to check transfers.
        fileDeletable - If true, this file will be deleted after upload to FTP.
        multipleDownloads - If true, the file will not be removed from FTP server automatically after first download.
        Returns:
        FTPRemoteFile object
        Throws:
        IOFailure - if FTPRemoteFile creation fails
      • copyTo

        public void copyTo​(File destFile)
        Description copied from interface: RemoteFile
        Copy remotefile to local disk storage. Used by the data recipient
        Specified by:
        copyTo in interface RemoteFile
        Parameters:
        destFile - local File
      • appendTo

        public void appendTo​(OutputStream out)
        Description copied from interface: RemoteFile
        Write the contents of this remote file to an output stream.
        Specified by:
        appendTo in interface RemoteFile
        Parameters:
        out - OutputStream that the data will be written to. This stream will not be closed by this operation.
      • getInputStream

        public InputStream getInputStream()
        Description copied from interface: RemoteFile
        Get an inputstream that contains the data transferred in this RemoteFile.
        Specified by:
        getInputStream in interface RemoteFile
        Returns:
        A stream object with the data in the object. Note that the close() method of this may throw exceptions if e.g. a transmission error is detected.
      • getName

        public String getName()
        Description copied from interface: RemoteFile
        Return the file name.
        Specified by:
        getName in interface RemoteFile
        Returns:
        the file name
      • getChecksum

        public String getChecksum()
        Checksums are not available in this implementation. Returns null.
        Specified by:
        getChecksum in interface RemoteFile
        Returns:
        null
      • cleanup

        public void cleanup()
        The cleanup to be effected is deletion of the intermediate file from the ftp server.
        Specified by:
        cleanup in interface RemoteFile
      • getSize

        public long getSize()
        For an ARCRecord, this is the length of the record as defined in the header. For a WARCRecods, this is the payload length, defined as the difference between the total record length and the size of the header.
        Specified by:
        getSize in interface RemoteFile
        Returns:
        the length of the record content in bytes.
      • toString

        public String toString()
        A human readable description of the object which should be sufficient to identify and track it.
        Overrides:
        toString in class Object
        Returns:
        description of this object.