dk.netarkivet.archive.checksum.distribute
Class ChecksumFileServer

java.lang.Object
  extended by dk.netarkivet.archive.distribute.ArchiveMessageHandler
      extended by dk.netarkivet.archive.checksum.distribute.ChecksumArchiveServer
          extended by dk.netarkivet.archive.checksum.distribute.ChecksumFileServer
All Implemented Interfaces:
ArchiveMessageVisitor, CleanupIF, javax.jms.MessageListener

public class ChecksumFileServer
extends ChecksumArchiveServer

The server for the ChecksumFileApplication. Used for communication between the ArcRepository and the checksum archive.


Field Summary
static java.lang.String APPLICATION_ID_SEPARATOR
          The character to separate the applicationInstanceId and the IP address.
protected  ChecksumArchive cs
          The archive which contain the actual data.
protected static ChecksumFileServer instance
          The instance of this server.
 
Fields inherited from class dk.netarkivet.archive.checksum.distribute.ChecksumArchiveServer
checksumAppId, jmsCon, theCR
 
Method Summary
 void cleanup()
          Method for cleaning up, when closing this instance down.
 void close()
          Method for closing the instance.
protected  java.lang.String createAppId()
          Method for creating the identification for this application.
 java.lang.String getAppId()
          Method for retrieving the identification of this application.
static ChecksumFileServer getInstance()
          Returns the unique instance of this class.
 void visit(CorrectMessage msg)
          Method for correcting an entry in the archive.
 void visit(GetAllChecksumsMessage msg)
          Method for retrieving a map containing all the checksums and their corresponding filenames within the archive.
 void visit(GetAllFilenamesMessage msg)
          Method for retrieving all the filenames within the archive.
 void visit(GetChecksumMessage msg)
          Method for retrieving the checksum of a record.
 void visit(UploadMessage msg)
          The method for uploading arc files.
 
Methods inherited from class dk.netarkivet.archive.distribute.ArchiveMessageHandler
onMessage, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

protected static ChecksumFileServer instance
The instance of this server.


cs

protected ChecksumArchive cs
The archive which contain the actual data.


APPLICATION_ID_SEPARATOR

public static final java.lang.String APPLICATION_ID_SEPARATOR
The character to separate the applicationInstanceId and the IP address.

See Also:
Constant Field Values
Method Detail

getInstance

public static ChecksumFileServer getInstance()
Returns the unique instance of this class. The server creates an instance of the checksum it creates access to and starts to listen to a JMS messages on the incoming JMS queue.

Should this do the heart beats to a monitor? This would be quite odd, since Checksum does not use a monitor.

Returns:
This instance.

close

public void close()
Method for closing the instance.

Specified by:
close in class ChecksumArchiveServer

cleanup

public void cleanup()
Method for cleaning up, when closing this instance down.

Specified by:
cleanup in interface CleanupIF
Specified by:
cleanup in class ChecksumArchiveServer

getAppId

public java.lang.String getAppId()
Method for retrieving the identification of this application.

Specified by:
getAppId in class ChecksumArchiveServer
Returns:
The id of this application.

createAppId

protected java.lang.String createAppId()
Method for creating the identification for this application.

Returns:
The id of this application.

visit

public void visit(UploadMessage msg)
           throws ArgumentNotValid
The method for uploading arc files.

Specified by:
visit in interface ArchiveMessageVisitor
Specified by:
visit in class ChecksumArchiveServer
Parameters:
msg - The upload message, containing the file to upload.
Throws:
ArgumentNotValid - If the UploadMessage is null.

visit

public void visit(CorrectMessage msg)
           throws ArgumentNotValid
Method for correcting an entry in the archive. It start by ensuring that the file exists, then it checks the credentials. Then it is checked whether the "bad entry" does have the "bad checksum". If no problems occurred, then the bad entry will be corrected by the archive (the bad entry is removed from the archive file and put into the "wrong entry" file. Then the new entry is placed in the archive file. If it fails in any of the above, then the method fails (throws an exception which is caught and use for replying NotOk to the message).

Specified by:
visit in interface ArchiveMessageVisitor
Specified by:
visit in class ChecksumArchiveServer
Parameters:
msg - The message containing the correct instance of the file to correct.
Throws:
ArgumentNotValid - If the correct message is null.

visit

public void visit(GetChecksumMessage msg)
           throws ArgumentNotValid
Method for retrieving the checksum of a record.

Specified by:
visit in interface ArchiveMessageVisitor
Specified by:
visit in class ChecksumArchiveServer
Parameters:
msg - The GetChecksumMessage which contains the name of the record to have its checksum retrieved.
Throws:
ArgumentNotValid - If the message is null.

visit

public void visit(GetAllFilenamesMessage msg)
           throws ArgumentNotValid
Method for retrieving all the filenames within the archive.

Specified by:
visit in interface ArchiveMessageVisitor
Specified by:
visit in class ChecksumArchiveServer
Parameters:
msg - The GetAllFilenamesMessage.
Throws:
ArgumentNotValid - If the GetAllFilenamesMessages is null.

visit

public void visit(GetAllChecksumsMessage msg)
           throws ArgumentNotValid
Method for retrieving a map containing all the checksums and their corresponding filenames within the archive.

Specified by:
visit in interface ArchiveMessageVisitor
Specified by:
visit in class ChecksumArchiveServer
Parameters:
msg - The GetAllChecksumMessage.
Throws:
ArgumentNotValid - If the GetAllChecksumMessage is null.