//# 5 errors, 106 messages
//#
/*
    //#OldFeedRequest.java:1:1: class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest
 * 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.rendering.velocity.deprecated;

import java.util.HashSet;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.weblogger.WebloggerException;
import org.apache.roller.weblogger.pojos.WeblogTemplate;


/**
 * Represents a request for an *old* Roller weblog feed.
 * 
 * any of /rss/*, /atom/*, /flavor/*
 *
 * While these urls are no longer used we do provide redirect support for them
 * for users who have upgraded from earlier versions.  We keep this class to
 * help with parsing these urls since they are fairly complex.
 */
public class OldFeedRequest {
    
    private static Log mLogger = LogFactory.getLog(OldFeedRequest.class);
    //#OldFeedRequest.java:42: method: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest.org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init
    //#OldFeedRequest.java:42: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest
    //#    method: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/rendering/velocity/deprecated/OldFeedRequest]
    //#output(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init): __Dispatch_Table.getContext()Ljava/lang/String;
    //#output(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init): __Dispatch_Table.getFlavor()Ljava/lang/String;
    //#output(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init): __Dispatch_Table.getWeblogCategory()Ljava/lang/String;
    //#output(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init): __Dispatch_Table.getWeblogHandle()Ljava/lang/String;
    //#output(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init): __Dispatch_Table.isExcerpts()Z
    //#output(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init): feedServlets
    //#output(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init): mLogger
    //#output(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init): new HashSet(OldFeedRequest__static_init#1) num objects
    //#new obj(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init): new HashSet(OldFeedRequest__static_init#1)
    //#post(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/rendering/velocity/deprecated/OldFeedRequest] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init): __Dispatch_Table.getContext()Ljava/lang/String; == &getContext
    //#post(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init): __Dispatch_Table.getFlavor()Ljava/lang/String; == &getFlavor
    //#post(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init): __Dispatch_Table.getWeblogCategory()Ljava/lang/String; == &getWeblogCategory
    //#post(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init): __Dispatch_Table.getWeblogHandle()Ljava/lang/String; == &getWeblogHandle
    //#post(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init): __Dispatch_Table.isExcerpts()Z == &isExcerpts
    //#post(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init): feedServlets == &new HashSet(OldFeedRequest__static_init#1)
    //#post(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init): init'ed(mLogger)
    //#post(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init): new HashSet(OldFeedRequest__static_init#1) num objects == 1
    
    private static Set feedServlets = new HashSet();
    
