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.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portal.model.Group;
20  import com.liferay.portal.model.UserGroup;
21  import com.liferay.portal.service.GroupLocalServiceUtil;
22  
23  /**
24   * <a href="UserGroupImpl.java.html"><b><i>View Source</i></b></a>
25   *
26   * @author Brian Wing Shun Chan
27   * @author Jorge Ferrer
28   */
29  public class UserGroupImpl extends UserGroupModelImpl implements UserGroup {
30  
31      public UserGroupImpl() {
32      }
33  
34      public Group getGroup() {
35          Group group = null;
36  
37          try {
38              group = GroupLocalServiceUtil.getUserGroupGroup(
39                  getCompanyId(), getUserGroupId());
40          }
41          catch (Exception e) {
42              group = new GroupImpl();
43  
44              _log.error(e);
45          }
46  
47          return group;
48      }
49  
50      public int getPrivateLayoutsPageCount() {
51          try {
52              Group group = getGroup();
53  
54              if (group == null) {
55                  return 0;
56              }
57              else {
58                  return group.getPrivateLayoutsPageCount();
59              }
60          }
61          catch (Exception e) {
62              _log.error(e);
63          }
64  
65          return 0;
66      }
67  
68      public boolean hasPrivateLayouts() {
69          if (getPrivateLayoutsPageCount() > 0) {
70              return true;
71          }
72          else {
73              return false;
74          }
75      }
76  
77      public int getPublicLayoutsPageCount() {
78          try {
79              Group group = getGroup();
80  
81              if (group == null) {
82                  return 0;
83              }
84              else {
85                  return group.getPublicLayoutsPageCount();
86              }
87          }
88          catch (Exception e) {
89              _log.error(e);
90          }
91  
92          return 0;
93      }
94  
95      public boolean hasPublicLayouts() {
96          if (getPublicLayoutsPageCount() > 0) {
97              return true;
98          }
99          else {
100             return false;
101         }
102     }
103 
104     private static Log _log = LogFactoryUtil.getLog(UserGroupImpl.class);
105 
106 }