Overview
XMLGrep.java greps for a particular XPath expression in a XML file and on success it moves the file from the source folder to a destination folder. It is currently used in the People Ingest to grep for an XPath expression and move files from source to destination.
Short Option |
Long Option |
Parameter Value Map |
Description |
Required |
---|---|---|---|---|
s |
src-dir |
SRC_DIRECTORY |
SRC directory to read files from |
true |
d |
dest-dir |
DEST_DIRECTORY |
DEST directory to write files to |
true |
a |
alt-dest |
ALT_DESTINATION_DIRECTORY |
Alternate destination for files that failed to match expression |
false |
n |
tag-name |
TAG_NAME |
TAG Name to Search for |
false |
v |
tag-value |
TAG_VALUE |
TAG value to Search for |
true |
Usage
Define Alias
XMLGrep="java $OPTS -Dprocess-task=XMLGrep org.vivoweb.harvester.util.XMLGrep"
Invocation
USERNAME=`$XMLGrep -s "soapsrc/" -d "soapdest/" -n "IGNORE" -v "YES"`
Methods
execute
- Find all non-folder files in the SRC Directory
- For each file
- Search for XPath expression using findInFile
- if found:
- move the XML file from source directory to destination directory using moveFile
- if not:
- move the XML file from source directory to alternate-destination directory (if provided) using moveFile
findInFile
- Call the XPathTool Utility with the XPath expression
- Return true if XPath expression found else return false
moveFile
- verify the destination folder, create it if not existing
- move file from source to specified destination.