/*
 * Copyright 2006, XpertNet SARL, and individual contributors as indicated
 * by the contributors.txt.
 *
 * 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.
 *
 * @author sdumitriu
 */

package com.xpn.xwiki.user.impl.exo;

import org.exoplatform.container.PortalContainer;
import org.exoplatform.container.RootContainer;

import javax.servlet.*;
import java.io.IOException;


public class ExoFilter implements Filter {

    public static final String EXO_CONTAINER = "portal";
    public static FilterConfig filterCongif_ = null;

    public void init(FilterConfig filterConfig) throws ServletException {
        if (filterConfig != null) {
            filterCongif_ = filterConfig;
        } else {
            PortalContainer manager = RootContainer.getInstance().getPortalContainer(EXO_CONTAINER);
            filterCongif_ = (FilterConfig) manager.getComponentInstanceOfType(FilterConfig.class);
        }
    }

    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
            throws IOException, ServletException {
        PortalContainer pcontainer = RootContainer.getInstance().getPortalContainer(EXO_CONTAINER);
        PortalContainer.setInstance(pcontainer);
        filterChain.doFilter(servletRequest, servletResponse);
    }

    public void destroy() {
    }

}

@@ -1252,33 +1252,25 @@
 tic 
-FilterConfig filterCongif
+String portalName
 _ = 
@@ -1365,95 +1365,100 @@
     
-if (filterConfig != null) %7B%0D%0A            filterCongif_ = filterConfig;%0D%0A        %7D else 
+portalName_ = filterConfig.getInitParameter(%22portalName%22);%0D%0A        if (portalName_ == null)
 %7B%0D%0A 
@@ -1470,83 +1470,22 @@
     
-  P
+p
 ortal
-Container manager = RootContainer.getInstance().getPortalContainer(
+Name_ = 
 EXO_
@@ -1485,33 +1485,32 @@
  = EXO_CONTAINER
-)
 ;%0D%0A            f
@@ -1508,109 +1508,109 @@
     
+%7D%0D%0A
     
-filterCongif_ = (FilterConfig) manager.getComponentInstanceOfType(FilterConfig.class);%0D%0A        %7D
+    System.out.append(%22init done%22);%0D%0A        System.out.append(%22portal Name: %22 + portalName_);
 %0D%0A  
@@ -1871,23 +1871,80 @@
 ner(
-EXO_CONTAINER);
+portalName_);%0D%0A        System.out.append(%22pcontainer: %22 + pcontainer);%0D%0A
 %0D%0A  
@@ -2105,8 +2105,10 @@
 %7D%0D%0A%0D%0A%7D%0D%0A
+%0D%0A

fix the exo filter