Class BatchStatus


  • public class BatchStatus
    extends Object
    Class for transferring batch status information.
    • Constructor Detail

      • BatchStatus

        public BatchStatus​(String bitArchiveAppId,
                           Collection<File> filesFailed,
                           int noOfFilesProcessed,
                           RemoteFile resultFile,
                           List<FileBatchJob.ExceptionOccurrence> exceptions)
        Create a new BatchStatus object for a specific bitarchive.
        Parameters:
        bitArchiveAppId - The application ID identifying the bitarchive, that run this batch job.
        filesFailed - A list of files that the batch job could not process.
        noOfFilesProcessed - The total number of files processed
        resultFile - A file containing the result of the batch job
        exceptions - A list of exceptions caught during the execution of the batchJob
      • BatchStatus

        public BatchStatus​(Collection<File> filesFailed,
                           int noOfFilesProcessed,
                           RemoteFile resultFile,
                           List<FileBatchJob.ExceptionOccurrence> exceptions)
        Create a new BatchStatus object for a specific bitarchive.
        Parameters:
        filesFailed - A list of files that the batch job could not process
        noOfFilesProcessed - The total number of files processed
        resultFile - A file containing the result of the batch job
        exceptions - A list of exceptions caught during the execution of the batchJob
    • Method Detail

      • getNoOfFilesProcessed

        public int getNoOfFilesProcessed()
        Get the number of files processed by the batch job. This counts all files whether failed or not.
        Returns:
        number of files passed to processFile
      • getFilesFailed

        public Collection<File> getFilesFailed()
        Get the File objects for the files that failed.
        Returns:
        A collection containing the files that processFile returned false on.
      • getBitArchiveAppId

        public String getBitArchiveAppId()
        Get the appId (internal string) for the bitarchive that these are the results from. Set to ALL_BITARCHIVE_APPS if this it the combined status.
        Returns:
        A uniquely identifying string that should *not* be parsed
      • getResultFile

        public RemoteFile getResultFile()
        Get the file containing results from a batch job. This may be null, if the batch job resulted in errors.
        Returns:
        A remote file containing results in some job-specific format.
      • getExceptions

        public List<FileBatchJob.ExceptionOccurrence> getExceptions()
        Get the list of exceptions that happened during the batch job.
        Returns:
        List of exceptions with information on where they occurred.
      • copyResults

        public void copyResults​(File targetFile)
                         throws IllegalState
        Copy the results of a batch job into a local file. This deletes the file from the remote server as appropriate. Note that this method or appendResults can only be called once on a given object. If hasResultFile() returns true, this method is safe to call.
        Parameters:
        targetFile - File to copy the results into. This file will be overridden if hasResultFile() returns true;
        Throws:
        IllegalState - If the results have already been copied, or there are no results to copy due to errors.
      • appendResults

        public void appendResults​(OutputStream stream)
                           throws IllegalState
        Append the results of a batch job into a stream. This deletes the results file from the remote server, so this or copyResults can only be called once. If hasResultFile() returns true, this method is safe to call.
        Parameters:
        stream - A stream to append results to.
        Throws:
        IllegalState - If the results have already been copied, or there are no results to copy due to errors.
      • hasResultFile

        public boolean hasResultFile()
        Returns true if this object has a result file. There is no result file if no bitarchives succeeded in processing any files, or if the result file sent has already been deleted (e.g., by calling copyResults or appendResults).
        Returns:
        True if this object has a result file.
      • toString

        public String toString()
        Returns a human-readable description of this object. The value returned should not be machine-processed, as it is subject to change without notice.
        Overrides:
        toString in class Object
        Returns:
        Human-readable description of this object.