|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dk.netarkivet.common.distribute.AbstractRemoteFile dk.netarkivet.common.distribute.HTTPRemoteFile
public class HTTPRemoteFile
A remote file implemented with point-to-point HTTP communication. Optimised to communicate locally, if file is on the same host. Optimised to transfer 0 byte files inline.
Field Summary | |
---|---|
protected java.lang.String |
checksum
If useChecksums is true, contains the file checksum. |
protected java.lang.String |
hostname
The name of the host this file originated on. |
static java.lang.String |
HTTPREMOTEFILE_PORT_NUMBER
settings.common.remoteFile.port: The setting for the HTTP remotefile port number used. |
protected java.net.URL |
url
The url that exposes this remote file. |
Fields inherited from class dk.netarkivet.common.distribute.AbstractRemoteFile |
---|
file, fileDeletable, filesize, multipleDownloads, useChecksums |
Constructor Summary | |
---|---|
protected |
HTTPRemoteFile(java.io.File file,
boolean useChecksums,
boolean fileDeletable,
boolean multipleDownloads)
Initialises a remote file implemented by point-to-point HTTP communication. |
Method Summary | |
---|---|
void |
cleanup()
Invalidate all file handles, by asking the remote registry to remove the url for this remote file from the list of shared files. |
void |
copyTo(java.io.File destFile)
Copy this remote file to the given file. |
java.lang.String |
getChecksum()
Get checksum for file, or null if checksums were not requested. |
java.io.InputStream |
getInputStream()
Get an input stream representing the remote file. |
static RemoteFile |
getInstance(java.io.File f,
java.lang.Boolean useChecksums,
java.lang.Boolean fileDeletable,
java.lang.Boolean multipleDownloads)
Initialises a remote file implemented by point-to-point HTTP communication. |
int |
getNumberOfRetries()
Retrieval of the number of retries for retrieving a file from a HTTP server. |
protected HTTPRemoteFileRegistry |
getRegistry()
Get the webserver registry for this class of files. |
protected boolean |
isLocal()
Helper method to determine if file resides on local machine. |
Methods inherited from class dk.netarkivet.common.distribute.AbstractRemoteFile |
---|
appendTo, getName, getSize |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final java.lang.String hostname
protected final java.net.URL url
protected final java.lang.String checksum
public static java.lang.String HTTPREMOTEFILE_PORT_NUMBER
Constructor Detail |
---|
protected HTTPRemoteFile(java.io.File file, boolean useChecksums, boolean fileDeletable, boolean multipleDownloads)
file
- The file to make a remote file foruseChecksums
- Whether communications are checksummed. If true,
getChecksum will also return the checksum.fileDeletable
- if true, the file given to this method is deletable,
once it is transferred.multipleDownloads
- if true, the file may be transferred more than
once. Otherwise, all file handles are attempted to be made invalid after
the first transfer, although no guarantees are made.
ArgumentNotValid
- if file is null, or not a readable file.
IOFailure
- if checksums are requested, but i/o errors occur while
checksumming.Method Detail |
---|
public static RemoteFile getInstance(java.io.File f, java.lang.Boolean useChecksums, java.lang.Boolean fileDeletable, java.lang.Boolean multipleDownloads)
f
- The file to make a remote file foruseChecksums
- Whether communications are checksummed. If true,
getChecksum will also return the checksum.fileDeletable
- if true, the file given to this method is deletable,
once it is transferred.multipleDownloads
- if true, the file may be transferred more than
once. Otherwise, all file handles are attempted to be made invalid after
the first transfer, although no guarantees are made.
ArgumentNotValid
- if file is null, or not a readable file.
IOFailure
- if checksums are requested, but i/o errors occur while
checksumming.protected HTTPRemoteFileRegistry getRegistry()
public void copyTo(java.io.File destFile)
copyTo
in interface RemoteFile
copyTo
in class AbstractRemoteFile
destFile
- The file to write the remote file to.
ArgumentNotValid
- on null destFile, or parent to destfile is not
a writeable directory, or destfile exists and cannot be overwritten.
IOFailure
- on I/O trouble writing remote file to destination.public java.io.InputStream getInputStream()
getInputStream
in interface RemoteFile
getInputStream
in class AbstractRemoteFile
IOFailure
- on I/O trouble generating inputstream for remote file.
Also, the returned remote file will throw IOFailure on close, if
checksums are requested, but do not match.public void cleanup()
cleanup
in interface RemoteFile
cleanup
in class AbstractRemoteFile
public java.lang.String getChecksum()
getChecksum
in interface RemoteFile
getChecksum
in class AbstractRemoteFile
protected boolean isLocal()
public int getNumberOfRetries()
getNumberOfRetries
in class AbstractRemoteFile
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |