Filewriter-call

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

Definition

Use this plug-in if you want to write the contain of a Buffer object into a file present or not in the local file system. The target file will be overwritten if it is already present.

GreenVulcano® ESB provides two different tools, GV Console® and VulCon®, to configure this plug-ins in GVServices.

VulCon / GV Console Configuration

This plug-in writes into a local filesystem file.

Complete file path is the concatenation of targetPath attribute, with the fileName attribute. Both of them can contain placeholders, that are expanded at plugin call time.


Attributes targetPath and fileName are subject to these constraints:

  • attribute targetPath is overridden by GVFW_DIRECTORY property, if present in current GVBuffer. If property is not defined in GVBuffer, the targetPath 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 GVFW_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 filewriter-call element is used by: Channel and routed-call. It has the following attributes:

Attribute Type Description
type fixed This attribute must assume the value call.
class fixed This attribute must assume the value it.greenvulcano.gvesb.virtual.file.reader.FileWriter.
name required Operation name. Used in the Flow section to associate workflow nodes to VCL operations.
targetPath required 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 GVFW_DIRECTORY is not defined in the current GVBuffer.
fileName required 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 GVFW_FILE_NAME is not defined in the current GVBuffer.

and does not have sub-elements.

How To

Suppose you want to create a file present in the ${{gv.app.home}}/TEST/TESTFS/TestXML/output folder. Right-clicking on Channel, insert after, FileWriter-call, a new element FileWriter-call will be created. Clicking above, on the Properties view you can set its attributes.

Filewriter_call attributes

Class and type are passed by default. Name, in this example, takes the value writeFile, 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.FileWriter"
            fileName="ognl{{property[&apos;FILE_NAME&apos;]}}"
            name="writeFile"
            srcPath="${{gv.app.home}}/TEST/TESTFS/TestXML/output"
            type="call"/>                                     
    </Channel>
</System>

associated to the Service ValidateRemoteSingleXMLFile.

<Service group-name="DEFAULT_GRP" id-service="ValidateRemoteSingleXMLFile" 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="-15" point-y="160" 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="write_file" id-system="GVESB" input="input"
                   next-node-id="move_file" op-type="call"
                   operation-name="writeFile" output="input"
                   point-x="628" point-y="263" type="flow-node"/>
           <GVEndNode class="it.greenvulcano.gvesb.core.flow.GVEndNode"
                   end-business-process="yes" id="end" op-type="end"
                   output="input" point-x="747" point-y="21" 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 written. After other elements, it is added the GVOperationNode: write_file who calls the operation filewriter_call: writeFile.