GVExample ValidateXMLFiles

From GreenVulcano Wiki
Revision as of 03:03, 11 February 2012 by Anonymous (talk) (Definition of Systems, Channels and Operations)
Jump to: navigation, search

Description

The flow is designed to show how GreenVulcano® ESB manages the files and how can perform a validation of an xml file. It is executed following these steps:

  • Reading XML files from a directory of inputs
  • Validating the read files using a predefined schema
  • Coping valid and invalid files in two separated directories
  • Saving a file <filename>.result with the <filename> validation error message

VulCon Configuration

The implementation consists of two services that perform the following tasks:

  • ValidateXMLFiles: Enumerates the files to be validated
  • ValidateSingleXMLFile: Validates and moves each single file

To configure this service, the steps are as follows:

  1. Definition of systems, Channels and Operations
  2. Definition of Services
  3. Flow implementation

Definition of Systems, Channels and Operations

For the definition of the system go to the VulCon core view and insert the System GVESB (if not present). Define the Channel TEST_CHANNEL_FILE with the following operations:

  • fsmonitor-call: This operation allows to analyse the directory "path" and return an XML report with the list of files that verify the regular expression "file-mask" ("*. \ xml") in the given directory. Set its attributes as:
Attribute Value
name ScanXMLFiles
LocalFileSystemMonitor/path ${{gv.app.home}}/TEST/TESTFS/TestXML/input
FileFilter/file-mask .*\.xml
FileFilter/file-type files-only
ResultFilter/existing true
InMemoryMonitorStatus
This operation also imposes some properties into the output GVBuffer, if files with the indicated conditions exist:
  • GVFSM_REPORT_CREATED setted to "true"
  • GVFSM_EXISTING_FILES number of file presents
  • filemanager-call: This operation allows to move a file, which name is present into the GVBuffer property "FILE_NAME" from the directory "sourcePath" to the directory ${{gv.app.home}}/TEST/TESTFS/TestXML/ ognl{{property[‘TARGET’]}}. The directory of destination depends on the property "TARGET" value that worflow gives when imposes it to "validated" if the XML file is correct, or "discarded" if don't. Set its attributes as:
Attribute Value
name MoveFile
FileCommands/FileMoveCommand/filePattern ognl{{property[‘FILE_NAME’]}}
FileCommands/FileMoveCommand/sourcePath ${{gv.app.home}}/TEST/TESTFS/TestXML/input
FileCommands/FileMoveCommand/targetPath ${{gv.app.home}}/TEST/TESTFS/TestXML/ognl{{property[‘TARGET’]}}
  • filereader-call: This operation allows to read the file which name is defined in the property "FILE_NAME" into the "srcPath" directory. The file content will be charged in GVBuffer.object field as array of bytes. Set its attributes as:
Attribute Value
name ReadFile
fileName ognl{{property[‘FILE_NAME’]}}
srcPath ${{gv.app.home}}/TEST/TESTFS/TestXML/input"
  • filewriter-call: This operation allows to write into the file which name is defined concatening the property "FILE_NAME" with the string ".result", into the "targetPath" directory. The file content will be this present into the GVBuffer.object field. Set its attributes as:
Attribute Value
name fileName
WriteStatusFile ognl{{property[‘FILE_NAME’]}}.result
targetPath ${{gv.app.home}}/TEST/TESTFS/TestXML/discarded

Definition of Services