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.announcements.action;
16  
17  import com.liferay.portal.kernel.util.ParamUtil;
18  import com.liferay.portal.util.PortalUtil;
19  import com.liferay.portal.util.WebKeys;
20  import com.liferay.portlet.announcements.model.AnnouncementsEntry;
21  import com.liferay.portlet.announcements.service.AnnouncementsEntryLocalServiceUtil;
22  
23  import javax.portlet.ActionRequest;
24  import javax.portlet.RenderRequest;
25  
26  import javax.servlet.http.HttpServletRequest;
27  
28  /**
29   * <a href="ActionUtil.java.html"><b><i>View Source</i></b></a>
30   *
31   * @author Raymond Augé
32   */
33  public class ActionUtil {
34  
35      public static void getEntry(ActionRequest actionRequest) throws Exception {
36          HttpServletRequest request = PortalUtil.getHttpServletRequest(
37              actionRequest);
38  
39          getEntry(request);
40      }
41  
42      public static void getEntry(RenderRequest renderRequest) throws Exception {
43          HttpServletRequest request = PortalUtil.getHttpServletRequest(
44              renderRequest);
45  
46          getEntry(request);
47      }
48  
49      public static void getEntry(HttpServletRequest request) throws Exception {
50          long entryId = ParamUtil.getLong(request, "entryId");
51  
52          AnnouncementsEntry entry = null;
53  
54          if (entryId > 0) {
55              entry = AnnouncementsEntryLocalServiceUtil.getEntry(entryId);
56          }
57  
58          request.setAttribute(WebKeys.ANNOUNCEMENTS_ENTRY, entry);
59      }
60  
61  }