Results 1 to 4 of 4

Thread: sftp:inbound-channel-adapter and delete-remote-files

  1. #1
    Join Date
    Jul 2011
    Posts
    2

    Question sftp:inbound-channel-adapter and delete-remote-files

    Hi everyone,

    I apologise in advance if there's been already a discussion on this matter. As I've yet to find it, please redirect me there and close/remove this thread.

    Scenario: batch app that monitors remote folder via sftp, transfers files and processes them

    Problem: using a property to define whether my "sftp:inbound-channel-adapter" should "delete-remote-files". Using the snippet below I encountered the following error:
    Offending resource: class path resource [launch-context.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefin itionStoreException: Line 14 in XML document from class path resource [META-INF/spring/si-module-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-datatype-valid.1.2.1: '${delete-remote-files}' is not a valid value for 'boolean'.

    Context snippet:
    Code:
        <sftp:inbound-channel-adapter id="sftpInboundAdapter" channel="inputDirChannel"
                 session-factory="sftpSessionFactory" local-directory="file:${local.dir}" remote-directory="${remote.dir}"
                 filename-pattern="${filename-pattern}" temporary-file-suffix="INC" auto-startup="${sftp.enabled}"
                 delete-remote-files="${delete-remote-files}" >
            <int:poller ref="poller" />
        </sftp:inbound-channel-adapter>

    Any help in overcoming this issue is greatly appreciated.

    P.S. latest idea that came to mind as a workaround is to define a different channel adapter for both true/false, each in its own xml, and then include the right one based on the value of the property, but I'd prefer a more elegant solution.

    Kind regards,
    M

  2. #2
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    I just looked. Its a bug in XSD
    Code:
    <xsd:attribute name="delete-remote-files" type="xsd:boolean">
    Since its boolean it does not except placeholders.
    Could you please file JIRA Bug for this?

  3. #3
    Join Date
    Jul 2011
    Posts
    2

    Default

    Hi Oleg,

    I noticed the xsd definition myself but I thought it was meant to be like that... thanks for the info, I've opened https://jira.springsource.org/browse/INT-1965, although it might some editing (I believe it has something to do with me not escaping the braces in ${delete-remote-files})

    In the meantime if anyone else has a similar problem, my workaround is:
    1) create an xml file with a channel definition having delete-remote-files="true" and one having "false"

    2) in the main context xml reference
    Code:
    <import resource="classpath:/META-INF/spring/file-remove-${delete-remote-files}-sftp-channel.xml" />
    3) since spring will try to include the resource first and later in the process set the placeholders, you need to manually read the property ${delete-remote-files} and add it to the system, prior to instantiating the spring context

    Cheers

  4. #4
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Thanks

    It will be addressed shortly an we are planning a release of 2.0.5 some time next week, so the wait will not be long, but it will be in the tonight's nighty

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •