protected void importUserSettings(UserExport user) {
    IUserSettingService settingService = PentahoSystem.get(IUserSettingService.class);
    IAnyUserSettingService userSettingService = null;
    if (settingService != null && settingService instanceof IAnyUserSettingService) {
      userSettingService = (IAnyUserSettingService) settingService;
    }

    if (userSettingService != null) {
      List<ExportManifestUserSetting> exportedSettings = user.getUserSettings();
      try {
        for (ExportManifestUserSetting exportedSetting : exportedSettings) {
          if (isOverwriteFile()) {
            userSettingService.setUserSetting(
                user.getUsername(), exportedSetting.getName(), exportedSetting.getValue());
          } else {
            // see if it's there first before we set this setting
            IUserSetting userSetting =
                userSettingService.getUserSetting(
                    user.getUsername(), exportedSetting.getName(), null);
            if (userSetting == null) {
              // only set it if we didn't find that it exists already
              userSettingService.setUserSetting(
                  user.getUsername(), exportedSetting.getName(), exportedSetting.getValue());
            }
          }
        }
      } catch (SecurityException e) {
        log.error(
            Messages.getInstance().getString("ERROR.ImportingUserSetting", user.getUsername()));
        log.debug(
            Messages.getInstance().getString("ERROR.ImportingUserSetting", user.getUsername()), e);
      }
    }
  }
  /**
   * Imports UserExport objects into the platform as users.
   *
   * @param users
   * @return A map of role names to list of users in that role
   */
  protected Map<String, List<String>> importUsers(List<UserExport> users) {
    Map<String, List<String>> roleToUserMap = new HashMap<>();
    IUserRoleDao roleDao = PentahoSystem.get(IUserRoleDao.class);
    ITenant tenant = new Tenant("/pentaho/" + TenantUtils.getDefaultTenant(), true);

    if (users != null && roleDao != null) {
      for (UserExport user : users) {
        String password = user.getPassword();
        log.debug("Importing user: "******"USER.Already.Exists", user.getUsername()));

          try {
            if (isOverwriteFile()) {
              // set the roles, maybe they changed
              roleDao.setUserRoles(tenant, user.getUsername(), userRoles);

              // set the password just in case it changed
              roleDao.setPassword(tenant, user.getUsername(), password);
            }
          } catch (Exception ex) {
            // couldn't set the roles or password either
            log.debug("Failed to set roles or password for existing user on import", ex);
          }
        } catch (Exception e) {
          log.error(Messages.getInstance().getString("ERROR.CreatingUser", user.getUsername()));
        }
        importUserSettings(user);
      }
    }
    return roleToUserMap;
  }