dk.netarkivet.archive.arcrepository.bitpreservation
Class FilePreservationStatus

java.lang.Object
  extended by dk.netarkivet.archive.arcrepository.bitpreservation.FilePreservationStatus

public class FilePreservationStatus
extends java.lang.Object

This class collects the available bit preservation information for a file. This information is the following: 1) admin information for the file for each bitarchive and 2) the actual upload status


Constructor Summary
FilePreservationStatus(java.lang.String filename, ArcRepositoryEntry admindata)
          Create new instance of the preservation status for a file.
 
Method Summary
protected  boolean fileIsMissing(Location bitarchive)
          Check if the file is missing from a bitarchive
 java.lang.String getAdminBitarchiveState(Location bitarchive)
          Get the status of the file in a bitarchive, according to the admin data.
 BitArchiveStoreState getAdminBitarchiveStoreState(Location bitarchive)
          Get the status of the file in a bitarchive, according to the admin data.
 java.lang.String getAdminChecksum()
          Get the MD5 checksum stored in the admin data.
 java.util.List<java.lang.String> getBitarchiveChecksum(Location bitarchive)
          Get the checksum of this file in a specific bitarchive.
protected  java.util.Map<Location,java.util.List<java.lang.String>> getChecksumMap()
          Generate a map of checksums for this file in the bitarchive.
protected  java.util.List<java.lang.String> getChecksums(Location ba)
          Get the checksum of a single file in a bitarchive.
 Location getReferenceBitarchive()
          Returns a reference to a bitarchive that contains a version of the file with the correct checksum.
 java.lang.String getReferenceCheckSum()
          Retrieve checksum that the majority of checksum references (bitarchives+admin) agree upon.
 boolean isAdminCheckSumOk()
          Returns true if the checksum reported by admin data is equal to the majority checksum.
 boolean isAdminDataOk()
          Check if the admin data reflect the actual status of the archive.
 java.lang.String toString()
          Returns a human-readable representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FilePreservationStatus

FilePreservationStatus(java.lang.String filename,
                       ArcRepositoryEntry admindata)
Create new instance of the preservation status for a file. Note that this involves calls to both bitarchives, and so should not be lightly undertaken.

Parameters:
filename - The filename to get status for
admindata - The admin data for the file
Throws:
ArgumentNotValid - if filename is null or empty string, or if admindata is null.
Method Detail

getChecksumMap

protected java.util.Map<Location,java.util.List<java.lang.String>> getChecksumMap()
Generate a map of checksums for this file in the bitarchive.

Returns:
Map containing the output of checksum jobs from the bitarchives.

getChecksums

protected java.util.List<java.lang.String> getChecksums(Location ba)
Get the checksum of a single file in a bitarchive.

Note that this method runs a batch job on the bitarchives, and therefore takes a long time.

Parameters:
ba - The bitarchive to ask for checksum
Returns:
The MD5 checksums of the file, or the empty string if the file was not in the bitarchive.
See Also:
ChecksumJob.parseLine(String)

getBitarchiveChecksum

public java.util.List<java.lang.String> getBitarchiveChecksum(Location bitarchive)
Get the checksum of this file in a specific bitarchive.

Parameters:
bitarchive - The bitarchive to get the checksum from.
Returns:
The file's checksum, if it is present in the bitarchive, or "" if it either is absent or an error occurred.

getAdminChecksum

public java.lang.String getAdminChecksum()
Get the MD5 checksum stored in the admin data.

Returns:
Checksum value as found in the admin data given at creation.

getAdminBitarchiveState

public java.lang.String getAdminBitarchiveState(Location bitarchive)
Get the status of the file in a bitarchive, according to the admin data. This returns the status as a string for presentation purposes only.

Parameters:
bitarchive - The bitarchive to get status for
Returns:
Status that the admin data knows for this file in the bitarchive.

getAdminBitarchiveStoreState

public BitArchiveStoreState getAdminBitarchiveStoreState(Location bitarchive)
Get the status of the file in a bitarchive, according to the admin data.

Parameters:
bitarchive - The bitarchive to get status for
Returns:
Status that the admin data knows for this file in the bitarchive.

isAdminDataOk

public boolean isAdminDataOk()
Check if the admin data reflect the actual status of the archive. Admin State checking: For each bitarchive the admin state is compared to the checksum received from the bitarchive. If no checksum is received from the bitarchive the valid admin states are UPLOAD_STARTED and UPLOAD_FAILED. If a checksum is received from the bitarchive the valid admin state is UPLOAD_COMPLETED Admin checksum checking: The admin checksum must match the majority of reported checksums. Notice that a valid Admin data record does NOT imply that everything is ok. Specifically a file may be missing from a bitarchive, or the checksum of a file in a bitarchive may be wrong.

Returns:
true, if admin data match the state of the bitarchives, false otherwise

fileIsMissing

protected boolean fileIsMissing(Location bitarchive)
Check if the file is missing from a bitarchive

Parameters:
bitarchive - the bitarchive to check
Returns:
true if the file is missing from the bitarchive

getReferenceBitarchive

public Location getReferenceBitarchive()
Returns a reference to a bitarchive that contains a version of the file with the correct checksum. The correct checksum is defined as the checksum that the majority of the bitarchives and admin data agree upon. If no bitarchive exists with a correct version of the file null is returned.

Returns:
the name of the reference bitarchive or null if no reference exists

getReferenceCheckSum

public java.lang.String getReferenceCheckSum()
Retrieve checksum that the majority of checksum references (bitarchives+admin) agree upon.

Returns:
the reference checksum or "" if no majority exists

isAdminCheckSumOk

public boolean isAdminCheckSumOk()
Returns true if the checksum reported by admin data is equal to the majority checksum. If no majority checksum exists true is also returned. When this method returns false it is possible to correct the admin checksum using the majority checksum - when true is returned no better checksum exists for admin data.

Returns:
true, if the checksum reported by admin data is equal to the majority checksum

toString

public java.lang.String toString()
Returns a human-readable representation of this object. Do not depend on this format for anything automated, as it may change at any time.

Overrides:
toString in class java.lang.Object
Returns:
Description of this object.