//# 0 errors, 230 messages
//#
/*
    //#PlanetCache.java:1:1: class: org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache
 * 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.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.weblogger.WebloggerException;
import org.apache.roller.weblogger.config.WebloggerConfig;
import org.apache.roller.weblogger.business.WebloggerFactory;
import org.apache.roller.planet.business.Planet;
import org.apache.roller.planet.business.PlanetFactory;
import org.apache.roller.planet.business.PlanetManager;
import org.apache.roller.weblogger.ui.rendering.util.PlanetRequest;
import org.apache.roller.weblogger.util.cache.Cache;
import org.apache.roller.weblogger.util.cache.CacheManager;
import org.apache.roller.weblogger.util.cache.ExpiringCacheEntry;


/**
 * Cache for planet content.
 */
public class PlanetCache {
    
    private static Log log = LogFactory.getLog(PlanetCache.class);
    //#PlanetCache.java:44: method: org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache.org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init
    //#PlanetCache.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.PlanetCache
    //#    method: org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/rendering/util/cache/PlanetCache]
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): __Dispatch_Table.clear()V
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): __Dispatch_Table.generateKey(Lorg/apache/roller/weblogger/ui/rendering/util/PlanetRequest;)Ljava/lang/String;
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): __Dispatch_Table.get(Ljava/lang/String;)Ljava/lang/Object;
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): __Dispatch_Table.getLastModified()Ljava/util/Date;
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): __Dispatch_Table.put(Ljava/lang/String;Ljava/lang/Object;)V
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): __Dispatch_Table.remove(Ljava/lang/String;)V
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): log
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): new PlanetCache(PlanetCache__static_init#1) num objects
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): singletonInstance.__Tag
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): singletonInstance.cacheEnabled
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): singletonInstance.contentCache
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): singletonInstance.lastUpdateTime
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): singletonInstance.timeout
    //#output(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): singletonInstance
    //#new obj(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): new PlanetCache(PlanetCache__static_init#1)
    //#presumption(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): org.apache.commons.logging.LogFactory:getLog(...)@44 != null
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/rendering/util/cache/PlanetCache] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): __Dispatch_Table.clear()V == &clear
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): __Dispatch_Table.generateKey(Lorg/apache/roller/weblogger/ui/rendering/util/PlanetRequest;)Ljava/lang/String; == &generateKey
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): __Dispatch_Table.get(Ljava/lang/String;)Ljava/lang/Object; == &get
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): __Dispatch_Table.getLastModified()Ljava/util/Date; == &getLastModified
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): __Dispatch_Table.put(Ljava/lang/String;Ljava/lang/Object;)V == &put
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): __Dispatch_Table.remove(Ljava/lang/String;)V == &remove
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): (soft) log != null
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): singletonInstance == &new PlanetCache(PlanetCache__static_init#1)
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): new PlanetCache(PlanetCache__static_init#1) num objects == 1
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): singletonInstance.__Tag == org/apache/roller/weblogger/ui/rendering/util/cache/PlanetCache
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): init'ed(singletonInstance.cacheEnabled)
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): init'ed(singletonInstance.contentCache)
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): singletonInstance.lastUpdateTime == null
    //#post(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): singletonInstance.timeout in -9_223_372_036_854_775_000..18_446_744_073_709_551_000
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): Effects-of-calling:org.apache.roller.weblogger.config.WebloggerConfig:getBooleanProperty
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): Effects-of-calling:java.util.HashMap
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): Effects-of-calling:java.util.Map:put
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): Effects-of-calling:org.apache.roller.weblogger.config.WebloggerConfig:keys
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): Effects-of-calling:java.util.Enumeration:hasMoreElements
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): Effects-of-calling:java.util.Enumeration:nextElement
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): Effects-of-calling:java.lang.String:startsWith
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): Effects-of-calling:java.lang.String:length
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): Effects-of-calling:java.lang.String:substring
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): Effects-of-calling:org.apache.roller.weblogger.config.WebloggerConfig:getProperty
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): Effects-of-calling:org.apache.commons.logging.Log:info
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): Effects-of-calling:org.apache.roller.weblogger.util.cache.CacheManager:constructCache
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): Effects-of-calling:org.apache.commons.logging.Log:warn
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): Effects-of-calling:java.lang.Long:parseLong
    //#unanalyzed(org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    
    // 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.planet";
    
    // keep cached content
    private boolean cacheEnabled = true;
    private Cache contentCache = null;
    
    // keep a cached version of last expired time
    private ExpiringCacheEntry lastUpdateTime = null;
    private long timeout = 15 * 60 * 1000;
    
    // reference to our singleton instance
    private static PlanetCache singletonInstance = new PlanetCache();
    //#PlanetCache.java:59: end of method: org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache.org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache__static_init
    
    
    private PlanetCache() {
    //#PlanetCache.java:62: method: void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache.org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()
    //#input(void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()): "Planet cache = "._tainted
    //#input(void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()): log
    //#input(void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()): this
    //#output(void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()): this.cacheEnabled
    //#output(void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()): this.contentCache
    //#output(void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()): this.lastUpdateTime
    //#output(void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()): this.timeout
    //#pre[1] (void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()): log != null
    //#presumption(void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()): java.lang.Long:parseLong(...)@91 in -9_223_372_036_854_775..18_446_744_073_709_551
    //#presumption(void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()): java.lang.String:length(...)@75 <= 4_294_967_294
    //#presumption(void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()): java.util.Enumeration:nextElement(...)@71 != null
    //#presumption(void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()): org.apache.roller.weblogger.config.WebloggerConfig:keys(...)@68 != null
    //#post(void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()): init'ed(this.cacheEnabled)
    //#post(void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()): init'ed(this.contentCache)
    //#post(void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()): this.lastUpdateTime == null
    //#post(void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()): this.timeout in -9_223_372_036_854_775_000..18_446_744_073_709_551_000
    //#test_vector(void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()): java.lang.String:startsWith(...)@74: {0}, {1}
    //#test_vector(void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()): java.util.Enumeration:hasMoreElements(...)@70: {0}, {1}
    //#test_vector(void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()): org.apache.roller.weblogger.config.WebloggerConfig:getBooleanProperty(...)@64: {0}, {1}
        
        cacheEnabled = WebloggerConfig.getBooleanProperty(CACHE_ID+".enabled");
    //#PlanetCache.java:64: 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.PlanetCache
    //#    method: void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()
    //#    unanalyzed callee: bool org.apache.roller.weblogger.config.WebloggerConfig:getBooleanProperty(String)
        
        Map cacheProps = new HashMap();
        cacheProps.put("id", CACHE_ID);
        Enumeration allProps = WebloggerConfig.keys();
    //#PlanetCache.java:68: 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.PlanetCache
    //#    method: void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()
    //#    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), 
    //#PlanetCache.java:75: 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.PlanetCache
    //#    method: void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()
    //#    unanalyzed callee: String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String)
                        WebloggerConfig.getProperty(prop));
            }
        }
        
        log.info("Planet cache = "+cacheProps);
    //#PlanetCache.java:80: 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.PlanetCache
    //#    method: void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:info(Object)
        
        if(cacheEnabled) {
            contentCache = CacheManager.constructCache(null, cacheProps);
    //#PlanetCache.java:83: 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.PlanetCache
    //#    method: void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()
    //#    unanalyzed callee: Cache org.apache.roller.weblogger.util.cache.CacheManager:constructCache(CacheHandler, Map)
        } else {
            log.warn("Caching has been DISABLED");
    //#PlanetCache.java:85: 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.PlanetCache
    //#    method: void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:warn(Object)
        }
        
        // lookup our timeout value
        String timeoutString = WebloggerConfig.getProperty("cache.planet.timeout");
    //#PlanetCache.java:89: 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.PlanetCache
    //#    method: void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()
    //#    unanalyzed callee: String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String)
        try {
            long timeoutSecs = Long.parseLong(timeoutString);
            this.timeout = timeoutSecs * 1000;
        } catch(Exception e) {
            // ignored ... illegal value
        }
    }
    //#PlanetCache.java:96: end of method: void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache.org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache()
    
    
    public static PlanetCache getInstance() {
        return singletonInstance;
    //#PlanetCache.java:100: method: PlanetCache org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache.getInstance()
    //#input(PlanetCache getInstance()): singletonInstance
    //#output(PlanetCache getInstance()): return_value
    //#pre[1] (PlanetCache getInstance()): init'ed(singletonInstance)
    //#post(PlanetCache getInstance()): return_value == singletonInstance
    //#post(PlanetCache getInstance()): init'ed(return_value)
    //#PlanetCache.java:100: end of method: PlanetCache org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache.getInstance()
    }
    
    
    public Object get(String key) {
        
        if(!cacheEnabled)
    //#PlanetCache.java:106: method: Object org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache.get(String)
    //#input(Object get(String)): "HIT "._tainted
    //#input(Object get(String)): "MISS "._tainted
    //#input(Object get(String)): key
    //#input(Object get(String)): key._tainted
    //#input(Object get(String)): log
    //#input(Object get(String)): this
    //#input(Object get(String)): this.cacheEnabled
    //#input(Object get(String)): this.contentCache
    //#output(Object get(String)): return_value
    //#pre[5] (Object get(String)): init'ed(this.cacheEnabled)
    //#pre[3] (Object get(String)): (soft) log != null
    //#pre[6] (Object get(String)): (soft) this.contentCache != null
    //#post(Object get(String)): init'ed(return_value)
    //#test_vector(Object get(String)): this.cacheEnabled: {1}, {0}
    //#test_vector(Object get(String)): org.apache.roller.weblogger.util.cache.Cache:get(...)@109: Inverse{null}, Addr_Set{null}
            return null;
        
        Object entry = contentCache.get(key);
    //#PlanetCache.java:109: 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.PlanetCache
    //#    method: Object get(String)
    //#    unanalyzed callee: Object org.apache.roller.weblogger.util.cache.Cache:get(String)
        
        if(entry == null) {
            log.debug("MISS "+key);
    //#PlanetCache.java:112: 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.PlanetCache
    //#    method: Object get(String)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
        } else {
            log.debug("HIT "+key);
    //#PlanetCache.java:114: 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.PlanetCache
    //#    method: Object get(String)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
        }
        
        return entry;
    //#PlanetCache.java:117: end of method: Object org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache.get(String)
    }
    
    
    public void put(String key, Object value) {
        
        if(!cacheEnabled)
    //#PlanetCache.java:123: method: void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache.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, value);
    //#PlanetCache.java:126: 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.PlanetCache
    //#    method: void put(String, Object)
    //#    unanalyzed callee: void org.apache.roller.weblogger.util.cache.Cache:put(String, Object)
        log.debug("PUT "+key);
    //#PlanetCache.java:127: 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.PlanetCache
    //#    method: void put(String, Object)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
    }
    //#PlanetCache.java:128: end of method: void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache.put(String, Object)
    
    
    public void remove(String key) {
        
        if(!cacheEnabled)
    //#PlanetCache.java:133: method: void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache.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);
    //#PlanetCache.java:136: 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.PlanetCache
    //#    method: void remove(String)
    //#    unanalyzed callee: void org.apache.roller.weblogger.util.cache.Cache:remove(String)
        log.debug("REMOVE "+key);
    //#PlanetCache.java:137: 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.PlanetCache
    //#    method: void remove(String)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
    }
    //#PlanetCache.java:138: end of method: void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache.remove(String)
    
    
    public void clear() {
        
        if(!cacheEnabled)
    //#PlanetCache.java:143: method: void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache.clear()
    //#input(void clear()): log
    //#input(void clear()): this
    //#input(void clear()): this.cacheEnabled
    //#input(void clear()): this.contentCache
    //#output(void clear()): this.lastUpdateTime
    //#pre[4] (void clear()): init'ed(this.cacheEnabled)
    //#pre[1] (void clear()): (soft) log != null
    //#pre[5] (void clear()): (soft) this.contentCache != null
    //#post(void clear()): this.lastUpdateTime == One-of{old this.lastUpdateTime, null}
    //#test_vector(void clear()): this.cacheEnabled: {1}, {0}
            return;
        
        contentCache.clear();
    //#PlanetCache.java:146: 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.PlanetCache
    //#    method: void clear()
    //#    unanalyzed callee: void org.apache.roller.weblogger.util.cache.Cache:clear()
        this.lastUpdateTime = null;
        log.debug("CLEAR");
    //#PlanetCache.java:148: 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.PlanetCache
    //#    method: void clear()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
    }
    //#PlanetCache.java:149: end of method: void org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache.clear()
    
    
    public Date getLastModified() {
        
        Date lastModified = null;
    //#PlanetCache.java:154: method: Date org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache.getLastModified()
    //#input(Date getLastModified()): log
    //#input(Date getLastModified()): this
    //#input(Date getLastModified()): this.lastUpdateTime
    //#input(Date getLastModified()): this.timeout
    //#output(Date getLastModified()): new Date(getLastModified#1) num objects
    //#output(Date getLastModified()): new ExpiringCacheEntry(getLastModified#2) num objects
    //#output(Date getLastModified()): return_value
    //#output(Date getLastModified()): this.lastUpdateTime
    //#new obj(Date getLastModified()): new Date(getLastModified#1)
    //#new obj(Date getLastModified()): new ExpiringCacheEntry(getLastModified#2)
    //#pre[2] (Date getLastModified()): init'ed(this.lastUpdateTime)
    //#pre[1] (Date getLastModified()): (soft) log != null
    //#pre[4] (Date getLastModified()): (soft) init'ed(this.timeout)
    //#post(Date getLastModified()): return_value != null
    //#post(Date getLastModified()): this.lastUpdateTime == One-of{old this.lastUpdateTime, &new ExpiringCacheEntry(getLastModified#2)}
    //#post(Date getLastModified()): this.lastUpdateTime != null
    //#post(Date getLastModified()): new Date(getLastModified#1) num objects <= 1
    //#post(Date getLastModified()): new ExpiringCacheEntry(getLastModified#2) num objects <= 1
    //#test_vector(Date getLastModified()): this.lastUpdateTime: Addr_Set{null}, Inverse{null}
        
        // first try our cached version
        if(this.lastUpdateTime != null) {
            lastModified = (Date) this.lastUpdateTime.getValue();
    //#PlanetCache.java:158: Warning: method not available
    //#    -- call on Object org.apache.roller.weblogger.util.cache.ExpiringCacheEntry:getValue()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache
    //#    method: Date getLastModified()
    //#    unanalyzed callee: Object org.apache.roller.weblogger.util.cache.ExpiringCacheEntry:getValue()
        }
        
        // still null, we need to get a fresh value
        if(lastModified == null) {
            
            // TODO: ROLLER40 last updated for planet
            lastModified = null; // PlanetFactory.getPlanet().getPlanetManager().getLastUpdated();
            
            if (lastModified == null) {
    //#PlanetCache.java:167: Warning: test always goes same way
    //#    test predetermined because lastModified == null
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache
    //#    method: Date getLastModified()
    //#    from bb: bb_4
    //#    live edge: bb_4-->bb_5
    //#    tested vn: 1
    //#    tested vn values: {1}
                lastModified = new Date();
                log.warn("Can't get lastUpdate time, using current time instead");
    //#PlanetCache.java:169: 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.PlanetCache
    //#    method: Date getLastModified()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:warn(Object)
            }
            
            this.lastUpdateTime = new ExpiringCacheEntry(lastModified, this.timeout);
    //#PlanetCache.java:172: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.util.cache.ExpiringCacheEntry(Object, long)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache
    //#    method: Date getLastModified()
    //#    unanalyzed callee: void org.apache.roller.weblogger.util.cache.ExpiringCacheEntry(Object, long)
        }
        
        return lastModified;
    //#PlanetCache.java:175: end of method: Date org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache.getLastModified()
    }
    
    
    /**
     * Generate a cache key from a parsed planet request.
     * This generates a key of the form ...
     *
     * <context>/<type>/<language>[/user]
     *   or
     * <context>/<type>[/flavor]/<language>[/excerpts]
     *
     *
     * examples ...
     *
     * planet/page/en
     * planet/feed/rss/en/excerpts
     *
     */
    public String generateKey(PlanetRequest planetRequest) {
        
        StringBuffer key = new StringBuffer();
    //#PlanetCache.java:196: method: String org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache.generateKey(PlanetRequest)
    //#input(String generateKey(PlanetRequest)): "."._tainted
    //#input(String generateKey(PlanetRequest)): ".excerpts"._tainted
    //#input(String generateKey(PlanetRequest)): ".group="._tainted
    //#input(String generateKey(PlanetRequest)): ".user="._tainted
    //#input(String generateKey(PlanetRequest)): ":"._tainted
    //#input(String generateKey(PlanetRequest)): "cache.planet"._tainted
    //#input(String generateKey(PlanetRequest)): org/apache/roller/weblogger/ui/rendering/util/PlanetRequest.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/util/PlanetRequest]
    //#input(String generateKey(PlanetRequest)): org/apache/roller/weblogger/ui/rendering/util/PlanetRequest.__Descendant_Table[others]
    //#input(String generateKey(PlanetRequest)): org/apache/roller/weblogger/ui/rendering/util/PlanetRequest.__Dispatch_Table.getAuthenticUser()Ljava/lang/String;
    //#input(String generateKey(PlanetRequest)): org/apache/roller/weblogger/ui/rendering/util/PlanetRequest.__Dispatch_Table.getContext()Ljava/lang/String;
    //#input(String generateKey(PlanetRequest)): org/apache/roller/weblogger/ui/rendering/util/PlanetRequest.__Dispatch_Table.getFlavor()Ljava/lang/String;
    //#input(String generateKey(PlanetRequest)): org/apache/roller/weblogger/ui/rendering/util/PlanetRequest.__Dispatch_Table.getGroup()Ljava/lang/String;
    //#input(String generateKey(PlanetRequest)): org/apache/roller/weblogger/ui/rendering/util/PlanetRequest.__Dispatch_Table.getLanguage()Ljava/lang/String;
    //#input(String generateKey(PlanetRequest)): org/apache/roller/weblogger/ui/rendering/util/PlanetRequest.__Dispatch_Table.getType()Ljava/lang/String;
    //#input(String generateKey(PlanetRequest)): org/apache/roller/weblogger/ui/rendering/util/PlanetRequest.__Dispatch_Table.isExcerpts()Z
    //#input(String generateKey(PlanetRequest)): planetRequest
    //#input(String generateKey(PlanetRequest)): planetRequest.__Tag
    //#input(String generateKey(PlanetRequest)): planetRequest.authenticUser
    //#input(String generateKey(PlanetRequest)): planetRequest.authenticUser._tainted
    //#input(String generateKey(PlanetRequest)): planetRequest.context
    //#input(String generateKey(PlanetRequest)): planetRequest.context._tainted
    //#input(String generateKey(PlanetRequest)): planetRequest.excerpts
    //#input(String generateKey(PlanetRequest)): planetRequest.flavor
    //#input(String generateKey(PlanetRequest)): planetRequest.flavor._tainted
    //#input(String generateKey(PlanetRequest)): planetRequest.group
    //#input(String generateKey(PlanetRequest)): planetRequest.group._tainted
    //#input(String generateKey(PlanetRequest)): planetRequest.language
    //#input(String generateKey(PlanetRequest)): planetRequest.language._tainted
    //#input(String generateKey(PlanetRequest)): planetRequest.type
    //#input(String generateKey(PlanetRequest)): planetRequest.type._tainted
    //#output(String generateKey(PlanetRequest)): java.lang.StringBuffer:toString(...)._tainted
    //#output(String generateKey(PlanetRequest)): return_value
    //#new obj(String generateKey(PlanetRequest)): java.lang.StringBuffer:toString(...)
    //#pre[6] (String generateKey(PlanetRequest)): planetRequest != null
    //#pre[7] (String generateKey(PlanetRequest)): planetRequest.__Tag == org/apache/roller/weblogger/ui/rendering/util/PlanetRequest
    //#pre[10] (String generateKey(PlanetRequest)): init'ed(planetRequest.context)
    //#pre[14] (String generateKey(PlanetRequest)): init'ed(planetRequest.flavor)
    //#pre[18] (String generateKey(PlanetRequest)): init'ed(planetRequest.group)
    //#pre[20] (String generateKey(PlanetRequest)): init'ed(planetRequest.language)
    //#pre[22] (String generateKey(PlanetRequest)): init'ed(planetRequest.type)
    //#pre[8] (String generateKey(PlanetRequest)): (soft) init'ed(planetRequest.authenticUser)
    //#pre[13] (String generateKey(PlanetRequest)): (soft) init'ed(planetRequest.excerpts)
    //#post(String generateKey(PlanetRequest)): init'ed(java.lang.StringBuffer:toString(...)._tainted)
    //#post(String generateKey(PlanetRequest)): return_value == &java.lang.StringBuffer:toString(...)
    //#test_vector(String generateKey(PlanetRequest)): planetRequest.authenticUser: Addr_Set{null}, Inverse{null}
    //#test_vector(String generateKey(PlanetRequest)): planetRequest.excerpts: {0}, {1}
    //#test_vector(String generateKey(PlanetRequest)): planetRequest.flavor: Addr_Set{null}, Inverse{null}
    //#test_vector(String generateKey(PlanetRequest)): planetRequest.group: Addr_Set{null}, Inverse{null}
        
        key.append(this.CACHE_ID).append(":");
        key.append(planetRequest.getContext());
        key.append("/");
        key.append(planetRequest.getType());
        
        if(planetRequest.getFlavor() != null) {
            key.append("/").append(planetRequest.getFlavor());
        }
        
        // add language
        key.append("/").append(planetRequest.getLanguage());
        
        if(planetRequest.getFlavor() != null) {
            // add excerpts
            if(planetRequest.isExcerpts()) {
                key.append("/excerpts");
            }
        } else {
            // add login state
            if(planetRequest.getAuthenticUser() != null) {
                key.append("/user=").append(planetRequest.getAuthenticUser());
            }
        }
        
        // add group
        if (planetRequest.getGroup() != null) {
            key.append("/group=").append(planetRequest.getGroup());
        }

        return key.toString();
    //#PlanetCache.java:227: end of method: String org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache.generateKey(PlanetRequest)
    }
    
}
    //#PlanetCache.java:: end of class: org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache
