use of org.simpleframework.xml.core.Persister in project netxms by netxms.
the class XMLTools method createSerializer.
/**
* Create serializer with registered converters
*
* @return serializer with registered converters
* @throws Exception on XML library failures
*/
public static Serializer createSerializer() throws Exception {
Registry registry = new Registry();
registry.bind(UUID.class, UUIDConverter.class);
return new Persister(new AnnotationStrategy(new RegistryStrategy(registry)));
}
use of org.simpleframework.xml.core.Persister in project netxms by netxms.
the class PassiveRackElementGroup method createXml.
/**
* Create XML from configuration
*
* @return XML document
* @throws Exception if the schema for the object is not valid
*/
public String createXml() throws Exception {
Serializer serializer = new Persister();
Writer writer = new StringWriter();
serializer.write(this, writer);
return writer.toString();
}
use of org.simpleframework.xml.core.Persister in project netxms by netxms.
the class InputFieldOptions method createXml.
/**
* Create XML from configuration.
*
* @return XML document or null if serialization failed
*/
public String createXml() {
try {
Serializer serializer = new Persister();
Writer writer = new StringWriter();
serializer.write(this, writer);
return writer.toString();
} catch (Exception e) {
return null;
}
}
use of org.simpleframework.xml.core.Persister 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.core.Persister in project syncany by syncany.
the class ApplicationLink method createTransferSettings.
private TransferSettings createTransferSettings(byte[] plaintextPluginSettingsBytes) throws StorageException, IOException {
// Find plugin ID and settings XML
int pluginIdentifierLength = Ints.fromByteArray(Arrays.copyOfRange(plaintextPluginSettingsBytes, 0, INTEGER_BYTES));
String pluginId = new String(Arrays.copyOfRange(plaintextPluginSettingsBytes, INTEGER_BYTES, INTEGER_BYTES + pluginIdentifierLength));
byte[] gzippedPluginSettingsByteArray = Arrays.copyOfRange(plaintextPluginSettingsBytes, INTEGER_BYTES + pluginIdentifierLength, plaintextPluginSettingsBytes.length);
String pluginSettings = IOUtils.toString(new GZIPInputStream(new ByteArrayInputStream(gzippedPluginSettingsByteArray)));
// Create transfer settings object
try {
TransferPlugin plugin = Plugins.get(pluginId, TransferPlugin.class);
if (plugin == null) {
throw new StorageException("Link contains unknown connection type '" + pluginId + "'. Corresponding plugin not found.");
}
Class<? extends TransferSettings> pluginTransferSettingsClass = TransferPluginUtil.getTransferSettingsClass(plugin.getClass());
TransferSettings transferSettings = new Persister().read(pluginTransferSettingsClass, pluginSettings);
logger.log(Level.INFO, "(Decrypted) link contains: " + pluginId + " -- " + pluginSettings);
return transferSettings;
} catch (Exception e) {
throw new StorageException(e);
}
}
Aggregations