public final class DatabaseBasedActiveBitPreservation extends Object implements ActiveBitPreservation, CleanupIF
A database is used to handle the bitpreservation.
Modifier and Type | Method and Description |
---|---|
void |
addMissingFilesToAdminData(String... filenames)
Old method, which refers to the checksum replica part of admin data.
|
void |
changeStateForAdminData(String filename)
This should reestablish the state for the file.
|
void |
cleanup()
Method for cleaning up this instance.
|
void |
close()
Method for closing the running instance of this class.
|
void |
findChangedFiles(Replica replica)
The method is used to update the checksum for all the files in a replica.
|
void |
findMissingFiles(Replica replica)
This method retrieves the filelist for the replica, and then it updates the database with this list of filenames.
|
Iterable<String> |
getChangedFiles(Replica replica)
This method retrieves the name of all the files which has a wrong checksum for the replica.
|
Iterable<String> |
getChangedFilesForAdminData()
Old method, which refers to the checksum replica part of admin data.
|
Date |
getDateForChangedFiles(Replica replica)
This method retrieves the date for the latest checksum update was performed for the replica.
|
Date |
getDateForMissingFiles(Replica replica)
This method retrieves the date for the latest filelist update was performed for the replica.
|
static DatabaseBasedActiveBitPreservation |
getInstance()
Method for retrieving the current instance of this class.
|
Iterable<String> |
getMissingFiles(Replica replica)
This method retrieves the name of all the files which are missing for the given replica.
|
Iterable<String> |
getMissingFilesForAdminData()
Old method, which refers to the checksum replica part of admin data.
|
long |
getNumberOfChangedFiles(Replica replica)
The method calculates the number of files which has a wrong checksum for the replica.
|
long |
getNumberOfFiles(Replica replica)
This method finds the number of files which are known to be in the archive of a specific replica.
|
long |
getNumberOfMissingFiles(Replica replica)
This method calculates the number of files which are not found in the given replica.
|
PreservationState |
getPreservationState(String filename)
Method for retrieving the FilePreservationState for a specific file.
|
Map<String,PreservationState> |
getPreservationStateMap(String... filenames)
Method for retrieving the FilePreservationState for a list of files.
|
void |
replaceChangedFile(Replica replica,
String filename,
String credentials,
String checksum)
Check that the checksum of the file is indeed different to the value in admin data and reference replica.
|
void |
uploadMissingFiles(Replica replica,
String... filenames)
This method is used to upload missing files to a replica.
|
public static DatabaseBasedActiveBitPreservation getInstance()
public long getNumberOfChangedFiles(Replica replica) throws ArgumentNotValid
getNumberOfChangedFiles
in interface ActiveBitPreservation
replica
- The replica for which to count the number of changed files.ArgumentNotValid
- If the replica is null.public Iterable<String> getChangedFiles(Replica replica) throws ArgumentNotValid
getChangedFiles
in interface ActiveBitPreservation
replica
- The replica for which the changed files should be found.ArgumentNotValid
- If the replica is null.public long getNumberOfMissingFiles(Replica replica) throws ArgumentNotValid
getNumberOfMissingFiles
in interface ActiveBitPreservation
replica
- The replica for which to count the number of missing files.ArgumentNotValid
- If the replica is null.public Iterable<String> getMissingFiles(Replica replica) throws ArgumentNotValid
getMissingFiles
in interface ActiveBitPreservation
replica
- The replica for which the missing files should be found.ArgumentNotValid
- If the replica is null.public Date getDateForChangedFiles(Replica replica) throws ArgumentNotValid
This method does not call out to the replicas. It only contacts the local database.
getDateForChangedFiles
in interface ActiveBitPreservation
replica
- The replica for which the date for last checksum update should be retrieved.ArgumentNotValid
- If the replica is null.public Date getDateForMissingFiles(Replica replica) throws ArgumentNotValid
This method does not call out to the replicas. It only contacts the local database.
getDateForMissingFiles
in interface ActiveBitPreservation
replica
- The replica for which the date for last filelist update should be retrieved.ArgumentNotValid
- If the replica is null.public void findChangedFiles(Replica replica) throws ArgumentNotValid
The corresponding replicafileinfo entries in the database for the retrieved checksum results will be updated. Then a checksum update will be performed to check for corrupted replicafileinfo.
Each replica can only be updated once at the time.
findChangedFiles
in interface ActiveBitPreservation
replica
- The replica to find the changed files for.ArgumentNotValid
- If the replica is null.public void findMissingFiles(Replica replica) throws ArgumentNotValid
findMissingFiles
in interface ActiveBitPreservation
replica
- The replica to find the missing files for.ArgumentNotValid
- If the replica is null.public PreservationState getPreservationState(String filename) throws ArgumentNotValid
getPreservationState
in interface ActiveBitPreservation
filename
- The name of the file for whom the FilePreservationState should be retrieved.ArgumentNotValid
- If the filename is null or the empty string.public Map<String,PreservationState> getPreservationStateMap(String... filenames) throws ArgumentNotValid
getPreservationStateMap
in interface ActiveBitPreservation
filenames
- The list of filenames whose FilePreservationState should be retrieved.ArgumentNotValid
- If the list of filenames are null.public long getNumberOfFiles(Replica replica) throws ArgumentNotValid
getNumberOfFiles
in interface ActiveBitPreservation
replica
- The replica for which the number of files should be counted.ArgumentNotValid
- If the replica is null.public void replaceChangedFile(Replica replica, String filename, String credentials, String checksum) throws ArgumentNotValid
replaceChangedFile
in interface ActiveBitPreservation
replica
- The replica to restore file tofilename
- The name of the filecredentials
- The credentials used to perform this replace operationchecksum
- The known bad checksum. Only a file with this bad checksum is attempted repaired.ArgumentNotValid
- If any of the arguments are not valid.public void uploadMissingFiles(Replica replica, String... filenames) throws ArgumentNotValid, IOFailure
uploadMissingFiles
in interface ActiveBitPreservation
replica
- The replica where the files are missing.filenames
- The names of the files which are missing in the given replica.ArgumentNotValid
- If the replica or list of filenames is null, or if the list of filenames is empty.IOFailure
- If some files could not be established.public void changeStateForAdminData(String filename) throws ArgumentNotValid, NotImplementedException
changeStateForAdminData
in interface ActiveBitPreservation
filename
- The name of the file to change the state for.ArgumentNotValid
- If the filename is invalid.NotImplementedException
- This will not be implemented.public Iterable<String> getMissingFilesForAdminData() throws NotImplementedException
getMissingFilesForAdminData
in interface ActiveBitPreservation
NotImplementedException
- This method will not be implemented.public Iterable<String> getChangedFilesForAdminData() throws NotImplementedException
getChangedFilesForAdminData
in interface ActiveBitPreservation
NotImplementedException
- This method will not be implemented.public void addMissingFilesToAdminData(String... filenames) throws ArgumentNotValid, NotImplementedException
addMissingFilesToAdminData
in interface ActiveBitPreservation
filenames
- The list of filenames which should be added to admin data.NotImplementedException
- This method will not be implemented.ArgumentNotValid
- If filenames invalid.public void close()
Copyright © 2005–2016 The Royal Danish Library, the Danish State and University Library, the National Library of France and the Austrian National Library.. All rights reserved.