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.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 static final long DEFAULT_PARENT_USER_GROUP_ID = 0;
32  
33      public UserGroupImpl() {
34      }
35  
36      public Group getGroup() {
37          Group group = null;
38  
39          try {
40              group = GroupLocalServiceUtil.getUserGroupGroup(
41                  getCompanyId(), getUserGroupId());
42          }
43          catch (Exception e) {
44              group = new GroupImpl();
45  
46              _log.error(e);
47          }
48  
49          return group;
50      }
51  
52      public int getPrivateLayoutsPageCount() {
53          try {
54              Group group = getGroup();
55  
56              if (group == null) {
57                  return 0;
58              }
59              else {
60                  return group.getPrivateLayoutsPageCount();
61              }
62          }
63          catch (Exception e) {
64              _log.error(e);
65          }
66  
67          return 0;
68      }
69  
70      public boolean hasPrivateLayouts() {
71          if (getPrivateLayoutsPageCount() > 0) {
72              return true;
73          }
74          else {
75              return false;
76          }
77      }
78  
79      public int getPublicLayoutsPageCount() {
80          try {
81              Group group = getGroup();
82  
83              if (group == null) {
84                  return 0;
85              }
86              else {
87                  return group.getPublicLayoutsPageCount();
88              }
89          }
90          catch (Exception e) {
91              _log.error(e);
92          }
93  
94          return 0;
95      }
96  
97      public boolean hasPublicLayouts() {
98          if (getPublicLayoutsPageCount() > 0) {
99              return true;
100         }
101         else {
102             return false;
103         }
104     }
105 
106     private static Log _log = LogFactoryUtil.getLog(UserGroupImpl.class);
107 
108 }