//# 0 errors, 118 messages
//#
/*
    //#CacheInfo.java:1:1: class: org.apache.roller.weblogger.ui.struts2.admin.CacheInfo
 * 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.struts2.admin;

import java.util.Collections;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.weblogger.ui.struts2.util.UIAction;
import org.apache.roller.weblogger.util.cache.CacheManager;


/**
 * Action for displaying rendering cache info.
 */
public class CacheInfo extends UIAction {
    
    private static Log log = LogFactory.getLog(CacheInfo.class);
    //#CacheInfo.java:34: method: org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init
    //#CacheInfo.java:34: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.admin.CacheInfo
    //#    method: org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/struts2/admin/CacheInfo]
    //#output(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): __Dispatch_Table.clear()Ljava/lang/String;
    //#output(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): __Dispatch_Table.execute()Ljava/lang/String;
    //#output(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): __Dispatch_Table.getCache()Ljava/lang/String;
    //#output(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): __Dispatch_Table.getStats()Ljava/util/Map;
    //#output(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): __Dispatch_Table.isWeblogRequired()Z
    //#output(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): __Dispatch_Table.myPrepare()V
    //#output(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): __Dispatch_Table.requiredUserRole()Ljava/lang/String;
    //#output(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): __Dispatch_Table.setCache(Ljava/lang/String;)V
    //#output(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): __Dispatch_Table.setStats(Ljava/util/Map;)V
    //#output(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): log
    //#post(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/struts2/admin/CacheInfo] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): __Dispatch_Table.clear()Ljava/lang/String; == &clear
    //#post(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): __Dispatch_Table.execute()Ljava/lang/String; == &execute
    //#post(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): __Dispatch_Table.getCache()Ljava/lang/String; == &getCache
    //#post(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): __Dispatch_Table.getStats()Ljava/util/Map; == &getStats
    //#post(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): __Dispatch_Table.isWeblogRequired()Z == &isWeblogRequired
    //#post(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): __Dispatch_Table.myPrepare()V == &myPrepare
    //#post(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): __Dispatch_Table.requiredUserRole()Ljava/lang/String; == &requiredUserRole
    //#post(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): __Dispatch_Table.setCache(Ljava/lang/String;)V == &setCache
    //#post(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): __Dispatch_Table.setStats(Ljava/util/Map;)V == &setStats
    //#post(org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init): init'ed(log)
    //#CacheInfo.java:34: end of method: org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.org.apache.roller.weblogger.ui.struts2.admin.CacheInfo__static_init
    
    // map of stats to display
    private Map stats = Collections.EMPTY_MAP;
    
    // cache which we would clear when clear() is called
    private String cache = null;
    
    
    public CacheInfo() {
    //#CacheInfo.java:43: method: void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.org.apache.roller.weblogger.ui.struts2.admin.CacheInfo()
    //#CacheInfo.java:43: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.ui.struts2.util.UIAction()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.admin.CacheInfo
    //#    method: void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo()
    //#    unanalyzed callee: void org.apache.roller.weblogger.ui.struts2.util.UIAction()
    //#input(void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo()): java.util.Collections.EMPTY_MAP
    //#input(void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo()): this
    //#output(void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo()): this.actionName
    //#output(void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo()): this.cache
    //#output(void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo()): this.desiredMenu
    //#output(void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo()): this.pageTitle
    //#output(void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo()): this.stats
    //#presumption(void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo()): init'ed(java.util.Collections.EMPTY_MAP)
    //#post(void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo()): this.actionName == &"cacheInfo"
    //#post(void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo()): this.cache == null
    //#post(void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo()): this.desiredMenu == &"admin"
    //#post(void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo()): this.pageTitle == &"cacheInfo.title"
    //#post(void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo()): this.stats == java.util.Collections.EMPTY_MAP
    //#post(void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo()): (soft) init'ed(this.stats)
        this.actionName = "cacheInfo";
        this.desiredMenu = "admin";
        this.pageTitle = "cacheInfo.title";
    }
    //#CacheInfo.java:47: end of method: void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.org.apache.roller.weblogger.ui.struts2.admin.CacheInfo()
    
    
    public String requiredUserRole() {
        return "admin";
    //#CacheInfo.java:51: method: String org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.requiredUserRole()
    //#output(String requiredUserRole()): return_value
    //#post(String requiredUserRole()): return_value == &"admin"
    //#CacheInfo.java:51: end of method: String org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.requiredUserRole()
    }
    
