dk.netarkivet.common.utils.archive
Class ArchiveBatchJobBase

java.lang.Object
  extended by dk.netarkivet.common.utils.batch.FileBatchJob
      extended by dk.netarkivet.common.utils.archive.ArchiveBatchJobBase
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ArchiveBatchJob

public abstract class ArchiveBatchJobBase
extends FileBatchJob

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class dk.netarkivet.common.utils.batch.FileBatchJob
FileBatchJob.ExceptionOccurrence
 
Field Summary
protected  int noOfRecordsProcessed
          The total number of records processed.
 
Fields inherited from class dk.netarkivet.common.utils.batch.FileBatchJob
batchJobTimeout, exceptions, filesFailed, noOfFilesProcessed
 
Constructor Summary
ArchiveBatchJobBase()
           
 
Method Summary
abstract  void finish(java.io.OutputStream os)
          Finish up the job.
 java.lang.Exception[] getExceptionArray()
          Returns a representation of the list of Exceptions recorded for this archive batch job.
 void handleException(java.lang.Exception e, java.io.File archiveFile, long index)
          When the org.archive.io.arc classes throw IOExceptions while reading, this is where they go.
protected  void handleOurException(NetarkivetException e, java.io.File archiveFile, long index)
          Private method that handles our exception.
abstract  void initialize(java.io.OutputStream os)
          Initialize the job before running.
 int noOfRecordsProcessed()
          Returns the number of records processed.
 
Methods inherited from class dk.netarkivet.common.utils.batch.FileBatchJob
addException, addFinishException, addInitializeException, getBatchJobTimeout, getExceptions, getFilenamePattern, getFilesFailed, getNoOfFilesProcessed, maxExceptionsReached, postProcess, processFile, processOnlyFileNamed, processOnlyFilesMatching, processOnlyFilesMatching, processOnlyFilesNamed, setBatchJobTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

noOfRecordsProcessed

protected int noOfRecordsProcessed
The total number of records processed.

Constructor Detail

ArchiveBatchJobBase

public ArchiveBatchJobBase()
Method Detail

initialize

public abstract void initialize(java.io.OutputStream os)
Initialize the job before running. This is called before the processRecord() calls start coming.

Specified by:
initialize in class FileBatchJob
Parameters:
os - The OutputStream to which output data is written

finish

public abstract void finish(java.io.OutputStream os)
Finish up the job. This is called after the last processRecord() call.

Specified by:
finish in class FileBatchJob
Parameters:
os - The OutputStream to which output data is written

handleOurException

protected void handleOurException(NetarkivetException e,
                                  java.io.File archiveFile,
                                  long index)
Private method that handles our exception.

Parameters:
e - the given exception
archiveFile - The archive file where the exception occurred.
index - The offset in the archive file where the exception occurred.

handleException

public void handleException(java.lang.Exception e,
                            java.io.File archiveFile,
                            long index)
                     throws ArgumentNotValid
When the org.archive.io.arc classes throw IOExceptions while reading, this is where they go. Subclasses are welcome to override the default functionality which simply logs and records them in a list. TODO: Actually use the archive file/index entries in the exception list

Parameters:
e - An Exception thrown by the org.archive.io.arc classes.
archiveFile - The archive file that was processed while the Exception was thrown
index - The index (in the archive file) at which the Exception was thrown
Throws:
ArgumentNotValid - if e is null

getExceptionArray

public java.lang.Exception[] getExceptionArray()
Returns a representation of the list of Exceptions recorded for this archive batch job. If called by a subclass, a method overriding handleException() should always call super.handleException().

Returns:
All Exceptions passed to handleException so far.

noOfRecordsProcessed

public int noOfRecordsProcessed()
Returns the number of records processed.

Returns:
the number of records processed.