spring - FileSystemPersistentAcceptOnceFileListFilter is incompatible with CompositeFileListFilter -
i watching several remote folders using int-sftp:inbound-channel-adapter
having trouble local-filters.
<int-sftp:inbound-channel-adapter id="inboundchannelpmse" session-factory="sftpsessionfactory" channel="chan" remote-directory="${rdir1}" filter="remoteunseenfilter" preserve-timestamp="true" local-directory="${ldir1}" auto-create-local-directory="true" temporary-file-suffix=".writing" local-filter="localonlyxmlfilter" delete-remote-files="false" local-filename-generator-expression="#this.tolowercase()" > <int:poller fixed-rate="10000" max-messages-per-poll="-1" /> </int-sftp:inbound-channel-adapter> <int-sftp:inbound-channel-adapter id="inboundchannelofcomdefault" session-factory="sftpsessionfactory" channel="chan" remote-directory="${rdir2}" filter="remoteunseenfilter" preserve-timestamp="true" local-directory="${ldir2}" auto-create-local-directory="true" temporary-file-suffix=".writing" local-filter="localonlycsvfilter" delete-remote-files="false" local-filename-generator-expression="#this.tolowercase()" > <int:poller fixed-rate="10000" max-messages-per-poll="-1" /> </int-sftp:inbound-channel-adapter>
each filter composite filter includes filesystempersistentacceptoncefilelistfilter , another, such ignorehiddenfilelistfilter and/or extensionfilelistfilter e.g.
<bean id="localonlyxmlfilter" class="org.springframework.integration.file.filters.compositefilelistfilter"> <constructor-arg> <list> <bean class="org.springframework.integration.file.filters.ignorehiddenfilelistfilter" /> <bean class="uk.co.bigsoft.app.imports.filters.extensionfilelistfilter"> <constructor-arg value="xml" /> </bean> <bean class="uk.co.bigsoft.app.imports.filters.prefixfilelistfilter"> <constructor-arg index="0" value="pref2_" /> </bean> <bean class="org.springframework.integration.file.filters.filesystempersistentacceptoncefilelistfilter"> <constructor-arg index="0" ref="localfilestore" /> <constructor-arg index="1" name="prefix" value="" /> <property name="flushonupdate" value="true" /> </bean> </list> </constructor-arg> </bean> <bean id="localonlycsvfilter" class="org.springframework.integration.file.filters.compositefilelistfilter"> <constructor-arg> <list> <bean class="org.springframework.integration.file.filters.ignorehiddenfilelistfilter" /> <bean class="uk.co.bigsoft.app.imports.filters.extensionfilelistfilter"> <constructor-arg value="csv" /> </bean> <bean class="uk.co.bigsoft.app.imports.filters.prefixfilelistfilter"> <constructor-arg index="0" value="pref1_" /> </bean> <bean class="org.springframework.integration.file.filters.filesystempersistentacceptoncefilelistfilter"> <constructor-arg index="0" ref="localfilestore" /> <constructor-arg index="1" name="prefix" value="" /> <property name="flushonupdate" value="true" /> </bean> </list> </constructor-arg> </bean>
the file downloads ok depending on whether localonlyxmlfilter or localonlycsvfilter runs first, 1 runs second won't see because has been remembered 1 ran first! suppose want local filter make way down filter list , stop when filter false (or returns no entries) instead of running filters anyway (which seems bit pointless me).
is there this? i've been looking @ reorganising filters keep running problems.
public class stoppingcompositefilefilter extends abstractfilelistfilter<file> { private list<abstractfilelistfilter<file>> filters; public stoppingcompositefilefilter(list<abstractfilelistfilter<file>> filters) { this.filters = filters; } @override protected boolean accept(file file) { (abstractfilelistfilter<file> filter : filters) { --> // fails compile because accept() abstract abstractfilelistfilter if (!filter.accept(file)) { return false; } } return true; } }
or 1 seems overly complicated:
class anotherfilter implements filelistfilter<file> { private list<filelistfilter<file>> filters; @override public list<file> filterfiles(file[] files) { list<file> keeping = new arraylist<file>(); (file file : files) { (filelistfilter<file> filter : filters) { keeping = filter.filterfiles(keeping.toarray(new file[keeping.size()])); if (keeping.size() == 0) { return new arraylist<file>(); } } } return keeping; } }
the compositefilelistfilter
logic looks like:
public list<f> filterfiles(f[] files) { assert.notnull(files, "'files' should not null"); list<f> results = new arraylist<f>(arrays.aslist(files)); (filelistfilter<f> filefilter : this.filefilters) { list<f> currentresults = filefilter.filterfiles(files); results.retainall(currentresults); } return results; }
so, think should build own logic based on existing algorithm, rather invent new design may wrong or enough complicated.
not sure yet you'd reach, in opinion acceptonce
must first in list...
Comments
Post a Comment