Difference between revisions of "GVExample ValidateXMLFiles"
(→Definition of Systems, Channels and Operations) |
(→Flow implementation) |
||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
==Description== | ==Description== | ||
+ | [[File:GVExamplesValidateXMLFilesShow.jpg|thumb|Validation of XML Files]] | ||
The flow is designed to show how {{GVESB}} manages the files and how can perform a validation of an xml file. It is executed following these steps: | The flow is designed to show how {{GVESB}} 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 | * Reading XML files from a directory of inputs | ||
* Validating the read files using a predefined schema | * Validating the read files using a predefined schema | ||
Line 41: | Line 43: | ||
:* GVFSM_REPORT_CREATED setted to "true" | :* GVFSM_REPORT_CREATED setted to "true" | ||
:* GVFSM_EXISTING_FILES number of file presents | :* 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 <nowiki>${{gv.app.home}}/TEST/TESTFS/TestXML/ ognl{{property[‘TARGET’]}}</nowiki>. 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: | + | * [[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 <nowiki>${{gv.app.home}}/TEST/TESTFS/TestXML/ ognl{{property[‘TARGET’]}}</nowiki>. 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: |
{|class="gvtable" | {|class="gvtable" | ||
! Attribute !! Value | ! Attribute !! Value | ||
Line 75: | Line 77: | ||
===Definition of Services=== | ===Definition of Services=== | ||
+ | |||
+ | To define a Service for reading the files present into a directory, use the voice "Wizard new Service" (right clicking the Services element) with the following parameters: | ||
+ | {|class="gvtable" | ||
+ | ! Attribute !! value | ||
+ | |- | ||
+ | | Service name || ValidateXMLFiles | ||
+ | |- | ||
+ | | Scenario || Synchronous- Synchronous | ||
+ | |- | ||
+ | | Client || GVESB | ||
+ | |- | ||
+ | | Server (Participant) || system = "GVESB" <br/> channel = "TEST_CHANNEL_FILE" <br/> request operation = "ScanXMLFiles" | ||
+ | |} | ||
+ | |||
+ | The Wizard will create a flow which has to be modified successively. | ||
+ | |||
+ | Analogously, use the "Wizard New Service" for creating the service for the validation of each single XML file present in the input directory, using the following parameters: | ||
+ | {|class="gvtable" | ||
+ | ! Attribute !! value | ||
+ | |- | ||
+ | | Service name || ValidateSingleXMLFile | ||
+ | |- | ||
+ | | Scenario || Synchronous-Synchronous | ||
+ | |- | ||
+ | | Client || GVESB | ||
+ | |- | ||
+ | | Server (Participant) || system = "GVESB" <br/> channel = "TEST_CHANNEL_FILE" <br/> request operation = "ReadFile" | ||
+ | |} | ||
+ | |||
+ | The Wizard will create a flow that must be modified successively. | ||
+ | |||
+ | ====Flow implementation==== | ||
+ | |||
+ | [[File:GVExamplesValidateXMLFiles.jpg|thumb|ValidateXMLFile Configuration]]To define the flow for the service ''ValidateXMLFiles'', design it as it is shown in the picture: | ||
+ | |||
+ | In this first flow all files present into the directory "dir_scanner" are read, and for each one, the service ''ValidateSingleXMLFile'' will be invoked validating it. | ||
+ | |||
+ | The following table shows the parameters to be defined for each flow operation: | ||
+ | {|class="gvtable" | ||
+ | ! Attribute !! value | ||
+ | |- | ||
+ | | [[Conditions]]/GVBufferCondition || condition="CheckNumFiles" <br/> Property: | ||
+ | : name="GVFSM-EXISTING_FILES" | ||
+ | : operator="greater" | ||
+ | : type="gvbuffer-field" | ||
+ | : value="0" | ||
+ | |- | ||
+ | | [[GVOperationNode]] || id="dir_scanner" <br/>id-system="GVESB" <br/>input="input" <br/>next-node-id="check_files" <br/>op-type="call" <br/>operation-name="ScanXMLFiles" <br/>output="files" | ||
+ | |- | ||
+ | | [[GVNodeCheck]] || default-id="end_nofile" id="check_files" <br/> input="files" <br/>on-exception-id="end_notok" <br/>op-type="check" | ||
+ | |- | ||
+ | | [[GVNodeCheck]]/GVRouting || condition="CheckNumFiles" <br/>next-node-id="iterate_file_list | ||
+ | |- | ||
+ | | [[GVIteratorOperationNode]] || id="iterate_file_list" <br/>collection-dp="fileNamesCollectionDP" <br/> input="files" <br/>next-node-id="end_ok" <br/>op-type="call" <br/>output="single-file" | ||
+ | |- | ||
+ | | [[GVIteratorOperationNode]]/CoreCall || change-log-context="true" <br/>id-service="ValidateSingleXMLFile" <br/>id-system="GVESB" <br/> operation="Request | ||
+ | |- | ||
+ | | [[GVEndNode]] || id="end_ok" <br/>op-type="end" <br/>output="files" | ||
+ | |- | ||
+ | | [[GVEndNode]] || id="end_notok" <br/>op-type="end" <br/>output="files" | ||
+ | |} | ||
+ | |||
+ | [[File:GVExamplesValidateSingleXMLFile.jpg|thumb| ValidateSingleXMLFile Configuration]]To define the flow for ValidateSingleXMLFile Service, design the flow as it is seen from the picture: | ||
+ | |||
+ | In this flow the file in input is read, validated using a specific XSD and, depending on the result, the file will be moved in other directory or a new file will be created with the result of the failed validation. | ||
+ | |||
+ | The workflow will be invoked passing into the GVBuffer.object of input an element "File" chosen from the generated XML report of the ScanXMLFiles operation. | ||
+ | |||
+ | The following table shows the parameters to be defined for each flow operation: | ||
+ | {|class="gvtable" | ||
+ | ! Attribute !! value | ||
+ | |- | ||
+ | | first-node || fillProperties | ||
+ | |- | ||
+ | | [[ChangeGVBufferNode]] || id="fillProperties" <br/> | ||
+ | input="node" <br/> | ||
+ | next-node-id="read_validate_file" <br/> | ||
+ | op-type="change GVBuffer" <br/> | ||
+ | output="input" | ||
+ | |- | ||
+ | | [[ChangeGVBufferNode]]/ChangeGVBuffer || OGNLScript: property['FILE_NAME']=@it.greenvulcano.configuration.XMLConfig@get(object,’@name’) | ||
+ | |- | ||
+ | | [[GVOperationNode]] || id="read_validate_file" <br/> | ||
+ | id-system="GVESB" <br/> | ||
+ | input="input" <br/> | ||
+ | next-node-id="check_validate" <br/> | ||
+ | op-type="call" <br/> | ||
+ | operation-name="ReadFile” | ||
+ | |- | ||
+ | | [[GVOperationNode]]/OutputServices || xml-validation-service: | ||
+ | : critical="yes" | ||
+ | : internal="yes" | ||
+ | : remove-fields="yes" | ||
+ | xml-validation-call: | ||
+ | : default-xsd="ValidateXML.xsd" | ||
+ | : name="ValidateXML" | ||
+ | : return-dom="false" | ||
+ | : xsd-policy="force-default” | ||
+ | |- | ||
+ | | [[GVNodeCheck]] || default-id="validation_ok" <br/> | ||
+ | id="check_validate" <br/> | ||
+ | input="payload" <br/> | ||
+ | on-exception-id="validation_failed" | ||
+ | |- | ||
+ | | [[ChangeGVBufferNode]] || id="validation_ok" <br/> | ||
+ | input="input" <br/> | ||
+ | next-node-id="move_file" <br/> | ||
+ | clear-data="false” | ||
+ | |- | ||
+ | | [[ChangeGVBufferNode]] || id="validation_ok" | ||
+ | input="input" | ||
+ | next-node-id="move_file" | ||
+ | clear-data="false” | ||
+ | |- | ||
+ | | [[GVOperationNode]] || OGNLScript: property['TARGET'] = 'validated' <br/> | ||
+ | id="move_file" <br/> | ||
+ | id-system="GVESB" <br/> | ||
+ | input="input" <br/> | ||
+ | next-node-id="end" <br/> | ||
+ | operation=”MoveFile” | ||
+ | |- | ||
+ | | [[ChangeGVBufferNode]] || id="validation_failed" | ||
+ | input="input" | ||
+ | next-node-id="write_status" | ||
+ | clear-data="false" | ||
+ | |- | ||
+ | | [[GVOperationNode]] || OGNLScript: property['TARGET'] = 'discarded', setObject(' ' + #environment.get('payload')) <br/> | ||
+ | id="write_status" <br/> | ||
+ | id-system="GVESB" <br/> | ||
+ | next-node-id="move_file" <br/> | ||
+ | operation-name="WriteStatusFile" <br/> | ||
+ | input=”input” | ||
+ | |- | ||
+ | | [[GVEndNode]] || end-business-process="yes" <br/> | ||
+ | id="end" <br/> | ||
+ | op-type="end" <br/> | ||
+ | output="input" | ||
+ | |} |
Latest revision as of 08:07, 27 February 2012
Contents
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:
- Definition of systems, Channels and Operations
- Definition of Services
- 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
To define a Service for reading the files present into a directory, use the voice "Wizard new Service" (right clicking the Services element) with the following parameters:
Attribute | value |
---|---|
Service name | ValidateXMLFiles |
Scenario | Synchronous- Synchronous |
Client | GVESB |
Server (Participant) | system = "GVESB" channel = "TEST_CHANNEL_FILE" request operation = "ScanXMLFiles" |
The Wizard will create a flow which has to be modified successively.
Analogously, use the "Wizard New Service" for creating the service for the validation of each single XML file present in the input directory, using the following parameters:
Attribute | value |
---|---|
Service name | ValidateSingleXMLFile |
Scenario | Synchronous-Synchronous |
Client | GVESB |
Server (Participant) | system = "GVESB" channel = "TEST_CHANNEL_FILE" request operation = "ReadFile" |
The Wizard will create a flow that must be modified successively.
Flow implementation
To define the flow for the service ValidateXMLFiles, design it as it is shown in the picture:
In this first flow all files present into the directory "dir_scanner" are read, and for each one, the service ValidateSingleXMLFile will be invoked validating it.
The following table shows the parameters to be defined for each flow operation:
Attribute | value |
---|---|
Conditions/GVBufferCondition | condition="CheckNumFiles" Property:
|
GVOperationNode | id="dir_scanner" id-system="GVESB" input="input" next-node-id="check_files" op-type="call" operation-name="ScanXMLFiles" output="files" |
GVNodeCheck | default-id="end_nofile" id="check_files" input="files" on-exception-id="end_notok" op-type="check" |
GVNodeCheck/GVRouting | condition="CheckNumFiles" next-node-id="iterate_file_list |
GVIteratorOperationNode | id="iterate_file_list" collection-dp="fileNamesCollectionDP" input="files" next-node-id="end_ok" op-type="call" output="single-file" |
GVIteratorOperationNode/CoreCall | change-log-context="true" id-service="ValidateSingleXMLFile" id-system="GVESB" operation="Request |
GVEndNode | id="end_ok" op-type="end" output="files" |
GVEndNode | id="end_notok" op-type="end" output="files" |
To define the flow for ValidateSingleXMLFile Service, design the flow as it is seen from the picture:
In this flow the file in input is read, validated using a specific XSD and, depending on the result, the file will be moved in other directory or a new file will be created with the result of the failed validation.
The workflow will be invoked passing into the GVBuffer.object of input an element "File" chosen from the generated XML report of the ScanXMLFiles operation.
The following table shows the parameters to be defined for each flow operation:
Attribute | value |
---|---|
first-node | fillProperties |
ChangeGVBufferNode | id="fillProperties" input="node" |
ChangeGVBufferNode/ChangeGVBuffer | OGNLScript: property['FILE_NAME']=@it.greenvulcano.configuration.XMLConfig@get(object,’@name’) |
GVOperationNode | id="read_validate_file" id-system="GVESB" |
GVOperationNode/OutputServices | xml-validation-service:
xml-validation-call:
|
GVNodeCheck | default-id="validation_ok" id="check_validate" |
ChangeGVBufferNode | id="validation_ok" input="input" |
ChangeGVBufferNode | id="validation_ok"
input="input" next-node-id="move_file" clear-data="false” |
GVOperationNode | OGNLScript: property['TARGET'] = 'validated' id="move_file" |
ChangeGVBufferNode | id="validation_failed"
input="input" next-node-id="write_status" clear-data="false" |
GVOperationNode | OGNLScript: property['TARGET'] = 'discarded', setObject(' ' + #environment.get('payload')) id="write_status" |
GVEndNode | end-business-process="yes" id="end" |