Class SampleProcessor
java.lang.Object
com.jalios.jcms.fileprocessor.test.SampleProcessor
- All Implemented Interfaces:
FileActionComponent,FileParser,FileProcessor
Sample FileProcessor and FileParse which can be used for testing.
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)
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 processandparseme2. 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.parseme: Request succesfull parsing (immediate)process.processme: Request succesfull processing (immediate)process666.parseme: Request succesfull parsing, and take 666 ms to do soprocess4242.processme: Request succesfull processing, and take 4242 ms to do soexception.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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionextractText(File file, Map<String, Object> ctxt) Parsers have to implement at least this method which extract the text from the specified file and returns it.More detailed description of the Parser.getName()Name of the Parser.intgetOrder()Used to schedule the FileProcessors while treating a file.booleanA processor or parser may be unavailable (for instance because of a network connection down).booleanMethod invoked to process a file.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.jalios.jcms.fileprocessor.FileParser
extractText
-
Constructor Details
-
SampleProcessor
public SampleProcessor()
-
-
Method Details
-
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
Description copied from interface:FileActionComponentMore detailed description of the Parser.- Specified by:
getDescriptionin interfaceFileActionComponent- Returns:
- The description.
-
process
Description 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
Description 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
-