public static ConfigTO load(File file) throws ConfigException {
try {
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
registry.bind(SaltedSecretKey.class, new SaltedSecretKeyConverter());
registry.bind(String.class, new EncryptedTransferSettingsConverter());
return new Persister(strategy).read(ConfigTO.class, file);
}
catch (ClassNotFoundException ex) {
String message = ex.getMessage();
if (!message.startsWith("org.syncany.plugins.")) {
throw new ConfigException("Config file does not exist or is invalid: " + file, ex);
}
message = message.replaceFirst("org.syncany.plugins.", "");
message = message.replaceAll("\\..*", "");
throw new ConfigException("Is the " + message + " plugin installed?");
}
catch (Exception ex) {
throw new ConfigException("Config file does not exist or is invalid: " + file, ex);
}
}