Example usage for org.apache.commons.configuration PropertiesConfiguration save

List of usage examples for org.apache.commons.configuration PropertiesConfiguration save

Introduction

In this page you can find the example usage for org.apache.commons.configuration PropertiesConfiguration save.

Prototype

public void save() throws ConfigurationException 

Source Link

Document

Save the configuration.

Usage

From source file:com.xemantic.tadedon.configuration.ConfigurationsTest.java

@Test
public void shouldCopyPropertyWithComments() throws IOException, ConfigurationException {
    // given/*from  w  ww .ja v a2s .c  o m*/
    File confFile1 = new File("src/test/data/conf1.properties");
    File confFile2 = new File("src/test/data/conf2.properties");
    File confFile3 = new File("src/test/data/conf3.properties");
    File outConfFile = new File(testConfDir, "outConf.properties");
    Files.copy(confFile1, outConfFile);
    PropertiesConfiguration conf2 = new PropertiesConfiguration(confFile2);
    PropertiesConfiguration outConf = new PropertiesConfiguration(outConfFile);

    // when
    Configurations.copyProperty("bar", conf2, outConf);
    outConf.save();

    // then
    assertThat(Files.equal(outConfFile, confFile3), is(true));
}

From source file:com.jorge.propiedades.FirmaConfiguracion.java

