use of org.simpleframework.xml.Serializer in project syncany by syncany.
the class TransferSettingsTest method testDeserializeCorrectClass.
@Test
public void testDeserializeCorrectClass() throws Exception {
Serializer serializer = new Persister();
InitOperationOptions initOperationOptions = TestConfigUtil.createTestInitOperationOptions("syncanytest");
// Always LocalTransferSettings
serializer.write(initOperationOptions.getConfigTO(), tmpFile);
ConfigTO confRestored = ConfigTO.load(tmpFile);
assertEquals(LocalTransferSettings.class, confRestored.getTransferSettings().getClass());
// Tear down
FileUtils.deleteDirectory(initOperationOptions.getLocalDir());
FileUtils.deleteDirectory(((LocalTransferSettings) initOperationOptions.getConfigTO().getTransferSettings()).getPath());
}
use of org.simpleframework.xml.Serializer in project syncany by syncany.
the class TransactionTO method save.
public void save(Transformer transformer, File transactionFile) throws Exception {
PrintWriter out;
if (transformer == null) {
out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(transactionFile), "UTF-8"));
} else {
out = new PrintWriter(new OutputStreamWriter(transformer.createOutputStream(new FileOutputStream(transactionFile)), "UTF-8"));
}
Serializer serializer = new Persister();
serializer.write(this, out);
out.flush();
out.close();
}
use of org.simpleframework.xml.Serializer in project syncany by syncany.
the class RepoTO method save.
public void save(File file, List<CipherSpec> cipherSpecs, SaltedSecretKey masterKey) throws ConfigException {
try {
ByteArrayOutputStream plaintextRepoOutputStream = new ByteArrayOutputStream();
Serializer serializer = new Persister();
serializer.write(this, plaintextRepoOutputStream);
CipherUtil.encrypt(new ByteArrayInputStream(plaintextRepoOutputStream.toByteArray()), new FileOutputStream(file), cipherSpecs, masterKey);
} catch (Exception e) {
throw new ConfigException("Cannot write repoTO (encrypted) to file " + file, e);
}
}
use of org.simpleframework.xml.Serializer in project syncany by syncany.
the class TestCliUtil method fixMachineName.
private static void fixMachineName(Map<String, String> client) throws Exception {
File configFile = new File(client.get("localdir") + "/" + Config.DIR_APPLICATION + "/" + Config.FILE_CONFIG);
Serializer serializer = new Persister();
ConfigTO configTO = serializer.read(ConfigTO.class, configFile);
configTO.setMachineName(client.get("machinename"));
serializer.write(configTO, configFile);
}
use of org.simpleframework.xml.Serializer in project syncany by syncany.
the class ConnectOperation method verifyRepoFile.
private void verifyRepoFile(String repoFileStr) throws StorageException {
try {
Serializer serializer = new Persister();
serializer.read(RepoTO.class, repoFileStr);
} catch (Exception e) {
throw new StorageException("Repo file corrupt.", e);
}
}
Aggregations