Package dk.netarkivet.common.distribute
Class TestRemoteFile
- java.lang.Object
-
- dk.netarkivet.common.distribute.AbstractRemoteFile
-
- dk.netarkivet.common.distribute.HTTPRemoteFile
-
- dk.netarkivet.common.distribute.TestRemoteFile
-
- All Implemented Interfaces:
RemoteFile
,Serializable
public class TestRemoteFile extends HTTPRemoteFile implements RemoteFile
Version of RemoteFile that reads/writes a file to local storage.Created by IntelliJ IDEA. User: csr Date: Mar 2, 2005 Time: 3:09:26 PM
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description boolean
failsOnCopy
static Map<RemoteFile,String>
remainingRemoteFiles
-
Fields inherited from class dk.netarkivet.common.distribute.HTTPRemoteFile
checksum, hostname, HTTPREMOTEFILE_PORT_NUMBER, url
-
Fields inherited from class dk.netarkivet.common.distribute.AbstractRemoteFile
file, fileDeletable, filesize, multipleDownloads, useChecksums
-
-
Constructor Summary
Constructors Constructor Description TestRemoteFile(File localFile, boolean useChecksum, boolean fileDeletable, boolean multipleDownloads)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendTo(OutputStream out)
Append this remote file to the given output stream.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(File destFile)
Copy this remote file to the given file.File
getFile()
static RemoteFile
getInstance(File remoteFile, Boolean useChecksums, Boolean fileDeletable, Boolean multipleDownloads)
boolean
isDeleted()
protected boolean
isLocal()
Helper method to determine if file resides on local machine.static Set<RemoteFile>
remainingFiles()
Give the set of remaining remote files.static void
removeRemainingFiles()
Remove any remote files that may have been left over.String
toString()
-
Methods inherited from class dk.netarkivet.common.distribute.HTTPRemoteFile
getChecksum, getInputStream, getNumberOfRetries, getRegistry
-
Methods inherited from class dk.netarkivet.common.distribute.AbstractRemoteFile
getName, getSize
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface dk.netarkivet.common.distribute.RemoteFile
getChecksum, getInputStream, getName, getSize
-
-
-
-
Field Detail
-
failsOnCopy
public boolean failsOnCopy
-
remainingRemoteFiles
public static Map<RemoteFile,String> remainingRemoteFiles
-
-
Method Detail
-
getInstance
public static RemoteFile getInstance(File remoteFile, Boolean useChecksums, Boolean fileDeletable, Boolean multipleDownloads) throws IOFailure
- Throws:
IOFailure
-
copyTo
public void copyTo(File destFile)
Description copied from class:HTTPRemoteFile
Copy this remote file to the given file. If the file resides on the current machine, remote file transfer is done locally. Otherwise, the remote file is transferred over http. If the file is not set to be able to be transferred multiple times, it is cleaned up after the transfer.- Specified by:
copyTo
in interfaceRemoteFile
- Overrides:
copyTo
in classHTTPRemoteFile
- Parameters:
destFile
- The file to write the remote file to.
-
appendTo
public void appendTo(OutputStream out)
Description copied from class:AbstractRemoteFile
Append this remote file to the given output stream. This method will use getInputStream to get the remote stream, and then copy that stream to the given output stream.- Specified by:
appendTo
in interfaceRemoteFile
- Overrides:
appendTo
in classAbstractRemoteFile
- Parameters:
out
- The stream to write the remote file to.
-
cleanup
public void cleanup()
Description copied from class:HTTPRemoteFile
Invalidate all file handles, by asking the remote registry to remove the url for this remote file from the list of shared files. Invalidating a file handle may delete the original files, if deletable. This method does not throw exceptions, but will warn on errors.- Specified by:
cleanup
in interfaceRemoteFile
- Overrides:
cleanup
in classHTTPRemoteFile
-
isDeleted
public boolean isDeleted()
-
toString
public String toString()
- Overrides:
toString
in classAbstractRemoteFile
-
removeRemainingFiles
public static void removeRemainingFiles()
Remove any remote files that may have been left over.
-
remainingFiles
public static Set<RemoteFile> remainingFiles()
Give the set of remaining remote files.- Returns:
- the Set of remaining files
-
getFile
public File getFile()
-
isLocal
protected boolean isLocal()
Description copied from class:HTTPRemoteFile
Helper method to determine if file resides on local machine.- Overrides:
isLocal
in classHTTPRemoteFile
- Returns:
- true if the file is on the local machine, false otherwise.
-
-