dk.netarkivet.archive.bitarchive.distribute
Class GetFileMessage

java.lang.Object
  extended by dk.netarkivet.common.distribute.NetarkivetMessage
      extended by dk.netarkivet.archive.distribute.ArchiveMessage
          extended by dk.netarkivet.archive.bitarchive.distribute.GetFileMessage
All Implemented Interfaces:
java.io.Serializable

public class GetFileMessage
extends ArchiveMessage

Message requesting a file from a bitarchive. Messages is forwarded through arcrepository, but reponds directly to sender.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class dk.netarkivet.common.distribute.NetarkivetMessage
replyOfId
 
Constructor Summary
GetFileMessage(ChannelID to, ChannelID replyTo, java.lang.String arcfileName, java.lang.String replicaId)
          Constructor for get file message.
 
Method Summary
 void accept(ArchiveMessageVisitor v)
          Should be implemented as a part of the visitor pattern.
 void clearBuffer()
          Clear content buffer.
 java.lang.String getArcfileName()
          Get name of the file to retrieve.
 void getData(java.io.File toFile)
          Writes the the content of the retrieved file into a local file.
 java.lang.String getReplicaId()
          Retrieve the replica id.
 void setFile(java.io.File data)
          Set the file this message should return.
 java.lang.String toString()
          Retrieval of a string representation of this instance.
 
Methods inherited from class dk.netarkivet.common.distribute.NetarkivetMessage
getErrMsg, getID, getReplyOfId, getReplyTo, getTo, hasBeenSent, isOk, setNotOk, setNotOk
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GetFileMessage

public GetFileMessage(ChannelID to,
                      ChannelID replyTo,
                      java.lang.String arcfileName,
                      java.lang.String replicaId)
Constructor for get file message.

Parameters:
to - Recipient
replyTo - Original sender
arcfileName - The file to retrieve
replicaId - The bitarchive replica id to retrieve it from.
Method Detail

setFile

public void setFile(java.io.File data)
Set the file this message should return. Note: This will make a remote file handle fopr the file.

Parameters:
data - Content of the file to retrieve

getData

public void getData(java.io.File toFile)
             throws ArgumentNotValid,
                    IOFailure
Writes the the content of the retrieved file into a local file. Note: This is transferred through a remote file handle, and then the handle is invalidated. This method may only be called once.

Parameters:
toFile - where to write the content
Throws:
IOFailure - on error reading the remote file or writing the local file
ArgumentNotValid - If the file is null.

getReplicaId

public java.lang.String getReplicaId()
Retrieve the replica id.

Returns:
replica id

getArcfileName

public java.lang.String getArcfileName()
Get name of the file to retrieve.

Returns:
file name

clearBuffer

public void clearBuffer()
Clear content buffer.


accept

public void accept(ArchiveMessageVisitor v)
Should be implemented as a part of the visitor pattern. fx.: public void accept(ArchiveMessageVisitor v) { v.visit(this); }

Specified by:
accept in class ArchiveMessage
Parameters:
v - A message visitor
See Also:
ArchiveMessageVisitor

toString

public java.lang.String toString()
Retrieval of a string representation of this instance.

Overrides:
toString in class NetarkivetMessage
Returns:
The string representing this instance.
See Also:
NetarkivetMessage.toString()