use of org.syncany.config.ConfigException in project syncany by syncany.
the class WatchServer method startWatchOperations.
private void startWatchOperations(Map<File, FolderTO> newWatchedFolderTOs) throws ConfigException, ServiceAlreadyStartedException {
for (Map.Entry<File, FolderTO> folderEntry : newWatchedFolderTOs.entrySet()) {
File localDir = folderEntry.getKey();
try {
Config watchConfig = ConfigHelper.loadConfig(localDir);
if (watchConfig != null) {
logger.log(Level.INFO, "- Starting watch operation at " + localDir + " ...");
WatchOperationOptions watchOptions = folderEntry.getValue().getWatchOptions();
if (watchOptions == null) {
watchOptions = new WatchOperationOptions();
}
WatchRunner watchRunner = new WatchRunner(watchConfig, watchOptions, daemonConfig.getPortTO());
watchRunner.start();
watchOperations.put(localDir, watchRunner);
} else {
logger.log(Level.INFO, "- CANNOT start watch, because no config found at " + localDir + " ...");
}
} catch (Exception e) {
logger.log(Level.SEVERE, " + Cannot start watch operation at " + localDir + ". IGNORING.", e);
}
}
}
use of org.syncany.config.ConfigException in project syncany by syncany.
the class ConfigTO method load.
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) {
// Ugly hack to catch common case of non-existing plugin
String message = ex.getMessage();
if (!message.startsWith("org.syncany.plugins.")) {
// Apparently there are other ClassNotFoundExceptions possible.
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);
}
}
use of org.syncany.config.ConfigException in project syncany by syncany.
the class ConfigTest method testConfigMultiChunkerNull.
@Test
public void testConfigMultiChunkerNull() throws Exception {
// Setup
File localDir = new File("/some/folder");
ConfigTO configTO = new ConfigTO();
RepoTO repoTO = new RepoTO();
// <<< valid
configTO.setMachineName("somevalidmachinename");
// <<< valid
repoTO.setChunkerTO(TestConfigUtil.createFixedChunkerTO());
// <<< valid
repoTO.setRepoId(new byte[] { 0x01, 0x02 });
// <<< valid
repoTO.setTransformers(null);
// <<< INVALID !!
repoTO.setMultiChunker(null);
// Run!
try {
new Config(localDir, configTO, repoTO);
fail("Config should not been have initialized.");
} catch (ConfigException e) {
TestAssertUtil.assertErrorStackTraceContains("No multichunker", e);
}
}
use of org.syncany.config.ConfigException in project syncany by syncany.
the class ConfigTest method testConfigMachineNameInvalidChars.
@Test
public void testConfigMachineNameInvalidChars() throws Exception {
File localDir = new File("/some/folder");
ConfigTO configTO = new ConfigTO();
RepoTO repoTO = new RepoTO();
configTO.setMachineName("invalid machine name");
// Run!
try {
new Config(localDir, configTO, repoTO);
fail("Machine name should not have been accepted.");
} catch (ConfigException e) {
TestAssertUtil.assertErrorStackTraceContains("Machine name", e);
}
}
use of org.syncany.config.ConfigException in project syncany by syncany.
the class ConfigTest method testConfigChunkerNull.
@Test
@Ignore
public // TODO [low] ChunkerTO is not used yet; so no test for it.
void testConfigChunkerNull() throws Exception {
// Setup
File localDir = new File("/some/folder");
ConfigTO configTO = new ConfigTO();
RepoTO repoTO = new RepoTO();
// <<< valid
configTO.setMachineName("somevalidmachinename");
// <<< valid
repoTO.setMultiChunker(TestConfigUtil.createZipMultiChunkerTO());
// <<< valid
repoTO.setRepoId(new byte[] { 0x01, 0x02 });
// <<< valid
repoTO.setTransformers(null);
// <<< INVALID !!
repoTO.setChunkerTO(null);
// Run!
try {
new Config(localDir, configTO, repoTO);
fail("Config should not been have initialized.");
} catch (ConfigException e) {
TestAssertUtil.assertErrorStackTraceContains("No multichunker", e);
}
}
Aggregations