com.jalios.jcms.fileprocessor.test
Class SampleProcessor

java.lang.Object
  extended by com.jalios.jcms.fileprocessor.test.SampleProcessor
All Implemented Interfaces:
FileActionComponent, FileParser, FileProcessor

public class SampleProcessor
extends Object
implements FileProcessor, FileParser

Sample FileProcessor and FileParse which can be used for testing.

1. Configure in custom.prop

 fileprocessor.repository.JCMSUpload.component.SampleParser.class: com.jalios.jcms.fileprocessor.test.SampleProcessor
 fileprocessor.repository.JCMSUpload.component.SampleParser.extensions: parseme processme processandparseme
 
2. Upload test file with the following filename to trigger the corresponding behavior :
An optionnal number can be added to end of each file basename (eg process1.processme, process2.processme).
An optionnal number can be added to end of each file extension, provided it has been configured for repository (eg ignore.processme1, ignore.processme2)


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.jalios.jcms.fileprocessor.FileActionComponent
FileActionComponent.Operation
 
Nested classes/interfaces inherited from interface com.jalios.jcms.fileprocessor.FileActionComponent
FileActionComponent.Operation
 
Field Summary
 
Fields inherited from interface com.jalios.jcms.fileprocessor.FileActionComponent
CURRENT_OPERATION, FILE_SEPARATOR, REVISION
 
Fields inherited from interface com.jalios.jcms.fileprocessor.FileActionComponent
CURRENT_OPERATION, FILE_SEPARATOR, REVISION
 
Constructor Summary
SampleProcessor()
           
 
Method Summary
 String extractText(File file, Map<String,Object> ctxt)
          Parsers have to implement at least this method which exctract the text from the specified file and returns it.
 String getDescription()
          More detailed description of the Parser.
 String getName()
          Name of the Parser.
 int getOrder()
          Used to schedule the FileProcessors while treating a file.
 boolean isAvailable()
          A processor or parser may be unavailable (for instance because of a network connection down).
 boolean process(File file, Map<String,Object> ctxt)
          Method invoked to process a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SampleProcessor

public SampleProcessor()
Method Detail

getName

public String getName()
Description copied from interface: FileActionComponent
Name of the Parser. Used in the logs, to identify the FileActionComponent.

Specified by:
getName in interface FileActionComponent
Returns:
The description.

getDescription

public String getDescription()
Description copied from interface: FileActionComponent
More detailed description of the Parser.

Specified by:
getDescription in interface FileActionComponent
Returns:
The description.

process

public boolean process(File file,
                       Map<String,Object> ctxt)
                throws ProcessingException
Description copied from interface: FileProcessor
Method invoked to process a file.

Specified by:
process in interface FileProcessor
Parameters:
file - the file to process
ctxt - a Map to share informations between processings.
Returns:
true if the process was successfully performed, false if no action was processed (do not return false in case of error, instead throw a ProcessingException).
Throws:
ProcessingException - if the processing operation failed or if the file should be blacklisted (for this or all processors)

extractText

public String extractText(File file,
                          Map<String,Object> ctxt)
                   throws ProcessingException
Description copied from interface: FileParser
Parsers have to implement at least this method which exctract the text from the specified file and returns it.

Specified by:
extractText in interface FileParser
Parameters:
file - the file to parse
ctxt - a Map to share informations between processings.
Returns:
the text to index (can be empty) or null if no action was processed (do not return null in case of error, instead throw a ProcessingException).
Throws:
ProcessingException - if the text could not be extracted.

getOrder

public int getOrder()
Description copied from interface: FileActionComponent
Used to schedule the FileProcessors while treating a file. Default is 0. FileActionComponent are called in the same order as their order values.

Specified by:
getOrder in interface FileActionComponent
Returns:
order

isAvailable

public boolean isAvailable()
Description copied from interface: FileActionComponent
A processor or parser may be unavailable (for instance because of a network connection down).

Specified by:
isAvailable in interface FileActionComponent
Returns:
true is the processor or parser is available


Copyright © 2001-2010 Jalios SA. All Rights Reserved.