Package org.simpleframework.xml.core

Examples of org.simpleframework.xml.core.Persister


  private PortTO portTO; // This is generated dynamically by the daemon. It should't be in the XML.

  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);
    }
  }
View Full Code Here


    }
  }

  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);
    }
  }
View Full Code Here

    this.salt = salt;
  }

  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);
    }
  }
View Full Code Here

    this.configEncryptionKey = configEncryptionKey;
  }

  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);
    }
  }
View Full Code Here

    }
  }

  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);
    }
  }
View Full Code Here

      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 (Exception ex) {
      throw new ConfigException("Config file does not exist or is invalid: " + file, ex);
    }
  }
View Full Code Here

      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);
    }
  }
View Full Code Here

    config.getDatabaseDir().mkdirs();
    config.getLogDir().mkdirs();
    config.getStateDir().mkdirs();

    // Write to config folder (required for some tests)
    new Persister().write(configTO, new File(config.getAppDir() + "/" + Config.FILE_CONFIG));
    new Persister().write(repoTO, new File(config.getAppDir() + "/" + Config.FILE_REPO));

    return config;
  }
View Full Code Here

      }
  }

    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);
    }
View Full Code Here

    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);
    }
View Full Code Here

TOP

Related Classes of org.simpleframework.xml.core.Persister

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.