Hi ,

In the existing file connector version 2 , File Search operation does not
process the files inside all the folders (Search the sub folders for files).

I have implemented File Search operation to process sub folders(Recursive
search).

*Proxy*
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse";
       name="FileConnector_Search"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property name="source" expression="json-eval($.source)"/>
         <property name="filePattern"
expression="json-eval($.filePattern)"/>
         <property name="setTimeout" expression="json-eval($.setTimeout)"/>
         <property name="setPassiveMode"
expression="json-eval($.setPassiveMode)"/>
         <property name="setSoTimeout"
expression="json-eval($.setSoTimeout)"/>
         <property name="setStrictHostKeyChecking"
                   expression="json-eval($.setStrictHostKeyChecking)"/>
         <property name="setUserDirIsRoot"
expression="json-eval($.setUserDirIsRoot)"/>
         <fileconnector.search>
            <source>{$ctx:source}</source>
            <filePattern>{$ctx:filePattern}</filePattern>
            <setTimeout>{$ctx:setTimeout}</setTimeout>
            <setPassiveMode>{$ctx:setPassiveMode}</setPassiveMode>
            <setSoTimeout>{$ctx:setSoTimeout}</setSoTimeout>
            <setUserDirIsRoot>{$ctx:setUserDirIsRoot}</setUserDirIsRoot>

<setStrictHostKeyChecking>{$ctx:setStrictHostKeyChecking}</setStrictHostKeyChecking>
         </fileconnector.search>
         <respond/>
      </inSequence>
   </target>
   <description/>
</proxy>

*Request*
{
"source":"file:////home/vives/Desktop/filecon/",
"filePattern":"[a-zA-Z][a-zA-Z]*[0-9].(txt|xml|jar)"
}

*Response*
{
    "result": {
        "file": [
            "/home/vives/Desktop/filecon/testf2.xml",
            "/home/vives/Desktop/filecon/test3/test1.jar",
            "/home/vives/Desktop/filecon/test3/test1.txt",
            "/home/vives/Desktop/filecon/test4/testf3.xml",
            "/home/vives/Desktop/filecon/test4/test5/testf2.xml",
            "/home/vives/Desktop/filecon/test4/test5/test6/test7/test7.txt"
        ]
    }
}

Any suggestion that I have to improve more in file search operation?



*Thank youVivekananthan Sivanayagam*

*Associate Software Engineer | WSO2*

*E:vivekanant...@wso2.com <e%3avivekanant...@wso2.com>*
*M:+94752786138*
_______________________________________________
Architecture mailing list
Architecture@wso2.org
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to