dk.netarkivet.common.distribute.arcrepository
Class BatchStatus

java.lang.Object
  extended by dk.netarkivet.common.distribute.arcrepository.BatchStatus

public class BatchStatus
extends java.lang.Object

Class for transferring batch status information.


Constructor Summary
BatchStatus(java.util.Collection<java.io.File> filesFailed, int noOfFilesProcessed, RemoteFile resultFile, java.util.List<FileBatchJob.ExceptionOccurrence> exceptions)
          Create a new BatchStatus object for a specific bitarchive.
BatchStatus(java.lang.String bitArchiveAppId, java.util.Collection<java.io.File> filesFailed, int noOfFilesProcessed, RemoteFile resultFile, java.util.List<FileBatchJob.ExceptionOccurrence> exceptions)
          Create a new BatchStatus object for a specific bitarchive.
 
Method Summary
 void appendResults(java.io.OutputStream stream)
          Append the results of a batch job into a stream.
 void copyResults(java.io.File targetFile)
          Copy the results of a batch job into a local file.
 java.lang.String getBitArchiveAppId()
          Get the appId (internal string) for the bitarchive that these are the results from.
 java.util.List<FileBatchJob.ExceptionOccurrence> getExceptions()
          Get the list of exceptions that happened during the batch job.
 java.util.Collection<java.io.File> getFilesFailed()
          Get the File objects for the files that failed.
 int getNoOfFilesProcessed()
          Get the number of files processed by the batch job.
 RemoteFile getResultFile()
          Get the file containing results from a batch job.
 boolean hasResultFile()
          Returns true if this object has a result file.
 java.lang.String toString()
          Returns a human-readable description of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BatchStatus

public BatchStatus(java.lang.String bitArchiveAppId,
                   java.util.Collection<java.io.File> filesFailed,
                   int noOfFilesProcessed,
                   RemoteFile resultFile,
                   java.util.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(java.util.Collection<java.io.File> filesFailed,
                   int noOfFilesProcessed,
                   RemoteFile resultFile,
                   java.util.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 java.util.Collection<java.io.File> getFilesFailed()
Get the File objects for the files that failed.

Returns:
A collection containing the files that processFile returned false on.

getBitArchiveAppId

public java.lang.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 java.util.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(java.io.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(java.io.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 java.lang.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 java.lang.Object
Returns:
Human-readable description of this object.