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); } } }
protected void importGlobalUserSettings(List<ExportManifestUserSetting> globalSettings) { IUserSettingService settingService = PentahoSystem.get(IUserSettingService.class); if (settingService != null) { for (ExportManifestUserSetting globalSetting : globalSettings) { if (isOverwriteFile()) { settingService.setGlobalUserSetting(globalSetting.getName(), globalSetting.getValue()); } else { IUserSetting userSetting = settingService.getGlobalUserSetting(globalSetting.getName(), null); if (userSetting == null) { settingService.setGlobalUserSetting(globalSetting.getName(), globalSetting.getValue()); } } } } }