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.portal.model.impl;
16  
17  import com.liferay.portal.model.Group;
18  import com.liferay.portal.model.Layout;
19  import com.liferay.portal.model.LayoutPrototype;
20  import com.liferay.portal.service.GroupLocalServiceUtil;
21  import com.liferay.portal.service.LayoutLocalServiceUtil;
22  
23  import java.util.List;
24  
25  /**
26   * <a href="LayoutPrototypeImpl.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Jorge Ferrer
29   */
30  public class LayoutPrototypeImpl
31      extends LayoutPrototypeModelImpl implements LayoutPrototype {
32  
33      public LayoutPrototypeImpl() {
34      }
35  
36      public Group getGroup() {
37          Group group = null;
38  
39          try {
40              group = GroupLocalServiceUtil.getLayoutPrototypeGroup(
41                  getCompanyId(), getLayoutPrototypeId());
42          }
43          catch (Exception e) {
44          }
45  
46          return group;
47      }
48  
49      public Layout getLayout() {
50          Layout layout = null;
51  
52          try {
53              Group group = getGroup();
54  
55              if ((group != null) && (group.getPrivateLayoutsPageCount() > 0)) {
56                  List<Layout> layouts = LayoutLocalServiceUtil.getLayouts(
57                      group.getGroupId(), true);
58  
59                  layout = layouts.get(0);
60              }
61          }
62          catch (Exception e) {
63          }
64  
65          return layout;
66      }
67  
68  }