dk.netarkivet.archive.checksum.distribute
Class CorrectMessage

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

public class CorrectMessage
extends ArchiveMessage

The message to correct a bad entry in an archive.

  • In a bitarchive it should replace a corrupted file.
  • In a checksum archive it should replace checksum entry of the file.

  • The message contains the checksum of the 'bad' entry in the archive, which is only corrected if it actually has this 'bad checksum'.

    See Also:
    Serialized Form

    Field Summary
     
    Fields inherited from class dk.netarkivet.common.distribute.NetarkivetMessage
    replyOfId
     
    Constructor Summary
    CorrectMessage(ChannelID to, ChannelID replyTo, java.lang.String badChecksum, RemoteFile rf, java.lang.String repId, java.lang.String cred)
              Constructor.
     
    Method Summary
     void accept(ArchiveMessageVisitor v)
              Accept this message.
     java.lang.String getArcfileName()
              Retrieve name of the uploaded file.
     RemoteFile getCorrectFile()
              Method for retrieving the correct file.
     java.lang.String getCredentials()
              The credentials to allow correction of an entry in the archive.
     void getData(java.io.File toFile)
              Retrieves the content of the remoteFile and writes it into the local file.
     java.lang.String getIncorrectChecksum()
              Method for retrieving the 'bad' checksum which should correspond to the checksum of the current entry on this file in the archive.
     RemoteFile getRemovedFile()
              Returns the removed file.
     java.lang.String getReplicaId()
              Method for retrieving the replica, where this message should be sent.
     void setRemovedFile(RemoteFile rf)
              Sets the removed file.
     java.lang.String toString()
              Generate String representation of this object.
     
    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

    CorrectMessage

    public CorrectMessage(ChannelID to,
                          ChannelID replyTo,
                          java.lang.String badChecksum,
                          RemoteFile rf,
                          java.lang.String repId,
                          java.lang.String cred)
                   throws ArgumentNotValid
    Constructor. Initializes the variables.

    Parameters:
    to - Where the message should be sent.
    replyTo - Who is sending this message.
    badChecksum - The checksum of the 'bad' entry.
    rf - The remote file to replace the 'bad' entry.
    repId - The identification of the replica, where this message should be sent.
    cred - The credentials to allow the correction of an entry.
    Throws:
    ArgumentNotValid - If any of the arguments are null, or any of the strings are empty.
    Method Detail

    getArcfileName

    public java.lang.String getArcfileName()
    Retrieve name of the uploaded file.

    Returns:
    current value of arcfileName

    getData

    public void getData(java.io.File toFile)
                 throws IOFailure,
                        ArgumentNotValid
    Retrieves the content of the remoteFile and writes it into the 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 toFile is null.

    getCorrectFile

    public RemoteFile getCorrectFile()
    Method for retrieving the correct file.

    Returns:
    The RemoteFile for the correct file.

    getIncorrectChecksum

    public java.lang.String getIncorrectChecksum()
    Method for retrieving the 'bad' checksum which should correspond to the checksum of the current entry on this file in the archive.

    Returns:
    The checksum for the archive entry.

    getReplicaId

    public java.lang.String getReplicaId()
    Method for retrieving the replica, where this message should be sent.

    Returns:
    The id of the replica where this message should be sent.

    getCredentials

    public java.lang.String getCredentials()
    The credentials to allow correction of an entry in the archive.

    Returns:
    The credentials.

    getRemovedFile

    public RemoteFile getRemovedFile()
                              throws IOFailure
    Returns the removed file.

    Returns:
    The removed file.
    Throws:
    IOFailure - If the removed file is null.

    setRemovedFile

    public void setRemovedFile(RemoteFile rf)
                        throws ArgumentNotValid
    Sets the removed file. This is the file which are returned to the sender of the message.

    Parameters:
    rf - The removed file which is part of the reply of this message.
    Throws:
    ArgumentNotValid - If the remote file is null.

    accept

    public void accept(ArchiveMessageVisitor v)
    Accept this message.

    Specified by:
    accept in class ArchiveMessage
    Parameters:
    v - The message visitor accepting this message.
    See Also:
    ArchiveMessageVisitor

    toString

    public java.lang.String toString()
    Generate String representation of this object.

    Overrides:
    toString in class NetarkivetMessage
    Returns:
    String representation of this object