Search in sources :

Example 1 with PropertiesConfigurationLayout

use of org.apache.commons.configuration2.PropertiesConfigurationLayout in project gocd by gocd.

the class AgentAutoRegistrationPropertiesImpl method scrubRegistrationProperties.

@Override
public void scrubRegistrationProperties() {
    if (!exist()) {
        return;
    }
    try {
        PropertiesConfiguration config = new PropertiesConfiguration();
        config.setIOFactory(new FilteringOutputWriterFactory());
        PropertiesConfigurationLayout layout = new PropertiesConfigurationLayout();
        layout.setLineSeparator("\n");
        layout.load(config, reader());
        try (FileWriter out = new FileWriter(this.configFile)) {
            layout.save(config, out);
        }
        loadProperties();
    } catch (ConfigurationException | IOException e) {
        LOG.warn("[Agent Auto Registration] Unable to scrub registration key.", e);
    }
}
Also used : ConfigurationException(org.apache.commons.configuration2.ex.ConfigurationException) PropertiesConfiguration(org.apache.commons.configuration2.PropertiesConfiguration) PropertiesConfigurationLayout(org.apache.commons.configuration2.PropertiesConfigurationLayout)

Aggregations

PropertiesConfiguration (org.apache.commons.configuration2.PropertiesConfiguration)1 PropertiesConfigurationLayout (org.apache.commons.configuration2.PropertiesConfigurationLayout)1 ConfigurationException (org.apache.commons.configuration2.ex.ConfigurationException)1