uk.org.ogsadai.activity.indexedfiles
Class AddAndIndexFileActivity

java.lang.Object
  |
  +--uk.org.ogsadai.activity.Activity
        |
        +--uk.org.ogsadai.activity.files.AbstractFileActivity
              |
              +--uk.org.ogsadai.activity.indexedfiles.AddAndIndexFileActivity
All Implemented Interfaces:
ActivityConfigurationCreator

public class AddAndIndexFileActivity
extends AbstractFileActivity
implements ActivityConfigurationCreator

Imports a flat file into a file system data resource and builds an index using the Jakarta Lucene full-text search engine. The types of flat file that are supported can be configured using the activity configuration mechanism. See the activity user documentation for more details: OGSADAI/doc/interaction/activities/indexedfiles/addIndexFile.html

Author:
The OGSA-DAI Project Team.

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
private static DAILogger LOG
          Logger object for logging in this class
private  java.io.File mDirectory
          Directory where the new file resides
private  java.lang.String mDirname
          Name of the directory where the new file resides
private  java.lang.String[] mFields
          Indexed fields
private  java.io.File mFile
          New file to be added and indexed
private  java.lang.String mFilename
          Name of the new file to be added and indexed
private  java.io.FileOutputStream mFileOutput
          Stream to the new file to be added and indexed
private  java.lang.String mFiletype
          Type of flat file
private  java.io.File mIndex
          Index directory
private  FlatFileIndexWriter mIndexHelper
          Index helper class used for indexing certain file types
private  java.lang.String mIndexName
          Index directory name
private  org.apache.lucene.index.IndexWriter mIndexWriter
          Current index writer for this activity
private  BlockReader mInput
          Activity input - new data file
 
Fields inherited from class uk.org.ogsadai.activity.files.AbstractFileActivity
mCredentials, mFileAccessProvider, mTopDir
 
Fields inherited from class uk.org.ogsadai.activity.Activity
mContext, mExternalInputs, mExternalOutputs, mInternalInputs, mInternalOutputs
 
Constructor Summary
AddAndIndexFileActivity(org.w3c.dom.Element element)
           
 
Method Summary
protected  void cleanUp()
          This method can be overridden by any Activity implementations that need to free up resources in the event of an error or intermediate termination of the activity processing.
 ActivityConfiguration createActivityConfiguration()
          Creates the ActivityConfiguration object for a particular activity.
private  void indexFile()
          Indexes a file using the file indexer and closes the index.
 void initialise()
          Gets the data resource accessor for the files data resource according to whether the users credentials permit this access.
protected  void processBlock()
          Performs an iteration of the processing of an activity.
protected  void processFirst()
          This method is called during the first iteration of processing an activity.
 
Methods inherited from class uk.org.ogsadai.activity.Activity
connectsTo, createOutputPipe, getActivityConfiguration, getActivityName, getCause, getName, getObservableStatus, getProperties, getSession, getStatus, hasActivityConfiguration, hasProperties, process, setActivityName, setCompleted, setError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
Copyright statement

See Also:
Constant Field Values

LOG

private static final DAILogger LOG
Logger object for logging in this class


mFilename

private java.lang.String mFilename
Name of the new file to be added and indexed


mFile

private java.io.File mFile
New file to be added and indexed


mFileOutput

private java.io.FileOutputStream mFileOutput
Stream to the new file to be added and indexed


mDirname

private java.lang.String mDirname
Name of the directory where the new file resides


mDirectory

private java.io.File mDirectory
Directory where the new file resides


mFiletype

private java.lang.String mFiletype
Type of flat file


mIndexName

private java.lang.String mIndexName
Index directory name


mIndex

private java.io.File mIndex
Index directory


mFields

private java.lang.String[] mFields
Indexed fields


mIndexWriter

private org.apache.lucene.index.IndexWriter mIndexWriter
Current index writer for this activity


mIndexHelper

private FlatFileIndexWriter mIndexHelper
Index helper class used for indexing certain file types


mInput

private BlockReader mInput
Activity input - new data file

Constructor Detail

AddAndIndexFileActivity

public AddAndIndexFileActivity(org.w3c.dom.Element element)
                        throws ActivityCreationException,
                               ActivitySpecificationException
Method Detail

initialise

public void initialise()
                throws ActivitySpecificationException,
                       ActivityExecutionException
Description copied from class: AbstractFileActivity
Gets the data resource accessor for the files data resource according to whether the users credentials permit this access.

Overrides:
initialise in class AbstractFileActivity
Throws:
ActivitySpecificationException - If the user is not permitted to access the resource.
ActivityExecutionException - If some internal problem occurs.
See Also:
Activity.initialise()

processFirst

protected void processFirst()
Description copied from class: Activity
This method is called during the first iteration of processing an activity. It can be overridden by subclasses to define some processing that should be done only once during the first iteration of the activity processing, for example evaluating a database query.

Overrides:
processFirst in class Activity

processBlock

protected void processBlock()
Description copied from class: Activity
Performs an iteration of the processing of an activity. This may involve reading a block of input data and writing a block of output data, or may involve some other kind of processing. When an activity is processed by the OGSA-DAI engine, this method will be invoked repeatedly until the activity either completes or stops due to an error or termination call. An implementation of this method should invoke the setCompleted method to indicate that processing is complete, or the setError method if an error occurs that will prevent the processing from completing.

Specified by:
processBlock in class Activity

cleanUp

protected void cleanUp()
Description copied from class: Activity
This method can be overridden by any Activity implementations that need to free up resources in the event of an error or intermediate termination of the activity processing.

Overrides:
cleanUp in class Activity

indexFile

private void indexFile()
Indexes a file using the file indexer and closes the index.


createActivityConfiguration

public ActivityConfiguration createActivityConfiguration()
Description copied from interface: ActivityConfigurationCreator
Creates the ActivityConfiguration object for a particular activity. The intialise method of the ActivityConfiguration object will be invoked by an ActivityCreator.

Specified by:
createActivityConfiguration in interface ActivityConfigurationCreator
Returns:
an ActivityConfiguration object