1
22
23 package com.liferay.portlet.messageboards.action;
24
25 import com.liferay.portal.kernel.util.ParamUtil;
26 import com.liferay.portal.struts.ActionConstants;
27 import com.liferay.portal.util.PortletKeys;
28 import com.liferay.portlet.PortletURLImpl;
29 import com.liferay.portlet.messageboards.NoSuchThreadException;
30 import com.liferay.portlet.messageboards.model.MBThread;
31 import com.liferay.portlet.messageboards.service.MBThreadLocalServiceUtil;
32
33 import javax.portlet.PortletMode;
34 import javax.portlet.PortletURL;
35 import javax.portlet.WindowState;
36
37 import javax.servlet.http.HttpServletRequest;
38 import javax.servlet.http.HttpServletResponse;
39 import javax.servlet.jsp.PageContext;
40
41 import org.apache.commons.logging.Log;
42 import org.apache.commons.logging.LogFactory;
43 import org.apache.struts.action.Action;
44 import org.apache.struts.action.ActionForm;
45 import org.apache.struts.action.ActionForward;
46 import org.apache.struts.action.ActionMapping;
47
48
54 public class FindThreadAction extends Action {
55
56 public ActionForward execute(
57 ActionMapping mapping, ActionForm form, HttpServletRequest req,
58 HttpServletResponse res)
59 throws Exception {
60
61 try {
62 long plid = ParamUtil.getLong(req, "p_l_id");
63 long threadId = ParamUtil.getLong(req, "threadId");
64
65 MBThread thread = MBThreadLocalServiceUtil.getThread(threadId);
66
67 PortletURL portletURL = new PortletURLImpl(
68 req, PortletKeys.MESSAGE_BOARDS, plid, false);
69
70 portletURL.setWindowState(WindowState.NORMAL);
71 portletURL.setPortletMode(PortletMode.VIEW);
72
73 portletURL.setParameter(
74 "struts_action", "/message_boards/view_message");
75 portletURL.setParameter(
76 "messageId", String.valueOf(thread.getRootMessageId()));
77
78 res.sendRedirect(portletURL.toString());
79
80 return null;
81 }
82 catch (NoSuchThreadException nste) {
83 if (_log.isWarnEnabled()) {
84 _log.warn(nste);
85 }
86
87 return null;
88 }
89 catch (Exception e) {
90 req.setAttribute(PageContext.EXCEPTION, e);
91
92 return mapping.findForward(ActionConstants.COMMON_ERROR);
93 }
94 }
95
96 private static Log _log = LogFactory.getLog(FindThreadAction.class);
97
98 }