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.bookmarks.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.bookmarks.model.BookmarksEntry;
21  import com.liferay.portlet.bookmarks.model.BookmarksFolder;
22  import com.liferay.portlet.bookmarks.service.BookmarksEntryServiceUtil;
23  import com.liferay.portlet.bookmarks.service.BookmarksFolderServiceUtil;
24  
25  import javax.portlet.ActionRequest;
26  import javax.portlet.RenderRequest;
27  
28  import javax.servlet.http.HttpServletRequest;
29  
30  /**
31   * <a href="ActionUtil.java.html"><b><i>View Source</i></b></a>
32   *
33   * @author Brian Wing Shun Chan
34   */
35  public class ActionUtil {
36  
37      public static void getFolder(ActionRequest actionRequest) throws Exception {
38          HttpServletRequest request = PortalUtil.getHttpServletRequest(
39              actionRequest);
40  
41          getFolder(request);
42      }
43  
44      public static void getFolder(RenderRequest renderRequest) throws Exception {
45          HttpServletRequest request = PortalUtil.getHttpServletRequest(
46              renderRequest);
47  
48          getFolder(request);
49      }
50  
51      public static void getFolder(HttpServletRequest request) throws Exception {
52          long folderId = ParamUtil.getLong(request, "folderId");
53  
54          BookmarksFolder folder = null;
55  
56          if (folderId > 0) {
57              folder = BookmarksFolderServiceUtil.getFolder(folderId);
58          }
59  
60          request.setAttribute(WebKeys.BOOKMARKS_FOLDER, folder);
61      }
62  
63      public static void getEntry(ActionRequest actionRequest) throws Exception {
64          HttpServletRequest request = PortalUtil.getHttpServletRequest(
65              actionRequest);
66  
67          getEntry(request);
68      }
69  
70      public static void getEntry(RenderRequest renderRequest) throws Exception {
71          HttpServletRequest request = PortalUtil.getHttpServletRequest(
72              renderRequest);
73  
74          getEntry(request);
75      }
76  
77      public static void getEntry(HttpServletRequest request) throws Exception {
78          long entryId = ParamUtil.getLong(request, "entryId");
79  
80          BookmarksEntry entry = null;
81  
82          if (entryId > 0) {
83              entry = BookmarksEntryServiceUtil.getEntry(entryId);
84          }
85  
86          request.setAttribute(WebKeys.BOOKMARKS_ENTRY, entry);
87      }
88  
89  }