1 package org.nemesis.forum.webapp.admin.action; 2 3 import javax.servlet.http.HttpServletRequest ; 4 import javax.servlet.http.HttpServletResponse ; 5 6 import org.apache.commons.logging.Log; 7 import org.apache.commons.logging.LogFactory; 8 import org.apache.struts.action.ActionError; 9 import org.apache.struts.action.ActionErrors; 10 import org.apache.struts.action.ActionForm; 11 import org.apache.struts.action.ActionForward; 12 import org.apache.struts.action.ActionMapping; 13 import org.nemesis.forum.ForumFactory; 14 import org.nemesis.forum.search.Indexer; 15 16 17 18 public class IndexationAction extends BaseAction { 19 20 static protected Log log =LogFactory.getLog(IndexationAction.class); 21 22 23 24 public ActionForward execute(ActionMapping mapping, 25 ActionForm form, 26 HttpServletRequest request, 27 HttpServletResponse response) 28 throws Exception { 29 30 checkUser(request); 32 checkPermission(request,OperationConstants.MANAGE_SEARCH); 34 35 ActionErrors errors = new ActionErrors(); 36 37 try { 38 ForumFactory forumFactory = ForumFactory.getInstance(getAuthToken(request)); 39 40 if(request.getParameter("autoindex")!=null){ 42 Indexer.setAutoIndex(!Indexer.isAutoIndex(),getAuthToken(request)); 43 } 44 if(request.getParameter("reindex")!=null){ 45 try { 46 Indexer.reindex(getAuthToken(request)); 47 } catch (Exception e) { 48 } 49 } 50 51 52 53 request.setAttribute("isAutoIndex",new Boolean (Indexer.isAutoIndex())); 55 56 } catch (Exception e) { 57 String eid=this.getClass().getName()+"_"+System.currentTimeMillis(); 58 log.error("eid:"+eid +"\nsessionID" +request.getSession().getId(),e) ; 59 errors.add("general", new ActionError("error.general","error id:"+eid)); 60 } 61 62 saveErrors(request, errors); 63 64 return mapping.findForward("view"); 65 } 66 67 } | Popular Tags |