Example usage for org.apache.commons.configuration2 FileBasedConfiguration addProperty

List of usage examples for org.apache.commons.configuration2 FileBasedConfiguration addProperty

Introduction

In this page you can find the example usage for org.apache.commons.configuration2 FileBasedConfiguration addProperty.

Prototype

void addProperty(String key, Object value);

Source Link

Document

Add a property to the configuration.

Usage

From source file:org.jbb.system.impl.install.InstallationFileManager.java

public void createInstallationFile(InstallationData installationData) {
    Parameters params = new Parameters();
    File installFile = getInstallFile();
    try {//from www  . j av  a  2 s  .c om
        FileUtils.touch(installFile);
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
    FileBasedConfigurationBuilder<FileBasedConfiguration> builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(
            PropertiesConfiguration.class).configure(params.fileBased().setFile(installFile));
    builder.setAutoSave(true);

    try {
        FileBasedConfiguration configuration = builder.getConfiguration();
        configuration.addProperty("installationId", UUID.randomUUID().toString());
        configuration.addProperty("installationVersion", jbbMetaData.jbbVersion());
        configuration.addProperty("installationDate", LocalDateTime.now().toString());
        configuration.addProperty("boardFounderUsername", installationData.getAdminUsername());
        builder.save();
    } catch (ConfigurationException e) {
        throw new IllegalStateException(e);
    }
}