dk.netarkivet.archive.bitarchive
Class Bitarchive

java.lang.Object
  extended by dk.netarkivet.archive.bitarchive.Bitarchive

public class Bitarchive
extends java.lang.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
protected  org.apache.commons.logging.Log log
          Logging output place.
 
Method Summary
 BatchStatus batch(java.lang.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(java.lang.String arcfile, long index)
          Get an ARC or WARC record out of the archive.
 java.io.File getFile(java.lang.String arcFileID)
          Get a file for a given arcFileID.
static Bitarchive getInstance()
          Get the one instance of the bitarchive.
 void upload(RemoteFile arcfile, java.lang.String fileName)
          Upload an ARC file to this archive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.commons.logging.Log log
Logging output place.

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(java.lang.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 bounds
IOFailure - If there were problems reading the arcfile.
UnknownID - Does it really, and when ?

upload

public void upload(RemoteFile arcfile,
                   java.lang.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 archive
IOFailure - 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(java.lang.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 java.io.File getFile(java.lang.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.