1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.calendar.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.calendar.model.CalEvent;
21  import com.liferay.portlet.calendar.service.CalEventServiceUtil;
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 Brian Wing Shun Chan
32   */
33  public class ActionUtil {
34  
35      public static void getEvent(ActionRequest actionRequest) throws Exception {
36          HttpServletRequest request = PortalUtil.getHttpServletRequest(
37              actionRequest);
38  
39          getEvent(request);
40      }
41  
42      public static void getEvent(RenderRequest renderRequest) throws Exception {
43          HttpServletRequest request = PortalUtil.getHttpServletRequest(
44              renderRequest);
45  
46          getEvent(request);
47      }
48  
49      public static void getEvent(HttpServletRequest request) throws Exception {
50          long eventId = ParamUtil.getLong(request, "eventId");
51  
52          CalEvent event = null;
53  
54          if (eventId > 0) {
55              event = CalEventServiceUtil.getEvent(eventId);
56          }
57  
58          request.setAttribute(WebKeys.CALENDAR_EVENT, event);
59      }
60  
61  }