//# 12 errors, 207 messages
//#
/*
    //#WeblogRequestMapper.java:1:1: class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
 * 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;

import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.weblogger.config.WebloggerConfig;
import org.apache.roller.weblogger.business.WebloggerFactory;
import org.apache.roller.weblogger.business.UserManager;
import org.apache.roller.weblogger.pojos.Weblog;


/**
 * Handles rendering requests for Roller pages/feeds by routing to the appropriate Servlet.
 *
 * This request mapper is used to map all weblog specific urls of the form
 * /<weblog handle>/* to the appropriate servlet for handling the actual
 * request.
 *
 * TODO: we should try and make this class easier to extend and build upon
 */
public class WeblogRequestMapper implements RequestMapper {
    
    private static Log log = LogFactory.getLog(WeblogRequestMapper.class);
    //#WeblogRequestMapper.java:49: method: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper.org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper__static_init
    //#WeblogRequestMapper.java:49: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/rendering/WeblogRequestMapper]
    //#output(org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper__static_init): __Dispatch_Table.calculateForwardUrl(Ljavax/servlet/http/HttpServletRequest;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    //#output(org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper__static_init): __Dispatch_Table.handleRequest(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)Z
    //#output(org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper__static_init): __Dispatch_Table.isLocale(Ljava/lang/String;)Z
    //#output(org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper__static_init): __Dispatch_Table.isWeblog(Ljava/lang/String;)Z
    //#output(org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper__static_init): log
    //#output(org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper__static_init): org/apache/roller/weblogger/ui/rendering/RequestMapper.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/WeblogRequestMapper]
    //#post(org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/rendering/WeblogRequestMapper] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper__static_init): org/apache/roller/weblogger/ui/rendering/RequestMapper.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/WeblogRequestMapper] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper__static_init): __Dispatch_Table.calculateForwardUrl(Ljavax/servlet/http/HttpServletRequest;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; == &calculateForwardUrl
    //#post(org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper__static_init): __Dispatch_Table.handleRequest(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)Z == &handleRequest
    //#post(org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper__static_init): __Dispatch_Table.isLocale(Ljava/lang/String;)Z == &isLocale
    //#post(org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper__static_init): __Dispatch_Table.isWeblog(Ljava/lang/String;)Z == &isWeblog
    //#post(org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper__static_init): init'ed(log)
    //#WeblogRequestMapper.java:49: end of method: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper.org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper__static_init
    
    private static final String PAGE_SERVLET = "/roller-ui/rendering/page";
    private static final String FEED_SERVLET = "/roller-ui/rendering/feed";
    private static final String RESOURCE_SERVLET = "/roller-ui/rendering/resources";
    private static final String SEARCH_SERVLET = "/roller-ui/rendering/search";
    private static final String RSD_SERVLET = "/roller-ui/rendering/rsd";
    
