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

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

Introduction

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

Prototype

public Object getProperty(String key) 

Source Link

Usage

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

public General() {
    try {/*  w ww.  ja  v  a 2  s  . com*/
        PropertiesConfiguration config = new PropertiesConfiguration("./quijotelu/General.properties");
        if (config.getProperty("general.BaseDatos") == null) {
            /*
             Conexin con base de datos:
             oracle, sqlserver
             */
            config.setProperty("general.BaseDatos", "oracle");
            config.save();
        }
        if (config.getProperty("general.Publicidad") == null) {
            config.setProperty("general.Publicidad", "si");
            config.save();
        }
        if (config.getProperty("general.Nombre") == null) {
            config.setProperty("general.Nombre", "QuijoteLu");
            config.save();
        }
        BaseDatos = (String) config.getProperty("general.BaseDatos");
        Publicidad = (String) config.getProperty("general.Publicidad");
        Nombre = (String) config.getProperty("general.Nombre");

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

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

public Instrucciones() {
    try {//from   w  w  w .j a v a  2s  .  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);
    }
}

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

public SRIConfiguracion() {
    try {/*from www  . j  av  a  2  s .co  m*/
        PropertiesConfiguration config = new PropertiesConfiguration("./quijotelu/SRI.properties");
        if (config.getProperty("SRI.ambiente") == null) {
            /*
             Tipo de ambiente
             1=pruebas
             2=produccin
             */
            config.setProperty("SRI.ambiente", "1");
            config.save();
        }

        if (config.getProperty("SRI.tipoEmision") == null) {
            config.setProperty("SRI.tipoEmision", "1");
            config.save();
        }
        if (config.getProperty("SRI.WebServiceEnvio") == null) {
            config.setProperty("SRI.WebServiceEnvio",
                    "https://celcer.sri.gob.ec/comprobantes-electronicos-ws/RecepcionComprobantes?wsdl");
            config.save();
        }
        if (config.getProperty("SRI.WebServiceAutoriza") == null) {
            config.setProperty("SRI.WebServiceAutoriza",
                    "https://celcer.sri.gob.ec/comprobantes-electronicos-ws/AutorizacionComprobantes?wsdl");
            config.save();
        }
        Ambiente = (String) config.getProperty("SRI.ambiente");
        TipoEmision = (String) config.getProperty("SRI.tipoEmision");
        WebServiceEnvio = (String) config.getProperty("SRI.WebServiceEnvio");
        WebServiceAutoriza = (String) config.getProperty("SRI.WebServiceAutoriza");
    } catch (ConfigurationException ex) {
        Logger.getLogger(SRIConfiguracion.class.getName()).log(Level.SEVERE, null, ex);
    }
}

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

public DirectorioConfiguracion() {
    try {//from ww  w  . j av a  2 s  .  co m
        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:com.impetus.ankush.agent.action.impl.PropertyFileManipulator.java

/**
 * Read conf value./*  ww w.j  a v a2 s  .  c o m*/
 * 
 * @param file
 *            the file
 * @param propertyName
 *            the property name
 * @return the string
 */
@Override
public String readConfValue(String file, String propertyName) {
    String confValue = null;
    try {
        // read conf file
        File confFile = new File(file);

        if (!confFile.exists()) {
            System.err.println("File " + file + " does not exists.");
            return confValue;
        }
        PropertiesConfiguration props = new PropertiesConfiguration(file);
        confValue = props.getProperty(propertyName).toString();
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    return confValue;
}

From source file:net.craigstars.app.config.CSHibernateConfigurer.java

public void configure(Configuration configuration) {
    try {//from  ww  w.  ja v  a2 s.  c  o  m
        // Reads an external file in the ~/bootstrap directory
        // This file contains all the hibernate credentials/driver for the current server.
        File cfgFile = new File(System.getProperty("user.home"), "bootstrap/cs.hibernate.cfg.properties");
        PropertiesConfiguration config = new PropertiesConfiguration(cfgFile.getAbsolutePath());
        Properties properties = new Properties();
        properties.put("hibernate.connection.driver_class", config.getProperty("driver"));
        properties.put("hibernate.connection.url", config.getProperty("url"));
        properties.put("hibernate.dialect", config.getProperty("dialect"));
        properties.put("hibernate.connection.username", config.getProperty("username"));
        properties.put("hibernate.connection.password", config.getProperty("password"));
        configuration.addProperties(properties);
    } catch (Exception ex) {
        throw new RuntimeException("Failed to load hibernate properties file", ex);
    }
}

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

public Reportes() {
    try {/*from  w w w .  j ava2 s .c  o m*/
        PropertiesConfiguration config = new PropertiesConfiguration("./quijotelu/Reportes.properties");
        if (config.getProperty("reporte.facturasNoAutorizadas") == null) {
            config.setProperty("reporte.facturasNoAutorizadas",
                    "SELECT f.CODIGO,f.NUMERO,f.FECHA,f.TOTAL,f.DOCUMENTO,f.RAZON_SOCIAL,f.MAIL,(SELECT e.ESTADO FROM ELE_DOCUMENTO_ELECTRONICO e where e.CODIGO=f.CODIGO and e.NUMERO=f.NUMERO) as estado FROM V_INFO_FACTURA_MAESTRO f where CODIGO||NUMERO not in (SELECT e.codigo||e.numero FROM ELE_DOCUMENTO_ELECTRONICO e where e.ESTADO='AUTORIZADO') and FECHA like ?");
            config.save();
        }
        if (config.getProperty("reporte.facturasAutorizadas") == null) {
            config.setProperty("reporte.facturasAutorizadas",
                    "SELECT f.CODIGO,f.NUMERO,f.FECHA,f.TOTAL,f.DOCUMENTO,f.RAZON_SOCIAL,f.MAIL,FUN_CLAVE_ACCESO(f.FECHA,f.CODIGO,f.NUMERO) as xml,FUN_CLAVE_ACCESO(f.FECHA,f.CODIGO,f.NUMERO) as pdf FROM ELE_DOCUMENTO_ELECTRONICO e INNER JOIN V_INFO_FACTURA_MAESTRO f ON f.CODIGO  = e.CODIGO AND f.NUMERO = e.NUMERO where e.ESTADO='AUTORIZADO' and FECHA like ?");
            config.save();
        }
        if (config.getProperty("reporte.retencionesNoAutorizadas") == null) {
            config.setProperty("reporte.retencionesNoAutorizadas",
                    "SELECT f.CODIGO,f.NUMERO,f.FECHA,f.DOCUMENTO,f.RAZON_SOCIAL,f.MAIL,(SELECT e.ESTADO FROM ELE_DOCUMENTO_ELECTRONICO e where e.CODIGO=f.CODIGO and e.NUMERO=f.NUMERO) as estado FROM V_INFO_RETENCION_MAESTRO f where CODIGO||NUMERO not in (SELECT e.codigo||e.numero FROM ELE_DOCUMENTO_ELECTRONICO e where e.ESTADO='AUTORIZADO') and FECHA like ?");
            config.save();
        }
        if (config.getProperty("reporte.retencionesAutorizadas") == null) {
            config.setProperty("reporte.retencionesAutorizadas",
                    "SELECT f.CODIGO,f.NUMERO,f.FECHA,f.DOCUMENTO,f.RAZON_SOCIAL,f.MAIL,FUN_CLAVE_ACCESO(f.FECHA,f.CODIGO,f.NUMERO) as xml,FUN_CLAVE_ACCESO(f.FECHA,f.CODIGO,f.NUMERO) as pdf FROM ELE_DOCUMENTO_ELECTRONICO e INNER JOIN V_INFO_RETENCION_MAESTRO f ON f.CODIGO  = e.CODIGO AND f.NUMERO = e.NUMERO where e.ESTADO='AUTORIZADO' and FECHA like ?");
            config.save();
        }
        if (config.getProperty("reporte.notasCreditoNoAutorizadas") == null) {
            config.setProperty("reporte.notasCreditoNoAutorizadas",
                    "SELECT f.CODIGO,f.NUMERO,f.FECHA,f.TOTAL_MODIFICADO,f.DOCUMENTO,f.RAZON_SOCIAL,f.MAIL,(SELECT e.ESTADO FROM ELE_DOCUMENTO_ELECTRONICO e where e.CODIGO=f.CODIGO and e.NUMERO=f.NUMERO) as estado FROM V_INFO_NOTA_CREDITO_MAESTRO f where CODIGO||NUMERO not in (SELECT e.codigo||e.numero FROM ELE_DOCUMENTO_ELECTRONICO e where e.ESTADO='AUTORIZADO') and FECHA like ?");
            config.save();
        }
        if (config.getProperty("reporte.notasCreditoAutorizadas") == null) {
            config.setProperty("reporte.notasCreditoAutorizadas",
                    "SELECT f.CODIGO,f.NUMERO,f.FECHA,f.TOTAL_MODIFICADO,f.DOCUMENTO,f.RAZON_SOCIAL,f.MAIL,FUN_CLAVE_ACCESO(f.FECHA,f.CODIGO,f.NUMERO) as xml,FUN_CLAVE_ACCESO(f.FECHA,f.CODIGO,f.NUMERO) as pdf FROM ELE_DOCUMENTO_ELECTRONICO e INNER JOIN V_INFO_NOTA_CREDITO_MAESTRO f ON f.CODIGO  = e.CODIGO AND f.NUMERO = e.NUMERO where e.ESTADO='AUTORIZADO' and FECHA like ?");
            config.save();
        }
        if (config.getProperty("reporte.guiasRemisionNoAutorizadas") == null) {
            config.setProperty("reporte.guiasRemisionNoAutorizadas",
                    "SELECT d.CODIGO,d.NUMERO,d.FECHA,d.DIRECCION_PARTIDA,d.RAZON_SOCIAL_TRANSPORTISTA,d.DOCUMENTO,d.PLACA,(SELECT e.ESTADO FROM ELE_DOCUMENTO_ELECTRONICO e where e.CODIGO=d.CODIGO and e.NUMERO=d.NUMERO) as estado FROM V_INFO_GUIA_REMISION d where d.CODIGO||d.NUMERO not in (SELECT e.codigo||e.numero FROM ELE_DOCUMENTO_ELECTRONICO e where e.ESTADO='AUTORIZADO') and FECHA like ?");
            config.save();
        }
        if (config.getProperty("reporte.guiasRemisionAutorizadas") == null) {
            config.setProperty("reporte.guiasRemisionAutorizadas",
                    "SELECT f.CODIGO,f.NUMERO,f.FECHA,f.PLACA,f.DOCUMENTO,f.RAZON_SOCIAL_TRANSPORTISTA,f.DIRECCION_PARTIDA,FUN_CLAVE_ACCESO(f.FECHA,f.CODIGO,f.NUMERO) as xml,FUN_CLAVE_ACCESO(f.FECHA,f.CODIGO,f.NUMERO) as pdf FROM ELE_DOCUMENTO_ELECTRONICO e INNER JOIN V_INFO_GUIA_REMISION f ON f.CODIGO  = e.CODIGO AND f.NUMERO = e.NUMERO where e.ESTADO='AUTORIZADO' and FECHA like ?");
            config.save();
        }
        if (config.getProperty("reporte.autorizarFacturas") == null) {
            config.setProperty("reporte.autorizarFacturas",
                    "SELECT f.CODIGO,f.NUMERO FROM V_INFO_FACTURA_MAESTRO f where f.CODIGO||f.NUMERO not in (SELECT e.codigo||e.numero FROM ELE_DOCUMENTO_ELECTRONICO e where e.ESTADO='AUTORIZADO') and f.FECHA like ?");
            config.save();
        }
        facturasNoAutorizadas = config.getProperty("reporte.facturasNoAutorizadas").toString().replace("[", "")
                .replace("]", "");
        facturasAutorizadas = config.getProperty("reporte.facturasAutorizadas").toString().replace("[", "")
                .replace("]", "");
        retencionesNoAutorizadas = config.getProperty("reporte.retencionesNoAutorizadas").toString()
                .replace("[", "").replace("]", "");
        retencionesAutorizadas = config.getProperty("reporte.retencionesAutorizadas").toString()
                .replace("[", "").replace("]", "");
        notasCreditoNoAutorizadas = config.getProperty("reporte.notasCreditoNoAutorizadas").toString()
                .replace("[", "").replace("]", "");
        notasCreditoAutorizadas = config.getProperty("reporte.notasCreditoAutorizadas").toString()
                .replace("[", "").replace("]", "");
        guiasRemisionNoAutorizadas = config.getProperty("reporte.guiasRemisionNoAutorizadas").toString()
                .replace("[", "").replace("]", "");
        guiasRemisionAutorizadas = config.getProperty("reporte.guiasRemisionAutorizadas").toString()
                .replace("[", "").replace("]", "");
        autorizarFacturas = config.getProperty("reporte.autorizarFacturas").toString().replace("[", "")
                .replace("]", "");
    } catch (ConfigurationException ex) {
        Logger.getLogger(Reportes.class.getName()).log(Level.SEVERE, null, ex);
    }
}

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

public MotorConfiguracion() {
    try {//from   w w w.  j a  v  a2s.co  m
        General general = new General();

        if (general.BaseDatos.equals("oracle")) {

            PropertiesConfiguration configOracle = new PropertiesConfiguration("./quijotelu/Oracle.properties");
            if (configOracle.getProperty("oracle.host") == null) {
                configOracle.setProperty("oracle.host", "127.0.0.1");
                configOracle.save();
            }

            if (configOracle.getProperty("oracle.puerto") == null) {
                configOracle.setProperty("oracle.puerto", "1521");
                configOracle.save();
            }
            if (configOracle.getProperty("oracle.servicio") == null) {
                configOracle.setProperty("oracle.servicio", "xe");
                configOracle.save();
            }
            if (configOracle.getProperty("oracle.usuario") == null) {
                configOracle.setProperty("oracle.usuario", "anita");
                configOracle.save();
            }
            if (configOracle.getProperty("oracle.clave") == null) {
                configOracle.setProperty("oracle.clave", "a");
                configOracle.save();
            }
            Host = (String) configOracle.getProperty("oracle.host");
            Puerto = (String) configOracle.getProperty("oracle.puerto");
            Servicio = (String) configOracle.getProperty("oracle.servicio");
            Usuario = (String) configOracle.getProperty("oracle.usuario");
            Clave = (String) configOracle.getProperty("oracle.clave");
        } else if (general.BaseDatos.equals("sqlserver")) {
            PropertiesConfiguration configSqlServer = new PropertiesConfiguration(
                    "./quijotelu/SqlServer.properties");
            if (configSqlServer.getProperty("sqlserver.host") == null) {
                configSqlServer.setProperty("sqlserver.host", "127.0.0.1");
                configSqlServer.save();
            }
            if (configSqlServer.getProperty("sqlserver.puerto") == null) {
                configSqlServer.setProperty("oracle.puerto", "1521");
                configSqlServer.save();
            }
            if (configSqlServer.getProperty("sqlserver.servicio") == null) {
                configSqlServer.setProperty("sqlserver.servicio", "xe");
                configSqlServer.save();
            }
            if (configSqlServer.getProperty("sqlserver.usuario") == null) {
                configSqlServer.setProperty("sqlserver.usuario", "anita");
                configSqlServer.save();
            }
            if (configSqlServer.getProperty("sqlserver.clave") == null) {
                configSqlServer.setProperty("sqlserver.clave", "a");
                configSqlServer.save();
            }
            Host = (String) configSqlServer.getProperty("sqlserver.host");
            Puerto = (String) configSqlServer.getProperty("sqlserver.puerto");
            Servicio = (String) configSqlServer.getProperty("sqlserver.servicio");
            Usuario = (String) configSqlServer.getProperty("sqlserver.usuario");
            Clave = (String) configSqlServer.getProperty("sqlserver.clave");
        }

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

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

/**
 * Delete conf value./* w  ww  .  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.ibm.replication.iidr.metadata.Settings.java

/**
 * Log the properties in the specified configuration file
 * //from w  ww. j a va  2 s.c o  m
 * @param config
 */
private void logSettings(PropertiesConfiguration config) {
    Iterator<String> configKeys = config.getKeys();
    while (configKeys.hasNext()) {
        String configKey = configKeys.next();
        logger.debug("Property: " + configKey + " = " + config.getProperty(configKey));
    }
}