001: /*
002: * Copyright (c) JForum Team
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms,
006: * with or without modification, are permitted provided
007: * that the following conditions are met:
008: *
009: * 1) Redistributions of source code must retain the above
010: * copyright notice, this list of conditions and the
011: * following disclaimer.
012: * 2) Redistributions in binary form must reproduce the
013: * above copyright notice, this list of conditions and
014: * the following disclaimer in the documentation and/or
015: * other materials provided with the distribution.
016: * 3) Neither the name of "Rafael Steil" nor
017: * the names of its contributors may be used to endorse
018: * or promote products derived from this software without
019: * specific prior written permission.
020: *
021: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
022: * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
023: * EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
024: * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
025: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR
026: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
027: * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
028: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
029: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES
030: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
031: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
032: * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
033: * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
034: * IN CONTRACT, STRICT LIABILITY, OR TORT
035: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
036: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
037: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
038: *
039: * Created on Feb 20, 2005 12:00:02 PM
040: * The JForum Project
041: * http://www.jforum.net
042: */
043: package net.jforum.view.admin;
044:
045: import java.util.Collection;
046:
047: import net.jforum.SessionFacade;
048: import net.jforum.dao.DataAccessDriver;
049: import net.jforum.repository.BBCodeRepository;
050: import net.jforum.repository.ForumRepository;
051: import net.jforum.repository.ModulesRepository;
052: import net.jforum.repository.PostRepository;
053: import net.jforum.repository.RankingRepository;
054: import net.jforum.repository.SecurityRepository;
055: import net.jforum.repository.SmiliesRepository;
056: import net.jforum.repository.TopicRepository;
057: import net.jforum.util.bbcode.BBCodeHandler;
058: import net.jforum.util.preferences.ConfigKeys;
059: import net.jforum.util.preferences.SystemGlobals;
060: import net.jforum.util.preferences.TemplateKeys;
061:
062: /**
063: * @author Rafael Steil
064: * @version $Id: CacheAction.java,v 1.9 2006/08/20 22:47:45 rafaelsteil Exp $
065: */
066: public class CacheAction extends AdminCommand {
067: /**
068: * @see net.jforum.Command#list()
069: */
070: public void list() {
071: this .setTemplateName(TemplateKeys.CACHE_LIST);
072:
073: this .context.put("bb", new BBCodeRepository());
074: this .context.put("modules", new ModulesRepository());
075: this .context.put("ranking", new RankingRepository());
076: this .context.put("smilies", new SmiliesRepository());
077: this .context.put("security", new SecurityRepository());
078: this .context.put("forum", new ForumRepository());
079: this .context.put("topic", new TopicRepository());
080: this .context.put("session", new SessionFacade());
081: this .context.put("posts", new PostRepository());
082: }
083:
084: public void bbReload() {
085: BBCodeRepository.setBBCollection(new BBCodeHandler().parse());
086: this .list();
087: }
088:
089: public void sessionClear() {
090: SessionFacade.clear();
091: this .list();
092: }
093:
094: public void modulesReload() {
095: ModulesRepository.init(SystemGlobals
096: .getValue(ConfigKeys.CONFIG_DIR));
097: this .list();
098: }
099:
100: public void smiliesReload() {
101: SmiliesRepository.loadSmilies();
102: this .list();
103: }
104:
105: public void rankingReload() {
106: RankingRepository.loadRanks();
107: this .list();
108: }
109:
110: public void topicsMoreInfo() {
111: if (!SystemGlobals.getBoolValue(ConfigKeys.TOPIC_CACHE_ENABLED)) {
112: this .list();
113: return;
114: }
115:
116: this .setTemplateName(TemplateKeys.CACHE_TOPICS_MOREINFO);
117:
118: this .context.put("categories", ForumRepository
119: .getAllCategories());
120: }
121:
122: public void topicsClear() {
123: int forumId = this .request.getIntParameter("forum_id");
124: TopicRepository.clearCache(forumId);
125: this .topicsMoreInfo();
126: }
127:
128: public void postsMoreInfo() {
129: if (!SystemGlobals.getBoolValue(ConfigKeys.POSTS_CACHE_ENABLED)) {
130: this .list();
131: return;
132: }
133:
134: Collection topics = PostRepository.cachedTopics();
135:
136: this .context.put("topics", DataAccessDriver.getInstance()
137: .newTopicDAO().selectTopicTitlesByIds(topics));
138: this .context.put("repository", new PostRepository());
139: this .setTemplateName(TemplateKeys.CACHE_POST_MOREINFO);
140: }
141:
142: public void postsClear() {
143: int topicId = this .request.getIntParameter("topic_id");
144: PostRepository.clearCache(topicId);
145: this.postsMoreInfo();
146: }
147: }
|