/** Create an instance using a default {@link Persister} instance for conversion. */ public static SimpleXmlConverterFactory create() { return create(new Persister()); }
/** Create an instance using a default {@link Persister} instance for non-strict conversion. */ public static SimpleXmlConverterFactory createNonStrict() { return createNonStrict(new Persister()); }
private static RepoTO loadPlaintextRepoTO(File repoFile, ConfigTO configTO) throws Exception { logger.log(Level.INFO, "Loading (unencrypted) repo file from {0} ...", repoFile); return new Persister().read(RepoTO.class, repoFile); }
public static TransactionTO load(Transformer transformer, File transactionFile) throws Exception { InputStream is; if (transformer == null) { is = new FileInputStream(transactionFile); } else { is = transformer.createInputStream(new FileInputStream(transactionFile)); } return new Persister().read(TransactionTO.class, is); }
private PortTO readPortConfig(File portFile) { try { return new Persister().read(PortTO.class, portFile); } catch (Exception e) { logger.log(Level.SEVERE, "ERROR: Could not read portFile to connect to daemon.", e); showErrorAndExit("Cannot connect to daemon."); return null; // Never reached! } }
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); } }
private byte[] getPlaintextStorageXml() throws Exception { ByteArrayOutputStream plaintextByteArrayOutputStream = new ByteArrayOutputStream(); DataOutputStream plaintextOutputStream = new DataOutputStream(plaintextByteArrayOutputStream); plaintextOutputStream.writeInt(transferSettings.getType().getBytes().length); plaintextOutputStream.write(transferSettings.getType().getBytes()); GZIPOutputStream plaintextGzipOutputStream = new GZIPOutputStream(plaintextOutputStream); new Persister(new Format(0)).write(transferSettings, plaintextGzipOutputStream); plaintextGzipOutputStream.close(); return plaintextByteArrayOutputStream.toByteArray(); } }
private static RepoTO loadEncryptedRepoTO(File repoFile, ConfigTO configTO) throws Exception { logger.log(Level.INFO, "Loading encrypted repo file from {0} ...", repoFile); SaltedSecretKey masterKey = configTO.getMasterKey(); if (masterKey == null) { throw new ConfigException("Repo file is encrypted, but master key not set in config file."); } String repoFileStr = new String(CipherUtil.decrypt(new FileInputStream(repoFile), masterKey)); return new Persister().read(RepoTO.class, repoFileStr); } }
private MasterTO readMasterFile(File tmpMasterFile) throws StorageException { try { Serializer serializer = new Persister(); return serializer.read(MasterTO.class, tmpMasterFile); } catch (Exception e) { throw new StorageException("Master file corrupt.", e); } } }
public void save(File file) throws ConfigException { try { new Persister().write(this, file); } catch (Exception e) { throw new ConfigException("Cannot write repoTO to file " + file, e); } }
public void save(File file) throws ConfigException { try { new Persister().write(this, file); } catch (Exception e) { throw new ConfigException("Config could not be written: " + file, e); } }
public static DaemonConfigTO load(File file) throws ConfigException { try { return new Persister().read(DaemonConfigTO.class, file); } catch (Exception e) { throw new ConfigException("Config file does not exist or is invalid: " + file, e); } }
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); } }
public void save(File file) throws ConfigException { try { new Persister().write(this, file); } catch (Exception e) { throw new ConfigException("Cannot write masterTO to file " + file, e); } }
private PluginInfo getRemotePluginInfo(String pluginId) throws Exception { String remoteListStr = getRemoteListStr(pluginId); PluginListResponse pluginListResponse = new Persister().read(PluginListResponse.class, remoteListStr); if (pluginListResponse.getPlugins().size() > 0) { return pluginListResponse.getPlugins().get(0); } else { return null; } }
private List<PluginInfo> getRemotePluginInfoList() throws Exception { String remoteListStr = getRemoteListStr(null); PluginListResponse pluginListResponse = new Persister().read(PluginListResponse.class, remoteListStr); return pluginListResponse.getPlugins(); }
public void save(File file) throws ConfigException { try { new Persister(new AnnotationStrategy()).write(this, file); } catch (Exception e) { throw new ConfigException("Cannot write user config to file " + file, e); } } }
public static UserConfigTO load(File file) throws ConfigException { try { return new Persister(new AnnotationStrategy()).read(UserConfigTO.class, file); } catch (Exception e) { throw new ConfigException("User config file cannot be read or is invalid: " + file, e); } }
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); }
public void save(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(transferSettings.getClass())); new Persister(strategy).write(this, file); } catch (Exception e) { throw new ConfigException("Cannot write config to file " + file, e); } }