protected void deleteRolePermissions(PortletDataContext portletDataContext, Role importedRole)
      throws SystemException {

    List<ResourcePermission> resourcePermissions =
        ResourcePermissionLocalServiceUtil.getRoleResourcePermissions(
            importedRole.getRoleId(),
            new int[] {ResourceConstants.SCOPE_COMPANY, ResourceConstants.SCOPE_GROUP_TEMPLATE},
            QueryUtil.ALL_POS,
            QueryUtil.ALL_POS);

    for (ResourcePermission resourcePermission : resourcePermissions) {
      ResourcePermissionLocalServiceUtil.deleteResourcePermission(resourcePermission);
    }

    List<ResourcePermission> groupResourcePermissions =
        ResourcePermissionLocalServiceUtil.getRoleResourcePermissions(
            importedRole.getRoleId(),
            new int[] {ResourceConstants.SCOPE_GROUP},
            QueryUtil.ALL_POS,
            QueryUtil.ALL_POS);

    for (ResourcePermission groupResourcePermission : groupResourcePermissions) {

      long groupId = GetterUtil.getLong(groupResourcePermission.getPrimKey());

      if ((groupId == portletDataContext.getCompanyGroupId())
          || (groupId == portletDataContext.getUserPersonalSiteGroupId())) {

        ResourcePermissionLocalServiceUtil.deleteResourcePermission(groupResourcePermission);
      }
    }

    List<ResourceTypePermission> resourceTypePermissions =
        getResourceTypePermissions(portletDataContext, importedRole);

    for (ResourceTypePermission resourceTypePermission : resourceTypePermissions) {

      ResourceTypePermissionLocalServiceUtil.deleteResourceTypePermission(resourceTypePermission);
    }
  }
Пример #2
0
  protected void deletePermissions_6(long companyId) throws Exception {
    Group group = GroupLocalServiceUtil.getGroup(companyId, GroupConstants.CONTROL_PANEL);

    long plid = LayoutLocalServiceUtil.getDefaultPlid(group.getGroupId(), true);

    Role role = RoleLocalServiceUtil.getRole(companyId, RoleConstants.GUEST);

    List<ResourcePermission> resourcePermissions =
        ResourcePermissionLocalServiceUtil.getRoleResourcePermissions(role.getRoleId());

    for (ResourcePermission resourcePermission : resourcePermissions) {
      if (isControlPanelLayout(plid, resourcePermission.getPrimKey())
          || isPrivateLayout(resourcePermission.getName(), resourcePermission.getPrimKey())) {

        ResourcePermissionLocalServiceUtil.deleteResourcePermission(
            resourcePermission.getResourcePermissionId());
      }
    }
  }