001
014
015 package com.liferay.portlet.messageboards.action;
016
017 import com.liferay.portal.kernel.util.ParamUtil;
018 import com.liferay.portal.util.PortalUtil;
019 import com.liferay.portal.util.PortletKeys;
020 import com.liferay.portlet.PortletURLImpl;
021 import com.liferay.portlet.messageboards.model.MBThread;
022 import com.liferay.portlet.messageboards.service.MBThreadLocalServiceUtil;
023
024 import javax.portlet.PortletMode;
025 import javax.portlet.PortletRequest;
026 import javax.portlet.PortletURL;
027 import javax.portlet.WindowState;
028
029 import javax.servlet.http.HttpServletRequest;
030 import javax.servlet.http.HttpServletResponse;
031
032 import org.apache.struts.action.Action;
033 import org.apache.struts.action.ActionForm;
034 import org.apache.struts.action.ActionForward;
035 import org.apache.struts.action.ActionMapping;
036
037
040 public class FindThreadAction extends Action {
041
042 public ActionForward execute(
043 ActionMapping mapping, ActionForm form, HttpServletRequest request,
044 HttpServletResponse response)
045 throws Exception {
046
047 try {
048 long plid = ParamUtil.getLong(request, "p_l_id");
049 long threadId = ParamUtil.getLong(request, "threadId");
050
051 MBThread thread = MBThreadLocalServiceUtil.getThread(threadId);
052
053 PortletURL portletURL = new PortletURLImpl(
054 request, PortletKeys.MESSAGE_BOARDS, plid,
055 PortletRequest.RENDER_PHASE);
056
057 portletURL.setWindowState(WindowState.NORMAL);
058 portletURL.setPortletMode(PortletMode.VIEW);
059
060 portletURL.setParameter(
061 "struts_action", "/message_boards/view_message");
062 portletURL.setParameter(
063 "messageId", String.valueOf(thread.getRootMessageId()));
064
065 response.sendRedirect(portletURL.toString());
066
067 return null;
068 }
069 catch (Exception e) {
070 PortalUtil.sendError(e, request, response);
071
072 return null;
073 }
074 }
075
076 }