1 26 30 package org.jresearch.gossip.actions.forum; 31 32 import java.sql.SQLException ; 33 import java.util.Date ; 34 import java.util.HashMap ; 35 import java.util.Iterator ; 36 import java.util.List ; 37 38 import javax.servlet.http.HttpServletRequest ; 39 import javax.servlet.http.HttpServletResponse ; 40 import javax.servlet.http.HttpSession ; 41 42 import org.apache.struts.action.Action; 43 import org.apache.struts.action.ActionForm; 44 import org.apache.struts.action.ActionForward; 45 import org.apache.struts.action.ActionMapping; 46 import org.jresearch.gossip.IConst; 47 import org.jresearch.gossip.beans.user.User; 48 import org.jresearch.gossip.dao.ForumDAO; 49 import org.jresearch.gossip.exception.SystemException; 50 import org.jresearch.gossip.forms.ProcessForumForm; 51 52 57 public class MarkReadAction extends Action { 58 75 public ActionForward execute(ActionMapping mapping, ActionForm form, 76 HttpServletRequest request, HttpServletResponse response) 77 throws Exception { 78 ForumDAO dao = ForumDAO.getInstance(); 79 HttpSession session = request.getSession(); 80 User user = (User) session.getAttribute(IConst.SESSION.USER_KEY); 81 List updatedTopics = null; 82 ActionForward forward = null; 83 String fid = ((ProcessForumForm) form).getFid(); 84 85 try { 86 87 if (fid == null || fid.equals("")) { 88 updatedTopics = dao.getUpdatedTopics(user); 89 forward = mapping.findForward(IConst.TOKEN.WELCOME); 90 } else { 91 updatedTopics = dao.getUpdatedTopics(user, Integer 92 .parseInt(fid)); 93 forward = new ActionForward("/ShowForum.do?fid=" + fid, true); 94 } 95 96 Iterator it = updatedTopics.iterator(); 97 98 HashMap lastIntimeMap = (HashMap ) session 99 .getAttribute(IConst.SESSION.LAST_INTIME); 100 Date now = dao.now(); 101 102 while (it.hasNext()) { 103 updateLastVisitTime(lastIntimeMap, (String ) it.next(), now); 104 } 105 } catch (SQLException sqle) { 106 getServlet().log("Connection.process", sqle); 107 throw new SystemException(sqle); 108 } 109 110 return (forward); 111 } 112 113 private void updateLastVisitTime(HashMap last_intime, String tid, Date now) { 115 if (last_intime.containsKey(tid)) { 116 last_intime.remove(tid); 117 } 118 119 last_intime.put(tid, now); 120 } 121 } 122 | Popular Tags |