use of org.syncany.plugins.transfer.TransferPluginOptionConverter in project syncany by syncany.
the class AbstractInitCommand method askNormalPluginSettings.
private void askNormalPluginSettings(TransferSettings settings, TransferPluginOption option, Map<String, String> knownPluginSettings, String nestPrefix) throws StorageException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
TransferPluginOptionCallback optionCallback = createOptionCallback(settings, option.getCallback());
TransferPluginOptionConverter optionConverter = createOptionConverter(settings, option.getConverter());
if (!isInteractive && !knownPluginSettings.containsKey(nestPrefix + option.getName())) {
throw new IllegalArgumentException("Missing plugin option (" + nestPrefix + option.getName() + ") in non-interactive mode.");
} else if (knownPluginSettings.containsKey(nestPrefix + option.getName())) {
settings.setField(option.getField().getName(), knownPluginSettings.get(nestPrefix + option.getName()));
} else if (!option.isVisible()) {
// Do nothing. Invisible option!
} else {
callAndPrintPreQueryCallback(optionCallback);
String optionValue = askPluginOption(settings, option);
if (optionConverter != null) {
optionValue = optionConverter.convert(optionValue);
}
settings.setField(option.getField().getName(), optionValue);
callAndPrintPostQueryCallback(optionCallback, optionValue);
}
}
use of org.syncany.plugins.transfer.TransferPluginOptionConverter in project syncany by syncany.
the class AbstractInitCommand method createOptionConverter.
private TransferPluginOptionConverter createOptionConverter(TransferSettings settings, Class<? extends TransferPluginOptionConverter> optionConverterClass) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
TransferPluginOptionConverter optionConverter = null;
if (optionConverterClass != null) {
Constructor<? extends TransferPluginOptionConverter> optionConverterClassConstructor = optionConverterClass.getDeclaredConstructor(settings.getClass());
optionConverter = optionConverterClassConstructor.newInstance(settings);
}
return optionConverter;
}
Aggregations