use of org.apache.commons.configuration2.PropertiesConfiguration in project hadoop by apache.
the class MetricsSystemImpl method currentConfig.
@Override
public synchronized String currentConfig() {
PropertiesConfiguration saver = new PropertiesConfiguration();
StringWriter writer = new StringWriter();
saver.copy(config);
try {
saver.write(writer);
} catch (Exception e) {
throw new MetricsConfigException("Error stringify config", e);
}
return writer.toString();
}
use of org.apache.commons.configuration2.PropertiesConfiguration in project hadoop by apache.
the class ConfigUtil method dump.
static void dump(String header, Configuration c, PrintWriter out) {
PropertiesConfiguration p = new PropertiesConfiguration();
p.copy(c);
if (header != null) {
out.println(header);
}
try {
p.write(out);
} catch (Exception e) {
throw new RuntimeException("Error saving config", e);
}
}
use of org.apache.commons.configuration2.PropertiesConfiguration in project data-prep by Talend.
the class PropertiesEncryption method modifyAndSave.
/**
* Applies the specified function to the specified set of parameters contained in the input file.
*
* @param input The specified name of file to encrypt
* @param mustBeModified the specified set of parameters
* @param function the specified function to apply to the set of specified parameters
*/
private void modifyAndSave(String input, Set<String> mustBeModified, Function<String, String> function) {
Path inputFilePath = Paths.get(input);
if (Files.exists(inputFilePath) && Files.isRegularFile(inputFilePath) && Files.isReadable(inputFilePath)) {
try {
Parameters params = new Parameters();
//
FileBasedConfigurationBuilder<PropertiesConfiguration> builder = //
new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class).configure(//
params.fileBased().setFile(//
inputFilePath.toFile()));
PropertiesConfiguration config = builder.getConfiguration();
mustBeModified.stream().filter(config::containsKey).forEach(key -> config.setProperty(key, function.apply(config.getString(key))));
builder.save();
} catch (ConfigurationException e) {
LOGGER.error("unable to read {} {}", input, e);
}
} else {
LOGGER.debug("No readable file at {}", input);
}
}
use of org.apache.commons.configuration2.PropertiesConfiguration in project xwiki-platform by xwiki.
the class AllTests method setupChannel.
private void setupChannel(XWikiExecutor executor, String channelName) throws Exception {
if (executor.getExecutionDirectory() != null) {
PropertiesConfiguration properties = executor.loadXWikiPropertiesConfiguration();
properties.setProperty("observation.remote.enabled", "true");
properties.setProperty("observation.remote.channels", channelName);
executor.saveXWikiProperties();
setupExecutor(executor);
}
}
use of org.apache.commons.configuration2.PropertiesConfiguration in project xwiki-platform by xwiki.
the class AllITs method preStart.
@XWikiExecutorSuite.PreStart
public void preStart(List<XWikiExecutor> executors) throws Exception {
XWikiExecutor executor = executors.get(0);
repositoryUtil = new RepositoryUtils();
LOGGER.info("Adding repository to xwiki.properties");
PropertiesConfiguration properties = executor.loadXWikiPropertiesConfiguration();
// Put self and Maven as extensions repository
properties.setProperty("extension.repositories", Arrays.asList("self:xwiki:http://localhost:8080/xwiki/rest", "maven-test:maven:" + repositoryUtil.getMavenRepository().toURI()));
// Disable core extension resolve because Jetty is not ready when it starts
properties.setProperty("extension.core.resolve", false);
executor.saveXWikiProperties();
}
Aggregations