Package dk.netarkivet.archive.bitarchive
Class Bitarchive
- java.lang.Object
-
- dk.netarkivet.archive.bitarchive.Bitarchive
-
public class Bitarchive extends Object
The central class in the bit archive. Implements the API: upload(), get(), correct(), batch(). A bit archive is expected to not know about any other bit archives, and is not considered responsible for making MD5 checksums.
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.Logger
log
Logging output place.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BatchStatus
batch(String bitarchiveAppId, FileBatchJob job)
Run a batch job on all ARC entries in the archive.void
close()
Release all resources allocated by the bitarchive Ensures that all admin data and log data are flushed.BitarchiveRecord
get(String arcfile, long index)
Get an ARC or WARC record out of the archive.File
getFile(String arcFileID)
Get a file for a given arcFileID.static Bitarchive
getInstance()
Get the one instance of the bitarchive.void
upload(RemoteFile arcfile, String fileName)
Upload an ARC file to this archive.
-
-
-
Method Detail
-
close
public void close()
Release all resources allocated by the bitarchive Ensures that all admin data and log data are flushed.
-
get
public BitarchiveRecord get(String arcfile, long index) throws ArgumentNotValid, UnknownID, IOFailure
Get an ARC or WARC record out of the archive. Returns null if the archive file is not found in this bitarchive.- Parameters:
arcfile
- The name of an Archive file.index
- Index of the Archive record in the file- Returns:
- A BitarchiveRecord object for the record in question. This record contains the data from the file.
- Throws:
ArgumentNotValid
- If arcfile is null/empty, or if index is out of boundsIOFailure
- If there were problems reading the arcfile.UnknownID
- Does it really, and when ?
-
upload
public void upload(RemoteFile arcfile, String fileName) throws PermissionDenied, ArgumentNotValid, IOFailure
Upload an ARC file to this archive.- Parameters:
arcfile
- A file to add to the archive.fileName
- the arcfiles filename. The file will be identified in the archive by this filename- Throws:
PermissionDenied
- if arcfile already exists in the archiveIOFailure
- if an IO failure occurs (e.g. running out of disk space)ArgumentNotValid
- if arcfile is null or the filename is null or empty.
-
batch
public BatchStatus batch(String bitarchiveAppId, FileBatchJob job) throws ArgumentNotValid, IOFailure
Run a batch job on all ARC entries in the archive.This currently runs synchronously, and returns only after finish() has been called.
- Parameters:
bitarchiveAppId
- A String representing the bitarchive AppId.job
- An object that implements the ARCBatchJob 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 ARC entry.- Returns:
- A localBatchStatus
- Throws:
ArgumentNotValid
- if job or file is null.IOFailure
- if there was problems writing to the RemoteFile
-
getFile
public File getFile(String arcFileID) throws ArgumentNotValid
Get a file for a given arcFileID.- Parameters:
arcFileID
- name of the file to be retrieved.- Returns:
- The file requested or null if not found
- Throws:
ArgumentNotValid
- If arcFileID was null or empty.
-
getInstance
public static Bitarchive getInstance() throws PermissionDenied
Get the one instance of the bitarchive.- Returns:
- An instance of the Bitarchive class.
- Throws:
PermissionDenied
- If the storage area used for files is not accessible.
-
-