1 25 29 package org.jresearch.gossip.actions.forum; 30 31 import java.lang.reflect.InvocationTargetException ; 32 import java.sql.SQLException ; 33 import java.util.Iterator ; 34 35 import javax.servlet.http.HttpServletRequest ; 36 import javax.servlet.http.HttpServletResponse ; 37 import javax.servlet.http.HttpSession ; 38 39 import org.apache.struts.action.ActionForm; 40 import org.apache.struts.action.ActionForward; 41 import org.apache.struts.action.ActionMapping; 42 import org.jresearch.gossip.IConst; 43 import org.jresearch.gossip.actions.BaseAction; 44 import org.jresearch.gossip.beans.forum.Forum; 45 import org.jresearch.gossip.beans.forum.Message; 46 import org.jresearch.gossip.beans.forum.Topic; 47 import org.jresearch.gossip.beans.user.User; 48 import org.jresearch.gossip.configuration.Configurator; 49 import org.jresearch.gossip.dao.ForumDAO; 50 import org.jresearch.gossip.dao.UserDAO; 51 import org.jresearch.gossip.exception.SystemException; 52 import org.jresearch.gossip.forms.ProcessForumForm; 53 import org.jresearch.gossip.list.RecordsData; 54 55 60 public class ShowForumAction extends BaseAction { 61 75 public ActionForward process(ActionMapping mapping, ActionForm form, 76 HttpServletRequest request, HttpServletResponse response) 77 throws SystemException { 78 ProcessForumForm pfForm = (ProcessForumForm) form; 79 80 ForumDAO dao = ForumDAO.getInstance(); 81 UserDAO userdao = UserDAO.getInstance(); 82 HttpSession session = request.getSession(); 83 84 User user = (User) session.getAttribute(IConst.SESSION.USER_KEY); 85 int fid = Integer.parseInt(pfForm.getFid()); 86 87 try { 88 89 Forum currForum = dao.getForumInfo(fid); 90 91 if ((currForum.getLocked() == IConst.Forum.STATUS_INVISIBLE) 93 && (user.getStatus() < Integer.parseInt(Configurator 94 .getInstance().get(IConst.CONFIG.INVADER1)))) { 95 return (mapping.findForward(IConst.TOKEN.DENIED)); 96 } 97 98 request.setAttribute(IConst.REQUEST.CURR_FORUM, currForum); 99 session.setAttribute(IConst.SESSION.CURR_FORUM, currForum); 100 101 RecordsData recordsData = new RecordsData(); 102 dao.fillThreadList(user, recordsData, pfForm); 103 104 Iterator it = recordsData.getRecords().iterator(); 105 106 while (it.hasNext()) { 107 Message mess = ((Topic) it.next()).getLastMessage(); 108 mess.setSenderInfo(userdao.getSenderInfo(mess.getSender())); 109 } 110 111 request.setAttribute(IConst.REQUEST.RECORDS_DATA, recordsData); 112 113 if (dao.checkMod(fid, user)) { 114 request.setAttribute(IConst.REQUEST.MOD_FLAG, 115 IConst.VALUES.TRUE); 116 } 117 } catch (SQLException sqle) { 118 getServlet().log("Connection.process", sqle); 119 throw new SystemException(sqle); 120 } catch (InstantiationException e) { 121 throw new SystemException(e); 122 } catch (IllegalAccessException e) { 123 throw new SystemException(e); 124 } catch (InvocationTargetException e) { 125 throw new SystemException(e); 126 } catch (NoSuchMethodException e) { 127 throw new SystemException(e); 128 } 129 130 return (mapping.findForward("showForum")); 131 } 132 } 133 | Popular Tags |