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