1 25 29 package org.jresearch.gossip.actions.message.attachment; 30 31 import java.lang.reflect.InvocationTargetException ; 32 import java.sql.SQLException ; 33 34 import javax.servlet.http.HttpServletRequest ; 35 import javax.servlet.http.HttpServletResponse ; 36 import javax.servlet.http.HttpSession ; 37 38 import org.apache.commons.beanutils.BeanUtils; 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.Message; 45 import org.jresearch.gossip.beans.forum.Topic; 46 import org.jresearch.gossip.beans.forum.attachment.FileDataInfo; 47 import org.jresearch.gossip.beans.user.User; 48 import org.jresearch.gossip.dao.ForumDAO; 49 import org.jresearch.gossip.exception.JGossipException; 50 import org.jresearch.gossip.exception.SystemException; 51 import org.jresearch.gossip.forms.AttachmentInfoForm; 52 53 57 public class UpdateAttachmentInfoAction extends BaseAction { 58 59 67 protected ActionForward process(ActionMapping mapping, ActionForm form, 68 HttpServletRequest request, HttpServletResponse response) 69 throws JGossipException { 70 HttpSession session = request.getSession(); 71 User user = (User) session.getAttribute(IConst.SESSION.USER_KEY); 72 ForumDAO dao = ForumDAO.getInstance(); 73 AttachmentInfoForm aiForm = (AttachmentInfoForm) form; 74 75 try { 76 boolean isUserMod = dao.checkMod(Integer.parseInt(aiForm.getFid()), 77 user); 78 Topic currThread = dao.getThreadInfo(Integer.parseInt(aiForm 79 .getTid())); 80 Message mess = dao.getMessage(aiForm.getMid()); 81 getServlet().log("check user access rights "); 83 if (isUserMod 84 || (user.getName().equals(mess.getSender()) && (currThread 85 .getLocked() == IConst.Topic.STATUS_UNLOCKED))) { 86 FileDataInfo fInfo = new FileDataInfo(); 87 BeanUtils.copyProperties(fInfo, aiForm); 88 dao.updateAttachmentInfo(fInfo); 89 } else { 90 return (mapping.findForward(IConst.TOKEN.DENIED)); 91 } 92 93 } catch (NumberFormatException e) { 94 throw new SystemException(e); 95 } catch (SQLException e) { 96 throw new SystemException(e); 97 } catch (IllegalAccessException e) { 98 throw new SystemException(e); 99 } catch (InvocationTargetException e) { 100 throw new SystemException(e); 101 } 102 StringBuffer forward = new StringBuffer (); 103 forward.append("/ShowMessage.do?fid="); 104 forward.append(aiForm.getFid()); 105 forward.append("&tid="); 106 forward.append(aiForm.getTid()); 107 forward.append("&mid="); 108 forward.append(aiForm.getMid()); 109 return (new ActionForward(forward.toString(), true)); 110 111 } 112 113 } | Popular Tags |