Filereader-call

From GreenVulcano Wiki
Revision as of 17:15, 7 February 2012 by Anonymous (talk) ({{VULCON}} / {{GVCONSOLE}} Configuration)
Jump to: navigation, search

Definition

This plug-in allows you to read the contents of a file on the local file system and saves it in the field "object" of output.

GreenVulcano® ESB provides two different tools, GV Console® and VulCon®, to configure all supported plug-ins in GV services.

VulCon / GV Console Configuration

This plug-in reads the local filesystem file's content, and saves it in output GVBuffer object field.

Complete file path is the concatenation of 'srcPath' attribute, with the fileName attribute.

Both of them can contain placeholders, that are expanded at plugin call time.

Attributes 'srcPath' and 'fileName' are subject to these constraints:

  • attribute srcPath is overridden by GVFR_DIRECTORY property, if present in current GVBuffer. If property is not defined in GVBuffer, the 'srcPath' attribute in the configuration is used. In both cases, the value of this attribute can be a placeholder, resolved at plugin call time, and the result of the expansion, must result in an absolute pathname, otherwise an exception is thrown. An exception is also thrown if neither the property nor the attribute in configuration are set.
  • attribute fileName is overridden by GVFR_FILE_NAME property, if present in current GVBuffer. If property is not defined in GVBuffer, the 'fileName' attribute in the configuration is used. In both cases, the value of this attribute can be a placeholder, resolved at plugin call time, and the result of the expansion, combined with the previous attribute, must result in an existent resource in the local filesystem, otherwise an exception is thrown. An exception is also thrown if neither the property nor the attribute in configuration are set.

The filereader-call Element is used by: Channel, routed-call. It has the following attributes:

  • type: call.
  • class: it.greenvulcano.gvesb.virtual.file.reader.FileReader.
  • name: Operation name. Used in the 'Flow' section to associate workflow nodes to VCL operations.
  • srcPath: This value can be static or dynamic, containing placeholders that could be replaced at plugin call time. This is a default value, and is used if the property 'GVFR_DIRECTORY' is not defined in the current GVBuffer.
  • fileName: This value can be static or dynamic, containing placeholders that could be replaced at plugin call time. This is a default value, and is used if the property 'GVFR_FILE_NAME' is not defined in the current GVBuffer.

and the subelements:

  • Description,
  • xml-processor.

xml-processor

If this element is specified, the plugin will read the file directly parsed as an XML.

The xml-processor Element is used by: filereader-call.

Its attributes are:

  • as-xml: If true the file is parsed as an XML. Default is false.
  • use-axiom: If true uses AXIOM instead of DOM to parse the file. Default is false.
  • validating: If true the XML representing the file is validated. This option applies only if as-xml is true. Default is false.
  • namespace-aware: If true the DOM keeps informations about the declared namespaces on the file. This option applies only if as-xml is true. Default is false.

xml-processor

If this element is specified, the plugin will read the file directly parsed as an XML. It is only used by filereader-call.

Its attributes are:

  • as-xml: If true the file is parsed as an XML. Default is false. The attribute's admitted values are:
    • true
    • false
  • use-axiom: If true uses AXIOM instead of DOM to parse the file. Default is false. The attribute's admitted values are:
    • true
    • false
  • validating: If true the XML representing the file is validated. This option applies only if as-xml is true. Default is false. The attribute's admitted values are:
    • true
    • false
  • namespace-aware: If true the DOM keeps informations about the declared namespaces on the file. This option applies only if as-xml is true. Default is false. The attribute's admitted values are:
    • true
    • false

How To

Suppose you want to read a file present in the ${{gv.app.home}}/TEST/TESTFS/TestXML/input folder. Right-clicking on Channel, insert after, FileReader-call, it adds a new element FileReader-call. Clicking above, on the Properties view you can set its attributes.

Filereader_call attributes

Class and type are passed by default. Name, in this example, takes the value ReadFile, and file-name is passed as a parameter through the property FILE_NAME (see placeholders).


The respective part of the GVCore.xml file becomes:

<System id-system="GVESB" system-activation="on">
    <Channel id-channel="TEST_CHANNEL_FILE">                    
        <filereader-call class="it.greenvulcano.gvesb.virtual.file.reader.FileReader"
            fileName="ognl{{property[&apos;FILE_NAME&apos;]}}"
            name="ReadFile"
            srcPath="${{gv.app.home}}/TEST/TESTFS/TestXML/input"
            type="call"/>                                     
    </Channel>
</System>

associated to the Service ValidateSingleXMLFile.

<Service group-name="DEFAULT_GRP" id-service="ValidateSingleXMLFile" service-activation="on" statistics="off">
   <Operation name="Request" operation-activation="on" out-check-type="none" type="operation">
      <Participant id-channel="TEST_CHANNEL_FILE" id-system="GVESB"/>
      <Flow first-node="fillProperties" point-x="9" point-y="31">
           <ChangeGVBufferNode class="it.greenvulcano.gvesb.core.flow.ChangeGVBufferNode"
                id="fillProperties" input="node" next-node-id="read_validate_file"
                op-type="change GVBuffer" output="input" point-x="-25" point-y="163" type="flow-node">
                 <ChangeGVBuffer clear-data="false">
                      <OGNLScript>property[&apos;FILE_NAME&apos;] =                                           
                                   @it.greenvulcano.configuration.XMLConfig@get(object,&apos;@name&apos;) 
                      </OGNLScript>
                 </ChangeGVBuffer>
           </ChangeGVBufferNode>
           <GVOperationNode class="it.greenvulcano.gvesb.core.flow.GVOperationNode"
                  id="read_validate_file" id-system="GVESB"
                  input="input" next-node-id="end"
                  op-type="call" operation-name="ReadFile"
                  output="payload" point-x="160" point-y="165"
                  type="flow-node">
                      <OutputServices>
                          <xml-validation-service internal="yes" type="service">
                              <xml-validation-call class="it.greenvulcano.gvesb.virtual.internal.xml.XMLValidationCallOperation"
                                      default-xsd="ValidateXML.xsd"
                                      name="ValidateXML"
                                      return-dom="false" type="call"
                                      xsd-policy="force-default"/>
                          </xml-validation-service>
                      </OutputServices>
           </GVOperationNode>
           <GVEndNode class="it.greenvulcano.gvesb.core.flow.GVEndNode"
                 end-business-process="yes" id="end" op-type="end"
                 output="input" point-x="729" point-y="33"
                 type="flow-node"/>
       </Flow>
   </Operation>
</Service>

The first operation node, ChangeGVBufferNode: fillProperties is used for setting the property FILE_NAME containing the name of the file to be read. Successively, it is added the GVOperationNode: read_validate_file who calls the operation filereader_call: ReadFile, and internally, it is define an OutputServices, xml-validation-service and xml-validation-call: ValidateXML in order to validate the XML file FILE_NAME using ValidateXML.xsd.