<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
      version="3.0">

  <!-- ===================================================================== -->
  <!-- Session configuration -->
  <!-- ===================================================================== -->
  <listener>
    <listener-class>servlet.SessionCleanupListener</listener-class>
  </listener>

  <!-- ===================================================================== -->
  <!-- Scalatra configuration -->
  <!-- ===================================================================== -->
  <listener>
    <listener-class>org.scalatra.servlet.ScalatraListener</listener-class>
  </listener>

  <servlet>
    <servlet-name>GitRepositoryServlet</servlet-name>
    <servlet-class>servlet.GitRepositoryServlet</servlet-class>
  </servlet>
  
  <servlet-mapping>
    <servlet-name>GitRepositoryServlet</servlet-name>
    <url-pattern>/git/*</url-pattern>
  </servlet-mapping>
  
  <filter>
    <filter-name>TransactionFilter</filter-name>
    <filter-class>servlet.TransactionFilter</filter-class>
  </filter>
  
  <filter-mapping>
    <filter-name>TransactionFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  
  <filter>
    <filter-name>BasicAuthenticationFilter</filter-name>
    <filter-class>servlet.BasicAuthenticationFilter</filter-class>
  </filter>
  
  <filter-mapping>
    <filter-name>BasicAuthenticationFilter</filter-name>
    <url-pattern>/git/*</url-pattern>
  </filter-mapping>
  
  <!-- ===================================================================== -->
  <!-- H2 database configuration -->
  <!-- ===================================================================== -->
  <listener>
    <listener-class>servlet.AutoUpdateListener</listener-class>
  </listener>
  
  <context-param>
    <param-name>db.url</param-name>
    <param-value>jdbc:h2:~/gitbucket/data</param-value>
  </context-param>
  
  <context-param>
    <param-name>db.user</param-name>
    <param-value>sa</param-value>
  </context-param>
  
  <context-param>
    <param-name>db.password</param-name>
    <param-value>sa</param-value>
  </context-param>
  
  <context-param>
    <param-name>db.tcpServer</param-name>
    <param-value>-tcpAllowOthers</param-value>
  </context-param>
  
  <!-- ===================================================================== -->
  <!-- H2 console configuration -->
  <!-- ===================================================================== -->
  <servlet>
    <servlet-name>H2Console</servlet-name>
    <servlet-class>org.h2.server.web.WebServlet</servlet-class>
    <init-param>
        <param-name>webAllowOthers</param-name>
        <param-value></param-value>
    </init-param>
      <!--
      <init-param>
          <param-name>trace</param-name>
          <param-value></param-value>
      </init-param>
      -->
    <load-on-startup>1</load-on-startup>
  </servlet>
  
  <servlet-mapping>
    <servlet-name>H2Console</servlet-name>
    <url-pattern>/console/*</url-pattern>
  </servlet-mapping>

  <!-- ===================================================================== -->
  <!-- Session timeout -->
  <!-- ===================================================================== -->
  <session-config>
    <session-timeout>1440</session-timeout>
  </session-config>

</web-app>