dk.netarkivet.common.distribute.arcrepository
Interface PreservationArcRepositoryClient

All Known Subinterfaces:
ArcRepositoryClient
All Known Implementing Classes:
JMSArcRepositoryClient, LocalArcRepositoryClient

public interface PreservationArcRepositoryClient

Implements the Facade pattern to shield off the methods in JMSArcRepositoryClient not to be used by the bit preservation system.


Method Summary
 BatchStatus batch(FileBatchJob job, java.lang.String replicaId, java.lang.String... args)
          Runs a batch batch job on each file in the ArcRepository.
 void close()
          Call on shutdown to release external resources.
 java.io.File correct(java.lang.String replicaId, java.lang.String checksum, java.io.File file, java.lang.String credentials)
          Method for correcting a file in a replica.
 BitarchiveRecord get(java.lang.String arcfile, long index)
          Gets a single ARC record out of the ArcRepository.
 java.io.File getAllChecksums(java.lang.String replicaId)
          Retrieves all the checksum from the replica through a GetAllChecksumMessage.
 java.io.File getAllFilenames(java.lang.String replicaId)
          Retrieves the names of all the files in the replica through a GetAllFilenamesMessage.
 java.lang.String getChecksum(java.lang.String replicaId, java.lang.String filename)
          Retrieves the checksum of a specific file.
 void getFile(java.lang.String arcfilename, Replica replica, java.io.File toFile)
          Retrieves a file from an ArcRepository and places it in a local file.
 java.io.File removeAndGetFile(java.lang.String fileName, java.lang.String replicaId, java.lang.String checksum, java.lang.String credentials)
          Remove a file from one part of the ArcRepository, retrieveing a copy for security purposes.
 void store(java.io.File file)
          Store the given file in the ArcRepository.
 void updateAdminChecksum(java.lang.String filename, java.lang.String checksum)
          Updates the checksum kept in the ArcRepository for a given file.
 void updateAdminData(java.lang.String fileName, java.lang.String replicaId, ReplicaStoreState newval)
          Updates the administrative data in the ArcRepository for a given file and bitarchive replica.
 

Method Detail

close

void close()
Call on shutdown to release external resources.


get

BitarchiveRecord get(java.lang.String arcfile,
                     long index)
                     throws ArgumentNotValid
Gets a single ARC record out of the ArcRepository.

Parameters:
arcfile - The name of a file containing the desired record.
index - The offset of the desired record in the file
Returns:
a BitarchiveRecord-object, or null if request times out or object is not found.
Throws:
ArgumentNotValid - If the get operation failed.

getFile

void getFile(java.lang.String arcfilename,
             Replica replica,
             java.io.File toFile)
Retrieves a file from an ArcRepository and places it in a local file.

Parameters:
arcfilename - Name of the arcfile to retrieve.
replica - The bitarchive to retrieve the data from.
toFile - Filename of a place where the file fetched can be put.
Throws:
IOFailure - if there are problems getting a reply or the file could not be found.

store

void store(java.io.File file)
           throws IOFailure,
                  ArgumentNotValid
Store the given file in the ArcRepository. After storing, the file is deleted.

Parameters:
file - A file to be stored. Must exist.
Throws:
IOFailure - thrown if store is unsuccesful, or failed to clean up files after the store operation.
ArgumentNotValid - if file parameter is null or file is not an existing file.

batch

BatchStatus batch(FileBatchJob job,
                  java.lang.String replicaId,
                  java.lang.String... args)
Runs a batch batch job on each file in the ArcRepository.

Parameters:
job - An object that implements the FileBatchJob interface. The initialize() method will be called before processing and the finish() method will be called afterwards. The process() method will be called with each File entry. An optional function postProcess() allows handling the combined results of the batchjob, e.g. summing the results, sorting, etc.
replicaId - The archive to execute the job on.
args - The arguments for the batchjob.
Returns:
The status of the batch job after it ended.

updateAdminData

void updateAdminData(java.lang.String fileName,
                     java.lang.String replicaId,
                     ReplicaStoreState newval)
Updates the administrative data in the ArcRepository for a given file and bitarchive replica.

Parameters:
fileName - The name of a file stored in the ArcRepository.
replicaId - The id if the replica that the administrative data for fileName is wrong for.
newval - What the administrative data will be updated to.

updateAdminChecksum

void updateAdminChecksum(java.lang.String filename,
                         java.lang.String checksum)
Updates the checksum kept in the ArcRepository for a given file. It is the responsibility of the ArcRepository implementation to ensure that this checksum matches that of the underlying files.

Parameters:
filename - The name of a file stored in the ArcRepository.
checksum - The new checksum.

removeAndGetFile

java.io.File removeAndGetFile(java.lang.String fileName,
                              java.lang.String replicaId,
                              java.lang.String checksum,
                              java.lang.String credentials)
Remove a file from one part of the ArcRepository, retrieveing a copy for security purposes. This is typically used when repairing a file that has been corrupted.

Parameters:
fileName - The name of the file to remove.
replicaId - The replica id from which to remove the file.
checksum - The checksum of the file to be removed.
credentials - A string that shows that the user is allowed to perform this operation.
Returns:
A local copy of the file removed.

getAllChecksums

java.io.File getAllChecksums(java.lang.String replicaId)
Retrieves all the checksum from the replica through a GetAllChecksumMessage. This is the checksum archive alternative to running a ChecksumBatchJob.

Parameters:
replicaId - The id of the replica from which the checksums should be retrieved.
Returns:
A list of ChecksumEntries which is the results of the GetAllChecksumMessage.
See Also:
GetAllChecksumsMessage

getChecksum

java.lang.String getChecksum(java.lang.String replicaId,
                             java.lang.String filename)
Retrieves the checksum of a specific file. This is the checksum archive alternative to running a ChecksumJob limited to a specific file.

Parameters:
replicaId - The name of the replica to send the message.
filename - The name of the file for whom the checksum should be retrieved.
Returns:
The checksum of the file in the replica. Or null if an error occurred.

getAllFilenames

java.io.File getAllFilenames(java.lang.String replicaId)
Retrieves the names of all the files in the replica through a GetAllFilenamesMessage. This is the checksum archive alternative to running a FilelistBatchJob.

Parameters:
replicaId - The id of the replica from which the list of filenames should be retrieved.
Returns:
A list of all the filenames within the archive of the given replica.
See Also:
GetAllFilenamesMessage

correct

java.io.File correct(java.lang.String replicaId,
                     java.lang.String checksum,
                     java.io.File file,
                     java.lang.String credentials)
Method for correcting a file in a replica. This is the checksum archive method for correcting a file entry in the archive. The bitarchive uses 'removeAndGetFile' followed by a 'store'.

Parameters:
replicaId - The identification of the replica.
file - The new file to replace the old one.
credentials - The password for allowing to remove a file entry in the archive.