1 43 package net.jforum.view.admin; 44 45 import java.util.Collection ; 46 47 import net.jforum.SessionFacade; 48 import net.jforum.dao.DataAccessDriver; 49 import net.jforum.repository.BBCodeRepository; 50 import net.jforum.repository.ForumRepository; 51 import net.jforum.repository.ModulesRepository; 52 import net.jforum.repository.PostRepository; 53 import net.jforum.repository.RankingRepository; 54 import net.jforum.repository.SecurityRepository; 55 import net.jforum.repository.SmiliesRepository; 56 import net.jforum.repository.TopicRepository; 57 import net.jforum.util.bbcode.BBCodeHandler; 58 import net.jforum.util.preferences.ConfigKeys; 59 import net.jforum.util.preferences.SystemGlobals; 60 import net.jforum.util.preferences.TemplateKeys; 61 62 66 public class CacheAction extends AdminCommand 67 { 68 71 public void list() throws Exception 72 { 73 this.setTemplateName(TemplateKeys.CACHE_LIST); 74 75 this.context.put("bb", new BBCodeRepository()); 76 this.context.put("modules", new ModulesRepository()); 77 this.context.put("ranking", new RankingRepository()); 78 this.context.put("smilies", new SmiliesRepository()); 79 this.context.put("security", new SecurityRepository()); 80 this.context.put("forum", new ForumRepository()); 81 this.context.put("topic", new TopicRepository()); 82 this.context.put("session", new SessionFacade()); 83 this.context.put("posts", new PostRepository()); 84 } 85 86 public void bbReload() throws Exception 87 { 88 BBCodeRepository.setBBCollection(new BBCodeHandler().parse()); 89 this.list(); 90 } 91 92 public void sessionClear() throws Exception 93 { 94 SessionFacade.clear(); 95 this.list(); 96 } 97 98 public void modulesReload() throws Exception 99 { 100 ModulesRepository.init(SystemGlobals.getValue(ConfigKeys.CONFIG_DIR)); 101 this.list(); 102 } 103 104 public void smiliesReload() throws Exception 105 { 106 SmiliesRepository.loadSmilies(); 107 this.list(); 108 } 109 110 public void rankingReload() throws Exception 111 { 112 RankingRepository.loadRanks(); 113 this.list(); 114 } 115 116 public void topicsMoreInfo() throws Exception 117 { 118 if (!SystemGlobals.getBoolValue(ConfigKeys.TOPIC_CACHE_ENABLED)) { 119 this.list(); 120 return; 121 } 122 123 this.setTemplateName(TemplateKeys.CACHE_TOPICS_MOREINFO); 124 125 this.context.put("categories", ForumRepository.getAllCategories()); 126 } 127 128 public void topicsClear() throws Exception 129 { 130 int forumId = this.request.getIntParameter("forum_id"); 131 TopicRepository.clearCache(forumId); 132 this.topicsMoreInfo(); 133 } 134 135 public void postsMoreInfo() throws Exception 136 { 137 if (!SystemGlobals.getBoolValue(ConfigKeys.POSTS_CACHE_ENABLED)) { 138 this.list(); 139 return; 140 } 141 142 Collection topics = PostRepository.cachedTopics(); 143 144 this.context.put("topics", DataAccessDriver.getInstance().newTopicDAO().selectTopicTitlesByIds(topics)); 145 this.context.put("repository", new PostRepository()); 146 this.setTemplateName(TemplateKeys.CACHE_POST_MOREINFO); 147 } 148 149 public void postsClear() throws Exception 150 { 151 int topicId = this.request.getIntParameter("topic_id"); 152 PostRepository.clearCache(topicId); 153 this.postsMoreInfo(); 154 } 155 } 156 | Popular Tags |