//# 3 errors, 150 messages
//#
/*
    //#ResourceServlet.java:1:1: class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
 * 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.servlets;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
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.WebloggerException;
import org.apache.roller.weblogger.business.FileManager;
import org.apache.roller.weblogger.business.WebloggerFactory;
import org.apache.roller.weblogger.pojos.ThemeResource;
import org.apache.roller.weblogger.pojos.WeblogTheme;
import org.apache.roller.weblogger.pojos.Weblog;
import org.apache.roller.weblogger.ui.rendering.util.ModDateHeaderUtil;
import org.apache.roller.weblogger.ui.rendering.util.WeblogResourceRequest;


/**
 * Serves files uploaded by users as well as static resources in shared themes.
 *
 * Since we keep resources in a location outside of the webapp
 * context we need a way to serve them up.  This servlet assumes that
 * resources are stored on a filesystem in the "uploads.dir" directory.
 *
 * @web.servlet name="ResourcesServlet" load-on-startup="5"
 * @web.servlet-mapping url-pattern="/roller-ui/rendering/resources/*"
 */
public class ResourceServlet extends HttpServlet {
    //#ResourceServlet.java:54: method: void org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet.org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet()
    //#input(void org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet()): this
    //#output(void org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet()): this.context
    //#post(void org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet()): this.context == null

    private static Log log = LogFactory.getLog(ResourceServlet.class);
    //#ResourceServlet.java:56: method: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet.org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet__static_init
    //#ResourceServlet.java:56: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/rendering/servlets/ResourceServlet]
    //#output(org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet__static_init): __Dispatch_Table.doGet(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V
    //#output(org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet__static_init): __Dispatch_Table.init(Ljavax/servlet/ServletConfig;)V
    //#output(org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet__static_init): log
    //#post(org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/rendering/servlets/ResourceServlet] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet__static_init): __Dispatch_Table.doGet(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V == &doGet
    //#post(org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet__static_init): __Dispatch_Table.init(Ljavax/servlet/ServletConfig;)V == &init
    //#post(org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet__static_init): init'ed(log)
    //#ResourceServlet.java:56: end of method: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet.org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet__static_init
    
    private ServletContext context = null;
    //#ResourceServlet.java:58: end of method: void org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet.org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet()


    public void init(ServletConfig config) throws ServletException {

        super.init(config);
    //#ResourceServlet.java:63: method: void org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet.init(ServletConfig)
    //#input(void init(ServletConfig)): config
    //#input(void init(ServletConfig)): log
    //#input(void init(ServletConfig)): this
    //#output(void init(ServletConfig)): this.context
    //#pre[1] (void init(ServletConfig)): config != null
    //#pre[2] (void init(ServletConfig)): log != null
    //#post(void init(ServletConfig)): init'ed(this.context)

        log.info("Initializing ResourceServlet");
    //#ResourceServlet.java:65: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:info(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void init(ServletConfig)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:info(Object)
        
        this.context = config.getServletContext();
    }
    //#ResourceServlet.java:68: end of method: void org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet.init(ServletConfig)


