protected void importResourceBlock(
      PortletDataContext portletDataContext, Role importedRole, Permission permission)
      throws PortalException, SystemException {

    int scope = permission.getScope();

    if (scope == ResourceConstants.SCOPE_COMPANY) {
      ResourceBlockLocalServiceUtil.addCompanyScopePermission(
          portletDataContext.getCompanyId(), permission.getName(),
          importedRole.getRoleId(), permission.getActionId());
    } else if (scope == ResourceConstants.SCOPE_GROUP) {
      long groupId = portletDataContext.getCompanyGroupId();

      long sourceGroupId = GetterUtil.getLong(permission.getPrimKey());

      if (sourceGroupId == portletDataContext.getSourceUserPersonalSiteGroupId()) {

        groupId = portletDataContext.getUserPersonalSiteGroupId();
      }

      ResourceBlockLocalServiceUtil.addGroupScopePermission(
          portletDataContext.getCompanyId(),
          groupId,
          permission.getName(),
          importedRole.getRoleId(),
          permission.getActionId());
    } else if (scope == ResourceConstants.SCOPE_GROUP_TEMPLATE) {
      ResourceBlockLocalServiceUtil.addGroupScopePermission(
          portletDataContext.getCompanyId(),
          GroupConstants.DEFAULT_PARENT_GROUP_ID,
          permission.getName(),
          importedRole.getRoleId(),
          permission.getActionId());
    } else {
      if (_log.isDebugEnabled()) {
        _log.debug("Individually scoped permissions are not exported");
      }
    }
  }