use of org.pentaho.platform.plugin.services.importexport.ExportManifestUserSetting in project pentaho-platform by pentaho.
the class SolutionImportHandler method importUserSettings.
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);
}
}
}
Aggregations