Package dk.netarkivet.common.distribute
Class ExtendedFTPRemoteFile
- java.lang.Object
-
- dk.netarkivet.common.distribute.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 Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendTo(OutputStream out)
Write the contents of this remote file to an output stream.void
cleanup()
The cleanup to be effected is deletion of the intermediate file from the ftp server.void
copyTo(File destFile)
Copy remotefile to local disk storage.String
getChecksum()
Checksums are not available in this implementation.InputStream
getInputStream()
Get an inputstream that contains the data transferred in this RemoteFile.static RemoteFile
getInstance(File localFile, Boolean useChecksums, Boolean fileDeletable, Boolean multipleDownloads)
This method returns an instance of FTPRemoteFile using the factory method with the same signature in that class.static RemoteFile
getInstance(File localFile, Boolean useChecksums, Boolean fileDeletable, Boolean multipleDownloads, RemoteFileSettings connectionParams)
This method returns an instance of FTPRemoteFile using the factory method with the same signature in that class.static RemoteFile
getInstance(org.archive.io.arc.ARCRecord record)
Create an instance of this class connected to an ARCRecord.static RemoteFile
getInstance(org.archive.io.ArchiveRecord record)
Create an instance of this class connected to an ARC or WARC record.static RemoteFile
getInstance(org.archive.io.warc.WARCRecord record)
Create an instance of this class connected to a WARCRecord.String
getName()
Return the file name.long
getSize()
For an ARCRecord, this is the length of the record as defined in the header.String
toString()
A human readable description of the object which should be sufficient to identify and track it.
-
-
-
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 fileuseChecksums
- 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 fileuseChecksums
- 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 interfaceRemoteFile
- 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 interfaceRemoteFile
- 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 interfaceRemoteFile
- 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 interfaceRemoteFile
- Returns:
- the file name
-
getChecksum
public String getChecksum()
Checksums are not available in this implementation. Returns null.- Specified by:
getChecksum
in interfaceRemoteFile
- 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 interfaceRemoteFile
-
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 interfaceRemoteFile
- Returns:
- the length of the record content in bytes.
-
-