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

<!--+
    | Configuration file for the web application. 
    |
    | Provides XMLRPC + SOAP access to eXist and configures Cocoon2. If you don't need
    | XMLRPC or SOAP or Cocoon, remove the corresponding servlets and servlet-mappings.
    +-->

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
    
	<display-name>eXist XML Database</display-name>
	<description>eXist Open Source Native XML Database</description>

    <!-- 
        Initialize Log4j using a servlet.
        Only needed when eXist is deployed as a .war file in e.g. Tomcat.
    -->
    <servlet>
        <servlet-name>log4j-init</servlet-name>
        <servlet-class>org.exist.http.servlets.Log4jInit</servlet-class>

        <init-param>
            <param-name>log4j-init-file</param-name>
            <param-value>WEB-INF/log4j.xml</param-value>
        </init-param>

        <load-on-startup>1</load-on-startup>
    </servlet>
    
	
    <!--
        RpcServlet provides XML-RPC access to eXist 
    -->
    <servlet>
        <servlet-name>org.exist.xmlrpc.RpcServlet</servlet-name>
        <servlet-class>org.exist.xmlrpc.RpcServlet</servlet-class>
    </servlet>
  
    <!-- 
        DatabaseAdminServlet: this servlet can be used to ensure that
        eXist is running in the background. Just set the start-parameter 
        to true and load-on-startup to 1 
    -->
    <servlet>
        <servlet-name>EXistServlet</servlet-name>
        <servlet-class>org.exist.http.servlets.EXistServlet</servlet-class>
    
        <!--
            where to find eXist's configuration file relative to the basedir 
            of the web-application.
        -->
        <init-param>
            <param-name>configuration</param-name>
            <param-value>conf.xml</param-value>
        </init-param>

        <!-- 
            eXist's home directory. All file names in the configuration file 
            will be relative to this directory.
        -->
        <init-param>
            <param-name>basedir</param-name>
            <param-value>WEB-INF/</param-value>
        </init-param>

        <init-param>
            <param-name>start</param-name>
            <param-value>true</param-value>
        </init-param>

        <load-on-startup>2</load-on-startup>
    </servlet>

    <!--  XForms Filter -->
    <filter>
      <filter-name>XForms Filter</filter-name>
      <filter-class>uk.gov.devonline.www.xforms.XFormsFilter</filter-class>
      <init-param>
	      <param-name>CHIBA_DEBUG</param-name>
	      <param-value>false</param-value>
      </init-param>
      <init-param>
	      <param-name>CHIBA_CONFIG</param-name>
	      <param-value>/usr/local/eXist/tools/XFormsFilter/chiba.default.xml</param-value>
      </init-param>
      <init-param>
	      <param-name>CHIBA_TEMP_UPLOAD_DESTINATION</param-name>
	      <param-value>/tmp</param-value>
      </init-param>
      <init-param>
	      <param-name>CHIBA_STYLESHEET_PATH</param-name>
	      <param-value>/usr/local/eXist/tools/XFormsFilter/xslt</param-value>
      </init-param>
      <init-param>
	      <param-name>CHIBA_STYLESHEET_FILE</param-name>
	      <param-value>xhtml.xsl</param-value>
      </init-param>
      <init-param>
		<param-name>CHIBA_CSS</param-name>
		<param-value>/exist/servlet/db/xforms/xforms.css</param-value>
	  </init-param>      
    </filter>

    <!-- 
        Servlet that enables webDAV 
    -->
    <servlet>
        <servlet-name>WebDAVServlet</servlet-name>
        <servlet-class>org.exist.http.servlets.WebDAVServlet</servlet-class>

        <init-param>
            <param-name>authentication</param-name>
            <param-value>basic</param-value>
        </init-param>
    </servlet>

    <!-- 
        XQueryServlet generates HTML from an XQuery file. 
    -->
    <servlet>
        <servlet-name>XQueryServlet</servlet-name>
        <servlet-class>org.exist.http.servlets.XQueryServlet</servlet-class>

        <init-param>
            <param-name>uri</param-name>
            <param-value>xmldb:exist:///db</param-value>
        </init-param>

        <init-param>
            <param-name>form-encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>

        <init-param>
            <param-name>container-encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>

        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
    </servlet>
	
    <!--
        Configure the Axis servlets. 
        Axis provides eXist's web-services via SOAP.
    -->
<!--
    <servlet>
        <servlet-name>AxisServlet</servlet-name>
        <servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
    </servlet>

    <servlet>
        <servlet-name>AdminServlet</servlet-name>
        <servlet-class>org.apache.axis.transport.http.AdminServlet</servlet-class>
        <load-on-startup>100</load-on-startup>
    </servlet>
