dk.netarkivet.archive.bitarchive.distribute
Class RemoveAndGetFileMessage

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

public class RemoveAndGetFileMessage
extends ArchiveMessage

Message requesting a file to be removed and returned 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
RemoveAndGetFileMessage(java.lang.String arcfileName, java.lang.String locationName, java.lang.String checksum, java.lang.String credentials)
          Constructor.
 
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.
 java.lang.String getCheckSum()
          Get the checksum of the file to remove.
 java.lang.String getCredentials()
          Get the credentials for the remove operation.
 java.io.File getData()
          Writes the the content of the retrieved file into a local file.
 java.lang.String getLocationName()
          Retrieve the location name.
 void setFile(java.io.File data)
          Set the file this message should remove and return.
 java.lang.String toString()
          Returns a string containing: : To ReplyTo [:error message].
 
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

RemoveAndGetFileMessage

public RemoveAndGetFileMessage(java.lang.String arcfileName,
                               java.lang.String locationName,
                               java.lang.String checksum,
                               java.lang.String credentials)
Constructor.

Parameters:
arcfileName - The file to retrieve & remove
locationName - The bitarchive to receive the response
checksum - the checksum of the file to retrieve & remove
credentials - the right credentials for this operation
Method Detail

setFile

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

Parameters:
data - Content of the file to retrieve

getData

public java.io.File getData()
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.

Returns:
file content
Throws:
IOFailure - on error reading the file

getLocationName

public java.lang.String getLocationName()
Retrieve the location name.

Returns:
location name

getArcfileName

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

Returns:
file name

getCheckSum

public java.lang.String getCheckSum()
Get the checksum of the file to remove.

Returns:
the checksum of the file to remove

getCredentials

public java.lang.String getCredentials()
Get the credentials for the remove operation.

Returns:
the credentials for the remove operation

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()
Description copied from class: NetarkivetMessage
Returns a string containing: : To ReplyTo [:error message].

Overrides:
toString in class NetarkivetMessage
Returns:
String representation of Message.
See Also:
NetarkivetMessage.toString()