<?xml version="1.0" encoding="UTF-8"?>
<!--
    R Service Bus
    
    Copyright (c) Copyright of OpenAnalytics BVBA, 2010-2014
 
    ===========================================================================
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.
 
    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>
        
    @author rsb.development@openanalytics.eu
-->
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:si="http://www.springframework.org/schema/integration"
    xmlns:http="http://www.springframework.org/schema/integration/http"
    xmlns:file="http://www.springframework.org/schema/integration/file"
    xmlns:mail="http://www.springframework.org/schema/integration/mail"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
        http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http.xsd
        http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
        http://www.springframework.org/schema/integration/mail http://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd">

    <bean id="mailSender"
          class="org.springframework.mail.javamail.JavaMailSenderImpl"
          p:host="#{configuration.smtpConfiguration.host}"
          p:port="#{configuration.smtpConfiguration.port}"
          p:username="#{configuration.smtpConfiguration.username}"
          p:password="#{configuration.smtpConfiguration.password}" />

    <si:channel id="outboundEmailChannel" />
    <mail:outbound-channel-adapter channel="outboundEmailChannel" mail-sender="mailSender"/>

    <bean id="zipJobFilter" class="org.springframework.integration.file.filters.CompositeFileListFilter">
      <constructor-arg>
        <list>
          <bean class="eu.openanalytics.rsb.si.MinimumAgeFileListFilter" p:minimumAge="5000" />
          <bean class="org.springframework.integration.file.filters.RegexPatternFileListFilter">
            <constructor-arg value="^.*\..*$"/>
          </bean>
        </list>
      </constructor-arg>
    </bean>
    <si:channel id="directoryDepositChannel" />
    <si:service-activator id="directoryDepositServiceActivator"
                          input-channel="directoryDepositChannel"
                          ref="directoryDepositHandler"
                          method="handleJob" />

    <si:channel id="emailDepositChannel" />
    <si:service-activator id="emailDepositServiceActivator"
                          input-channel="emailDepositChannel"
                          ref="emailDepositHandler"
                          method="handleJob" />
  </beans>