-->	
    
    <!-- 
        ================ Cocoon2 Configuration starts here ================ 
    -->

    <servlet>
        <servlet-name>Cocoon</servlet-name>

        <!--
            The regular servlet class (trusts the servlet container classloader)
        -->
        <servlet-class>org.apache.cocoon.servlet.CocoonServlet</servlet-class>

        <!--
            In cases you're facing class loading problems, you can alternatively
            use the following servlet-class instead of the above one
      
            <servlet-class>org.apache.cocoon.servlet.ParanoidCocoonServlet</servlet-class>
        -->

        <!--
            This parameter tells cocoon to set the thread's context classloader
            to its own classloader. If you experience strange classloader issues,
            try setting this parameter to "true" or using ParanoidCocoonServlet.
        -->
        <init-param>
            <param-name>init-classloader</param-name>
            <param-value>false</param-value>
        </init-param>
    
        <!--
            This parameter points to the main configuration file for Cocoon.
            Note that the path is specified in absolute notation but it will be
            resolved relative to the servlets webapp context path
        -->
        <init-param>
            <param-name>configurations</param-name>
            <param-value>/WEB-INF/cocoon.xconf</param-value>
        </init-param>

        <!--
            This parameter indicates the configuration file of the LogKit 
            management
        -->
        <init-param>
            <param-name>logkit-config</param-name>
            <param-value>/WEB-INF/logkit.xconf</param-value>
        </init-param>

        <!--
            This parameter indicates the category id of the logger from the 
            LogKit configuration used by the CocoonServlet.
        -->
        <init-param>
            <param-name>servlet-logger</param-name>
            <param-value>access</param-value>
        </init-param>

        <!--
            This parameter indicates the category id of the logger from the 
            LogKit management configuration for the Cocoon engine.
            
            This logger is used for all components described in the cocoon.xconf
            and sitemap.xmap file not having specified a logger with the
            logger="..." attribute in the component configuration file.
        -->
        <init-param>
            <param-name>cocoon-logger</param-name>
            <param-value>core</param-value>
        </init-param>

        <!--
            This parameter indicates the log level to use throughout startup of
            the system. As soon as the logkit.xconf the setting of the 
            logkit.xconf configuration is used instead! 
            Only for startup and if the logkit.xconf is not readable/available
            this log level is of importance.

            Available levels are:
            DEBUG:        prints all level of log messages.
            INFO:         prints all level of log messages except DEBUG ones.
            WARN:         prints all level of log messages except DEBUG and INFO ones.
            ERROR:        prints all level of log messages except DEBUG, INFO and WARN ones.
            FATAL_ERROR:  prints only log messages of this level
        -->
        <init-param>
            <param-name>log-level</param-name>
            <param-value>WARN</param-value>
        </init-param>

        <!--
            Allow reinstantiating (reloading) of the cocoon instance. If this is
            set to "yes" or "true", a new cocoon instance can be created using
            the request parameter "cocoon-reload".
        -->
        <init-param>
            <param-name>allow-reload</param-name>
            <param-value>no</param-value>
        </init-param>

        <!--
            This parameter is used to list classes that should be loaded
            at initialization time of the servlet.
            Usually this classes are JDBC Drivers used
        -->
        <init-param>
            <param-name>load-class</param-name>
            <param-value>
            <!-- For IBM WebSphere:
            com.ibm.servlet.classloader.Handler -->

            <!-- For Database Driver: -->
            <!-- org.hsqldb.jdbcDriver -->

            <!-- For PostgeSQL Database: 
            org.postgresql.Driver -->

            <!-- For Oracle Database:
            oracle.jdbc.driver.OracleDriver -->

            <!-- ODBC 
            sun.jdbc.odbc.JdbcOdbcDriver -->
 
            <!-- For parent ComponentManager sample:
            org.apache.cocoon.samples.parentcm.Configurator
            --></param-value>
        </init-param>

        <!--
            Causes all files in multipart requests to be processed. Default is 
            false for security reasons. Unsupported values will be interpreted 
            as false.
        -->
        <init-param>
            <param-name>enable-uploads</param-name>
            <param-value>true</param-value>
        </init-param>
    
        <!--
            This parameter allows to specify where Cocoon should put uploaded
            files. The path specified can be either absolute or relative to the
            context path of the servlet. On windows platform, absolute directory
            must start with volume: C:\Path\To\Upload\Directory

            The default directory is "upload-dir" in the work-directory
        -->
        <!--init-param>
            <param-name>upload-directory</param-name>
            <param-value>WEB-INF/work/upload-dir</param-value>
        </init-param-->

        <!--
            Causes all files in multipart requests to be saved to upload-dir.
            Default is true for security reasons. Unsupported values will be
            interpreted as false.
        -->
        <init-param>
            <param-name>autosave-uploads</param-name>
            <param-value>true</param-value>
        </init-param>

        <!--
            Specify handling of name conflicts when saving uploaded files
            to disk.  Acceptable values are deny, allow, rename (default).
            Files are renamed x_filename where x is an integer value
            incremented to make the new filename unique.
        -->
        <init-param>
            <param-name>overwrite-uploads</param-name>
            <param-value>allow</param-value>
        </init-param>
    
        <!--
            Specify maximum allowed size of the upload. Defaults to 10 Mb.
        -->
        <init-param>
            <param-name>upload-max-size</param-name>
            <param-value>100000000</param-value>
        </init-param>

        <!--
            This parameter allows to specify where Cocoon should create its page
            and other objects cache. The path specified can be either absolute
            or relative to the context path of the servlet. On windows platform,
            absolute directory must start with volume: C:\Path\To\Cache\Directory
      
            The default directory is "cache-dir" in the work-directory
        -->
        <!--init-param>
            <param-name>cache-directory</param-name>
            <param-value>WEB-INF/work/cache-dir</param-value>
        </init-param-->

        <!--
            This parameter allows to specify where Cocoon should put it's
            working files. The path specified is either absolute or relative
            to the context path of the Cocoon servlet.  On windows platform,
            absolute directory must start with volume: C:\Path\To\Work\Directory

            The default directory is "cocoon-files" directory in the servlet
            context's temp directory (context property javax.servlet.context.tempdir).
        -->
        <!--init-param>
            <param-name>work-directory</param-name>
            <param-value>WEB-INF/work</param-value>
        </init-param-->

        <!--
            This parameter allows to specify additional directories or jars
            which Cocoon should put into it's own classpath.
            Note that you must separate them using the platforms path.separator
            (":" for *nix and ";" for Windows systems). Also note that absolute
            pathes are take as such but relative pathes are rooted at the context
            root of the Cocoon servlet.
        -->
        <!--init-param>
            <param-name>extra-classpath</param-name>
            <param-value>WEB-INF/extra-classes1:/[YOU-ABSOLUTE-PATH-TO]/own.jar</param-value>
        </init-param-->
        

        <!--
            This parameter allows you to select the parent component manager.
            The class will be instantiated via the constructor that takes a
            single String as a parameter. That String will be equal to the text
            after the '/'.

            Cocoon honors the LogEnabled and Initializable interfaces for this
            class, if it implements them.

            If you uncomment the following lines the parent CM is set to the 
            Parent CM sample, which will look up a configuration via JNDI at 
            org/apache/cocoon/samples/parentcm/ParentCMConfiguration and use it.
        -->
        <!--init-param>
            <param-name>parent-component-manager</param-name>
            <param-value>org.apache.cocoon.samples.parentcm.ParentComponentManager/org/apache/cocoon/samples/parentcm/ParentCMConfiguration</param-value>
        </init-param-->
        

        <!--
            If you set this parameter to 'true' or 'yes', Cocoon will add
            processing time to the end of each response. Value 'hide' adds 
            processing time as an HTML comment. By default, processing time is 
            not added (corresponds to value 'no').
        -->
        <!--init-param>
            <param-name>show-time</param-name>
            <param-value>hide</param-value>
        </init-param-->
        

        <!--
            If true or not set, this class will try to catch and handle all 
            Cocoon exceptions. If false, it will rethrow them to the servlet 
            container.
        -->
        <init-param>
            <param-name>manage-exceptions</param-name>
            <param-value>true</param-value>
        </init-param>
    
        <!--
            If true, Avalon Excalibur instrumentation will be enabled on all 
            Instrumentable components with Cocoon and your Cocoon application.
        -->
        <!--init-param>
            <param-name>enable-instrumentation</param-name>
            <param-value>true</param-value>
        </init-param-->

        <!--
            This defines the location of the instrument manager configuration, 
            only used if the init-param enable-instrumentation is enabled.
        -->
        <!--init-param>
            <param-name>instrumentation-config</param-name>
            <param-value>/WEB-INF/instrumentation.xconf</param-value>
        </init-param-->

        <!--
            Set encoding used by the container. If not set the ISO-8859-1 
            encoding will be assumed.
        -->
        <init-param>
            <param-name>container-encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>

        <!--
            Set form encoding. This will be the character set used to decode 
            request parameters. If not set the ISO-8859-1 encoding will be 
            assumed. 
        -->
        <init-param>
            <param-name>form-encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>

        <!--
            This parameter allows you to startup Cocoon2 immediately after 
            startup of your servlet engine.
        -->
        <load-on-startup>1</load-on-startup>
    </servlet>

    <!--
        Needed to overwrite the Cocoon default 
    -->
    <servlet>
        <servlet-name>Jasper</servlet-name>
        <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
    </servlet>
    
    <!--
        Register Webstart servlet
    -->
    <servlet>
        <servlet-name>jnlp</servlet-name>
        <servlet-class>org.exist.webstart.JnlpServlet</servlet-class>
    </servlet>
    
    
    <!-- ====================== URL space mappings ======================= -->

    <!-- XMLRPC -->
    <servlet-mapping>
        <servlet-name>org.exist.xmlrpc.RpcServlet</servlet-name>
        <url-pattern>/xmlrpc</url-pattern>
    </servlet-mapping>
     
    <!-- REST new mapping-->
    <servlet-mapping>
        <servlet-name>EXistServlet</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
    
    <!-- REST original mapping-->
    <servlet-mapping>
        <servlet-name>EXistServlet</servlet-name>
        <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping>

    <!--  XForms filter mapping -->
    <filter-mapping>
    	<filter-name>XForms Filter</filter-name>
    	<url-pattern>/servlet/*</url-pattern>
    </filter-mapping>

    <!-- webDAV -->
    <servlet-mapping>
        <servlet-name>WebDAVServlet</servlet-name>
        <url-pattern>/webdav/*</url-pattern>
    </servlet-mapping>

    <!-- XQuery (not for database stored queries) -->
    <servlet-mapping>
        <servlet-name>XQueryServlet</servlet-name>
        <url-pattern>*.xql</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>XQueryServlet</servlet-name>
        <url-pattern>*.xqy</url-pattern>
    </servlet-mapping>
      
    <!-- SOAP (Apache Axis) -->
<!--
    <servlet-mapping>
        <servlet-name>AxisServlet</servlet-name>
        <url-pattern>/axis-servlet/AxisServlet</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>AxisServlet</servlet-name>
        <url-pattern>*.jws</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>AxisServlet</servlet-name>
        <url-pattern>/services/*</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>AdminServlet</servlet-name>
        <url-pattern>/axis-servlet/AdminServlet</url-pattern>
    </servlet-mapping>
-->  
    
    <!-- 
        Finally, we establish the main mapping for Cocoon  
    -->
  
    <!--
        Cocoon handles all the URL space assigned to the webapp using its 
        sitemap. It is recommended to leave it unchanged. Under some 
        circumstances though (like integration with proprietary webapps or 
        servlets) you might have to change this parameter.
    -->
    <servlet-mapping>
        <servlet-name>Cocoon</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>Jasper</servlet-name>
        <url-pattern>*.jsp</url-pattern>
    </servlet-mapping>

    <!--
        Some servlet engines (WebLogic) have defaults which are not overriden
        by '/' mapping, but must be overriden explicitly.
    -->
    <servlet-mapping>
        <servlet-name>Cocoon</servlet-name>
        <url-pattern>*.html</url-pattern>
    </servlet-mapping>

    <!-- Java Webstart -->
    <servlet-mapping>
        <servlet-name>jnlp</servlet-name>
        <url-pattern>/webstart/*</url-pattern>
    </servlet-mapping>
    
    
    <!-- ==================== various MIME type mappings ================== -->

    <mime-mapping>
        <extension>css</extension>
        <mime-type>text/css</mime-type>
    </mime-mapping>

    <mime-mapping>
        <extension>xml</extension>
        <mime-type>text/xml</mime-type>
    </mime-mapping>

    <mime-mapping>
        <extension>xsl</extension>
        <mime-type>text/xml</mime-type>
    </mime-mapping>

    <mime-mapping>
        <extension>xconf</extension>
        <mime-type>text/xml</mime-type>
    </mime-mapping>

    <mime-mapping>
        <extension>xmap</extension>
        <mime-type>text/xml</mime-type>
    </mime-mapping>

    <mime-mapping>
        <extension>ent</extension>
        <mime-type>text/plain</mime-type>
    </mime-mapping>

    <mime-mapping>
        <extension>grm</extension>
        <mime-type>text/plain</mime-type>
    </mime-mapping>

    <jsp-config>
        <taglib>
            <taglib-uri>http://exist-db.org/exist</taglib-uri>
            <taglib-location>/WEB-INF/exist.tld</taglib-location>
        </taglib>
    </jsp-config>
    
</web-app>