    private String context = null;
    private String flavor = null;
    private String weblogHandle = null;
    private String weblogCategory = null;
    private boolean excerpts = false;
    
    
    static {
        // initialize our servlet list
        feedServlets.add("rss");
        feedServlets.add("flavor");
        feedServlets.add("atom");
    }
    //#OldFeedRequest.java:58: end of method: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest.org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest__static_init
    
    
    /**
     * Construct the WeblogFeedRequest by parsing the incoming url
     */
    public OldFeedRequest(HttpServletRequest request) throws Exception {
    //#OldFeedRequest.java:64: method: void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest.org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)
    //#input(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): "not a weblog feed request, "._tainted
    //#input(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): "parsing url "._tainted
    //#input(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): feedServlets
    //#input(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): mLogger
    //#input(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): request
    //#input(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): this
    //#output(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): java.lang.String:substring(...)._tainted
    //#output(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): this.context
    //#output(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): this.excerpts
    //#output(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): this.flavor
    //#output(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): this.weblogCategory
    //#output(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): this.weblogHandle
    //#new obj(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): java.lang.String:substring(...)
    //#pre[1] (void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): feedServlets != null
    //#pre[2] (void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): mLogger != null
    //#pre[3] (void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): request != null
    //#presumption(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): java.lang.Boolean:valueOf(...)@132 != null
    //#presumption(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): java.util.Set:contains(...)@77 == 1
    //#presumption(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): javax.servlet.http.HttpServletRequest:getParameter(...)@120 != null
    //#presumption(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): javax.servlet.http.HttpServletRequest:getServletPath(...)@69 != null
    //#post(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): java.lang.String:substring(...)._tainted == 0
    //#post(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): this.context in Addr_Set{&"weblog",&"main"}
    //#post(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): init'ed(this.excerpts)
    //#post(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): this.flavor != null
    //#post(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): init'ed(this.weblogCategory)
    //#post(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): this.weblogHandle == null
    //#test_vector(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): java.lang.String:equals(...)@138: {0}, {1}
    //#test_vector(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): java.lang.String:length(...)@89: {0,1}, {2..4_294_967_295}
    //#test_vector(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): java.lang.String:length(...)@94: {0}, {1..4_294_967_295}
    //#test_vector(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): javax.servlet.http.HttpServletRequest:getParameter(...)@119: Addr_Set{null}, Inverse{null}
    //#test_vector(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): javax.servlet.http.HttpServletRequest:getParameter(...)@123: Addr_Set{null}, Inverse{null}
    //#test_vector(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): javax.servlet.http.HttpServletRequest:getParameter(...)@127: Addr_Set{null}, Inverse{null}
    //#test_vector(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): javax.servlet.http.HttpServletRequest:getParameter(...)@131: Addr_Set{null}, Inverse{null}
    //#test_vector(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)): javax.servlet.http.HttpServletRequest:getPathInfo(...)@70: Addr_Set{null}, Inverse{null}
        
        // parse the request object and figure out what we've got
        mLogger.debug("parsing url "+request.getRequestURL());
    //#OldFeedRequest.java:67: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest
    //#    method: void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
        
        String servlet = request.getServletPath();
        String pathInfo = request.getPathInfo();
        
        // what servlet is our destination?
        if(servlet != null) {
            // strip off the leading slash
            servlet = servlet.substring(1);
            
            if(feedServlets.contains(servlet)) {
                this.context = "weblog";
                this.flavor = servlet;
            } else {
                // not a request to a feed servlet
                throw new Exception("not a weblog feed request, "+request.getRequestURL());
            }
        } else {
            throw new Exception("not a weblog feed request, "+request.getRequestURL());
        }
        
        // parse the path info
        if(pathInfo != null && pathInfo.trim().length() > 1) {
            // strip off the leading slash
            pathInfo = pathInfo.substring(1);
            String[] pathElements = pathInfo.split("/");
            
            if(pathElements[0].length() > 0) {
    //#OldFeedRequest.java:94: ?use of default init
    //#    init'ed(pathElements.length)
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest
    //#    method: void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)
    //#    basic block: bb_8
    //#    assertion: init'ed(pathElements.length)
    //#    VN: undefined
    //#    Expected: {-Inf..+Inf}
    //#    Bad: {Invalid}
    //#    Attribs:  Int  Bad only invalid
    //#OldFeedRequest.java:94: ?use of default init
    //#    init'ed(pathElements[0])
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest
    //#    method: void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)
    //#    basic block: bb_8
    //#    assertion: init'ed(pathElements[0])
    //#    VN: undefined
    //#    Expected: Univ-VN-Set
    //#    Bad: {Invalid}
    //#    Attribs:  Ptr  Bad only invalid
    //#OldFeedRequest.java:94: ?null dereference
    //#    not_init'ed(pathElements[0])
    //#    severity: MEDIUM
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest
    //#    method: void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)
    //#    basic block: bb_8
    //#    assertion: not_init'ed(pathElements[0])
    //#    VN: undefined
    //#    Expected: Inverse{null} or Invalid
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
                this.weblogHandle = pathElements[0];
    //#OldFeedRequest.java:95: ?use of default init
    //#    init'ed(pathElements.length)
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest
    //#    method: void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)
    //#    basic block: bb_9
    //#    assertion: init'ed(pathElements.length)
    //#    VN: undefined
    //#    Expected: {-Inf..+Inf}
    //#    Bad: {Invalid}
    //#    Attribs:  Int  Bad only invalid
    //#OldFeedRequest.java:95: ?use of default init
    //#    init'ed(pathElements[0])
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest
    //#    method: void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)
    //#    basic block: bb_9
    //#    assertion: init'ed(pathElements[0])
    //#    VN: undefined
    //#    Expected: Univ-VN-Set
    //#    Bad: {Invalid}
    //#    Attribs:  Ptr  Bad only invalid
            }
            
        } else {
            
            // no path info means this was a non-weblog request
            // we handle a few exceptions for this which include
            //   /rss - main rss feed
            //   /atom - main atom feed
            //   /flavor - main flavor feed
            
            this.context = "main";
        }
        
        /* 
         * parse request parameters
         *
         * the only params we currently care about are:
         *   flavor - defines the feed type
         *   catname - specifies a weblog category
         *   path - specifies a weblog category
         *   excerpts - specifies the feed should only include excerpts
         *
         */
        if(request.getParameter("flavor") != null) {
            this.flavor = request.getParameter("flavor");
        }
        
        if(request.getParameter("path") != null) {
            this.weblogCategory = request.getParameter("path");
        }
        
        if(request.getParameter("catname") != null) {
            this.weblogCategory = request.getParameter("catname");
        }
        
        if(request.getParameter("excerpts") != null) {
            this.excerpts = Boolean.valueOf(request.getParameter("excerpts")).booleanValue();
        }
        
        // one small final adjustment.
        // if our flavor is "flavor" then that means someone is just getting
        // the default flavor, which is rss, so let's set that
        if(this.flavor.equals("flavor")) {
            this.flavor = "rss";
        }
        
    }
    //#OldFeedRequest.java:142: end of method: void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest.org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest(HttpServletRequest)
    

