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

    Copyright (C) 2009 eXo Platform SAS.
    
    This is free software; you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License as
    published by the Free Software Foundation; either version 2.1 of
    the License, or (at your option) any later version.
    
    This software is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    Lesser General Public License for more details.
    
    You should have received a copy of the GNU Lesser General Public
    License along with this software; if not, write to the Free
    Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
    02110-1301 USA, or see the FSF site: http://www.fsf.org.

-->

<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="Shindig"
         version="2.5">

  <display-name>eXoGadgetServer</display-name>

  <!-- configuration -->
  <!-- If you have your own Guice module(s), put them here as a colon-separated list. -->
  <context-param>
    <param-name>guice-modules</param-name>
    <param-value>
      org.apache.shindig.common.PropertiesModule:
      org.apache.shindig.gadgets.DefaultGuiceModule:
      org.apache.shindig.gadgets.servlet.AuthenticationModule:
      org.exoplatform.portal.gadget.core.ExoOAuthModule:
      org.apache.shindig.common.cache.ehcache.EhCacheModule:
      org.exoplatform.portal.gadget.core.ExoModule
    </param-value>
  </context-param>

  <filter>
    <filter-name>authFilter</filter-name>
    <filter-class>org.apache.shindig.auth.AuthenticationServletFilter</filter-class>
  </filter>

  <filter>
    <filter-name>ProxyServletFilter</filter-name>
    <filter-class>org.exoplatform.portal.gadget.core.ProxyServletFilter</filter-class>
  </filter>
    
  <filter>
    <filter-name>hostFilter</filter-name>
    <filter-class>org.apache.shindig.common.servlet.HostFilter</filter-class>
  </filter>
  
  <filter-mapping>
    <filter-name>hostFilter</filter-name>
    <url-pattern>/gadgets/ifr</url-pattern>
    <url-pattern>/gadgets/js/*</url-pattern>
    <url-pattern>/gadgets/proxy/*</url-pattern>
    <url-pattern>/gadgets/concat</url-pattern>
    <url-pattern>/rpc/*</url-pattern>
    <url-pattern>/rest/*</url-pattern>
  </filter-mapping>
  
  <filter-mapping>
    <filter-name>authFilter</filter-name>
    <url-pattern>/gadgets/ifr</url-pattern>
  </filter-mapping>

  <filter-mapping>
    <filter-name>authFilter</filter-name>
    <url-pattern>/gadgets/makeRequest</url-pattern>
  </filter-mapping>

  <filter-mapping>
    <filter-name>authFilter</filter-name>
    <url-pattern>/gadgets/api/rpc/*</url-pattern>
  </filter-mapping>

  <filter-mapping>
    <filter-name>authFilter</filter-name>
    <url-pattern>/gadgets/api/rest/*</url-pattern>
  </filter-mapping>

  <filter-mapping>
    <filter-name>ProxyServletFilter</filter-name>
    <servlet-name>proxy</servlet-name>
  </filter-mapping>

  <listener>
     <listener-class>org.exoplatform.portal.gadget.core.GateInGuiceServletContextListener</listener-class>
  </listener>

  <!-- Render a Gadget -->
  <servlet>
    <servlet-name>xml-to-html</servlet-name>
    <servlet-class>
      org.apache.shindig.gadgets.servlet.GadgetRenderingServlet
    </servlet-class>
  </servlet>

  <!-- Proxy -->
  <servlet>
    <servlet-name>proxy</servlet-name>
    <servlet-class>
      org.apache.shindig.gadgets.servlet.ProxyServlet
    </servlet-class>
  </servlet>

  <servlet>
    <servlet-name>concat</servlet-name>
    <servlet-class>
      org.apache.shindig.gadgets.servlet.ConcatProxyServlet
    </servlet-class>
  </servlet>

  <!-- OAuth callback -->
  <servlet>
    <servlet-name>oauthCallback</servlet-name>
    <servlet-class>
      org.apache.shindig.gadgets.servlet.OAuthCallbackServlet
    </servlet-class>
  </servlet>

  <!-- Metadata RPC -->
  <servlet>
    <servlet-name>metadata</servlet-name>
    <servlet-class>
      org.apache.shindig.gadgets.servlet.RpcServlet
    </servlet-class>
  </servlet>

  <!-- makeRequest -->
  <servlet>
    <servlet-name>makeRequest</servlet-name>
    <servlet-class>
      org.apache.shindig.gadgets.servlet.MakeRequestServlet
    </servlet-class>
  </servlet>


  <!-- Serve gadgets RPC api -->
  <servlet>
    <servlet-name>gadgetsJsonRpcServlet</servlet-name>
    <servlet-class>
      org.apache.shindig.protocol.JsonRpcServlet
    </servlet-class>
    <init-param>
      <param-name>handlers</param-name>
      <param-value>org.apache.shindig.handlers</param-value>
    </init-param>
  </servlet>

  <servlet>
    <servlet-name>gadgetsRestapiServlet</servlet-name>
    <servlet-class>
      org.apache.shindig.protocol.DataServiceServlet
    </servlet-class>
    <init-param>
      <param-name>handlers</param-name>
      <param-value>org.apache.shindig.handlers</param-value>
    </init-param>
  </servlet>

  <!-- javascript serving -->
  <servlet>
    <servlet-name>js</servlet-name>
    <servlet-class>org.apache.shindig.gadgets.servlet.JsServlet</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>js</servlet-name>
    <url-pattern>/gadgets/js/*</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>proxy</servlet-name>
    <url-pattern>/gadgets/proxy/*</url-pattern>
  </servlet-mapping>

   <servlet-mapping>
    <servlet-name>makeRequest</servlet-name>
    <url-pattern>/gadgets/makeRequest</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>gadgetsJsonRpcServlet</servlet-name>
    <url-pattern>/gadgets/api/rpc/*</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>gadgetsRestapiServlet</servlet-name>
    <url-pattern>/gadgets/api/rest/*</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>concat</servlet-name>
    <url-pattern>/gadgets/concat</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>oauthCallback</servlet-name>
    <url-pattern>/gadgets/oauthcallback</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>xml-to-html</servlet-name>
    <url-pattern>/gadgets/ifr</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>metadata</servlet-name>
    <url-pattern>/gadgets/metadata</url-pattern>
  </servlet-mapping>

</web-app>
