1 7 package org.roller.presentation.website.actions; 8 9 import java.io.IOException ; 10 11 import javax.servlet.ServletException ; 12 import javax.servlet.http.HttpServletRequest ; 13 import javax.servlet.http.HttpServletResponse ; 14 15 import org.apache.commons.logging.Log; 16 import org.apache.commons.logging.LogFactory; 17 import org.apache.struts.action.ActionForm; 18 import org.apache.struts.action.ActionForward; 19 import org.apache.struts.action.ActionMapping; 20 import org.apache.struts.action.ActionMessage; 21 import org.apache.struts.action.ActionMessages; 22 import org.apache.struts.actions.DispatchAction; 23 import org.roller.RollerException; 24 import org.roller.business.search.operations.RebuildUserIndexOperation; 25 import org.roller.model.IndexManager; 26 import org.roller.pojos.UserData; 27 import org.roller.presentation.RollerRequest; 28 import org.roller.presentation.pagecache.PageCacheFilter; 29 30 38 public class MaintenanceAction extends DispatchAction 39 { 40 private static Log mLogger = 41 LogFactory.getFactory().getInstance(MaintenanceAction.class); 42 43 44 51 protected ActionForward unspecified( 52 ActionMapping mapping, 53 ActionForm actionForm, 54 HttpServletRequest request, 55 HttpServletResponse response) 56 throws ServletException 57 { 58 return mapping.findForward("maintenance.page"); 59 } 60 61 65 public ActionForward index( 66 ActionMapping mapping, 67 ActionForm actionForm, 68 HttpServletRequest request, 69 HttpServletResponse response) 70 throws IOException , ServletException 71 { 72 try 73 { 74 RollerRequest rreq = RollerRequest.getRollerRequest(request); 75 if ( rreq.isUserAuthorizedToEdit() ) 76 { 77 UserData ud = rreq.getUser(); 78 IndexManager manager = rreq.getRoller().getIndexManager(); 79 manager.rebuildUserIndex(); 80 81 ActionMessages messages = new ActionMessages(); 82 messages.add(null, new ActionMessage("maintenance.message.indexed")); 83 saveMessages(request, messages); 84 } 85 } 86 catch (RollerException re) 87 { 88 mLogger.error("Unexpected exception",re.getRootCause()); 89 throw new ServletException (re); 90 } 91 catch (Exception e) 92 { 93 mLogger.error("Unexpected exception",e); 94 throw new ServletException (e); 95 } 96 return mapping.findForward("maintenance.page"); 97 } 98 99 103 public ActionForward flushCache( 104 ActionMapping mapping, 105 ActionForm actionForm, 106 HttpServletRequest request, 107 HttpServletResponse response) 108 throws IOException , ServletException 109 { 110 try 111 { 112 RollerRequest rreq = RollerRequest.getRollerRequest(request); 113 if ( rreq.isUserAuthorizedToEdit() ) 114 { 115 UserData user = rreq.getUser(); 116 PageCacheFilter.removeFromCache(request, user); 117 118 ActionMessages messages = new ActionMessages(); 119 messages.add(null, new ActionMessage("maintenance.message.flushed")); 120 saveMessages(request, messages); 121 } 122 } 123 catch (Exception e) 124 { 125 throw new ServletException (e); 126 } 127 return mapping.findForward("maintenance.page"); 128 } 129 } 130 | Popular Tags |