public FirmaConfiguracion() {
    try {/*from   w  w  w . ja v a 2  s  .  com*/
        PropertiesConfiguration config = new PropertiesConfiguration("./quijotelu/Firma.properties");
        if (config.getProperty("Firma.Ruta_PKCS12") == null) {
            config.setProperty("Firma.Ruta_PKCS12", "/data/startup/BCE/jorge_luis_quiguango_teran.p12");
            config.save();
        }

        if (config.getProperty("Firma.Clave_PKCS12") == null) {
            config.setProperty("Firma.Clave_PKCS12", "Gluc4g0n");
            config.save();
        }
        PKCS12_RESOURCE = (String) config.getProperty("Firma.Ruta_PKCS12");
        PKCS12_PASSWORD = (String) config.getProperty("Firma.Clave_PKCS12");
    } catch (ConfigurationException ex) {
        Logger.getLogger(FirmaConfiguracion.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.impetus.ankush.agent.action.impl.PropertyFileManipulator.java

/**
 * Edits the conf value.//from   www  .j  a va2 s  . co  m
 * 
 * @param file
 *            the file
 * @param propertyName
 *            the property name
 * @param newPropertyValue
 *            the new property value
 * @return true, if successful
 */
@Override
public boolean editConfValue(String file, String propertyName, String newPropertyValue) {
    boolean status = false;
    try {
        // read conf file
        File confFile = new File(file);

        if (!confFile.exists()) {
            System.err.println("File " + file + " does not exists.");
            status = false;
        }
        PropertiesConfiguration props = new PropertiesConfiguration(file);
        props.setProperty(propertyName, newPropertyValue);
        props.getLayout().setSeparator(propertyName, "=");
        props.save();
        status = true;
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    return status;
}

From source file:com.mirth.connect.server.migration.Migrate3_4_0.java

@Override
public void updateConfiguration(PropertiesConfiguration configuration) {
    if (StringUtils.containsIgnoreCase(configuration.getLayout().getComment("database"), "sqlserver2000")) {
        configuration.getLayout().setComment("database", "options: derby, mysql, postgres, oracle, sqlserver");

        try {//w  ww .  j  a v a 2  s . c  om
            configuration.save();
        } catch (ConfigurationException e) {
            logger.warn("An error occurred updating the database property comment.");
        }
    }
}

From source file:config.Login.java

private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed

    try {/*  w w w.  j a  v a2s.c o m*/
        String propFileName = "config.properties";
        PropertiesConfiguration prop = new PropertiesConfiguration(propFileName);

        // set the properties value
        prop.setProperty("Login", cmbOrderTimer.getSelectedItem().toString());

        prop.save();

    } catch (ConfigurationException ex) {
        Logger.getLogger(Timers.class.getName()).log(Level.SEVERE, null, ex);
    }

    JOptionPane.showMessageDialog(null, "Login updated. ");
    dispose();
}

From source file:com.jorge.propiedades.DirectorioConfiguracion.java

public DirectorioConfiguracion() {
    try {/*from  ww  w .j  a  va 2s .com*/
        PropertiesConfiguration config = new PropertiesConfiguration("./quijotelu/Directorio.properties");
        if (config.getProperty("directorio.generado") == null) {
            config.setProperty("directorio.generado", "/app/quijotelu/generado");
            config.save();
        }
        if (config.getProperty("directorio.firmado") == null) {
            config.setProperty("directorio.firmado", "/app/quijotelu/firmado");
            config.save();
        }
        if (config.getProperty("directorio.autorizado") == null) {
            config.setProperty("directorio.autorizado", "/app/quijotelu/autorizado");
            config.save();
        }
        if (config.getProperty("directorio.noautorizado") == null) {
            config.setProperty("directorio.noautorizado", "/app/quijotelu/noautorizado");
            config.save();
        }
        if (config.getProperty("directorio.pdf") == null) {
            config.setProperty("directorio.pdf", "/app/quijotelu/pdf");
            config.save();
        }
        RutaArchivoNoAutorizado = (String) config.getProperty("directorio.noautorizado");
        RutaArchivoAutorizado = (String) config.getProperty("directorio.autorizado");
        RutaArchivoFirmado = (String) config.getProperty("directorio.firmado");
        RutaArchivoGenerado = (String) config.getProperty("directorio.generado");
        RutaArchivoPDF = (String) config.getProperty("directorio.pdf");

    } catch (ConfigurationException ex) {
        Logger.getLogger(DirectorioConfiguracion.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:fr.mby.portal.coreimpl.configuration.PropertiesConfigurationManager.java

@Override
public void flushConfiguration(final String key) throws IllegalArgumentException, ConfigurationException {
    Assert.hasText(key, "No key provided !");

    final PropertiesConfiguration config = this.configurationByKey.get(key);
    if (config == null) {
        throw new IllegalArgumentException("No configuration element found for key: " + key + " !");
    }/*from  w w w .  j  a  v  a2  s.co  m*/

    config.save();
}

From source file:com.impetus.ankush.agent.action.impl.PropertyFileManipulator.java

/**
 * Delete conf value./*from w w w  .  j  a  v a 2  s .  c  o  m*/
 * 
 * @param file
 *            the file
 * @param propertyName
 *            the property name
 * @return true, if successful
 */
@Override
public boolean deleteConfValue(String file, String propertyName) {
    boolean status = false;
    try {
        // read conf file
        File confFile = new File(file);

        if (!confFile.exists()) {
            System.err.println("File " + file + " does not exists.");
            status = false;
        }
        PropertiesConfiguration props = new PropertiesConfiguration(file);
        props.getLayout().setSeparator(propertyName, "=");
        if (props.getProperty(propertyName) != null) {
            props.clearProperty(propertyName);
            props.save();
            status = true;
        }
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    return status;

}

From source file:com.akman.enjoyfood.SelectPrinters.java

private void btnContinueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnContinueActionPerformed
    if (tblPrinters.getSelectedRow() != -1) {
        int row = tblPrinters.getSelectedRow();
        if (tblPrinters.getValueAt(row, 1) == "Offline") {
            JOptionPane.showMessageDialog(null, "Printer is Offline", "Offine error",
                    JOptionPane.ERROR_MESSAGE);
        } else {//from w w  w.  j a  va  2s.  com

        }

        Printer printer = (Printer) tblPrinters.getValueAt(row, 0);

        try {
            String propFileName = "config.properties";
            PropertiesConfiguration prop = new PropertiesConfiguration(propFileName);
            prop.setProperty("Printer", printer.getName());
            prop.save();

        } catch (ConfigurationException ex) {

        }

        this.dispose();

        if (order == null) {

        } else {
            order.setPrinter(printer);
            order.run();
        }

    }
}

From source file:com.jorge.db.Instrucciones.java

public Instrucciones() {
    try {//from ww  w  .  j  av a  2  s.c o  m
        PropertiesConfiguration config = new PropertiesConfiguration("./quijotelu/Respuesta.properties");
        if (config.getProperty("respuesta.VerificaComprobante") == null) {
            config.setProperty("respuesta.VerificaComprobante",
                    "SELECT count(*) FROM ELE_DOCUMENTO_ELECTRONICO");
            config.save();
        }
        if (config.getProperty("respuesta.InsertaComprobante") == null) {
            config.setProperty("respuesta.InsertaComprobante",
                    "INSERT INTO ELE_DOCUMENTO_ELECTRONICO(ID,CODIGO,NUMERO,NUMERO_AUTORIZACION,FECHA_AUTORIZACION,OBSERVACION,ESTADO) VALUES (S_ELE_DOCUMENTO_ELECTRONICO.NEXTVAL,?,?,?,?,?,?)");
            config.save();
        }
        if (config.getProperty("respuesta.ActualizaComprobante") == null) {
            config.setProperty("respuesta.ActualizaComprobante",
                    "UPDATE ELE_DOCUMENTO_ELECTRONICO SET NUMERO_AUTORIZACION=?,FECHA_AUTORIZACION=?,OBSERVACION=?,ESTADO=? WHERE CODIGO=? AND NUMERO=?");
            config.save();
        }
        if (config.getProperty("respuesta.CorreoAlternativo") == null) {
            config.setProperty("respuesta.CorreoAlternativo",
                    "SELECT MAIL_ALTERNATIVO FROM V_INFO_CORREO_ALTERNATIVO where DOCUMENTO=?");
            config.save();
        }
        verificarComprobante = config.getProperty("respuesta.VerificaComprobante").toString().replace("[", "")
                .replace("]", "");
        insertaComprobante = config.getProperty("respuesta.InsertaComprobante").toString().replace("[", "")
                .replace("]", "");
        actualizaComprobante = config.getProperty("respuesta.ActualizaComprobante").toString().replace("[", "")
                .replace("]", "");
        correoAlternativo = config.getProperty("respuesta.CorreoAlternativo").toString().replace("[", "")
                .replace("]", "");
    } catch (ConfigurationException ex) {
        Logger.getLogger(Instrucciones.class.getName()).log(Level.SEVERE, null, ex);
    }
}