<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="
		http://www.springframework.org/schema/beans
		http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
		http://www.springframework.org/schema/context
		http://www.springframework.org/schema/context/spring-context-3.1.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">

    <context:component-scan base-package="com.wisemapping.ncontroller"/>
    <context:annotation-config/>
    <mvc:annotation-driven/>
    <context:property-placeholder location="/WEB-INF/app.properties" ignore-unresolvable="true"/>

    <!-- Interceptors Registration -->
    <mvc:interceptors>
        <bean id="browserSupportInterceptor" class="com.wisemapping.filter.BrowserSupportInterceptor">
            <property name="exclude">
                <set>
                    <value>/</value>
                    <value>/index.jsp</value>
                    <value>/c/home</value>
                    <value>/c/j_spring_security</value>
                    <value>/c/login</value>
                    <value>/c/GCFInstall</value>
                    <value>/service/</value>
                    <value>/c/maps/*/embed</value>
                    <value>/c/maps/*/public</value>
                    <value>/c/embeddedView</value>
                    <value>/c/user/resetPassword</value>
                    <value>/c/user/registration</value>
                </set>
            </property>
        </bean>
        <bean id="userLocaleInterceptor" class="com.wisemapping.filter.UserLocaleInterceptor"/>
        <bean id="requestInterceptor" class="com.wisemapping.filter.RequestPropertiesInterceptor"/>
    </mvc:interceptors>


    <bean id="exceptionHandlerResolver"
          class="com.wisemapping.mail.NotifyingExceptionResolver">
        <property name="defaultStatusCode" value="500"/>
        <property name="defaultErrorView" value="unexpectedError"/>
        <property name="exceptionMappings">
            <props>
                <prop key="com.wisemapping.exceptions.UnsupportedBrowserException">browserNotSupported</prop>
                <prop key="com.wisemapping.exceptions.GoogleChromeFrameRequiredException">GCFPluginRequired</prop>
                <!-- Security exceptions are wrapped in this exceptions -->
                <prop key="java.lang.reflect.UndeclaredThrowableException">securityError</prop>
            </props>
        </property>
        <property name="exclude">
            <set>
                <value>java.lang.reflect.UndeclaredThrowableException</value>
                <value>com.wisemapping.exceptions.GoogleChromeFrameRequiredException</value>
                <value>com.wisemapping.exceptions.UnsupportedBrowserException</value>
            </set>
        </property>
        <property name="notificationService" ref="notificationService"/>
    </bean>

    <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
    </bean>

    <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
        <property name="definitions">
            <list>
                <value>/WEB-INF/defs/definitions.xml</value>
            </list>
        </property>
    </bean>

    <bean id="localeResolver"
          class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
    </bean>

    <bean id="reCaptcha" class="net.tanesha.recaptcha.ReCaptchaImpl">
        <property name="privateKey" value="${google.recaptcha.privateKey}"/>
        <property name="publicKey" value="${google.recaptcha.publicKey}"/>
        <property name="includeNoscript" value="false"/>
    </bean>

    <bean id="multipartResolver"
          class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <!-- one of the properties available; the maximum file size in bytes -->
        <property name="maxUploadSize" value="522240"/>
    </bean>

    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basenames">
            <list>
                <value>messages</value>
            </list>
        </property>
    </bean>
</beans>
