<?xml version="1.0" encoding="UTF-8"?>
<!--

    The contents of this file are subject to the license and copyright
    detailed in the LICENSE and NOTICE files at the root of the source
    tree and available online at

    http://www.dspace.org/license/

-->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         id="WebApp_ID" version="2.5">

    <filter>
        <filter-name>dspace.request</filter-name>
        <filter-class>org.dspace.utils.servlet.DSpaceWebappServletFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>dspace.request</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>


    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>


    <servlet>
        <servlet-name>DSpace REST API</servlet-name>
        <servlet-class>
            org.glassfish.jersey.servlet.ServletContainer
        </servlet-class>
        <init-param>
            <param-name>javax.ws.rs.Application</param-name>
            <param-value>org.dspace.rest.DSpaceRestApplication</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>DSpace REST API</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>/static/*</url-pattern>
    </servlet-mapping>

    <!-- Security settings and mapping -->
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>DSpace REST API</web-resource-name>
            <url-pattern>/*</url-pattern>
        </web-resource-collection>
        <user-data-constraint>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>
    
    <!-- ConfigurationService initialization for dspace.dir -->
    <context-param>
        <description>
            The location of the DSpace home directory
        </description>
        <param-name>dspace.dir</param-name>
        <param-value>${dspace.dir}</param-value>
    </context-param>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/applicationContext.xml,
            /WEB-INF/security-applicationContext.xml
        </param-value>
    </context-param>

    <listener>
        <listener-class>org.dspace.app.util.DSpaceContextListener</listener-class>
    </listener>

    <!-- kernel start listener (from impl)
        The following listener can be used instead of the filter below, it is simpler, cleaner
        and eliminates the need for a DSpaceKernelServletFilter filter to be involved with the
        request cycle.
    -->
    <listener>
        <listener-class>org.dspace.servicemanager.servlet.DSpaceKernelServletContextListener</listener-class>
    </listener>
    
    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>

    <listener>
        <listener-class>org.dspace.app.util.DSpaceWebappListener</listener-class>
    </listener>


</web-app>