    private static final String COMMENT_SERVLET = "/roller-ui/rendering/comment";
    private static final String TRACKBACK_SERVLET = "/roller-ui/rendering/trackback";
    
    
    // url patterns that are not allowed to be considered weblog handles
    Set restricted = null;
    
    
    public WeblogRequestMapper() {
    //#WeblogRequestMapper.java:65: method: void org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper.org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper()
    //#input(void org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper()): this
    //#output(void org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper()): new HashSet(WeblogRequestMapper#1) num objects
    //#output(void org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper()): this.restricted
    //#new obj(void org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper()): new HashSet(WeblogRequestMapper#1)
    //#post(void org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper()): this.restricted == &new HashSet(WeblogRequestMapper#1)
    //#post(void org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper()): new HashSet(WeblogRequestMapper#1) num objects == 1
    //#test_vector(void org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper()): java.lang.String:length(...)@72: {0}, {1..4_294_967_295}
    //#test_vector(void org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper()): java.lang.String:length(...)@82: {0}, {1..4_294_967_295}
    //#test_vector(void org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper()): org.apache.roller.weblogger.config.WebloggerConfig:getProperty(...)@70: Addr_Set{null}, Inverse{null}
    //#test_vector(void org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper()): org.apache.roller.weblogger.config.WebloggerConfig:getProperty(...)@80: Addr_Set{null}, Inverse{null}
        
        this.restricted = new HashSet();
        
        // build roller restricted list
        String restrictList = 
    //#WeblogRequestMapper.java:70: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: void org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper()
    //#    unanalyzed callee: String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String)
                WebloggerConfig.getProperty("rendering.weblogMapper.rollerProtectedUrls");
        if(restrictList != null && restrictList.trim().length() > 0) {
            String[] restrict = restrictList.split(",");
            for(int i=0; i < restrict.length; i++) {
    //#WeblogRequestMapper.java:74: ?use of default init
    //#    init'ed(restrict.length)
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: void org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper()
    //#    basic block: bb_4
    //#    assertion: init'ed(restrict.length)
    //#    VN: undefined
    //#    Expected: {-Inf..+Inf}
    //#    Bad: {Invalid}
    //#    Attribs:  Int  Bad only invalid
    //#WeblogRequestMapper.java:74: Warning: test always goes same way
    //#    test predetermined because i == restrict.length
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: void org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper()
    //#    from bb: bb_4
    //#    live edge: bb_4-->bb_6
    //#    tested vn: i - undefined
    //#    tested vn values: {0}
                this.restricted.add(restrict[i]);
    //#WeblogRequestMapper.java:75: Warning: dead code
    //#    dead code here because i == restrict.length
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: void org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper()
    //#    dead bb: bb_5
            }
        }
        
        // add user restricted list
        restrictList = 
    //#WeblogRequestMapper.java:80: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: void org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper()
    //#    unanalyzed callee: String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String)
                WebloggerConfig.getProperty("rendering.weblogMapper.userProtectedUrls");
        if(restrictList != null && restrictList.trim().length() > 0) {
            String[] restrict = restrictList.split(",");
            for(int i=0; i < restrict.length; i++) {
    //#WeblogRequestMapper.java:84: ?use of default init
    //#    init'ed(restrict.length)
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: void org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper()
    //#    basic block: bb_9
    //#    assertion: init'ed(restrict.length)
    //#    VN: undefined
    //#    Expected: {-Inf..+Inf}
    //#    Bad: {Invalid}
    //#    Attribs:  Int  Bad only invalid
    //#WeblogRequestMapper.java:84: Warning: test always goes same way
    //#    test predetermined because i == restrict.length
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: void org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper()
    //#    from bb: bb_9
    //#    live edge: bb_9-->bb_11
    //#    tested vn: i - undefined
    //#    tested vn values: {0}
                this.restricted.add(restrict[i]);
    //#WeblogRequestMapper.java:85: Warning: dead code
    //#    dead code here because i == restrict.length
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: void org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper()
    //#    dead bb: bb_10
            }
        }
    }
    //#WeblogRequestMapper.java:88: end of method: void org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper.org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper()
    
    
    public boolean handleRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        
        // kinda silly, but we need to keep track of whether or not the url had
        // a trailing slash so that we can act accordingly
        boolean trailingSlash = false;
    //#WeblogRequestMapper.java:96: method: bool org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper.handleRequest(HttpServletRequest, HttpServletResponse)
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): ","._tainted
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): "."._tainted
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): ".roller-ui.rendering.comment"._tainted
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): ".roller-ui.rendering.feed"._tainted
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): ".roller-ui.rendering.page"._tainted
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): ".roller-ui.rendering.resources"._tainted
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): ".roller-ui.rendering.rsd"._tainted
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): ".roller-ui.rendering.search"._tainted
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): ".roller-ui.rendering.trackback"._tainted
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): "?"._tainted
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): "FORWARD_URL "._tainted
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): "SKIPPED "._tainted
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): "WEBLOG_URL "._tainted
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): "]"._tainted
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): "checking weblog handle "._tainted
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): "evaluating ["._tainted
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): "forwarding to "._tainted
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): "potential weblog handle = "._tainted
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): log
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): request
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): response
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): this
    //#input(bool handleRequest(HttpServletRequest, HttpServletResponse)): this.restricted
    //#output(bool handleRequest(HttpServletRequest, HttpServletResponse)): return_value
    //#pre[1] (bool handleRequest(HttpServletRequest, HttpServletResponse)): log != null
    //#pre[2] (bool handleRequest(HttpServletRequest, HttpServletResponse)): request != null
    //#pre[5] (bool handleRequest(HttpServletRequest, HttpServletResponse)): this.restricted != null
    //#pre[3] (bool handleRequest(HttpServletRequest, HttpServletResponse)): (soft) response != null
    //#presumption(bool handleRequest(HttpServletRequest, HttpServletResponse)): java.lang.String:indexOf(...)@125 <= 4_294_967_294
    //#presumption(bool handleRequest(HttpServletRequest, HttpServletResponse)): javax.servlet.http.HttpServletRequest:getContextPath(...)@112 != null
    //#presumption(bool handleRequest(HttpServletRequest, HttpServletResponse)): javax.servlet.http.HttpServletRequest:getRequestDispatcher(...)@224 != null
    //#post(bool handleRequest(HttpServletRequest, HttpServletResponse)): init'ed(return_value)
    //#unanalyzed(bool handleRequest(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.String:length
    //#unanalyzed(bool handleRequest(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.String:split
    //#unanalyzed(bool handleRequest(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(bool handleRequest(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(bool handleRequest(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(bool handleRequest(HttpServletRequest, HttpServletResponse)): Effects-of-calling:org.apache.commons.logging.Log:debug
    //#unanalyzed(bool handleRequest(HttpServletRequest, HttpServletResponse)): Effects-of-calling:org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger
    //#unanalyzed(bool handleRequest(HttpServletRequest, HttpServletResponse)): Effects-of-calling:org.apache.roller.weblogger.business.Weblogger:getUserManager
    //#unanalyzed(bool handleRequest(HttpServletRequest, HttpServletResponse)): Effects-of-calling:org.apache.roller.weblogger.business.UserManager:getWebsiteByHandle
    //#unanalyzed(bool handleRequest(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(bool handleRequest(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.StringBuffer
    //#unanalyzed(bool handleRequest(HttpServletRequest, HttpServletResponse)): Effects-of-calling:javax.servlet.http.HttpServletRequest:getMethod
    //#unanalyzed(bool handleRequest(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.String:equals
    //#unanalyzed(bool handleRequest(HttpServletRequest, HttpServletResponse)): Effects-of-calling:javax.servlet.http.HttpServletRequest:getParameter
    //#unanalyzed(bool handleRequest(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.StringBuffer:append
    //#unanalyzed(bool handleRequest(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.StringBuffer:toString
    //#test_vector(bool handleRequest(HttpServletRequest, HttpServletResponse)): java.lang.String:endsWith(...)@118: {0}, {1}
    //#test_vector(bool handleRequest(HttpServletRequest, HttpServletResponse)): java.lang.String:indexOf(...)@123: {-1}, {-2_147_483_648..-2, 0..4_294_967_295}
    //#test_vector(bool handleRequest(HttpServletRequest, HttpServletResponse)): java.lang.String:length(...)@109: {0,1}, {2..4_294_967_295}
    //#test_vector(bool handleRequest(HttpServletRequest, HttpServletResponse)): java.util.Set:contains(...)@134: {1}, {0}
    //#test_vector(bool handleRequest(HttpServletRequest, HttpServletResponse)): javax.servlet.http.HttpServletRequest:getContextPath(...)@111: Addr_Set{null}, Inverse{null}
    //#test_vector(bool handleRequest(HttpServletRequest, HttpServletResponse)): javax.servlet.http.HttpServletRequest:getQueryString(...)@189: Addr_Set{null}, Inverse{null}
    //#test_vector(bool handleRequest(HttpServletRequest, HttpServletResponse)): javax.servlet.http.HttpServletRequest:getRequestURI(...)@106: Addr_Set{null}, Inverse{null}
        
        String weblogHandle = null;
        String weblogLocale = null;
        String weblogRequestContext = null;
        String weblogRequestData = null;
        
        log.debug("evaluating ["+request.getRequestURI()+"]");
    //#WeblogRequestMapper.java:103: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
        
        // figure out potential weblog handle
        String servlet = request.getRequestURI();
        String pathInfo = null;
                
        if(servlet != null && servlet.trim().length() > 1) {
            
            if(request.getContextPath() != null)
                servlet = servlet.substring(request.getContextPath().length());
            
            // strip off the leading slash
            servlet = servlet.substring(1);
            
            // strip off trailing slash if needed
            if(servlet.endsWith("/")) {
                servlet = servlet.substring(0, servlet.length() - 1);
                trailingSlash = true;
            }
            
            if(servlet.indexOf("/") != -1) {
                weblogHandle = servlet.substring(0, servlet.indexOf("/"));
                pathInfo = servlet.substring(servlet.indexOf("/")+1);
            } else {
                weblogHandle = servlet;
            }
        }
        
        log.debug("potential weblog handle = "+weblogHandle);
    //#WeblogRequestMapper.java:131: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
        
        // check if it's a valid weblog handle
        if(restricted.contains(weblogHandle) || !this.isWeblog(weblogHandle)) {
            log.debug("SKIPPED "+weblogHandle);
    //#WeblogRequestMapper.java:135: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
            return false;
        }
        
        log.debug("WEBLOG_URL "+request.getServletPath());
    //#WeblogRequestMapper.java:139: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
        
        // parse the rest of the url and build forward url
        if(pathInfo != null) {
            
            // parse the next portion of the url
            // we expect [locale/]<context>/<extra>/<info>
            String[] urlPath = pathInfo.split("/", 3);
            
            // if we have a locale, deal with it
            if(this.isLocale(urlPath[0])) {
    //#WeblogRequestMapper.java:149: ?use of default init
    //#    init'ed(urlPath.length)
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    basic block: bb_14
    //#    assertion: init'ed(urlPath.length)
    //#    VN: undefined
    //#    Expected: {-Inf..+Inf}
    //#    Bad: {Invalid}
    //#    Attribs:  Int  Bad only invalid
    //#WeblogRequestMapper.java:149: ?use of default init
    //#    init'ed(urlPath[0])
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    basic block: bb_14
    //#    assertion: init'ed(urlPath[0])
    //#    VN: undefined
    //#    Expected: Univ-VN-Set
    //#    Bad: {Invalid}
    //#    Attribs:  Ptr  Bad only invalid
    //#WeblogRequestMapper.java:149: Warning: test always goes same way
    //#    test predetermined because isLocale(...) == 0
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    from bb: bb_14
    //#    live edge: bb_14-->bb_19
    //#    tested vn: isLocale(...)
    //#    tested vn values: {0}
                weblogLocale = urlPath[0];
    //#WeblogRequestMapper.java:150: Warning: dead code
    //#    dead code here because isLocale(...) == 0
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    dead bb: bb_15
                
                // no extra path info specified
                if(urlPath.length == 2) {
                    weblogRequestContext = urlPath[1];
    //#WeblogRequestMapper.java:154: Warning: dead code continues
    //#    dead code continues
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    dead bb: bb_16
                    weblogRequestData = null;
                    
                // request contains extra path info
                } else if(urlPath.length == 3) {
    //#WeblogRequestMapper.java:158: Warning: dead code continues
    //#    dead code continues
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    dead bb: bb_17
                    weblogRequestContext = urlPath[1];
    //#WeblogRequestMapper.java:159: Warning: dead code continues
    //#    dead code continues
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    dead bb: bb_18
                    weblogRequestData = urlPath[2];
                }
            
            // otherwise locale is empty
            } else {
                weblogLocale = null;
                weblogRequestContext = urlPath[0];
    //#WeblogRequestMapper.java:166: ?use of default init
    //#    init'ed(urlPath.length)
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    basic block: bb_19
    //#    assertion: init'ed(urlPath.length)
    //#    VN: undefined
    //#    Expected: {-Inf..+Inf}
    //#    Bad: {Invalid}
    //#    Attribs:  Int  Bad only invalid
    //#WeblogRequestMapper.java:166: ?use of default init
    //#    init'ed(urlPath[0])
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    basic block: bb_19
    //#    assertion: init'ed(urlPath[0])
    //#    VN: undefined
    //#    Expected: Univ-VN-Set
    //#    Bad: {Invalid}
    //#    Attribs:  Ptr  Bad only invalid
                
                // last part of request is extra path info
                if(urlPath.length == 2) {
    //#WeblogRequestMapper.java:169: ?use of default init
    //#    init'ed(urlPath.length)
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    basic block: bb_19
    //#    assertion: init'ed(urlPath.length)
    //#    VN: undefined
    //#    Expected: {-Inf..+Inf}
    //#    Bad: {Invalid}
    //#    Attribs:  Int  Bad only invalid
    //#WeblogRequestMapper.java:169: Warning: test always goes same way
    //#    test predetermined because urlPath.length == 0
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    from bb: bb_19
    //#    live edge: bb_19-->bb_21
    //#    tested vn: undefined - 2
    //#    tested vn values: {-2}
                    weblogRequestData = urlPath[1];
    //#WeblogRequestMapper.java:170: Warning: dead code
    //#    dead code here because urlPath.length == 0
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    dead bb: bb_20
                    
                // if we didn't have a locale then we have split too much
                // so we reassemble the last 2 path elements together
                } else if(urlPath.length == 3) {
    //#WeblogRequestMapper.java:174: ?use of default init
    //#    init'ed(urlPath.length)
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    basic block: bb_21
    //#    assertion: init'ed(urlPath.length)
    //#    VN: undefined
    //#    Expected: {-Inf..+Inf}
    //#    Bad: {Invalid}
    //#    Attribs:  Int  Bad only invalid
    //#WeblogRequestMapper.java:174: Warning: test always goes same way
    //#    test predetermined because urlPath.length == 0
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    from bb: bb_21
    //#    live edge: bb_21-->bb_23
    //#    tested vn: undefined - 3
    //#    tested vn values: {-3}
                    weblogRequestData = urlPath[1] + "/" + urlPath[2];
    //#WeblogRequestMapper.java:175: Warning: dead code
    //#    dead code here because urlPath.length == 0
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    dead bb: bb_22
                }
            }
            
        }
        
        // special handling for trailing slash issue
        // we need this because by http standards the urls /foo and /foo/ are
        // supposed to be considered different, so we must enforce that
        if(weblogRequestContext == null && !trailingSlash) {
    //#WeblogRequestMapper.java:184: ?use of default init
    //#    init'ed(weblogRequestContext)
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    basic block: bb_23
    //#    assertion: init'ed(weblogRequestContext)
    //#    VN: weblogRequestContext
    //#    Expected: Univ-VN-Set
    //#    Bad: {Invalid}
    //#    Attribs:  Ptr  Bad only invalid
    //#WeblogRequestMapper.java:184: Warning: test always goes same way
    //#    test predetermined because weblogRequestContext == null
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    from bb: bb_23
    //#    live edge: bb_23-->bb_24
    //#    tested vn: weblogRequestContext == null
    //#    tested vn values: {1}
            // this means someone referred to a weblog index page with the 
            // shortest form of url /<weblog> or /<weblog>/<locale> and we need
            // to do a redirect to /<weblog>/ or /<weblog>/<locale>/
            String redirectUrl = request.getRequestURI() + "/";
            if(request.getQueryString() != null) {
                redirectUrl += "?"+request.getQueryString();
            }
            
            response.sendRedirect(redirectUrl);
            return true;
            
        } else if(weblogRequestContext != null &&
    //#WeblogRequestMapper.java:196: Warning: test always goes same way
    //#    test predetermined because weblogRequestContext == null
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    from bb: bb_28
    //#    live edge: bb_28-->bb_35
    //#    tested vn: weblogRequestContext == null
    //#    tested vn values: {1}
    //#WeblogRequestMapper.java:196: Warning: dead code
    //#    dead code here because weblogRequestContext == null
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    dead bb: bb_29
                "tags".equals(weblogRequestContext)) {
            // tags section can have an index page at /<weblog>/tags/ and
            // a tags query at /<weblog>/tags/tag1+tag2, buth that's it
            if((weblogRequestData == null && !trailingSlash) ||
    //#WeblogRequestMapper.java:200: Warning: dead code continues
    //#    dead code continues
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    dead bb: bb_30
                    (weblogRequestData != null && trailingSlash)) {
                response.sendError(HttpServletResponse.SC_NOT_FOUND);
    //#WeblogRequestMapper.java:202: Warning: dead code continues
    //#    dead code continues
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    dead bb: bb_34
                return true;
            }
        } else if(weblogRequestContext != null && trailingSlash) {
    //#WeblogRequestMapper.java:205: Warning: test always goes same way
    //#    test predetermined because weblogRequestContext == null
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    from bb: bb_35
    //#    live edge: bb_35-->bb_38
    //#    tested vn: weblogRequestContext == null
    //#    tested vn values: {1}
    //#WeblogRequestMapper.java:205: Warning: dead code
    //#    dead code here because weblogRequestContext == null
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    dead bb: bb_36
            // this means that someone has accessed a weblog url and included
            // a trailing slash, like /<weblog>/entry/<anchor>/ which is not
            // supported, so we need to offer up a 404 Not Found
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
    //#WeblogRequestMapper.java:209: Warning: dead code continues
    //#    dead code continues
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    dead bb: bb_37
            return true;
        }
        
        // calculate forward url
        String forwardUrl = calculateForwardUrl(request, weblogHandle, weblogLocale,
                weblogRequestContext, weblogRequestData);
        
        // if we don't have a forward url then the request was invalid somehow
        if(forwardUrl == null) {
            return false;
        }
        
        // dispatch to forward url
        log.debug("forwarding to "+forwardUrl);
    //#WeblogRequestMapper.java:223: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool handleRequest(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
        RequestDispatcher dispatch = request.getRequestDispatcher(forwardUrl);
        dispatch.forward(request, response);
        
        // we dealt with this request ourselves, so return "true"
        return true;
    //#WeblogRequestMapper.java:228: end of method: bool org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper.handleRequest(HttpServletRequest, HttpServletResponse)
    }

    
    /**
     * Convenience method for caculating the servlet forward url given a set
     * of information to make the decision with.
     *
     * handle is always assumed valid, all other params may be null.
     */
    private String calculateForwardUrl(HttpServletRequest request,
                                       String handle, String locale,
                                       String context, String data) {
        
        log.debug(handle+","+locale+","+context+","+data);
    //#WeblogRequestMapper.java:242: method: String org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper.calculateForwardUrl(HttpServletRequest, String, String, String, String)
    //#WeblogRequestMapper.java:242: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: String calculateForwardUrl(HttpServletRequest, String, String, String, String)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
    //#input(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): ","._tainted
    //#input(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): "."._tainted
    //#input(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): ".roller-ui.rendering.comment"._tainted
    //#input(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): ".roller-ui.rendering.feed"._tainted
    //#input(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): ".roller-ui.rendering.page"._tainted
    //#input(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): ".roller-ui.rendering.resources"._tainted
    //#input(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): ".roller-ui.rendering.rsd"._tainted
    //#input(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): ".roller-ui.rendering.search"._tainted
    //#input(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): ".roller-ui.rendering.trackback"._tainted
    //#input(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): "FORWARD_URL "._tainted
    //#input(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): context
    //#input(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): context._tainted
    //#input(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): data
    //#input(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): data._tainted
    //#input(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): handle
    //#input(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): handle._tainted
    //#input(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): locale
    //#input(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): locale._tainted
    //#input(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): log
    //#input(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): request
    //#output(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): java.lang.StringBuffer:toString(...)._tainted
    //#output(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): return_value
    //#new obj(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): java.lang.StringBuffer:toString(...)
    //#pre[13] (String calculateForwardUrl(HttpServletRequest, String, String, String, String)): log != null
    //#pre[14] (String calculateForwardUrl(HttpServletRequest, String, String, String, String)): request != null
    //#post(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): init'ed(java.lang.StringBuffer:toString(...)._tainted)
    //#post(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): return_value in Addr_Set{null,&java.lang.StringBuffer:toString(...)}
    //#test_vector(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): context: Inverse{null}, Addr_Set{null}
    //#test_vector(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): data: Addr_Set{null}, Inverse{null}
    //#test_vector(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): locale: Addr_Set{null}, Inverse{null}
    //#test_vector(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): java.lang.String:equals(...)@247: {0}, {1}
    //#test_vector(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): java.lang.String:equals(...)@249: {0}, {1}
    //#test_vector(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): java.lang.String:equals(...)@303: {1}, {0}
    //#test_vector(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): java.lang.String:equals(...)@303: {0}, {1}
    //#test_vector(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): java.lang.String:equals(...)@322: {0}, {1}
    //#test_vector(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): java.lang.String:equals(...)@337: {0}, {1}
    //#test_vector(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): java.lang.String:equals(...)@348: {0}, {1}
    //#test_vector(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): java.lang.String:equals(...)@355: {0}, {1}
    //#test_vector(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): javax.servlet.http.HttpServletRequest:getParameter(...)@251: Addr_Set{null}, Inverse{null}
    //#test_vector(String calculateForwardUrl(HttpServletRequest, String, String, String, String)): javax.servlet.http.HttpServletRequest:getParameter(...)@268: Addr_Set{null}, Inverse{null}
        
        StringBuffer forwardUrl = new StringBuffer();
        
        // POST urls, like comment and trackback servlets
        if("POST".equals(request.getMethod())) {
            // posting to permalink, this means comment or trackback
            if(context.equals("entry")) {
    //#WeblogRequestMapper.java:249: ?null dereference
    //#    context != null
    //#    severity: MEDIUM
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: String calculateForwardUrl(HttpServletRequest, String, String, String, String)
    //#    basic block: bb_2
    //#    assertion: context != null
    //#    VN: context
    //#    Expected: Inverse{null} or Invalid
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
                // trackback requests are required to have an "excerpt" param
                if(request.getParameter("excerpt") != null) {
                    
                    forwardUrl.append(TRACKBACK_SERVLET);
                    forwardUrl.append("/");
                    forwardUrl.append(handle);
                    if(locale != null) {
                        forwardUrl.append("/");
                        forwardUrl.append(locale);
                    }
                    forwardUrl.append("/");
                    forwardUrl.append(context);
                    if(data != null) {
                        forwardUrl.append("/");
                        forwardUrl.append(data);
                    }
                    
                // comment requests are required to have a "content" param
                } else if(request.getParameter("content") != null) {
                    
                    forwardUrl.append(COMMENT_SERVLET);
                    forwardUrl.append("/");
                    forwardUrl.append(handle);
                    if(locale != null) {
                        forwardUrl.append("/");
                        forwardUrl.append(locale);
                    }
                    forwardUrl.append("/");
                    forwardUrl.append(context);
                    if(data != null) {
                        forwardUrl.append("/");
                        forwardUrl.append(data);
                    }
                }
                
            } else {
                // someone posting data where they aren't supposed to
                return null;
            }
            
        } else {
            // no context means weblog homepage
            if(context == null) {
                
                forwardUrl.append(PAGE_SERVLET);
                forwardUrl.append("/");
                forwardUrl.append(handle);
                if(locale != null) {
                    forwardUrl.append("/");
                    forwardUrl.append(locale);
                }
                
                // requests handled by PageServlet
            } else if(context.equals("page") || context.equals("entry") ||
                    context.equals("date") || context.equals("category")
                    || context.equals("tags")) {
                
                forwardUrl.append(PAGE_SERVLET);
                forwardUrl.append("/");
                forwardUrl.append(handle);
                if(locale != null) {
                    forwardUrl.append("/");
                    forwardUrl.append(locale);
                }
                forwardUrl.append("/");
                forwardUrl.append(context);
                if(data != null) {
                    forwardUrl.append("/");
                    forwardUrl.append(data);
                }
                
                // requests handled by FeedServlet
            } else if(context.equals("feed")) {
                
                forwardUrl.append(FEED_SERVLET);
                forwardUrl.append("/");
                forwardUrl.append(handle);
                if(locale != null) {
                    forwardUrl.append("/");
                    forwardUrl.append(locale);
                }
                if(data != null) {
                    forwardUrl.append("/");
                    forwardUrl.append(data);
                }
                
                // requests handled by ResourceServlet
            } else if(context.equals("resource")) {
                
                forwardUrl.append(RESOURCE_SERVLET);
                forwardUrl.append("/");
                forwardUrl.append(handle);
                if(data != null) {
                    forwardUrl.append("/");
                    forwardUrl.append(data);
                }
                
                // requests handled by SearchServlet
            } else if(context.equals("search")) {
                
                forwardUrl.append(SEARCH_SERVLET);
                forwardUrl.append("/");
                forwardUrl.append(handle);
                
                // requests handled by RSDServlet
            } else if(context.equals("rsd")) {
                
                forwardUrl.append(RSD_SERVLET);
                forwardUrl.append("/");
                forwardUrl.append(handle);
                
                // unsupported url
            } else {
                return null;
            }
        }
        
        log.debug("FORWARD_URL "+forwardUrl.toString());
    //#WeblogRequestMapper.java:367: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: String calculateForwardUrl(HttpServletRequest, String, String, String, String)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
        
        return forwardUrl.toString();
    //#WeblogRequestMapper.java:369: end of method: String org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper.calculateForwardUrl(HttpServletRequest, String, String, String, String)
    }
    
    
    /**
     * convenience method which determines if the given string is a valid
     * weblog handle.
     *
     * TODO 3.0: some kind of caching
     */
    private boolean isWeblog(String potentialHandle) {
        
        log.debug("checking weblog handle "+potentialHandle);
    //#WeblogRequestMapper.java:381: method: bool org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper.isWeblog(String)
    //#WeblogRequestMapper.java:381: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool isWeblog(String)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
    //#input(bool isWeblog(String)): "checking weblog handle "._tainted
    //#input(bool isWeblog(String)): log
    //#input(bool isWeblog(String)): potentialHandle
    //#input(bool isWeblog(String)): potentialHandle._tainted
    //#output(bool isWeblog(String)): return_value
    //#pre[1] (bool isWeblog(String)): log != null
    //#presumption(bool isWeblog(String)): org.apache.roller.weblogger.business.Weblogger:getUserManager(...)@386 != null
    //#presumption(bool isWeblog(String)): org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger(...)@386 != null
    //#post(bool isWeblog(String)): init'ed(return_value)
    //#test_vector(bool isWeblog(String)): org.apache.roller.weblogger.business.UserManager:getWebsiteByHandle(...)@387: Addr_Set{null}, Inverse{null}
        
        boolean isWeblog = false;
        
        try {
            UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
    //#WeblogRequestMapper.java:386: Warning: method not available
    //#    -- call on Weblogger org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool isWeblog(String)
    //#    unanalyzed callee: Weblogger org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger()
    //#WeblogRequestMapper.java:386: Warning: method not available
    //#    -- call on UserManager org.apache.roller.weblogger.business.Weblogger:getUserManager()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool isWeblog(String)
    //#    unanalyzed callee: UserManager org.apache.roller.weblogger.business.Weblogger:getUserManager()
            Weblog weblog = mgr.getWebsiteByHandle(potentialHandle);
    //#WeblogRequestMapper.java:387: Warning: method not available
    //#    -- call on Weblog org.apache.roller.weblogger.business.UserManager:getWebsiteByHandle(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool isWeblog(String)
    //#    unanalyzed callee: Weblog org.apache.roller.weblogger.business.UserManager:getWebsiteByHandle(String)
            
            if(weblog != null) {
                isWeblog = true;
            }
        } catch(Exception ex) {
            // doesn't really matter to us why it's not a valid website
        }
        
        return isWeblog;
    //#WeblogRequestMapper.java:396: end of method: bool org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper.isWeblog(String)
    }
    
    
    /**
     * Convenience method which determines if the given string is a valid
     * locale string.
     */
    private boolean isLocale(String potentialLocale) {
        
        boolean isLocale = false;
    //#WeblogRequestMapper.java:406: method: bool org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper.isLocale(String)
    //#input(bool isLocale(String)): potentialLocale
    //#input(bool isLocale(String)): potentialLocale._tainted
    //#output(bool isLocale(String)): return_value
    //#post(bool isLocale(String)): return_value == 0
    //#test_vector(bool isLocale(String)): potentialLocale: Addr_Set{null}, Inverse{null}
    //#test_vector(bool isLocale(String)): java.lang.String:length(...)@409: {2}, {0,1, 3..4_294_967_295}
    //#test_vector(bool isLocale(String)): java.lang.String:length(...)@409: {0..4, 6..4_294_967_295}, {5}
        
        // we only support 2 or 5 character locale strings, so check that first
        if(potentialLocale != null && 
                (potentialLocale.length() == 2 || potentialLocale.length() == 5)) {
            
            // now make sure that the format is proper ... e.g. "en_US"
            // we are not going to be picky about capitalization
            String[] langCountry = potentialLocale.split("_");
            if(langCountry.length == 1 && 
    //#WeblogRequestMapper.java:415: ?use of default init
    //#    init'ed(langCountry.length)
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool isLocale(String)
    //#    basic block: bb_4
    //#    assertion: init'ed(langCountry.length)
    //#    VN: undefined
    //#    Expected: {-Inf..+Inf}
    //#    Bad: {Invalid}
    //#    Attribs:  Int  Bad only invalid
    //#WeblogRequestMapper.java:415: Warning: test always goes same way
    //#    test predetermined because langCountry.length == 0
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool isLocale(String)
    //#    from bb: bb_4
    //#    live edge: bb_4-->bb_8
    //#    tested vn: undefined - 1
    //#    tested vn values: {-1}
    //#WeblogRequestMapper.java:415: Warning: dead code
    //#    dead code here because langCountry.length == 0
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool isLocale(String)
    //#    dead bb: bb_5
    //#WeblogRequestMapper.java:415: Warning: dead code continues
    //#    dead code continues
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool isLocale(String)
    //#    dead bb: bb_6
                    langCountry[0] != null && langCountry[0].length() == 2) {
                isLocale = true;
    //#WeblogRequestMapper.java:417: Warning: dead code continues
    //#    dead code continues
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool isLocale(String)
    //#    dead bb: bb_7
                
            } else if(langCountry.length == 2 && 
    //#WeblogRequestMapper.java:419: ?use of default init
    //#    init'ed(langCountry.length)
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool isLocale(String)
    //#    basic block: bb_8
    //#    assertion: init'ed(langCountry.length)
    //#    VN: undefined
    //#    Expected: {-Inf..+Inf}
    //#    Bad: {Invalid}
    //#    Attribs:  Int  Bad only invalid
    //#WeblogRequestMapper.java:419: Warning: test always goes same way
    //#    test predetermined because langCountry.length == 0
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool isLocale(String)
    //#    from bb: bb_8
    //#    live edge: bb_8-->bb_14
    //#    tested vn: undefined - 2
    //#    tested vn values: {-2}
    //#WeblogRequestMapper.java:419: Warning: dead code
    //#    dead code here because langCountry.length == 0
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool isLocale(String)
    //#    dead bb: bb_9
    //#WeblogRequestMapper.java:419: Warning: dead code continues
    //#    dead code continues
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool isLocale(String)
    //#    dead bb: bb_10
    //#WeblogRequestMapper.java:419: Warning: dead code continues
    //#    dead code continues
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool isLocale(String)
    //#    dead bb: bb_11
    //#WeblogRequestMapper.java:419: Warning: dead code continues
    //#    dead code continues
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool isLocale(String)
    //#    dead bb: bb_12
                    langCountry[0] != null && langCountry[0].length() == 2 && 
                    langCountry[1] != null && langCountry[1].length() == 2) {
                
                isLocale = true;
    //#WeblogRequestMapper.java:423: Warning: dead code continues
    //#    dead code continues
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
    //#    method: bool isLocale(String)
    //#    dead bb: bb_13
            }
        }
        
        return isLocale;
    //#WeblogRequestMapper.java:427: end of method: bool org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper.isLocale(String)
    }
    
}
    //#WeblogRequestMapper.java:: end of class: org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
