private File saveDatastoreDirectory;
private QuickAnalysisStrategy quickAnalysisStrategy = new QuickAnalysisStrategy();
protected static UserPreferences load(File file, boolean loadDrivers) {
ChangeAwareObjectInputStream inputStream = null;
try {
inputStream = new ChangeAwareObjectInputStream(new FileInputStream(file));
UserPreferences result = (UserPreferences) inputStream.readObject();
if (loadDrivers) {
List<UserDatabaseDriver> installedDatabaseDrivers = result.getDatabaseDrivers();
for (UserDatabaseDriver userDatabaseDriver : installedDatabaseDrivers) {
try {
userDatabaseDriver.loadDriver();
} catch (IllegalStateException e) {
logger.error("Could not load database driver", e);
}
}
}
return result;
} catch (InvalidClassException e) {
logger.warn("User preferences file version does not match application version: {}", e.getMessage());
return null;
} catch (Exception e) {
logger.warn("Could not read user preferences file", e);
return null;
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
}