1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portlet.messageboards.action;
16  
17  import com.liferay.portal.kernel.util.ParamUtil;
18  import com.liferay.portal.util.PortalUtil;
19  import com.liferay.portal.util.PortletKeys;
20  import com.liferay.portlet.PortletURLImpl;
21  
22  import javax.portlet.PortletMode;
23  import javax.portlet.PortletRequest;
24  import javax.portlet.PortletURL;
25  import javax.portlet.WindowState;
26  
27  import javax.servlet.http.HttpServletRequest;
28  import javax.servlet.http.HttpServletResponse;
29  
30  import org.apache.struts.action.Action;
31  import org.apache.struts.action.ActionForm;
32  import org.apache.struts.action.ActionForward;
33  import org.apache.struts.action.ActionMapping;
34  
35  /**
36   * <a href="FindRecentPostsAction.java.html"><b><i>View Source</i></b></a>
37   *
38   * @author Brian Wing Shun Chan
39   */
40  public class FindRecentPostsAction extends Action {
41  
42      public ActionForward execute(
43              ActionMapping mapping, ActionForm form, HttpServletRequest request,
44              HttpServletResponse response)
45          throws Exception {
46  
47          try {
48              long plid = ParamUtil.getLong(request, "p_l_id");
49  
50              PortletURL portletURL = new PortletURLImpl(
51                  request, PortletKeys.MESSAGE_BOARDS, plid,
52                  PortletRequest.RENDER_PHASE);
53  
54              portletURL.setWindowState(WindowState.NORMAL);
55              portletURL.setPortletMode(PortletMode.VIEW);
56  
57              portletURL.setParameter("struts_action", "/message_boards/view");
58              portletURL.setParameter("tabs2", "recent-posts");
59  
60              response.sendRedirect(portletURL.toString());
61  
62              return null;
63          }
64          catch (Exception e) {
65              PortalUtil.sendError(e, request, response);
66  
67              return null;
68          }
69      }
70  
71  }