//# 1 errors, 257 messages
//#
/*
    //#WeblogPageCache.java:1:1: class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
 * 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.util.cache;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.weblogger.config.WebloggerConfig;
import org.apache.roller.weblogger.ui.rendering.util.WeblogPageRequest;
import org.apache.roller.weblogger.util.Utilities;
import org.apache.roller.weblogger.util.cache.Cache;
import org.apache.roller.weblogger.util.cache.CacheManager;
import org.apache.roller.weblogger.util.cache.LazyExpiringCacheEntry;


/**
 * Cache for weblog page content.
 */
public class WeblogPageCache {
    
    private static Log log = LogFactory.getLog(WeblogPageCache.class);
    //#WeblogPageCache.java:44: method: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache.org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init
    //#WeblogPageCache.java:44: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/rendering/util/cache/WeblogPageCache]
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): __Dispatch_Table.clear()V
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): __Dispatch_Table.generateKey(Lorg/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest;)Ljava/lang/String;
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): __Dispatch_Table.get(Ljava/lang/String;J)Ljava/lang/Object;
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): __Dispatch_Table.paramsToString(Ljava/util/Map;)Ljava/lang/String;
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): __Dispatch_Table.put(Ljava/lang/String;Ljava/lang/Object;)V
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): __Dispatch_Table.remove(Ljava/lang/String;)V
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): log
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): new WeblogPageCache(WeblogPageCache__static_init#1) num objects
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): singletonInstance.__Tag
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): singletonInstance.cacheEnabled
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): singletonInstance.contentCache
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): singletonInstance
    //#new obj(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): new WeblogPageCache(WeblogPageCache__static_init#1)
    //#presumption(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): org.apache.commons.logging.LogFactory:getLog(...)@44 != null
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/rendering/util/cache/WeblogPageCache] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): __Dispatch_Table.clear()V == &clear
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): __Dispatch_Table.generateKey(Lorg/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest;)Ljava/lang/String; == &generateKey
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): __Dispatch_Table.get(Ljava/lang/String;J)Ljava/lang/Object; == &get
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): __Dispatch_Table.paramsToString(Ljava/util/Map;)Ljava/lang/String; == &paramsToString
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): __Dispatch_Table.put(Ljava/lang/String;Ljava/lang/Object;)V == &put
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): __Dispatch_Table.remove(Ljava/lang/String;)V == &remove
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): (soft) log != null
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): singletonInstance == &new WeblogPageCache(WeblogPageCache__static_init#1)
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): new WeblogPageCache(WeblogPageCache__static_init#1) num objects == 1
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): singletonInstance.__Tag == org/apache/roller/weblogger/ui/rendering/util/cache/WeblogPageCache
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): init'ed(singletonInstance.cacheEnabled)
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): init'ed(singletonInstance.contentCache)
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): Effects-of-calling:org.apache.roller.weblogger.config.WebloggerConfig:getBooleanProperty
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): Effects-of-calling:java.util.HashMap
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): Effects-of-calling:java.util.Map:put
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): Effects-of-calling:org.apache.roller.weblogger.config.WebloggerConfig:keys
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): Effects-of-calling:java.util.Enumeration:hasMoreElements
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): Effects-of-calling:java.util.Enumeration:nextElement
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): Effects-of-calling:java.lang.String:startsWith
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): Effects-of-calling:java.lang.String:length
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): Effects-of-calling:java.lang.String:substring
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): Effects-of-calling:org.apache.roller.weblogger.config.WebloggerConfig:getProperty
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): Effects-of-calling:org.apache.commons.logging.Log:info
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): Effects-of-calling:org.apache.roller.weblogger.util.cache.CacheManager:constructCache
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init): Effects-of-calling:org.apache.commons.logging.Log:warn
    
    // a unique identifier for this cache, this is used as the prefix for
    // roller config properties that apply to this cache
    public static final String CACHE_ID = "cache.weblogpage";
    
    // keep cached content
    private boolean cacheEnabled = true;
    private Cache contentCache = null;
    
    // reference to our singleton instance
    private static WeblogPageCache singletonInstance = new WeblogPageCache();
    //#WeblogPageCache.java:55: end of method: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache.org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache__static_init
    
    
    private WeblogPageCache() {
    //#WeblogPageCache.java:58: method: void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache.org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache()
    //#input(void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache()): log
    //#input(void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache()): this
    //#output(void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache()): this.cacheEnabled
    //#output(void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache()): this.contentCache
    //#pre[1] (void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache()): log != null
    //#presumption(void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache()): java.lang.String:length(...)@71 <= 4_294_967_294
    //#presumption(void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache()): java.util.Enumeration:nextElement(...)@67 != null
    //#presumption(void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache()): org.apache.roller.weblogger.config.WebloggerConfig:keys(...)@64 != null
    //#post(void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache()): init'ed(this.cacheEnabled)
    //#post(void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache()): init'ed(this.contentCache)
    //#test_vector(void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache()): java.lang.String:startsWith(...)@70: {0}, {1}
    //#test_vector(void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache()): java.util.Enumeration:hasMoreElements(...)@66: {0}, {1}
    //#test_vector(void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache()): org.apache.roller.weblogger.config.WebloggerConfig:getBooleanProperty(...)@60: {0}, {1}
        
        cacheEnabled = WebloggerConfig.getBooleanProperty(CACHE_ID+".enabled");
    //#WeblogPageCache.java:60: Warning: method not available
    //#    -- call on bool org.apache.roller.weblogger.config.WebloggerConfig:getBooleanProperty(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache()
    //#    unanalyzed callee: bool org.apache.roller.weblogger.config.WebloggerConfig:getBooleanProperty(String)
        
        Map cacheProps = new HashMap();
        cacheProps.put("id", CACHE_ID);
        Enumeration allProps = WebloggerConfig.keys();
    //#WeblogPageCache.java:64: Warning: method not available
    //#    -- call on Enumeration org.apache.roller.weblogger.config.WebloggerConfig:keys()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache()
    //#    unanalyzed callee: Enumeration org.apache.roller.weblogger.config.WebloggerConfig:keys()
        String prop = null;
        while(allProps.hasMoreElements()) {
            prop = (String) allProps.nextElement();
            
            // we are only interested in props for this cache
            if(prop.startsWith(CACHE_ID+".")) {
                cacheProps.put(prop.substring(CACHE_ID.length()+1), 
    //#WeblogPageCache.java:71: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache()
    //#    unanalyzed callee: String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String)
                        WebloggerConfig.getProperty(prop));
            }
        }
        
        log.info(cacheProps);
    //#WeblogPageCache.java:76: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:info(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:info(Object)
        
        if(cacheEnabled) {
            contentCache = CacheManager.constructCache(null, cacheProps);
    //#WeblogPageCache.java:79: Warning: method not available
    //#    -- call on Cache org.apache.roller.weblogger.util.cache.CacheManager:constructCache(CacheHandler, Map)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache()
    //#    unanalyzed callee: Cache org.apache.roller.weblogger.util.cache.CacheManager:constructCache(CacheHandler, Map)
        } else {
            log.warn("Caching has been DISABLED");
    //#WeblogPageCache.java:81: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:warn(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:warn(Object)
        }
    }
    //#WeblogPageCache.java:83: end of method: void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache.org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache()
    
    
    public static WeblogPageCache getInstance() {
        return singletonInstance;
    //#WeblogPageCache.java:87: method: WeblogPageCache org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache.getInstance()
    //#input(WeblogPageCache getInstance()): singletonInstance
    //#output(WeblogPageCache getInstance()): return_value
    //#pre[1] (WeblogPageCache getInstance()): init'ed(singletonInstance)
    //#post(WeblogPageCache getInstance()): return_value == singletonInstance
    //#post(WeblogPageCache getInstance()): init'ed(return_value)
    //#WeblogPageCache.java:87: end of method: WeblogPageCache org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache.getInstance()
    }
    
    
    public Object get(String key, long lastModified) {
        
        if(!cacheEnabled)
    //#WeblogPageCache.java:93: method: Object org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache.get(String, long)
    //#input(Object get(String, long)): "HIT "._tainted
    //#input(Object get(String, long)): "HIT-EXPIRED "._tainted
    //#input(Object get(String, long)): "MISS "._tainted
    //#input(Object get(String, long)): key
    //#input(Object get(String, long)): key._tainted
    //#input(Object get(String, long)): lastModified
    //#input(Object get(String, long)): log
    //#input(Object get(String, long)): this
    //#input(Object get(String, long)): this.cacheEnabled
    //#input(Object get(String, long)): this.contentCache
    //#output(Object get(String, long)): return_value
    //#pre[6] (Object get(String, long)): init'ed(this.cacheEnabled)
    //#pre[4] (Object get(String, long)): (soft) log != null
    //#pre[7] (Object get(String, long)): (soft) this.contentCache != null
    //#post(Object get(String, long)): init'ed(return_value)
    //#test_vector(Object get(String, long)): this.cacheEnabled: {1}, {0}
    //#test_vector(Object get(String, long)): org.apache.roller.weblogger.util.cache.Cache:get(...)@98: Addr_Set{null}, Inverse{null}
    //#test_vector(Object get(String, long)): org.apache.roller.weblogger.util.cache.LazyExpiringCacheEntry:getValue(...)@101: Addr_Set{null}, Inverse{null}
            return null;
        
        Object entry = null;
        
        LazyExpiringCacheEntry lazyEntry =
    //#WeblogPageCache.java:98: Warning: method not available
    //#    -- call on Object org.apache.roller.weblogger.util.cache.Cache:get(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: Object get(String, long)
    //#    unanalyzed callee: Object org.apache.roller.weblogger.util.cache.Cache:get(String)
                (LazyExpiringCacheEntry) this.contentCache.get(key);
        if(lazyEntry != null) {
            entry = lazyEntry.getValue(lastModified);
    //#WeblogPageCache.java:101: Warning: method not available
    //#    -- call on Object org.apache.roller.weblogger.util.cache.LazyExpiringCacheEntry:getValue(long)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: Object get(String, long)
    //#    unanalyzed callee: Object org.apache.roller.weblogger.util.cache.LazyExpiringCacheEntry:getValue(long)
            
            if(entry != null) {
                log.debug("HIT "+key);
    //#WeblogPageCache.java:104: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: Object get(String, long)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
            } else {
                log.debug("HIT-EXPIRED "+key);
    //#WeblogPageCache.java:106: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: Object get(String, long)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
            }
            
        } else {
            log.debug("MISS "+key);
    //#WeblogPageCache.java:110: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: Object get(String, long)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
        }
        
        return entry;
    //#WeblogPageCache.java:113: end of method: Object org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache.get(String, long)
    }
    
    
    public void put(String key, Object value) {
        
        if(!cacheEnabled)
    //#WeblogPageCache.java:119: method: void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache.put(String, Object)
    //#input(void put(String, Object)): "PUT "._tainted
    //#input(void put(String, Object)): key
    //#input(void put(String, Object)): key._tainted
    //#input(void put(String, Object)): log
    //#input(void put(String, Object)): this
    //#input(void put(String, Object)): this.cacheEnabled
    //#input(void put(String, Object)): this.contentCache
    //#input(void put(String, Object)): value
    //#pre[5] (void put(String, Object)): init'ed(this.cacheEnabled)
    //#pre[3] (void put(String, Object)): (soft) log != null
    //#pre[6] (void put(String, Object)): (soft) this.contentCache != null
    //#test_vector(void put(String, Object)): this.cacheEnabled: {1}, {0}
            return;
        
        contentCache.put(key, new LazyExpiringCacheEntry(value));
    //#WeblogPageCache.java:122: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.util.cache.LazyExpiringCacheEntry(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: void put(String, Object)
    //#    unanalyzed callee: void org.apache.roller.weblogger.util.cache.LazyExpiringCacheEntry(Object)
    //#WeblogPageCache.java:122: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.util.cache.Cache:put(String, Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: void put(String, Object)
    //#    unanalyzed callee: void org.apache.roller.weblogger.util.cache.Cache:put(String, Object)
        log.debug("PUT "+key);
    //#WeblogPageCache.java:123: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: void put(String, Object)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
    }
    //#WeblogPageCache.java:124: end of method: void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache.put(String, Object)
    
    
    public void remove(String key) {
        
        if(!cacheEnabled)
    //#WeblogPageCache.java:129: method: void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache.remove(String)
    //#input(void remove(String)): "REMOVE "._tainted
    //#input(void remove(String)): key
    //#input(void remove(String)): key._tainted
    //#input(void remove(String)): log
    //#input(void remove(String)): this
    //#input(void remove(String)): this.cacheEnabled
    //#input(void remove(String)): this.contentCache
    //#pre[5] (void remove(String)): init'ed(this.cacheEnabled)
    //#pre[3] (void remove(String)): (soft) log != null
    //#pre[6] (void remove(String)): (soft) this.contentCache != null
    //#test_vector(void remove(String)): this.cacheEnabled: {1}, {0}
            return;
        
        contentCache.remove(key);
    //#WeblogPageCache.java:132: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.util.cache.Cache:remove(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: void remove(String)
    //#    unanalyzed callee: void org.apache.roller.weblogger.util.cache.Cache:remove(String)
        log.debug("REMOVE "+key);
    //#WeblogPageCache.java:133: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: void remove(String)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
    }
    //#WeblogPageCache.java:134: end of method: void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache.remove(String)
    
    
    public void clear() {
        
        if(!cacheEnabled)
    //#WeblogPageCache.java:139: method: void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache.clear()
    //#input(void clear()): log
    //#input(void clear()): this
    //#input(void clear()): this.cacheEnabled
    //#input(void clear()): this.contentCache
    //#pre[3] (void clear()): init'ed(this.cacheEnabled)
    //#pre[1] (void clear()): (soft) log != null
    //#pre[4] (void clear()): (soft) this.contentCache != null
    //#test_vector(void clear()): this.cacheEnabled: {1}, {0}
            return;
        
        contentCache.clear();
    //#WeblogPageCache.java:142: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.util.cache.Cache:clear()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: void clear()
    //#    unanalyzed callee: void org.apache.roller.weblogger.util.cache.Cache:clear()
        log.debug("CLEAR");
    //#WeblogPageCache.java:143: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: void clear()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
    }
    //#WeblogPageCache.java:144: end of method: void org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache.clear()
    
    
    /**
     * Generate a cache key from a parsed weblog page request.
     * This generates a key of the form ...
     *
     * <handle>/<ctx>[/anchor][/language][/user]
     *   or
     * <handle>/<ctx>[/weblogPage][/date][/category][/language][/user]
     *
     *
     * examples ...
     *
     * foo/en
     * foo/entry_anchor
     * foo/20051110/en
     * foo/MyCategory/en/user=myname
     *
     */
    public String generateKey(WeblogPageRequest pageRequest) {
        
        StringBuffer key = new StringBuffer();
    //#WeblogPageCache.java:166: method: String org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache.generateKey(WeblogPageRequest)
    //#WeblogPageCache.java:166: Warning: suspicious precondition
    //#    the precondition for pageRequest.__Tag is not a contiguous range of values
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: String generateKey(WeblogPageRequest)
    //#    suspicious precondition index: [5]
    //#input(String generateKey(WeblogPageRequest)): ","._tainted
    //#input(String generateKey(WeblogPageRequest)): "."._tainted
    //#input(String generateKey(WeblogPageRequest)): ".entry."._tainted
    //#input(String generateKey(WeblogPageRequest)): ".page."._tainted
    //#input(String generateKey(WeblogPageRequest)): ".page="._tainted
    //#input(String generateKey(WeblogPageRequest)): ".qp="._tainted
    //#input(String generateKey(WeblogPageRequest)): ".tags."._tainted
    //#input(String generateKey(WeblogPageRequest)): ".user="._tainted
    //#input(String generateKey(WeblogPageRequest)): ":"._tainted
    //#input(String generateKey(WeblogPageRequest)): "="._tainted
    //#input(String generateKey(WeblogPageRequest)): "cache.weblogpage"._tainted
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest]
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewRequest]
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.__Descendant_Table[others]
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.__Dispatch_Table.getAuthenticUser()Ljava/lang/String;
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.__Dispatch_Table.getContext()Ljava/lang/String;
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.__Dispatch_Table.getCustomParams()Ljava/util/Map;
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.__Dispatch_Table.getLocale()Ljava/lang/String;
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.__Dispatch_Table.getPageNum()I
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.__Dispatch_Table.getTags()Ljava/util/List;
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.__Dispatch_Table.getWeblogAnchor()Ljava/lang/String;
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.__Dispatch_Table.getWeblogCategoryName()Ljava/lang/String;
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.__Dispatch_Table.getWeblogDate()Ljava/lang/String;
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.__Dispatch_Table.getWeblogHandle()Ljava/lang/String;
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.__Dispatch_Table.getWeblogPageName()Ljava/lang/String;
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewRequest.__Dispatch_Table.getAuthenticUser()Ljava/lang/String;
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewRequest.__Dispatch_Table.getContext()Ljava/lang/String;
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewRequest.__Dispatch_Table.getCustomParams()Ljava/util/Map;
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewRequest.__Dispatch_Table.getLocale()Ljava/lang/String;
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewRequest.__Dispatch_Table.getPageNum()I
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewRequest.__Dispatch_Table.getTags()Ljava/util/List;
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewRequest.__Dispatch_Table.getWeblogAnchor()Ljava/lang/String;
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewRequest.__Dispatch_Table.getWeblogCategoryName()Ljava/lang/String;
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewRequest.__Dispatch_Table.getWeblogDate()Ljava/lang/String;
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewRequest.__Dispatch_Table.getWeblogHandle()Ljava/lang/String;
    //#input(String generateKey(WeblogPageRequest)): org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewRequest.__Dispatch_Table.getWeblogPageName()Ljava/lang/String;
    //#input(String generateKey(WeblogPageRequest)): pageRequest
    //#input(String generateKey(WeblogPageRequest)): pageRequest.__Tag
    //#input(String generateKey(WeblogPageRequest)): pageRequest.authenticUser
    //#input(String generateKey(WeblogPageRequest)): pageRequest.authenticUser._tainted
    //#input(String generateKey(WeblogPageRequest)): pageRequest.context
    //#input(String generateKey(WeblogPageRequest)): pageRequest.customParams
    //#input(String generateKey(WeblogPageRequest)): pageRequest.locale
    //#input(String generateKey(WeblogPageRequest)): pageRequest.locale._tainted
    //#input(String generateKey(WeblogPageRequest)): pageRequest.pageNum
    //#input(String generateKey(WeblogPageRequest)): pageRequest.tags
    //#input(String generateKey(WeblogPageRequest)): pageRequest.weblogAnchor
    //#input(String generateKey(WeblogPageRequest)): pageRequest.weblogCategoryName
    //#input(String generateKey(WeblogPageRequest)): pageRequest.weblogDate
    //#input(String generateKey(WeblogPageRequest)): pageRequest.weblogDate._tainted
    //#input(String generateKey(WeblogPageRequest)): pageRequest.weblogHandle
    //#input(String generateKey(WeblogPageRequest)): pageRequest.weblogHandle._tainted
    //#input(String generateKey(WeblogPageRequest)): pageRequest.weblogPageName
    //#input(String generateKey(WeblogPageRequest)): pageRequest.weblogPageName._tainted
    //#input(String generateKey(WeblogPageRequest)): this
    //#output(String generateKey(WeblogPageRequest)): java.lang.StringBuffer:toString(...)._tainted
    //#output(String generateKey(WeblogPageRequest)): return_value
    //#new obj(String generateKey(WeblogPageRequest)): java.lang.StringBuffer:toString(...)
    //#pre[4] (String generateKey(WeblogPageRequest)): pageRequest != null
    //#pre[5] (String generateKey(WeblogPageRequest)): pageRequest.__Tag in {org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest, org/apache/roller/weblogger/ui/rendering/util/WeblogPreviewRequest}
    //#pre[10] (String generateKey(WeblogPageRequest)): init'ed(pageRequest.locale)
    //#pre[14] (String generateKey(WeblogPageRequest)): init'ed(pageRequest.weblogAnchor)
    //#pre[21] (String generateKey(WeblogPageRequest)): init'ed(pageRequest.weblogHandle)
    //#pre[24] (String generateKey(WeblogPageRequest)): init'ed(pageRequest.weblogPageName)
    //#pre[6] (String generateKey(WeblogPageRequest)): (soft) init'ed(pageRequest.authenticUser)
    //#pre[8] (String generateKey(WeblogPageRequest)): (soft) init'ed(pageRequest.context)
    //#pre[9] (String generateKey(WeblogPageRequest)): (soft) pageRequest.customParams != null
    //#pre[12] (String generateKey(WeblogPageRequest)): (soft) init'ed(pageRequest.pageNum)
    //#pre[13] (String generateKey(WeblogPageRequest)): (soft) init'ed(pageRequest.tags)
    //#pre[18] (String generateKey(WeblogPageRequest)): (soft) init'ed(pageRequest.weblogCategoryName)
    //#pre[19] (String generateKey(WeblogPageRequest)): (soft) init'ed(pageRequest.weblogDate)
    //#presumption(String generateKey(WeblogPageRequest)): java.util.Set:size(...)@208 >= 0
    //#post(String generateKey(WeblogPageRequest)): init'ed(java.lang.StringBuffer:toString(...)._tainted)
    //#post(String generateKey(WeblogPageRequest)): return_value == &java.lang.StringBuffer:toString(...)
    //#unanalyzed(String generateKey(WeblogPageRequest)): Effects-of-calling:java.lang.String:substring
    //#unanalyzed(String generateKey(WeblogPageRequest)): Effects-of-calling:java.lang.StringBuffer
    //#unanalyzed(String generateKey(WeblogPageRequest)): Effects-of-calling:java.util.Map:keySet
    //#unanalyzed(String generateKey(WeblogPageRequest)): Effects-of-calling:java.util.Set:iterator
    //#unanalyzed(String generateKey(WeblogPageRequest)): Effects-of-calling:java.util.Iterator:hasNext
    //#unanalyzed(String generateKey(WeblogPageRequest)): Effects-of-calling:java.util.Iterator:next
    //#unanalyzed(String generateKey(WeblogPageRequest)): Effects-of-calling:java.util.Map:get
    //#unanalyzed(String generateKey(WeblogPageRequest)): Effects-of-calling:java.lang.StringBuffer:append
    //#unanalyzed(String generateKey(WeblogPageRequest)): Effects-of-calling:java.lang.StringBuffer:toString
    //#unanalyzed(String generateKey(WeblogPageRequest)): Effects-of-calling:java.lang.String:getBytes
    //#unanalyzed(String generateKey(WeblogPageRequest)): Effects-of-calling:org.apache.roller.weblogger.util.Utilities:toBase64
    //#test_vector(String generateKey(WeblogPageRequest)): pageRequest.locale: Addr_Set{null}, Inverse{null}
    //#test_vector(String generateKey(WeblogPageRequest)): pageRequest.tags: Addr_Set{null}, Inverse{null}
    //#test_vector(String generateKey(WeblogPageRequest)): pageRequest.weblogAnchor: Addr_Set{null}, Inverse{null}
    //#test_vector(String generateKey(WeblogPageRequest)): pageRequest.weblogCategoryName: Addr_Set{null}, Inverse{null}
    //#test_vector(String generateKey(WeblogPageRequest)): pageRequest.weblogDate: Addr_Set{null}, Inverse{null}
    //#test_vector(String generateKey(WeblogPageRequest)): pageRequest.weblogPageName: Addr_Set{null}, Inverse{null}
    //#test_vector(String generateKey(WeblogPageRequest)): java.lang.String:equals(...)@204: {0}, {1}
    //#test_vector(String generateKey(WeblogPageRequest)): java.util.List:size(...)@206: {-2_147_483_648..0}, {1..4_294_967_295}
    //#test_vector(String generateKey(WeblogPageRequest)): java.util.Map:size(...)@229: {-2_147_483_648..0}, {1..4_294_967_295}
        
        key.append(this.CACHE_ID).append(":");
        key.append(pageRequest.getWeblogHandle());
        
        if(pageRequest.getWeblogAnchor() != null) {
            
            String anchor = null;
            try {
                // may contain spaces or other bad chars
                anchor = URLEncoder.encode(pageRequest.getWeblogAnchor(), "UTF-8");
            } catch(UnsupportedEncodingException ex) {
                // ignored
            }
            
            key.append("/entry/").append(anchor);
        } else {
            
            if(pageRequest.getWeblogPageName() != null) {
                key.append("/page/").append(pageRequest.getWeblogPageName());
            }
            
            if(pageRequest.getWeblogDate() != null) {
                key.append("/").append(pageRequest.getWeblogDate());
            }
            
            if(pageRequest.getWeblogCategoryName() != null) {
                String cat = null;
                try {
                    // may contain spaces or other bad chars
                    cat = URLEncoder.encode(pageRequest.getWeblogCategoryName(), "UTF-8");
                } catch(UnsupportedEncodingException ex) {
                    // ignored
                }
                
                key.append("/").append(cat);
            }
            
            if("tags".equals(pageRequest.getContext())) {
                key.append("/tags/");
                if(pageRequest.getTags() != null && pageRequest.getTags().size() > 0) {
                    Set ordered = new TreeSet(pageRequest.getTags());
                    String[] tags = (String[]) ordered.toArray(new String[ordered.size()]);
                    key.append(Utilities.stringArrayToString(tags,"+"));
    //#WeblogPageCache.java:209: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.util.Utilities:stringArrayToString(String[], String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: String generateKey(WeblogPageRequest)
    //#    unanalyzed callee: String org.apache.roller.weblogger.util.Utilities:stringArrayToString(String[], String)
                }
            }
        }
        
        if(pageRequest.getLocale() != null) {
            key.append("/").append(pageRequest.getLocale());
        }
        
        // add page number when applicable
        if(pageRequest.getWeblogAnchor() == null) {
            key.append("/page=").append(pageRequest.getPageNum());
        }
        
        // add login state
        if(pageRequest.getAuthenticUser() != null) {
            key.append("/user=").append(pageRequest.getAuthenticUser());
        }
        
        // we allow for arbitrary query params for custom pages
        if(pageRequest.getWeblogPageName() != null &&
                pageRequest.getCustomParams().size() > 0) {
            String queryString = paramsToString(pageRequest.getCustomParams());
            
            key.append("/qp=").append(queryString);
        }
        
        return key.toString();
    //#WeblogPageCache.java:236: end of method: String org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache.generateKey(WeblogPageRequest)
    }
    
    
    private String paramsToString(Map map) {
        
        if(map == null) {
    //#WeblogPageCache.java:242: method: String org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache.paramsToString(Map)
    //#input(String paramsToString(Map)): ","._tainted
    //#input(String paramsToString(Map)): "="._tainted
    //#input(String paramsToString(Map)): map
    //#output(String paramsToString(Map)): return_value
    //#presumption(String paramsToString(Map)): java.util.Map:keySet(...)@250 != null
    //#presumption(String paramsToString(Map)): value.length@253 >= 1
    //#post(String paramsToString(Map)): init'ed(return_value)
    //#test_vector(String paramsToString(Map)): map: Inverse{null}, Addr_Set{null}
    //#test_vector(String paramsToString(Map)): java.util.Iterator:hasNext(...)@251: {0}, {1}
    //#test_vector(String paramsToString(Map)): java.util.Map:get(...)@253: Addr_Set{null}, Inverse{null}
            return null;
        }
        
        StringBuffer string = new StringBuffer();
        
        String key = null;
    //#WeblogPageCache.java:248: Warning: unused assignment
    //#    unused assignment into key
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: String paramsToString(Map)
    //#    Attribs:  Uncertain
        String[] value = null;
    //#WeblogPageCache.java:249: Warning: unused assignment
    //#    unused assignment into value
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: String paramsToString(Map)
    //#    Attribs:  Uncertain
        Iterator keys = map.keySet().iterator();
        while(keys.hasNext()) {
            key = (String) keys.next();
            value = (String[]) map.get(key);
            
            if(value != null) {
                string.append(",").append(key).append("=").append(value[0]);
    //#WeblogPageCache.java:256: ?use of default init
    //#    init'ed(value[0])
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: String paramsToString(Map)
    //#    basic block: bb_6
    //#    assertion: init'ed(value[0])
    //#    VN: undefined
    //#    Expected: Univ-VN-Set
    //#    Bad: {Invalid}
    //#    Attribs:  Ptr  Bad only invalid
            }
        }
        
        return Utilities.toBase64(string.toString().substring(1).getBytes());
    //#WeblogPageCache.java:260: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.util.Utilities:toBase64(byte[])
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
    //#    method: String paramsToString(Map)
    //#    unanalyzed callee: String org.apache.roller.weblogger.util.Utilities:toBase64(byte[])
    //#WeblogPageCache.java:260: end of method: String org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache.paramsToString(Map)
    }
    
}
    //#WeblogPageCache.java:: end of class: org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache
