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.verify;
16  
17  import com.liferay.portal.NoSuchRoleException;
18  import com.liferay.portal.model.Role;
19  import com.liferay.portal.model.RoleConstants;
20  import com.liferay.portal.service.RoleLocalServiceUtil;
21  import com.liferay.portal.util.PortalInstances;
22  
23  /**
24   * <a href="VerifyRole.java.html"><b><i>View Source</i></b></a>
25   *
26   * @author Brian Wing Shun Chan
27   */
28  public class VerifyRole extends VerifyProcess {
29  
30      protected void doVerify() throws Exception {
31          long[] companyIds = PortalInstances.getCompanyIdsBySQL();
32  
33          for (long companyId : companyIds) {
34              RoleLocalServiceUtil.checkSystemRoles(companyId);
35  
36              try {
37                  Role communityMemberRole = RoleLocalServiceUtil.getRole(
38                      companyId, RoleConstants.COMMUNITY_MEMBER);
39  
40                  deleteImplicitAssociations(communityMemberRole);
41              }
42              catch (NoSuchRoleException nsre) {
43              }
44  
45              try {
46                  Role organizationMemberRole = RoleLocalServiceUtil.getRole(
47                      companyId, RoleConstants.ORGANIZATION_MEMBER);
48  
49                  deleteImplicitAssociations(organizationMemberRole);
50              }
51              catch (NoSuchRoleException nsre) {
52              }
53          }
54      }
55  
56      protected void deleteImplicitAssociations(Role role) throws Exception {
57          runSQL(
58              "delete from UserGroupGroupRole where roleId = " +
59                  role.getRoleId());
60          runSQL(
61              "delete from UserGroupRole where roleId = " + role.getRoleId());
62      }
63  
64  }