Search in sources :

Example 6 with ExportManifestUserSetting

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);
        }
    }
}
Also used : IAnyUserSettingService(org.pentaho.platform.api.usersettings.IAnyUserSettingService) IUserSettingService(org.pentaho.platform.api.usersettings.IUserSettingService) ExportManifestUserSetting(org.pentaho.platform.plugin.services.importexport.ExportManifestUserSetting) IUserSetting(org.pentaho.platform.api.usersettings.pojo.IUserSetting)

Aggregations

ExportManifestUserSetting (org.pentaho.platform.plugin.services.importexport.ExportManifestUserSetting)6 Test (org.junit.Test)4 IAnyUserSettingService (org.pentaho.platform.api.usersettings.IAnyUserSettingService)4 IUserSettingService (org.pentaho.platform.api.usersettings.IUserSettingService)4 IUserSetting (org.pentaho.platform.api.usersettings.pojo.IUserSetting)4 UserExport (org.pentaho.platform.plugin.services.importexport.UserExport)3 ArrayList (java.util.ArrayList)2 IUserRoleListService (org.pentaho.platform.api.engine.IUserRoleListService)1 ITenant (org.pentaho.platform.api.mt.ITenant)1 RoleExport (org.pentaho.platform.plugin.services.importexport.RoleExport)1 IRoleAuthorizationPolicyRoleBindingDao (org.pentaho.platform.security.policy.rolebased.IRoleAuthorizationPolicyRoleBindingDao)1 UserDetailsService (org.springframework.security.core.userdetails.UserDetailsService)1