Class SampleProcessor
- java.lang.Object
-
- com.jalios.jcms.fileprocessor.test.SampleProcessor
-
- All Implemented Interfaces:
FileActionComponent,FileParser,FileProcessor
public class SampleProcessor extends java.lang.Object implements FileProcessor, FileParser
Sample FileProcessor and FileParse which can be used for testing.1. Configure in
custom.propfileprocessor.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 optional number can be added to end of each file basename (eg process1.processme, process2.processme).
An optional number can be added to end of each file extension, provided it has been configured for repository (eg ignore.processme1, ignore.processme2)ignore.parsemeignore.processmeprocess.parsemeprocess.processmeexception.parsemeexception.processmeexception-long.parsemeexception-long.processmepartially-blacklist-exception.parsemepartially-blacklist-exception.processmeglobally-blacklist-exception.parsemeglobally-blacklist-exception.processmeunknown-exception.parsemeunknown-exception.processmeprocesserror-parsesuccess.processandparsemeprocesssuccess-parseerror.processandparseme
-
-
Nested Class Summary
-
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_FILE_DOCUMENT, CURRENT_OPERATION, FILE_SEPARATOR, PROCESSING_TYPE, REVISION
-
-
Constructor Summary
Constructors Constructor Description SampleProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringextractText(java.io.File file, java.util.Map<java.lang.String,java.lang.Object> ctxt)Parsers have to implement at least this method which extract the text from the specified file and returns it.java.lang.StringgetDescription()More detailed description of the Parser.java.lang.StringgetName()Name of the Parser.intgetOrder()Used to schedule the FileProcessors while treating a file.booleanisAvailable()A processor or parser may be unavailable (for instance because of a network connection down).booleanprocess(java.io.File file, java.util.Map<java.lang.String,java.lang.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
-
Methods inherited from interface com.jalios.jcms.fileprocessor.FileParser
extractText
-
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from interface:FileActionComponentName of the Parser. Used in the logs, to identify the FileActionComponent.- Specified by:
getNamein interfaceFileActionComponent- Returns:
- The description.
-
getDescription
public java.lang.String getDescription()
Description copied from interface:FileActionComponentMore detailed description of the Parser.- Specified by:
getDescriptionin interfaceFileActionComponent- Returns:
- The description.
-
process
public boolean process(java.io.File file, java.util.Map<java.lang.String,java.lang.Object> ctxt) throws ProcessingExceptionDescription copied from interface:FileProcessorMethod invoked to process a file.- Specified by:
processin interfaceFileProcessor- Parameters:
file- the file to processctxt- 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 java.lang.String extractText(java.io.File file, java.util.Map<java.lang.String,java.lang.Object> ctxt) throws ProcessingExceptionDescription copied from interface:FileParserParsers have to implement at least this method which extract the text from the specified file and returns it.- Specified by:
extractTextin interfaceFileParser- Parameters:
file- the file to parsectxt- 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:FileActionComponentUsed to schedule the FileProcessors while treating a file. Default is 0. FileActionComponent are called in the same order as their order values.- Specified by:
getOrderin interfaceFileActionComponent- Returns:
- order
-
isAvailable
public boolean isAvailable()
Description copied from interface:FileActionComponentA processor or parser may be unavailable (for instance because of a network connection down).- Specified by:
isAvailablein interfaceFileActionComponent- Returns:
- true is the processor or parser is available
-
-