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.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 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.parseme
ignore.processme
process.parseme
process.processme
exception.parseme
exception.processme
exception-long.parseme
exception-long.processme
partially-blacklist-exception.parseme
partially-blacklist-exception.processme
globally-blacklist-exception.parseme
globally-blacklist-exception.processme
unknown-exception.parseme
unknown-exception.processme
processerror-parsesuccess.processandparseme
processsuccess-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.String
extractText(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.String
getDescription()
More detailed description of the Parser.java.lang.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(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:FileActionComponent
Name of the Parser. Used in the logs, to identify the FileActionComponent.- Specified by:
getName
in interfaceFileActionComponent
- Returns:
- The description.
-
getDescription
public java.lang.String getDescription()
Description copied from interface:FileActionComponent
More detailed description of the Parser.- Specified by:
getDescription
in interfaceFileActionComponent
- Returns:
- The description.
-
process
public boolean process(java.io.File file, java.util.Map<java.lang.String,java.lang.Object> ctxt) throws ProcessingException
Description copied from interface:FileProcessor
Method invoked to process a file.- Specified by:
process
in 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 ProcessingException
Description copied from interface:FileParser
Parsers have to implement at least this method which extract the text from the specified file and returns it.- Specified by:
extractText
in 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: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 interfaceFileActionComponent
- 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 interfaceFileActionComponent
- Returns:
- true is the processor or parser is available
-
-