List of usage examples for org.apache.commons.configuration XMLConfiguration save
public void save(Writer writer) throws ConfigurationException
From source file:org.zaproxy.gradle.UpdateDailyZapVersionsEntries.java
@TaskAction public void update() throws Exception { File dailyRelease = from.get().getAsFile(); if (!Files.isRegularFile(dailyRelease.toPath())) { throw new IllegalArgumentException( "The provided daily release does not exist or it's not a file: " + dailyRelease); }// w w w . jav a2s . c o m if (checksumAlgorithm.get().isEmpty()) { throw new IllegalArgumentException("The checksum algorithm must not be empty."); } if (baseDownloadUrl.get().isEmpty()) { throw new IllegalArgumentException("The base download URL must not be empty."); } String fileName = dailyRelease.getName(); String dailyVersion = getDailyVersion(fileName); String hash = createChecksum(checksumAlgorithm.get(), dailyRelease); String size = String.valueOf(dailyRelease.length()); String url = baseDownloadUrl.get() + dailyVersion.substring(2) + "/" + fileName; for (File zapVersionsFile : into.getFiles()) { if (!Files.isRegularFile(zapVersionsFile.toPath())) { throw new IllegalArgumentException("The provided path is not a file: " + zapVersionsFile); } XMLConfiguration zapVersionsXml = new CustomXmlConfiguration(); zapVersionsXml.load(zapVersionsFile); zapVersionsXml.setProperty(DAILY_VERSION_ELEMENT, dailyVersion); zapVersionsXml.setProperty(DAILY_FILE_ELEMENT, fileName); zapVersionsXml.setProperty(DAILY_HASH_ELEMENT, hash); zapVersionsXml.setProperty(DAILY_SIZE_ELEMENT, size); zapVersionsXml.setProperty(DAILY_URL_ELEMENT, url); zapVersionsXml.save(zapVersionsFile); } }
From source file:put.semantic.fcanew.ui.EntryImpl.java
public void save(File f) { try {/*from w w w. ja v a 2 s . c o m*/ XMLConfiguration c = new XMLConfiguration(); c.setDelimiterParsingDisabled(true); c.addProperty("mappings.endpoint", endpoint); c.addProperty("mappings.prefixes", prefixes); for (Entry e : entries) { if (!e.getPattern().isEmpty()) { c.addProperty("mappings.mapping(-1).attribute", e.getAttribute().toString()); c.addProperty("mappings.mapping.pattern", e.getPattern()); } } c.save(f); } catch (ConfigurationException ex) { throw new RuntimeException(ex); } }