1 6 7 package org.contineo.actions.admin.logging; 8 9 import javax.servlet.http.HttpServletRequest ; 10 import javax.servlet.http.HttpServletResponse ; 11 import javax.servlet.http.HttpSession ; 12 import org.apache.log4j.Level; 13 import org.apache.log4j.Logger; 14 import org.apache.struts.action.Action; 15 import org.apache.struts.action.ActionForm; 16 import org.apache.struts.action.ActionForward; 17 import org.apache.struts.action.ActionMapping; 18 import org.contineo.core.FileBean; 19 import org.contineo.core.LoggingManager; 20 import org.contineo.core.SessionManagement; 21 import org.contineo.core.config.LoggingConfigurator; 22 26 public class ShowLoggingAction extends Action { 27 28 32 private Logger logger; 33 34 35 36 public ShowLoggingAction() { 37 logger = LoggingManager.getLogger(this.getClass()); 38 } 39 40 public ActionForward execute(ActionMapping mapping, 41 ActionForm form, HttpServletRequest request, 42 HttpServletResponse response) { 43 ActionForward actionForward = new ActionForward(); 44 HttpSession session = request.getSession(); 45 if (SessionManagement.isValid(session)) { 46 try { 47 String appender = request.getParameter("appender"); 48 LoggingConfigurator conf = new LoggingConfigurator(); 49 String file = conf.getFile(appender); 50 StringBuffer content = FileBean.readFile(file); 51 String table = content.toString(); 52 request.setAttribute("table", table); 53 } catch (Exception e) { 54 if (logger.isEnabledFor(Level.ERROR)) 55 logger.error(e.getMessage()); 56 } 57 actionForward = mapping.findForward("showlogging"); 58 } else 59 actionForward = mapping.findForward("invalid"); 60 return actionForward; 61 } 62 } 63 | Popular Tags |