<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
  <!-- Listeners -->
  <!-- we're not using @WebListener annotations so that our manager is initialized *after* the webapp logger -->
  <listener>
    <listener-class>com.republicate.slf4j.impl.ServletContextLoggerListener</listener-class>
  </listener>
  <listener>
    <listener-class>org.jeudego.pairgoth.web.WebappManager</listener-class>
  </listener>

  <!-- filters -->
  <filter>
    <filter-name>webapp-slf4j-logger-ip-tag-filter</filter-name>
    <filter-class>com.republicate.slf4j.impl.IPTagFilter</filter-class>
    <async-supported>true</async-supported>
  </filter>
  <filter>
    <filter-name>dispatching-filter</filter-name>
    <filter-class>org.jeudego.pairgoth.web.DispatchingFilter</filter-class>
    <async-supported>true</async-supported>
  </filter>
  <filter>
    <filter-name>auth-filter</filter-name>
    <filter-class>org.jeudego.pairgoth.web.AuthFilter</filter-class>
    <async-supported>true</async-supported>
  </filter>
  <filter>
    <filter-name>language-filter</filter-name>
    <filter-class>org.jeudego.pairgoth.web.LanguageFilter</filter-class>
    <async-supported>true</async-supported>
  </filter>

  <!-- filters mapping -->
  <filter-mapping>
    <filter-name>webapp-slf4j-logger-ip-tag-filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
  </filter-mapping>
  <filter-mapping>
    <filter-name>dispatching-filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
  </filter-mapping>
  <filter-mapping>
    <filter-name>auth-filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
  </filter-mapping>
  <filter-mapping>
    <filter-name>language-filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
  </filter-mapping>

  <!-- servlets -->
  <servlet>
    <servlet-name>view</servlet-name>
    <servlet-class>org.jeudego.pairgoth.web.ViewServlet</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>sse</servlet-name>
    <servlet-class>org.jeudego.pairgoth.web.SSEServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    <async-supported>true</async-supported>
  </servlet>
  <servlet>
    <servlet-name>api</servlet-name>
    <servlet-class>org.jeudego.pairgoth.web.ApiServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    <async-supported>true</async-supported>
  </servlet>
  <servlet>
    <servlet-name>search</servlet-name>
    <servlet-class>org.jeudego.pairgoth.web.SearchServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    <async-supported>true</async-supported>
  </servlet>
  <servlet>
    <servlet-name>import</servlet-name>
    <servlet-class>org.jeudego.pairgoth.web.ImportServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    <async-supported>true</async-supported>
  </servlet>
  <servlet>
    <servlet-name>login</servlet-name>
    <servlet-class>org.jeudego.pairgoth.web.LoginServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    <async-supported>true</async-supported>
  </servlet>
  <servlet>
    <servlet-name>logout</servlet-name>
    <servlet-class>org.jeudego.pairgoth.web.LogoutServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    <async-supported>true</async-supported>
  </servlet>

  <!-- servlet mappings -->
  <servlet-mapping>
    <servlet-name>view</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>sse</servlet-name>
    <url-pattern>/events/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>api</servlet-name>
    <url-pattern>/api/tour/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>search</servlet-name>
    <url-pattern>/api/search/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>import</servlet-name>
    <url-pattern>/api/import/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>login</servlet-name>
    <url-pattern>/api/login</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>logout</servlet-name>
    <url-pattern>/api/logout</url-pattern>
  </servlet-mapping>

  <!-- context params -->
  <context-param>
    <param-name>webapp-slf4j-logger.format</param-name>
    <param-value>%logger [%level] [%ip] %message @%file:%line:%column</param-value>
  </context-param>
  <context-param>
    <param-name>org.apache.velocity.tools.loadDefaults</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <param-name>org.apache.velocity.tools.cleanConfiguration</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <param-name>org.apache.velocity.tools.userCanOverwriteTools</param-name>
    <param-value>false</param-value>
  </context-param>
</web-app>
