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

  1. Find all non-folder files in the SRC Directory
  2. For each file
    1. Search for XPath expression using findInFile
    2. if found:
      1. move the XML file from source directory to destination directory using moveFile
    3. if not:
      1. move the XML file from source directory to alternate-destination directory (if provided) using moveFile

findInFile

  1. Call the XPathTool Utility with the XPath expression
  2. Return true if XPath expression found else return false

moveFile

  1. verify the destination folder, create it if not existing
  2. move file from source to specified destination.