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.enterpriseadmin.search;
16  
17  import com.liferay.portal.kernel.dao.search.RowChecker;
18  import com.liferay.portal.kernel.log.Log;
19  import com.liferay.portal.kernel.log.LogFactoryUtil;
20  import com.liferay.portal.model.Group;
21  import com.liferay.portal.model.UserGroup;
22  import com.liferay.portal.service.UserGroupLocalServiceUtil;
23  
24  import javax.portlet.RenderResponse;
25  
26  /**
27   * <a href="UserGroupGroupChecker.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Charles May
30   */
31  public class UserGroupGroupChecker extends RowChecker {
32  
33      public UserGroupGroupChecker(RenderResponse renderResponse, Group group) {
34          super(renderResponse);
35  
36          _group = group;
37      }
38  
39      public boolean isChecked(Object obj) {
40          UserGroup userGroup = (UserGroup)obj;
41  
42          try {
43              return UserGroupLocalServiceUtil.hasGroupUserGroup(
44                  _group.getGroupId(), userGroup.getUserGroupId());
45          }
46          catch (Exception e) {
47              _log.error(e);
48  
49              return false;
50          }
51      }
52  
53      private static Log _log = LogFactoryUtil.getLog(
54          UserGroupGroupChecker.class);
55  
56      private Group _group;
57  
58  }