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.layoutprototypes.action;
16  
17  import com.liferay.portal.NoSuchLayoutPrototypeException;
18  import com.liferay.portal.kernel.util.ParamUtil;
19  import com.liferay.portal.model.LayoutPrototype;
20  import com.liferay.portal.service.LayoutPrototypeServiceUtil;
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 Jorge Ferrer
32   */
33  public class ActionUtil {
34  
35      public static void getLayoutPrototype(PortletRequest portletRequest)
36          throws Exception {
37  
38          HttpServletRequest request = PortalUtil.getHttpServletRequest(
39              portletRequest);
40  
41          getLayoutPrototype(request);
42      }
43  
44      public static void getLayoutPrototype(HttpServletRequest request)
45          throws Exception {
46  
47          long layoutPrototypeId = ParamUtil.getLong(
48              request, "layoutPrototypeId");
49  
50          LayoutPrototype layoutPrototype = null;
51  
52          try {
53              layoutPrototype = LayoutPrototypeServiceUtil.getLayoutPrototype(
54                  layoutPrototypeId);
55          }
56          catch (NoSuchLayoutPrototypeException nslpte) {
57          }
58  
59          request.setAttribute(WebKeys.LAYOUT_PROTOTYPE, layoutPrototype);
60      }
61  
62  }