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)
          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)
          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.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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BatchStatus

public BatchStatus(java.lang.String bitArchiveAppId,
                   java.util.Collection<java.io.File> filesFailed,
                   int noOfFilesProcessed,
                   RemoteFile resultFile)
Create a new BatchStatus object for a specific bitarchive.

Parameters:
bitArchiveAppId -
filesFailed -
noOfFilesProcessed -
resultFile -

BatchStatus

public BatchStatus(java.util.Collection<java.io.File> filesFailed,
                   int noOfFilesProcessed,
                   RemoteFile resultFile)
Create a new BatchStatus object for a specific bitarchive.

Parameters:
filesFailed -
noOfFilesProcessed -
resultFile -
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.

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.