Interface PreservationState
-
- All Known Implementing Classes:
DatabasePreservationState
,FilePreservationState
public interface PreservationState
The interface for the preservations states used by the web applications.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
fileIsMissing(Replica bitarchive)
Check if the file is missing from a bitarchive.String
getAdminChecksum()
Get the MD5 checksum stored in the admin data.String
getAdminReplicaState(Replica replica)
Get the status of the file in a bitarchive, according to the admin data.String
getFilename()
Get the filename, this FilePreservationState is about.Replica
getReferenceBitarchive()
Returns a reference to a bitarchive that contains a version of the file with the correct checksum.String
getReferenceCheckSum()
Retrieve checksum that the majority of checksum references (bitarchives+admin) agree upon.List<String>
getReplicaChecksum(Replica replica)
Get the checksum of this file in a specific replica.String
getUniqueChecksum(Replica replica)
Get a checksum that the whole bitarchive agrees upon, or else "".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.String
toString()
Returns a human-readable representation of this object.
-
-
-
Method Detail
-
getReplicaChecksum
List<String> getReplicaChecksum(Replica replica)
Get the checksum of this file in a specific replica.- Parameters:
replica
- The replica to get the checksum from.- Returns:
- The file's checksum, if it is present in the replica, or "" if it either is absent or an error occurred.
-
getAdminChecksum
String getAdminChecksum()
Get the MD5 checksum stored in the admin data.- Returns:
- Checksum value as found in the admin data given at creation.
-
getAdminReplicaState
String getAdminReplicaState(Replica replica)
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. TODO Needs localisation.- Parameters:
replica
- The replica to get status for- Returns:
- Status that the admin data knows for this file in the bitarchive.
-
isAdminDataOk
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
-
getReferenceBitarchive
Replica 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
-
getUniqueChecksum
String getUniqueChecksum(Replica replica)
Get a checksum that the whole bitarchive agrees upon, or else "".- Parameters:
replica
- A replica to get checksum for this file from- Returns:
- The checksum for this file in the replica, if all machines that have that file agree, otherwise "". If no checksums are found, also returns "".
-
fileIsMissing
boolean fileIsMissing(Replica 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
-
getReferenceCheckSum
String getReferenceCheckSum()
Retrieve checksum that the majority of checksum references (bitarchives+admin) agree upon.- Returns:
- the reference checksum or "" if no majority exists
-
isAdminCheckSumOk
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
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.
-
getFilename
String getFilename()
Get the filename, this FilePreservationState is about. Needed to get at the filename given to constructor, and allow for a better datastructure.- Returns:
- the filename
-
-