public class LocalArcRepositoryClient extends Object implements ArcRepositoryClient
Constructor and Description |
---|
LocalArcRepositoryClient()
Create a new LocalArcRepositoryClient based on current settings.
|
Modifier and Type | Method and Description |
---|---|
BatchStatus |
batch(FileBatchJob job,
String replicaId,
String... args)
Runs a batch job on each file in the ArcRepository.
|
void |
close()
Call on shutdown to release external resources.
|
File |
correct(String replicaId,
String checksum,
File file,
String credentials)
Method for correcting a bad entry.
|
BitarchiveRecord |
get(String arcfile,
long index)
Gets a single ARC record out of the ArcRepository.
|
File |
getAllChecksums(String replicaId)
Method for retrieving the checksums of all the files of the replica.
|
File |
getAllFilenames(String replicaId)
Method for retrieving all the filenames of the replica.
|
String |
getChecksum(String replicaId,
String filename)
Method for finding the checksum of a file.
|
void |
getFile(String arcfilename,
Replica replica,
File toFile)
Retrieves a file from an ArcRepository and places it in a local file.
|
File |
removeAndGetFile(String fileName,
String bitarchiveId,
String checksum,
String credentials)
Remove a file from one part of the ArcRepository, retrieving a copy for security purposes.
|
void |
store(File file)
Store the given file in the ArcRepository.
|
void |
updateAdminChecksum(String filename,
String checksum)
Updates the checksum kept in the ArcRepository for a given file.
|
void |
updateAdminData(String fileName,
String bitarchiveId,
ReplicaStoreState newval)
Updates the administrative data in the ArcRepository for a given file and replica.
|
public LocalArcRepositoryClient()
public void close()
ArcRepositoryClient
close
in interface ArcRepositoryClient
close
in interface HarvesterArcRepositoryClient
close
in interface PreservationArcRepositoryClient
close
in interface ViewerArcRepositoryClient
public void store(File file) throws IOFailure, ArgumentNotValid
store
in interface ArcRepositoryClient
store
in interface HarvesterArcRepositoryClient
store
in interface PreservationArcRepositoryClient
file
- A file to be stored. Must exist.IOFailure
- thrown if store is unsuccessful, or failed to clean up files after the store operation.IllegalState
- if file already exists.ArgumentNotValid
- if file parameter is null or file is not an existing file.public BitarchiveRecord get(String arcfile, long index) throws ArgumentNotValid
get
in interface ArcRepositoryClient
get
in interface PreservationArcRepositoryClient
get
in interface ViewerArcRepositoryClient
arcfile
- The name of a file containing the desired record.index
- The offset of the desired record in the fileArgumentNotValid
- on null or empty filenames, or if index is negative.IOFailure
- If the get operation failed.public void getFile(String arcfilename, Replica replica, File toFile)
getFile
in interface ArcRepositoryClient
getFile
in interface PreservationArcRepositoryClient
getFile
in interface ViewerArcRepositoryClient
arcfilename
- Name of the arcfile to retrieve.replica
- The bitarchive to retrieve the data from. (Note argument is ignored)toFile
- Filename of a place where the file fetched can be put.ArgumentNotValid
- if arcfilename is null or empty, or if toFile is nullIOFailure
- if there are problems reading or writing file, or the file with the given arcfilename could not
be found.public BatchStatus batch(FileBatchJob job, String replicaId, String... args) throws ArgumentNotValid, IOFailure
batch
in interface ArcRepositoryClient
batch
in interface PreservationArcRepositoryClient
batch
in interface ViewerArcRepositoryClient
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. This can be null.ArgumentNotValid
- If the job is null or the replicaId is either null or the empty string.IOFailure
- If a problem occurs during processing the batchjob.public void updateAdminData(String fileName, String bitarchiveId, ReplicaStoreState newval)
updateAdminData
in interface ArcRepositoryClient
updateAdminData
in interface PreservationArcRepositoryClient
fileName
- The name of a file stored in the ArcRepository.bitarchiveId
- The id of the replica that the administrative data for fileName is wrong for.newval
- What the administrative data will be updated to.public void updateAdminChecksum(String filename, String checksum)
updateAdminChecksum
in interface ArcRepositoryClient
updateAdminChecksum
in interface PreservationArcRepositoryClient
filename
- The name of a file stored in the ArcRepository.checksum
- The new checksum.public File removeAndGetFile(String fileName, String bitarchiveId, String checksum, String credentials)
removeAndGetFile
in interface ArcRepositoryClient
removeAndGetFile
in interface PreservationArcRepositoryClient
fileName
- The name of the file to remove.bitarchiveId
- The id of the replica from which to remove the file. Not used in this implementation, may be
null.checksum
- The checksum of the file to be removed.credentials
- A string that shows that the user is allowed to perform this operation.ArgumentNotValid
- On null or empty parameters for fileName, checksum or credentials.IOFailure
- On IO trouble.PermissionDenied
- On wrong MD5 sum or wrong credentials.public File getAllChecksums(String replicaId) throws IOFailure, ArgumentNotValid
getAllChecksums
in interface PreservationArcRepositoryClient
replicaId
- Inherited dummy argument.ArgumentNotValid
- If the replicaId is either null or the empty string.IOFailure
- If an unexpected IOException is caught.GetAllChecksumsMessage
public File getAllFilenames(String replicaId) throws IOFailure, ArgumentNotValid
getAllFilenames
in interface PreservationArcRepositoryClient
replicaId
- Inherited dummy argument.ArgumentNotValid
- If the replicaId is either null or empty.IOFailure
- If an IOException is caught.GetAllFilenamesMessage
public File correct(String replicaId, String checksum, File file, String credentials) throws ArgumentNotValid, PermissionDenied
correct
in interface PreservationArcRepositoryClient
replicaId
- Inherited dummy argument.checksum
- The checksum of the bad entry.file
- The new file to replace the bad entry.credentials
- The 'password' to allow changing the archive.ArgumentNotValid
- If one of the arguments are null, or if a string is empty.PermissionDenied
- If the credentials or checksum are invalid.public String getChecksum(String replicaId, String filename) throws ArgumentNotValid
getChecksum
in interface PreservationArcRepositoryClient
replicaId
- Inherited dummy variable.filename
- The name of the file to calculate the checksum.ArgumentNotValid
- If the replicaId or the filename is either null or the empty string.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.