//# 0 errors, 44 messages
//#
/*
    //#PersistenceSessionFilter.java:1:1: class: org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter
 * Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  The ASF licenses this file to You
 * under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.  For additional information regarding
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */

package org.apache.roller.weblogger.ui.core.filters;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.weblogger.business.WebloggerFactory;
import org.apache.roller.weblogger.config.WebloggerConfig;
import org.apache.roller.planet.business.PlanetFactory;


/**
 * Sole responsibility is to ensure that each request's Roller
 * persistence session is released at end of the request.
 *
 * @web.filter name="PersistenceSessionFilter"
 */
public class PersistenceSessionFilter implements Filter {
    //#PersistenceSessionFilter.java:43: method: void org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter.org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter()
    //#PersistenceSessionFilter.java:43: end of method: void org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter.org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter()
    
    private static Log log = LogFactory.getLog(PersistenceSessionFilter.class);
    //#PersistenceSessionFilter.java:45: method: org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter.org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter__static_init
    //#PersistenceSessionFilter.java:45: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter
    //#    method: org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/core/filters/PersistenceSessionFilter]
    //#output(org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter__static_init): __Dispatch_Table.destroy()V
    //#output(org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter__static_init): __Dispatch_Table.doFilter(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;Ljavax/servlet/FilterChain;)V
    //#output(org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter__static_init): __Dispatch_Table.init(Ljavax/servlet/FilterConfig;)V
    //#output(org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter__static_init): log
    //#post(org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/core/filters/PersistenceSessionFilter] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter__static_init): __Dispatch_Table.destroy()V == &destroy
    //#post(org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter__static_init): __Dispatch_Table.doFilter(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;Ljavax/servlet/FilterChain;)V == &doFilter
    //#post(org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter__static_init): __Dispatch_Table.init(Ljavax/servlet/FilterConfig;)V == &init
    //#post(org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter__static_init): init'ed(log)
    //#PersistenceSessionFilter.java:45: end of method: org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter.org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter__static_init
    
    
    /**
     * Release Roller persistence session at end of request processing.
     */
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
            throws IOException, ServletException {
        
        HttpServletRequest request = (HttpServletRequest) req;
    //#PersistenceSessionFilter.java:54: method: void org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter.doFilter(ServletRequest, ServletResponse, FilterChain)
    //#input(void doFilter(ServletRequest, ServletResponse, FilterChain)): "Entered "._tainted
    //#input(void doFilter(ServletRequest, ServletResponse, FilterChain)): "Exiting "._tainted
    //#input(void doFilter(ServletRequest, ServletResponse, FilterChain)): chain
    //#input(void doFilter(ServletRequest, ServletResponse, FilterChain)): log
    //#input(void doFilter(ServletRequest, ServletResponse, FilterChain)): req
    //#input(void doFilter(ServletRequest, ServletResponse, FilterChain)): res
    //#pre[1] (void doFilter(ServletRequest, ServletResponse, FilterChain)): chain != null
    //#pre[2] (void doFilter(ServletRequest, ServletResponse, FilterChain)): log != null
    //#pre[3] (void doFilter(ServletRequest, ServletResponse, FilterChain)): req != null
    //#presumption(void doFilter(ServletRequest, ServletResponse, FilterChain)): org.apache.roller.planet.business.PlanetFactory:getPlanet(...)@69 != null
    //#presumption(void doFilter(ServletRequest, ServletResponse, FilterChain)): org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger(...)@64 != null
        HttpServletResponse response = (HttpServletResponse) res;
        
        log.debug("Entered "+request.getRequestURI());
    //#PersistenceSessionFilter.java:57: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter
    //#    method: void doFilter(ServletRequest, ServletResponse, FilterChain)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
        
        try {
            chain.doFilter(request, response);
        } finally {
            if (WebloggerFactory.isBootstrapped()) {
    //#PersistenceSessionFilter.java:62: Warning: method not available
    //#    -- call on bool org.apache.roller.weblogger.business.WebloggerFactory:isBootstrapped()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter
    //#    method: void doFilter(ServletRequest, ServletResponse, FilterChain)
    //#    unanalyzed callee: bool org.apache.roller.weblogger.business.WebloggerFactory:isBootstrapped()
                log.debug("Releasing Roller Session");
    //#PersistenceSessionFilter.java:63: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter
    //#    method: void doFilter(ServletRequest, ServletResponse, FilterChain)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
                WebloggerFactory.getWeblogger().release();
    //#PersistenceSessionFilter.java:64: Warning: method not available
    //#    -- call on Weblogger org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter
    //#    method: void doFilter(ServletRequest, ServletResponse, FilterChain)
    //#    unanalyzed callee: Weblogger org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger()
    //#PersistenceSessionFilter.java:64: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.business.Weblogger:release()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter
    //#    method: void doFilter(ServletRequest, ServletResponse, FilterChain)
    //#    unanalyzed callee: void org.apache.roller.weblogger.business.Weblogger:release()
                
                // if planet is enabled then release planet backend as well
                if (WebloggerConfig.getBooleanProperty("planet.aggregator.enabled")) {
    //#PersistenceSessionFilter.java:67: Warning: method not available
    //#    -- call on bool org.apache.roller.weblogger.config.WebloggerConfig:getBooleanProperty(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter
    //#    method: void doFilter(ServletRequest, ServletResponse, FilterChain)
    //#    unanalyzed callee: bool org.apache.roller.weblogger.config.WebloggerConfig:getBooleanProperty(String)
                    if (PlanetFactory.isBootstrapped()) {
    //#PersistenceSessionFilter.java:68: Warning: method not available
    //#    -- call on bool org.apache.roller.planet.business.PlanetFactory:isBootstrapped()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter
    //#    method: void doFilter(ServletRequest, ServletResponse, FilterChain)
    //#    unanalyzed callee: bool org.apache.roller.planet.business.PlanetFactory:isBootstrapped()
                        PlanetFactory.getPlanet().release();
    //#PersistenceSessionFilter.java:69: Warning: method not available
    //#    -- call on Planet org.apache.roller.planet.business.PlanetFactory:getPlanet()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter
    //#    method: void doFilter(ServletRequest, ServletResponse, FilterChain)
    //#    unanalyzed callee: Planet org.apache.roller.planet.business.PlanetFactory:getPlanet()
    //#PersistenceSessionFilter.java:69: Warning: method not available
    //#    -- call on void org.apache.roller.planet.business.Planet:release()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter
    //#    method: void doFilter(ServletRequest, ServletResponse, FilterChain)
    //#    unanalyzed callee: void org.apache.roller.planet.business.Planet:release()
                    }
                }
            }
            
        }
        
        log.debug("Exiting "+request.getRequestURI());
    //#PersistenceSessionFilter.java:76: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter
    //#    method: void doFilter(ServletRequest, ServletResponse, FilterChain)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
    }
    //#PersistenceSessionFilter.java:77: end of method: void org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter.doFilter(ServletRequest, ServletResponse, FilterChain)
    
    
    public void init(FilterConfig filterConfig) throws ServletException {}
    //#PersistenceSessionFilter.java:80: method: void org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter.init(FilterConfig)
    //#PersistenceSessionFilter.java:80: end of method: void org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter.init(FilterConfig)
    
    public void destroy() {}
    //#PersistenceSessionFilter.java:82: method: void org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter.destroy()
    //#PersistenceSessionFilter.java:82: end of method: void org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter.destroy()
    
}

    //#PersistenceSessionFilter.java:: end of class: org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter
