1 18 23 24 package org.apache.roller.ui.admin.struts.actions; 25 26 import java.io.IOException ; 27 import java.util.Map ; 28 import javax.servlet.ServletException ; 29 import javax.servlet.http.HttpServletRequest ; 30 import javax.servlet.http.HttpServletResponse ; 31 import org.apache.commons.logging.Log; 32 import org.apache.commons.logging.LogFactory; 33 import org.apache.struts.action.ActionForm; 34 import org.apache.struts.action.ActionForward; 35 import org.apache.struts.action.ActionMapping; 36 import org.apache.struts.actions.DispatchAction; 37 import org.apache.roller.ui.core.BasePageModel; 38 import org.apache.roller.ui.core.RollerRequest; 39 import org.apache.roller.ui.core.RollerSession; 40 import org.apache.roller.util.cache.CacheManager; 41 42 43 52 public class CacheInfoAction extends DispatchAction { 53 54 private static Log mLogger = LogFactory.getLog(CacheInfoAction.class); 55 56 57 public ActionForward unspecified( 58 ActionMapping mapping, 59 ActionForm actionForm, 60 HttpServletRequest request, 61 HttpServletResponse response) 62 throws IOException , ServletException { 63 64 ActionForward forward = mapping.findForward("cacheInfo.page"); 65 66 try { 67 BasePageModel pageModel = new BasePageModel( 68 "cacheInfo.title", request, response, mapping); 69 request.setAttribute("model",pageModel); 70 RollerRequest rreq = RollerRequest.getRollerRequest(request); 71 RollerSession rollerSession = RollerSession.getRollerSession(request); 72 if (rollerSession.isGlobalAdminUser() ) { 73 74 Map cacheStats = CacheManager.getStats(); 76 request.setAttribute("cacheStats", cacheStats); 77 78 } else { 79 forward = mapping.findForward("access-denied"); 80 } 81 82 } catch (Exception e) { 83 mLogger.error("ERROR in action",e); 84 throw new ServletException (e); 85 } 86 87 return forward; 88 } 89 90 91 97 public ActionForward clear( 98 ActionMapping mapping, 99 ActionForm actionForm, 100 HttpServletRequest request, 101 HttpServletResponse response) 102 throws IOException , ServletException { 103 104 ActionForward forward = mapping.findForward("cacheInfo.page"); 105 106 try { 107 BasePageModel pageModel = new BasePageModel( 108 "cacheInfo.title", request, response, mapping); 109 request.setAttribute("model",pageModel); 110 RollerRequest rreq = RollerRequest.getRollerRequest(request); 111 RollerSession rollerSession = RollerSession.getRollerSession(request); 112 if (rollerSession.isGlobalAdminUser() ) { 113 114 String handlerClass = request.getParameter("cache"); 116 if(handlerClass != null && handlerClass.length() > 0) { 117 CacheManager.clear(handlerClass); 118 } else { 119 CacheManager.clear(); 120 } 121 122 Map cacheStats = CacheManager.getStats(); 124 request.setAttribute("cacheStats", cacheStats); 125 126 } else { 127 forward = mapping.findForward("access-denied"); 128 } 129 130 } catch (Exception e) { 131 mLogger.error("ERROR in action",e); 132 throw new ServletException (e); 133 } 134 135 return forward; 136 } 137 } 138 | Popular Tags |