    public String getContext() {
        return context;
    //#OldFeedRequest.java:146: method: String org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest.getContext()
    //#input(String getContext()): this
    //#input(String getContext()): this.context
    //#output(String getContext()): return_value
    //#pre[2] (String getContext()): init'ed(this.context)
    //#post(String getContext()): return_value == this.context
    //#post(String getContext()): init'ed(return_value)
    //#OldFeedRequest.java:146: end of method: String org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest.getContext()
    }

    public String getFlavor() {
        return flavor;
    //#OldFeedRequest.java:150: method: String org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest.getFlavor()
    //#input(String getFlavor()): this
    //#input(String getFlavor()): this.flavor
    //#output(String getFlavor()): return_value
    //#pre[2] (String getFlavor()): init'ed(this.flavor)
    //#post(String getFlavor()): return_value == this.flavor
    //#post(String getFlavor()): init'ed(return_value)
    //#OldFeedRequest.java:150: end of method: String org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest.getFlavor()
    }

    public String getWeblogHandle() {
        return weblogHandle;
    //#OldFeedRequest.java:154: method: String org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest.getWeblogHandle()
    //#input(String getWeblogHandle()): this
    //#input(String getWeblogHandle()): this.weblogHandle
    //#output(String getWeblogHandle()): return_value
    //#pre[2] (String getWeblogHandle()): init'ed(this.weblogHandle)
    //#post(String getWeblogHandle()): return_value == this.weblogHandle
    //#post(String getWeblogHandle()): init'ed(return_value)
    //#OldFeedRequest.java:154: end of method: String org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest.getWeblogHandle()
    }

    public String getWeblogCategory() {
        return weblogCategory;
    //#OldFeedRequest.java:158: method: String org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest.getWeblogCategory()
    //#input(String getWeblogCategory()): this
    //#input(String getWeblogCategory()): this.weblogCategory
    //#output(String getWeblogCategory()): return_value
    //#pre[2] (String getWeblogCategory()): init'ed(this.weblogCategory)
    //#post(String getWeblogCategory()): return_value == this.weblogCategory
    //#post(String getWeblogCategory()): init'ed(return_value)
    //#OldFeedRequest.java:158: end of method: String org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest.getWeblogCategory()
    }

    public boolean isExcerpts() {
        return excerpts;
    //#OldFeedRequest.java:162: method: bool org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest.isExcerpts()
    //#input(bool isExcerpts()): this
    //#input(bool isExcerpts()): this.excerpts
    //#output(bool isExcerpts()): return_value
    //#pre[2] (bool isExcerpts()): init'ed(this.excerpts)
    //#post(bool isExcerpts()): return_value == this.excerpts
    //#post(bool isExcerpts()): init'ed(return_value)
    //#OldFeedRequest.java:162: end of method: bool org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest.isExcerpts()
    }

}
    //#OldFeedRequest.java:: end of class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldFeedRequest
