2016-08-10 7 views
0

私の目標は、与えられたパターン(私の場合はD [MMDDYYYY]〜[MMDDYYYY])に一致するファイルのリストを探し、返されたファイル名のリストを反復し、それらを宛先にコピーします。 fileconnector.search操作の結果を正しく解析する方法がわかりません。 fileconnector.searchが返すファイル名を解析するための正しいXPath式は何ですか?私のコードと出力は以下の通りです。WSO2でfileconnector.search(v2)から結果を読み取る方法ESB

ありがとうございます。

<sequence name="TestFTPDownloadSeq" trace="disable" xmlns="http://ws.apache.org/ns/synapse"> 
    <fileconnector.search> 
    <source>ftp://username:[email protected]/data/</source> 
    <filePattern>D08082016/.+/.csv</filePattern> 
    <recursiveSearch>false</recursiveSearch> 
    </fileconnector.search> 
    <iterate expression="//file" xmlns:ns2="http://org.apache.synapse/xsd" xmlns:sec="http://secservice.samples.esb.wso2.org"> 
    <target> 
    <sequence> 
     <property expression="//file" name="fileName" 
     scope="default" type="STRING"/> 
     <fileconnector.copy> 
     <source>ftp://username:[email protected]/data/</destination> 
     <destination>C:/MyApps/data/in</destination> 
     <filePattern>{$ctx:fileName}</filePattern> 
     </fileconnector.copy> 
     <drop/> 
    </sequence> 
    </target> 
    </iterate> 
</sequence> 

ログファイル

[2016-08-10 13:00:08,519] DEBUG - TemplateMediator Start : EIP Sequence paramNames : [source, filePattern, recursiveSearch, setTimeout, setPassiveMode, setSoTimeout, setStrictHostKeyChecking, setUserDirIsRoot] 
[2016-08-10 13:00:08,519] DEBUG - TemplateMediator Sequence <TemplateMediator> :: mediate() 
[2016-08-10 13:00:08,519] DEBUG - TemplateMediator Mediation started from mediator position : 0 
[2016-08-10 13:00:08,519] DEBUG - TemplateMediator Building message. Sequence <TemplateMediator> is content aware 
[2016-08-10 13:00:08,519] DEBUG - PropertyMediator Start : Property mediator 
[2016-08-10 13:00:08,519] DEBUG - PropertyMediator Setting property : source at scope : default to : ftp://username:[email protected]/data/ (i.e. result of expression : $func:source) 
[2016-08-10 13:00:08,519] DEBUG - PropertyMediator End : Property mediator 
[2016-08-10 13:00:08,519] DEBUG - PropertyMediator Start : Property mediator 
[2016-08-10 13:00:08,519] DEBUG - PropertyMediator Setting property : filePattern at scope : default to : D08082016/.+/.csv (i.e. result of expression : $func:filePattern) 
[2016-08-10 13:00:08,519] DEBUG - PropertyMediator End : Property mediator 
[2016-08-10 13:00:08,520] DEBUG - PropertyMediator Start : Property mediator 
[2016-08-10 13:00:08,520] DEBUG - PropertyMediator Setting property : recursiveSearch at scope : default to : false (i.e. result of expression : $func:recursiveSearch) 
[2016-08-10 13:00:08,520] DEBUG - PropertyMediator End : Property mediator 
[2016-08-10 13:00:08,520] DEBUG - PropertyMediator Start : Property mediator 
[2016-08-10 13:00:08,520] DEBUG - PropertyMediator Setting property : setTimeout at scope : default to : null (i.e. result of expression : $func:setTimeout) 
[2016-08-10 13:00:08,520] DEBUG - PropertyMediator End : Property mediator 
[2016-08-10 13:00:08,520] DEBUG - PropertyMediator Start : Property mediator 
[2016-08-10 13:00:08,520] DEBUG - PropertyMediator Setting property : setPassiveMode at scope : default to : null (i.e. result of expression : $func:setPassiveMode) 
[2016-08-10 13:00:08,520] DEBUG - PropertyMediator End : Property mediator 
[2016-08-10 13:00:08,520] DEBUG - PropertyMediator Start : Property mediator 
[2016-08-10 13:00:08,520] DEBUG - PropertyMediator Setting property : setSoTimeout at scope : default to : null (i.e. result of expression : $func:setSoTimeout) 
[2016-08-10 13:00:08,520] DEBUG - PropertyMediator End : Property mediator 
[2016-08-10 13:00:08,520] DEBUG - PropertyMediator Start : Property mediator 
[2016-08-10 13:00:08,520] DEBUG - PropertyMediator Setting property : setStrictHostKeyChecking at scope : default to : null (i.e. result of expression : $func:setStrictHostKeyChecking) 
[2016-08-10 13:00:08,521] DEBUG - PropertyMediator End : Property mediator 
[2016-08-10 13:00:08,521] DEBUG - PropertyMediator Start : Property mediator 
[2016-08-10 13:00:08,521] DEBUG - PropertyMediator Setting property : setUserDirIsRoot at scope : default to : null (i.e. result of expression : $func:setUserDirIsRoot) 
[2016-08-10 13:00:08,521] DEBUG - PropertyMediator End : Property mediator 
[2016-08-10 13:00:08,521] DEBUG - ClassMediator Start : Class mediator 
[2016-08-10 13:00:08,521] DEBUG - ClassMediator invoking : class org.wso2.carbon.connector.FileSearch.mediate() 
[2016-08-10 13:00:08,547] DEBUG - ClassMediator End : Class mediator 
[2016-08-10 13:00:08,547] DEBUG - IterateMediator Start : Iterate mediator 
[2016-08-10 13:00:08,550] DEBUG - IterateMediator Splitting with XPath : //file resulted in 0 elements 

答えて

0

、また、このブログの記事にhttps://medium.com/@lmanohara99/wso2-esb-file-connector-version-2-f789ad389d7d#.2ivi97d9x

に従ってください、あなたの正規表現パターンは、結果を取得しているかどうかを確認してください。正規表現のパターンをここから検証できますhttps://regex101.com/

+0

https://medium.com/@lmanohara99/wso2-esb-file-connector-version-2-f789ad389d7d#.2ivi97d9x作品に解決のための!手伝ってくれてどうもありがとう。 –

1

パターンで検索してその場所に移動するサンプルプロキシです。よりhere

<?xml version="1.0" encoding="UTF-8"?> 
<proxy xmlns="http://ws.apache.org/ns/synapse" 
    name="SampleProxy" 
    transports="https,http" 
    statistics="disable" 
    trace="disable" 
    startOnLoad="true"> 
<target> 
<inSequence> 
    <property name="fileLocation" expression="//fileLocation"/> 
    <property name="fileName" expression="//fileName"/> 
    <property name="newfilelocation" expression="//newfilelocation"/> 
    <property name="filebeforeprocess" expression="//filebeforeprocess"/> 
    <property name="fileafterprocess" expression="//fileafterprocess"/> 
    <property name="OUT_ONLY" value="true" scope="default" type="STRING"/> 
    <fileconnector.search> 
     <filelocation>{$ctx:fileLocation}</filelocation> 
     <filepattern>([^\s]+(\.(?i)(txt|png|gif|bmp))$)</filepattern> 
     <searchinlocal>false</searchinlocal> 
    </fileconnector.search> 
    <property name="sequence" value="after-smooks"/> 
</log> 
<iterate xmlns:ns2="http://org.apache.synapse/xsd" 
     xmlns:sec="http://secservice.samples.esb.wso2.org" 
     expression="//file"> 
    <target> 
     <sequence> 
      <log level="full"/> 
      <fileconnector.move> 
       <filelocation>{$ctx:fileLocation}</filelocation> 
       <file>fileSample.txt</file> 
       <newfilelocation>{$ctx:newfilelocation}</newfilelocation> 
       <filebeforeprocess>{$ctx:filebeforeprocess}</filebeforeprocess> 
       <fileafterprocess>{$ctx:fileafterprocess}</fileafterprocess> 
      </fileconnector.move> 
      <drop/> 
     </sequence> 
    </target> 
</iterate> 
</inSequence> 
</target> 
<description/> 
    </proxy> 
関連する問題