    public boolean isWeblogRequired() {
        return false;
    //#CacheInfo.java:55: method: bool org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.isWeblogRequired()
    //#output(bool isWeblogRequired()): return_value
    //#post(bool isWeblogRequired()): return_value == 0
    //#CacheInfo.java:55: end of method: bool org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.isWeblogRequired()
    }
    
    
    public void myPrepare() {
        Map cacheStats = CacheManager.getStats();
    //#CacheInfo.java:60: method: void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.myPrepare()
    //#CacheInfo.java:60: Warning: method not available
    //#    -- call on Map org.apache.roller.weblogger.util.cache.CacheManager:getStats()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.admin.CacheInfo
    //#    method: void myPrepare()
    //#    unanalyzed callee: Map org.apache.roller.weblogger.util.cache.CacheManager:getStats()
    //#input(void myPrepare()): __Descendant_Table[org/apache/roller/weblogger/ui/struts2/admin/CacheInfo]
    //#input(void myPrepare()): __Descendant_Table[others]
    //#input(void myPrepare()): __Dispatch_Table.setStats(Ljava/util/Map;)V
    //#input(void myPrepare()): this
    //#input(void myPrepare()): this.__Tag
    //#output(void myPrepare()): this.stats
    //#pre[2] (void myPrepare()): this.__Tag == org/apache/roller/weblogger/ui/struts2/admin/CacheInfo
    //#post(void myPrepare()): init'ed(this.stats)
        setStats(cacheStats);
    }
    //#CacheInfo.java:62: end of method: void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.myPrepare()
    
    
    public String execute() {
        return SUCCESS;
    //#CacheInfo.java:66: method: String org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.execute()
    //#output(String execute()): return_value
    //#post(String execute()): return_value == &"success"
    //#CacheInfo.java:66: end of method: String org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.execute()
    }

    
    /**
     * clear action.
     *
     * this is triggered when someone has indicated that they want to clear
     * one or all of the caches.
     */
    public String clear() {
        
        // see if a specific cache was specified
        String handlerClass = getCache();
    //#CacheInfo.java:79: method: String org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.clear()
    //#input(String clear()): __Descendant_Table[org/apache/roller/weblogger/ui/struts2/admin/CacheInfo]
    //#input(String clear()): __Descendant_Table[others]
    //#input(String clear()): __Dispatch_Table.getCache()Ljava/lang/String;
    //#input(String clear()): __Dispatch_Table.myPrepare()V
    //#input(String clear()): __Dispatch_Table.setStats(Ljava/util/Map;)V
    //#input(String clear()): this
    //#input(String clear()): this.__Tag
    //#input(String clear()): this.cache
    //#output(String clear()): return_value
    //#output(String clear()): this.stats
    //#pre[2] (String clear()): this.__Tag == org/apache/roller/weblogger/ui/struts2/admin/CacheInfo
    //#pre[3] (String clear()): init'ed(this.cache)
    //#post(String clear()): return_value == &"success"
    //#post(String clear()): init'ed(this.stats)
    //#unanalyzed(String clear()): Effects-of-calling:org.apache.roller.weblogger.util.cache.CacheManager:getStats
    //#test_vector(String clear()): this.cache: Addr_Set{null}, Inverse{null}
    //#test_vector(String clear()): java.lang.String:length(...)@80: {0}, {1..4_294_967_295}
        if(handlerClass != null && handlerClass.length() > 0) {
            CacheManager.clear(handlerClass);
    //#CacheInfo.java:81: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.util.cache.CacheManager:clear(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.admin.CacheInfo
    //#    method: String clear()
    //#    unanalyzed callee: void org.apache.roller.weblogger.util.cache.CacheManager:clear(String)
        } else {
            CacheManager.clear();
    //#CacheInfo.java:83: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.util.cache.CacheManager:clear()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.struts2.admin.CacheInfo
    //#    method: String clear()
    //#    unanalyzed callee: void org.apache.roller.weblogger.util.cache.CacheManager:clear()
        }
        
        // update stats after clear
        myPrepare();
        
        return SUCCESS;
    //#CacheInfo.java:89: end of method: String org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.clear()
    }

    
    public Map getStats() {
        return stats;
    //#CacheInfo.java:94: method: Map org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.getStats()
    //#input(Map getStats()): this
    //#input(Map getStats()): this.stats
    //#output(Map getStats()): return_value
    //#pre[2] (Map getStats()): init'ed(this.stats)
    //#post(Map getStats()): return_value == this.stats
    //#post(Map getStats()): init'ed(return_value)
    //#CacheInfo.java:94: end of method: Map org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.getStats()
    }

    public void setStats(Map stats) {
        this.stats = stats;
    //#CacheInfo.java:98: method: void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.setStats(Map)
    //#input(void setStats(Map)): stats
    //#input(void setStats(Map)): this
    //#output(void setStats(Map)): this.stats
    //#post(void setStats(Map)): this.stats == stats
    //#post(void setStats(Map)): init'ed(this.stats)
    }
    //#CacheInfo.java:99: end of method: void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.setStats(Map)

    public String getCache() {
        return cache;
    //#CacheInfo.java:102: method: String org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.getCache()
    //#input(String getCache()): this
    //#input(String getCache()): this.cache
    //#output(String getCache()): return_value
    //#pre[2] (String getCache()): init'ed(this.cache)
    //#post(String getCache()): return_value == this.cache
    //#post(String getCache()): init'ed(return_value)
    //#CacheInfo.java:102: end of method: String org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.getCache()
    }

    public void setCache(String cache) {
        this.cache = cache;
    //#CacheInfo.java:106: method: void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.setCache(String)
    //#input(void setCache(String)): cache
    //#input(void setCache(String)): this
    //#output(void setCache(String)): this.cache
    //#post(void setCache(String)): this.cache == cache
    //#post(void setCache(String)): init'ed(this.cache)
    }
    //#CacheInfo.java:107: end of method: void org.apache.roller.weblogger.ui.struts2.admin.CacheInfo.setCache(String)

}
    //#CacheInfo.java:: end of class: org.apache.roller.weblogger.ui.struts2.admin.CacheInfo
