SolutionImportHandler implements IPlatformImportHandler { 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 { IUserSetting userSetting = userSettingService.getUserSetting( user.getUsername(), exportedSetting.getName(), null ); if ( userSetting == null ) { userSettingService.setUserSetting( user.getUsername(), exportedSetting.getName(), exportedSetting.getValue() ); } } } } catch ( SecurityException e ) { String errorMsg = Messages.getInstance().getString( "ERROR.ImportingUserSetting", user.getUsername() ); getLogger().error( errorMsg ); getLogger().debug( errorMsg, e ); } } } SolutionImportHandler( List<IMimeType> mimeTypes ); ImportSession getImportSession(); Log getLogger(); @Override void importFile( IPlatformImportBundle bundle ); @Override List<IMimeType> getMimeTypes(); IPlatformImportBundle build( RepositoryFileImportBundle.Builder builder ); Response createSchedulerJob( SchedulerResource scheduler, JobScheduleRequest jobScheduleRequest ); boolean isOverwriteFile(); void setOverwriteFile( boolean overwriteFile );  }
@Test public void testImportUserSettings() throws Exception { UserExport user = new UserExport(); user.setUsername( "pentaho" ); user.addUserSetting( new ExportManifestUserSetting( "theme", "crystal" ) ); user.addUserSetting( new ExportManifestUserSetting( "language", "en_US" ) ); IAnyUserSettingService userSettingService = Mockito.mock( IAnyUserSettingService.class ); PentahoSystem.registerObject( userSettingService ); importHandler.setOverwriteFile( true ); importHandler.importUserSettings( user ); Mockito.verify( userSettingService ).setUserSetting( "pentaho", "theme", "crystal" ); Mockito.verify( userSettingService ).setUserSetting( "pentaho", "language", "en_US" ); }