<?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:util="http://www.springframework.org/schema/util"
    xmlns:p="http://www.springframework.org/schema/p" xmlns:jaxws="http://cxf.apache.org/jaxws"
    xmlns:jaxrs="http://cxf.apache.org/jaxrs" 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/util http://www.springframework.org/schema/util/spring-util.xsd
        http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
        http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">

    <import resource="classpath:META-INF/cxf/cxf.xml" />
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

    <jaxws:endpoint id="jaxwsMtomJobEndpoint" implementor="#soapMtomJobHandler"
        address="/soap/mtom-jobs">
        <jaxws:properties>
            <entry key="mtom-enabled" value="true" />
        </jaxws:properties>
    </jaxws:endpoint>

    <util:list id="jsonRsbTypes">
        <value>#{T(eu.openanalytics.rsb.Constants).RSB_JSON_CONTENT_TYPE}
        </value>
        <value>#{T(eu.openanalytics.rsb.Constants).JSON_CONTENT_TYPE}</value>
    </util:list>

    <jaxrs:server id="jaxrsRestServer" address="/rest">
        <jaxrs:serviceBeans>
            <ref bean="jobsResource" />
            <ref bean="processResource" />
            <ref bean="resultsResource" />
            <ref bean="resultResource" />
            <ref bean="dataDirectoriesResource" />
            <ref bean="systemResource" />
            <ref bean="adminResource" />
        </jaxrs:serviceBeans>
        <jaxrs:providers>
            <bean class="org.apache.cxf.jaxrs.provider.json.JSONProvider"
                p:consumeMediaTypes-ref="jsonRsbTypes" p:produceMediaTypes-ref="jsonRsbTypes"
                p:ignoreNamespaces="true" p:attributesToElements="true" />
            <bean class="eu.openanalytics.rsb.jaxrs.IllegalArgumentExceptionMapper" />
            <bean class="eu.openanalytics.rsb.jaxrs.AccessDeniedExceptionMapper" />
            <bean class="eu.openanalytics.rsb.jaxrs.WebApplicationExceptionMapper" />
            <bean class="eu.openanalytics.rsb.jaxrs.ThrowableExceptionMapper" />
        </jaxrs:providers>
    </jaxrs:server>
</beans>
