Class 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 Detail

      • log

        protected static final org.slf4j.Logger 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​(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,
                           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​(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.