DLESE Tools
v1.2

org.dlese.dpc.index.writer
Class ErrorFileIndexingWriter

java.lang.Object
  extended byorg.dlese.dpc.index.writer.FileIndexingServiceWriter
      extended byorg.dlese.dpc.index.writer.ErrorFileIndexingWriter
All Implemented Interfaces:
DocWriter

public class ErrorFileIndexingWriter
extends FileIndexingServiceWriter

Writes a Lucene Document that represents an error that has occured in in indexing a File. This writer is used by FileIndexingService. The error message and exception are also added to the default field for searching.


The Lucene Document fields that are created by this class are (in addition the the ones listed for FileIndexingServiceWriter):

error - Set to 'true' for all documents indexed by this writer. Not stored.
errormsg - The description of the error, for display. Stored.
exception - The name of the Java exception that was thrown. Stored.

Author:
John Weatherley
See Also:
FileIndexingServiceWriter, FileIndexingService

Constructor Summary
ErrorFileIndexingWriter(String errMsg, String exceptionName)
          Constructor for the ErrorFileIndexingWriter object
 
Method Summary
protected  void addCustomFields(Document newDoc, Document existingDoc, File sourceFile)
          Adds the error message to the Lucene document.
protected  void destroy()
          Does nothing.
 String getDocType()
          Gets the docType, which is 'errordoc.'
 String getReaderClass()
          Gets the name of the concrete DocReader class that is used to read this type of Document, which is "ErrorDocReader".
 void init(File source, Document existingDoc)
          Does nothing.
 
Methods inherited from class org.dlese.dpc.index.writer.FileIndexingServiceWriter
abortIndexing, addToAdminDefaultField, addToDefaultField, create, getDeletedDoc, getExistingDoc, getFileIndexingService, getSourceDir, getSourceFile, getValidationReport, isValidationEnabled, prtln, prtlnErr, setDebug, setDefaultFieldName, setFileIndexingService, setValidationEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ErrorFileIndexingWriter

public ErrorFileIndexingWriter(String errMsg,
                               String exceptionName)
Constructor for the ErrorFileIndexingWriter object

Parameters:
errMsg - A message indicating the error that occured when trying to index the file.
exceptionName - The name of the exception that was thrown when the error occured.
Method Detail

getDocType

public String getDocType()
                  throws Exception
Gets the docType, which is 'errordoc.'

Specified by:
getDocType in interface DocWriter
Specified by:
getDocType in class FileIndexingServiceWriter
Returns:
Returns 'errordoc.'
Throws:
Exception - If error.

getReaderClass

public String getReaderClass()
Gets the name of the concrete DocReader class that is used to read this type of Document, which is "ErrorDocReader".

Specified by:
getReaderClass in interface DocWriter
Specified by:
getReaderClass in class FileIndexingServiceWriter
Returns:
The STring "ErrorDocReader".

addCustomFields

protected final void addCustomFields(Document newDoc,
                                     Document existingDoc,
                                     File sourceFile)
                              throws Exception
Adds the error message to the Lucene document.

Specified by:
addCustomFields in class FileIndexingServiceWriter
Parameters:
newDoc - The new Document that is being created for this resource
existingDoc - An existing Document that currently resides in the index for the given resource, or null if none was previously present
sourceFile - The sourceFile that is being indexed.
Throws:
Exception - If an error occurs

init

public void init(File source,
                 Document existingDoc)
          throws Exception
Does nothing.

Specified by:
init in class FileIndexingServiceWriter
Parameters:
source - The source file being indexed
existingDoc - An existing Document that currently resides in the index for the given resource, or null if none was previously present
Throws:
Exception - If an error occured during set-up.

destroy

protected void destroy()
Does nothing.

Specified by:
destroy in class FileIndexingServiceWriter

DLESE Tools
v1.2