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.layoutsetprototypes.action;
16  
17  import com.liferay.portal.NoSuchLayoutSetPrototypeException;
18  import com.liferay.portal.kernel.util.ParamUtil;
19  import com.liferay.portal.model.LayoutSetPrototype;
20  import com.liferay.portal.service.LayoutSetPrototypeServiceUtil;
21  import com.liferay.portal.util.PortalUtil;
22  import com.liferay.portal.util.WebKeys;
23  
24  import javax.portlet.PortletRequest;
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 getLayoutSetPrototype(PortletRequest portletRequest)
36          throws Exception {
37  
38          HttpServletRequest request = PortalUtil.getHttpServletRequest(
39              portletRequest);
40  
41          getLayoutSetPrototype(request);
42      }
43  
44      public static void getLayoutSetPrototype(HttpServletRequest request)
45          throws Exception {
46  
47          long layoutSetPrototypeId = ParamUtil.getLong(
48              request, "layoutSetPrototypeId");
49  
50          LayoutSetPrototype layoutSetPrototype = null;
51  
52          try {
53              layoutSetPrototype =
54                  LayoutSetPrototypeServiceUtil.getLayoutSetPrototype(
55                      layoutSetPrototypeId);
56          }
57          catch (NoSuchLayoutSetPrototypeException nslpte) {
58          }
59  
60          request.setAttribute(WebKeys.LAYOUT_PROTOTYPE, layoutSetPrototype);
61      }
62  
63  }