    /**
     * Handles requests for user uploaded resources.
     */
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        
        Weblog weblog = null;
    //#ResourceServlet.java:77: method: void org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet.doGet(HttpServletRequest, HttpServletResponse)
    //#ResourceServlet.java:77: Warning: unused assignment
    //#    unused assignment into weblog
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    Attribs:  Uncertain
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "Error looking up weblog "._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "NOT MODIFIED "._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "Resource requested ["._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "]"._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "handle = "._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "invalid resource path info, "._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "last mod date (trucated to seconds) = "._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "locale = "._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "not a weblog request, "._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "parsing path "._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "pathInfo = "._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "resourcePath = "._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "since date = "._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "unable to lookup weblog: "._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): log
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/ModDateHeaderUtil.log
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogCommentRequest.__Dispatch_Table.isLocale(Ljava/lang/String;)Z
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogFeedRequest.__Dispatch_Table.isLocale(Ljava/lang/String;)Z
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.__Dispatch_Table.isLocale(Ljava/lang/String;)Z
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewRequest.__Dispatch_Table.isLocale(Ljava/lang/String;)Z
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewResourceRequest.__Dispatch_Table.getPathInfo()Ljava/lang/String;
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewResourceRequest.__Dispatch_Table.getResourcePath()Ljava/lang/String;
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewResourceRequest.__Dispatch_Table.getWeblog()Lorg/apache/roller/weblogger/pojos/Weblog;
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewResourceRequest.__Dispatch_Table.getWeblogHandle()Ljava/lang/String;
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewResourceRequest.__Dispatch_Table.isLocale(Ljava/lang/String;)Z
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogRequest.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/util/WeblogCommentRequest]
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogRequest.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/util/WeblogFeedRequest]
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogRequest.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest]
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogRequest.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewRequest]
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogRequest.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewResourceRequest]
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogRequest.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/util/WeblogRequest]
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogRequest.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/util/WeblogResourceRequest]
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogRequest.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/util/WeblogSearchRequest]
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogRequest.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/util/WeblogTrackbackRequest]
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogRequest.__Descendant_Table[others]
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogRequest.__Dispatch_Table.isLocale(Ljava/lang/String;)Z
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogRequest.java.lang.Boolean.TRUE
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogRequest.log
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogResourceRequest.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewResourceRequest]
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogResourceRequest.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/util/WeblogResourceRequest]
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogResourceRequest.__Descendant_Table[others]
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogResourceRequest.__Dispatch_Table.getPathInfo()Ljava/lang/String;
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogResourceRequest.__Dispatch_Table.getResourcePath()Ljava/lang/String;
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogResourceRequest.__Dispatch_Table.getWeblog()Lorg/apache/roller/weblogger/pojos/Weblog;
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogResourceRequest.__Dispatch_Table.getWeblogHandle()Ljava/lang/String;
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogResourceRequest.__Dispatch_Table.isLocale(Ljava/lang/String;)Z
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogResourceRequest.log
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogSearchRequest.__Dispatch_Table.isLocale(Ljava/lang/String;)Z
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/util/WeblogTrackbackRequest.__Dispatch_Table.isLocale(Ljava/lang/String;)Z
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): request
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): response
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): this
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): this.context
    //#pre[1] (void doGet(HttpServletRequest, HttpServletResponse)): log != null
    //#pre[4] (void doGet(HttpServletRequest, HttpServletResponse)): request != null
    //#pre[2] (void doGet(HttpServletRequest, HttpServletResponse)): (soft) org/apache/roller/weblogger/ui/rendering/util/WeblogRequest.log != null
    //#pre[3] (void doGet(HttpServletRequest, HttpServletResponse)): (soft) org/apache/roller/weblogger/ui/rendering/util/WeblogResourceRequest.log != null
    //#pre[5] (void doGet(HttpServletRequest, HttpServletResponse)): (soft) response != null
    //#pre[7] (void doGet(HttpServletRequest, HttpServletResponse)): (soft) this.context != null
    //#presumption(void doGet(HttpServletRequest, HttpServletResponse)): javax.servlet.http.HttpServletResponse:getOutputStream(...)@154 != null
    //#presumption(void doGet(HttpServletRequest, HttpServletResponse)): org.apache.roller.weblogger.business.FileManager:getFile(...)@125 != null
    //#presumption(void doGet(HttpServletRequest, HttpServletResponse)): org.apache.roller.weblogger.business.Weblogger:getFileManager(...)@124 != null
    //#presumption(void doGet(HttpServletRequest, HttpServletResponse)): org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger(...)@124 != null
    //#presumption(void doGet(HttpServletRequest, HttpServletResponse)): org.apache.roller.weblogger.pojos.ThemeResource:getInputStream(...)@128 != null
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:org.apache.roller.weblogger.ui.rendering.util.WeblogRequest
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:javax.servlet.http.HttpServletRequest:getServletPath
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:getPathInfo
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:org.apache.commons.logging.Log:debug
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.String:trim
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.String:length
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.String:startsWith
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.String:substring
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.String:replaceAll
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:org.apache.roller.weblogger.util.URLUtilities:decode
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:org.apache.commons.logging.Log:isDebugEnabled
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:javax.servlet.http.HttpServletRequest:getRequestURL
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:org.apache.roller.weblogger.WebloggerException
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.String:split
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:org.apache.roller.weblogger.ui.rendering.util.ParsedRequest
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:javax.servlet.http.HttpServletRequest:getPathInfo
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.String:endsWith
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:javax.servlet.http.HttpServletRequest:getUserPrincipal
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.security.Principal:getName
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:org.apache.roller.weblogger.business.Weblogger:getUserManager
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:org.apache.roller.weblogger.business.UserManager:getWebsiteByHandle
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:org.apache.commons.logging.Log:error
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:javax.servlet.http.HttpServletRequest:getDateHeader
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:javax.servlet.http.HttpServletResponse:setStatus
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:javax.servlet.http.HttpServletResponse:setDateHeader
    //#test_vector(void doGet(HttpServletRequest, HttpServletResponse)): java.io.InputStream:read(...)@155: {-2_147_483_648..0}, {1..4_294_967_295}
    //#test_vector(void doGet(HttpServletRequest, HttpServletResponse)): org.apache.roller.weblogger.pojos.Weblog:getTheme(...)@107: Addr_Set{null}, Inverse{null}
    //#test_vector(void doGet(HttpServletRequest, HttpServletResponse)): org.apache.roller.weblogger.pojos.WeblogTheme:getResource(...)@109: Addr_Set{null}, Inverse{null}
        String context = request.getContextPath();
    //#ResourceServlet.java:78: Warning: unused assignment
    //#    unused assignment into context
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
        String servlet = request.getServletPath();
    //#ResourceServlet.java:79: Warning: unused assignment
    //#    unused assignment into servlet
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
        String reqURI = request.getRequestURI();
    //#ResourceServlet.java:80: Warning: unused assignment
    //#    unused assignment into reqURI
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
        
        WeblogResourceRequest resourceRequest = null;
    //#ResourceServlet.java:82: Warning: unused assignment
    //#    unused assignment into resourceRequest
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    Attribs:  Uncertain
        try {
            // parse the incoming request and extract the relevant data
            resourceRequest = new WeblogResourceRequest(request);

            weblog = resourceRequest.getWeblog();
    //#ResourceServlet.java:87: ?precondition failure
    //#    org/apache/roller/weblogger/ui/rendering/util/WeblogRequest.getWeblog: (soft) init'ed(this.weblogHandle)
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    basic block: bb_2
    //#    assertion: (soft) init'ed(this.weblogHandle)
    //#    callee: Weblog org/apache/roller/weblogger/ui/rendering/util/WeblogRequest.getWeblog()
    //#    callee assertion: (soft) init'ed(this.weblogHandle)
    //#    callee file: WeblogRequest.java
    //#    callee precondition index: [8]
    //#    callee srcpos: 187
    //#    VN: this.weblogHandle
    //#    Expected: Univ-VN-Set
    //#    Bad: {Invalid}
    //#    Attribs:  Ptr  Soft  Bad only invalid
            if(weblog == null) {
                throw new WebloggerException("unable to lookup weblog: "+
    //#ResourceServlet.java:89: ?conditional throw
    //#    weblog != null
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    basic block: bb_2
    //#    assertion: weblog != null
    //#    VN: getWeblog(...) == null
    //#    Expected: {0}
    //#    Bad: {1}
    //#    Attribs:  Int  Exp in +/-1000  Exp singleton  Bad singleton  Bad overlaps +/-1000  Bad > Exp
                        resourceRequest.getWeblogHandle());
            }

        } catch(Exception e) {
            // invalid resource request or weblog doesn't exist
            log.debug("error creating weblog resource request", e);
    //#ResourceServlet.java:95: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object, Throwable)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object, Throwable)
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
        
        log.debug("Resource requested ["+resourceRequest.getResourcePath()+"]");
    //#ResourceServlet.java:100: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
        
        long resourceLastMod = 0;
        InputStream resourceStream = null;
        
        // first see if resource comes from weblog's shared theme
        try {
            WeblogTheme weblogTheme = weblog.getTheme();
    //#ResourceServlet.java:107: Warning: method not available
    //#    -- call on WeblogTheme org.apache.roller.weblogger.pojos.Weblog:getTheme()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: WeblogTheme org.apache.roller.weblogger.pojos.Weblog:getTheme()
            if(weblogTheme != null) {
                ThemeResource resource = weblogTheme.getResource(resourceRequest.getResourcePath());
    //#ResourceServlet.java:109: Warning: method not available
    //#    -- call on ThemeResource org.apache.roller.weblogger.pojos.WeblogTheme:getResource(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: ThemeResource org.apache.roller.weblogger.pojos.WeblogTheme:getResource(String)
                if(resource != null) {
                    resourceLastMod = resource.getLastModified();
    //#ResourceServlet.java:111: Warning: method not available
    //#    -- call on long org.apache.roller.weblogger.pojos.ThemeResource:getLastModified()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: long org.apache.roller.weblogger.pojos.ThemeResource:getLastModified()
                    resourceStream = resource.getInputStream();
    //#ResourceServlet.java:112: Warning: method not available
    //#    -- call on InputStream org.apache.roller.weblogger.pojos.ThemeResource:getInputStream()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: InputStream org.apache.roller.weblogger.pojos.ThemeResource:getInputStream()
                }
            }
        } catch (Exception ex) {
            // hmmm, some kind of error getting theme.  that's an error.
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            return;
        }
        
        // if not from theme then see if resource is in weblog's upload dir
        if(resourceStream == null) {
            try {
                FileManager fileMgr = WebloggerFactory.getWeblogger().getFileManager();
    //#ResourceServlet.java:124: Warning: method not available
    //#    -- call on Weblogger org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: Weblogger org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger()
    //#ResourceServlet.java:124: Warning: method not available
    //#    -- call on FileManager org.apache.roller.weblogger.business.Weblogger:getFileManager()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: FileManager org.apache.roller.weblogger.business.Weblogger:getFileManager()
                ThemeResource resource = fileMgr.getFile(weblog, 
    //#ResourceServlet.java:125: Warning: method not available
    //#    -- call on ThemeResource org.apache.roller.weblogger.business.FileManager:getFile(Weblog, String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: ThemeResource org.apache.roller.weblogger.business.FileManager:getFile(Weblog, String)
                        resourceRequest.getResourcePath());
                resourceLastMod = resource.getLastModified();
    //#ResourceServlet.java:127: Warning: method not available
    //#    -- call on long org.apache.roller.weblogger.pojos.ThemeResource:getLastModified()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: long org.apache.roller.weblogger.pojos.ThemeResource:getLastModified()
                resourceStream = resource.getInputStream();
    //#ResourceServlet.java:128: Warning: method not available
    //#    -- call on InputStream org.apache.roller.weblogger.pojos.ThemeResource:getInputStream()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: InputStream org.apache.roller.weblogger.pojos.ThemeResource:getInputStream()
            } catch (Exception ex) {
                // still not found? then we don't have it, 404.
                log.debug("Unable to get resource", ex);
    //#ResourceServlet.java:131: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object, Throwable)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object, Throwable)
                response.sendError(HttpServletResponse.SC_NOT_FOUND);
                return;
            }
        }
        
        // Respond with 304 Not Modified if it is not modified.
        if (ModDateHeaderUtil.respondIfNotModified(request, response, resourceLastMod)) {
    //#ResourceServlet.java:138: ?precondition failure
    //#    org/apache/roller/weblogger/ui/rendering/util/ModDateHeaderUtil.respondIfNotModified: (soft) lastModifiedTimeMillis%1_000 - lastModifiedTimeMillis in -18_446_744_073_709_551_615..9_223_372_036_854_775_808
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    basic block: bb_16
    //#    assertion: (soft) resourceLastMod - resourceLastMod%1_000 in -9_223_372_036_854_775_808..18_446_744_073_709_551_615
    //#    callee: bool org/apache/roller/weblogger/ui/rendering/util/ModDateHeaderUtil.respondIfNotModified(HttpServletRequest, HttpServletResponse, long)
    //#    callee assertion: (soft) lastModifiedTimeMillis%1_000 - lastModifiedTimeMillis in -18_446_744_073_709_551_615..9_223_372_036_854_775_808
    //#    callee file: ModDateHeaderUtil.java
    //#    callee precondition index: [3]
    //#    callee srcpos: 53
    //#    VN: -(resourceLastMod - resourceLastMod%1_000)
    //#    Expected: {-18_446_744_073_709_551_615..9_223_372_036_854_775_808}
    //#    Bad: {-18_446_744_073_709_552_614..-18_446_744_073_709_551_616, 9_223_372_036_854_775_809..9_223_372_036_854_776_807}
    //#    Attribs:  Int  Soft  Bad < Exp  Bad > Exp
            return;
        } else {
            // set last-modified date
            ModDateHeaderUtil.setLastModifiedHeader(response, resourceLastMod);
        }
        

        // set the content type based on whatever is in our web.xml mime defs
        response.setContentType(this.context.getMimeType(resourceRequest.getResourcePath()));
        
        OutputStream out = null;
    //#ResourceServlet.java:149: Warning: unused assignment
    //#    unused assignment into out
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    Attribs:  Uncertain
        try {
            // ok, lets serve up the file
            byte[] buf = new byte[8192];
            int length = 0;
    //#ResourceServlet.java:153: Warning: unused assignment
    //#    unused assignment into length
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    Attribs:  Uncertain
            out = response.getOutputStream();
            while((length = resourceStream.read(buf)) > 0) {
                out.write(buf, 0, length);
            }
            
            // close output stream
            out.close();
            
        } catch (Exception ex) {
    //#ResourceServlet.java:162: Warning: unused assignment
    //#    unused assignment into ex
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
            if(!response.isCommitted()) {
                response.reset();
                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            }
        } finally {
            // make sure stream to resource file is closed
            resourceStream.close();
        }

    }
    //#ResourceServlet.java:172: end of method: void org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet.doGet(HttpServletRequest, HttpServletResponse)

}
    //#ResourceServlet.java:: end of class: org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet
