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

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

Introduction

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

Prototype

public void setProperty(String key, Object value) 

Source Link

Document

Sets a new value for the specified property.

Usage

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

public SRIConfiguracion() {
    try {/*from w w w. j a  v a  2s  . c  o  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.mirth.connect.model.DatabaseSettings.java

@Override
public Properties getProperties() {
    PropertiesConfiguration configuration = new PropertiesConfiguration();

    if (getDirBase() != null) {
        configuration.setProperty(DIR_BASE, getDirBase());
    }// w  w  w.j  a va  2 s.  co m

    if (getDatabase() != null) {
        configuration.setProperty(DATABASE, getDatabase());
    }

    if (getDatabaseUrl() != null) {
        configuration.setProperty(DATABASE_URL, getDatabaseUrl());
    }

    if (getMappedDatabaseDriver() != null) {
        configuration.setProperty(DATABASE_DRIVER, getMappedDatabaseDriver());
    }

    if (getDatabasePool() != null) {
        configuration.setProperty(DATABASE_POOL, getDatabasePool());
    }

    if (getMappedJdbc4() != null) {
        configuration.setProperty(DATABASE_JDBC4, getMappedJdbc4());
    }

    if (getMappedTestQuery() != null) {
        configuration.setProperty(DATABASE_TEST_QUERY, getMappedTestQuery());
    }

    /*
     * MIRTH-1749: in case someone comments out the username and password properties
     */
    if (getDatabaseUsername() != null) {
        configuration.setProperty(DATABASE_USERNAME, getDatabaseUsername());
    } else {
        configuration.setProperty(DATABASE_USERNAME, StringUtils.EMPTY);
    }

    if (getDatabasePassword() != null) {
        configuration.setProperty(DATABASE_PASSWORD, getDatabasePassword());
    } else {
        configuration.setProperty(DATABASE_PASSWORD, StringUtils.EMPTY);
    }

    if (getDatabaseMaxConnections() != null) {
        configuration.setProperty(DATABASE_MAX_CONNECTIONS, getDatabaseMaxConnections().toString());
    } else {
        configuration.setProperty(DATABASE_MAX_CONNECTIONS, StringUtils.EMPTY);
    }

    if (getDatabaseTestIdleTime() != null) {
        configuration.setProperty(DATABASE_TEST_IDLE_TIME, getDatabaseTestIdleTime().toString());
    } else {
        configuration.setProperty(DATABASE_TEST_IDLE_TIME, "10000");
    }

    return ConfigurationConverter.getProperties(configuration);
}

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

public Consultas() {
    try {/*from   www.  j a v a  2s. c  om*/
        PropertiesConfiguration config = new PropertiesConfiguration("./quijotelu/Consultas.properties");
        if (config.getProperty("consulta.InformacionTributaria") == null) {
            config.setProperty("consulta.InformacionTributaria",
                    "SELECT RAZON_SOCIAL,NOMBRE_COMERCIAL,RUC,DIRECCION,OBLIGADO_CONTABILIDAD,CONTRIBUYENTE_ESPECIAL FROM V_INFO_TRIBUTARIA");
            config.save();
        }
        if (config.getProperty("consulta.FacturaMaestro") == null) {
            config.setProperty("consulta.FacturaMaestro",
                    "SELECT CODIGO,NUMERO,CODIGO_DOCUMENTO,ESTABLECIMIENTO,PUNTO_EMISION,SECUENCIAL,FECHA,TOTAL_SIN_IVA,TOTAL_CON_IVA,IVA,DESCUENTOS,TOTAL,ESTADO,TIPO_DOCUMENTO,DOCUMENTO,RAZON_SOCIAL,DIRECCION,TELEFONO,MAIL,GUIA_REMISION FROM V_INFO_FACTURA_MAESTRO");
            config.save();
        }
        if (config.getProperty("consulta.FacturaDetalle") == null) {
            config.setProperty("consulta.FacturaDetalle",
                    "SELECT CODIGO_PRINCIPAL,DESCRIPCION,CANTIDAD,PRECIO_UNITARIO,CODIGO_PORCENTAJE,PORCENTAJE_IVA,VALOR_IVA,DESCUENTO,PRECIO_TOTAL_SIN_IMPUESTO FROM V_INFO_FACTURA_DETALLE");
            config.save();
        }
        if (config.getProperty("consulta.RetencionMaestro") == null) {
            config.setProperty("consulta.RetencionMaestro",
                    "SELECT CODIGO,NUMERO,CODIGO_DOCUMENTO,ESTABLECIMIENTO,PUNTO_EMISION,SECUENCIAL,FECHA,TIPO_DOCUMENTO,DOCUMENTO,RAZON_SOCIAL,PERIODO_FISCAL,DIRECCION,TELEFONO,MAIL FROM V_INFO_RETENCION_MAESTRO");
            config.save();
        }
        if (config.getProperty("consulta.RetencionDetalle") == null) {
            config.setProperty("consulta.RetencionDetalle",
                    "select CODIGO,NUMERO,TIPO,CODIGO_SRI,BASE_IMPONIBLE,PORCENTAJE,VALOR_RETENIDO,TIPO_COMPROBANTE,NUMERO_COMPROBANTE,FECHA_COMPROBANTE from V_INFO_RETENCION_DETALLE");
            config.save();
        }
        if (config.getProperty("consulta.NotaCreditoMaestro") == null) {
            config.setProperty("consulta.NotaCreditoMaestro",
                    "SELECT CODIGO,NUMERO,CODIGO_DOCUMENTO,ESTABLECIMIENTO,PUNTO_EMISION,SECUENCIAL,FECHA,TIPO_DOCUMENTO,RAZON_SOCIAL,DOCUMENTO,DOCUMENTO_MODIFICADO,MODIFICADO,FECHA_MODIFICADO,TOTAL_SIN_IMPUESTOS,TOTAL_MODIFICADO,TOTAL_SIN_IVA,TOTAL_CON_IVA,IVA,MOTIVO,DIRECCION,TELEFONO,MAIL FROM V_INFO_NOTA_CREDITO_MAESTRO");
            config.save();
        }
        if (config.getProperty("consulta.NotaCreditoDetalle") == null) {
            config.setProperty("consulta.NotaCreditoDetalle",
                    "SELECT CODIGO,NUMERO,CODIGO_INTERNO,DESCRIPCION,CANTIDAD,PRECIO_UNITARIO,DESCUENTO,PRECIO_TOTAL_SIN_IMPUESTO,CODIGO_PORCENTAJE,PORCENTAJE_IVA,VALOR_IVA from V_INFO_NOTA_CREDITO_DETALLE");
            config.save();
        }
        if (config.getProperty("consulta.NotaDebitoMaestro") == null) {
            config.setProperty("consulta.NotaDebitoMaestro",
                    "SELECT CODIGO,NUMERO,CODIGO_DOCUMENTO,ESTABLECIMIENTO,PUNTO_EMISION,SECUENCIAL,FECHA,TIPO_DOCUMENTO,RAZON_SOCIAL,DOCUMENTO,DOCUMENTO_MODIFICADO,MODIFICADO,FECHA_MODIFICADO,TOTAL_SIN_IMPUESTOS,DIRECCION,TELEFONO,MAIL FROM V_INFO_NOTA_DEBITO_MAESTRO");
            config.save();
        }
        if (config.getProperty("consulta.NotaDebitoDetalle") == null) {
            config.setProperty("consulta.NotaDebitoDetalle",
                    "SELECT CODIGO, NUMERO, MOTIVO, VALOR FROM V_INFO_NOTA_DEBITO_DETALLE");
            config.save();
        }
        if (config.getProperty("consulta.GuiaRemision") == null) {
            config.setProperty("consulta.GuiaRemision",
                    "SELECT CODIGO,NUMERO,CODIGO_DOCUMENTO,ESTABLECIMIENTO,PUNTO_EMISION,SECUENCIAL,FECHA,DIRECCION_PARTIDA,RAZON_SOCIAL_TRANSPORTISTA,TIPO_DOCUMENTO,DOCUMENTO,PLACA FROM V_INFO_GUIA_REMISION");
            config.save();
        }
        if (config.getProperty("consulta.Destinatario") == null) {
            config.setProperty("consulta.Destinatario",
                    "SELECT CODIGO,NUMERO,DOCUMENTO,RAZON_SOCIAL,DIRECCION,MOTIVO_TRASLADO FROM V_INFO_DESTINATARIO");
            config.save();
        }
        if (config.getProperty("consulta.DestinatarioDetalle") == null) {
            config.setProperty("consulta.DestinatarioDetalle",
                    "SELECT CODIGO,NUMERO,DOCUMENTO,CODIGO_ARTICULO,NOMBRE_ARTICULO,CANTIDAD FROM V_INFO_DESTINATARIO_DETALLE");
            config.save();
        }
        if (config.getProperty("consulta.GuiaRemisionFactura") == null) {
            config.setProperty("consulta.GuiaRemisionFactura",
                    "SELECT CODIGO,NUMERO,CODIGO_FACTURA,NUMERO_FACTURA FROM V_INFO_GUIA_REMISION_FACTURA");
            config.save();
        }
        if (config.getProperty("consulta.FormaPago") == null) {
            config.setProperty("consulta.FormaPago",
                    "SELECT FACTURA,CODIGO,FORMA_PAGO,PLAZO,TIEMPO FROM V_FORMA_PAGO_FACTURA");
            config.save();
        }
        if (config.getProperty("consulta.FacturaPorcentajeIva") == null) {
            config.setProperty("consulta.FacturaPorcentajeIva",
                    "SELECT CODIGO,NUMERO,PORCENTAJE_IVA FROM V_INFO_FACTURA_PORCENTAJE_IVA");
            config.save();
        }
        InformacionTributaria = config.getProperty("consulta.InformacionTributaria").toString().replace("[", "")
                .replace("]", "");
        FacturaMaestro = config.getProperty("consulta.FacturaMaestro").toString().replace("[", "").replace("]",
                "");
        FacturaDetalle = config.getProperty("consulta.FacturaDetalle").toString().replace("[", "").replace("]",
                "");
        RetencionMaestro = config.getProperty("consulta.RetencionMaestro").toString().replace("[", "")
                .replace("]", "");
        RetencionDetalle = config.getProperty("consulta.RetencionDetalle").toString().replace("[", "")
                .replace("]", "");
        NotaCreditoMaestro = config.getProperty("consulta.NotaCreditoMaestro").toString().replace("[", "")
                .replace("]", "");
        NotaCreditoDetalle = config.getProperty("consulta.NotaCreditoDetalle").toString().replace("[", "")
                .replace("]", "");
        NotaDebitoMaestro = config.getProperty("consulta.NotaDebitoMaestro").toString().replace("[", "")
                .replace("]", "");
        NotaDebitoDetalle = config.getProperty("consulta.NotaDebitoDetalle").toString().replace("[", "")
                .replace("]", "");
        GuiaRemision = config.getProperty("consulta.GuiaRemision").toString().replace("[", "").replace("]", "");
        Destinatario = config.getProperty("consulta.Destinatario").toString().replace("[", "").replace("]", "");
        DestinatarioDetalle = config.getProperty("consulta.DestinatarioDetalle").toString().replace("[", "")
                .replace("]", "");
        GuiaRemisionFactura = config.getProperty("consulta.GuiaRemisionFactura").toString().replace("[", "")
                .replace("]", "");
        FormaPago = config.getProperty("consulta.FormaPago").toString().replace("[", "").replace("]", "");
        FacturaPorcentajeIva = config.getProperty("consulta.FacturaPorcentajeIva").toString().replace("[", "")
                .replace("]", "");
        //System.out.print("InformacionTributaria "+InformacionTributaria);
    } catch (ConfigurationException ex) {
        Logger.getLogger(Consultas.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.manydesigns.portofino.actions.admin.mail.MailSettingsAction.java

@Button(list = "settings", key = "update", order = 1, type = Button.TYPE_PRIMARY)
public Resolution update() {
    setupFormAndBean();/*from   w w w  .j ava  2 s .  c o m*/
    form.readFromRequest(context.getRequest());
    if (form.validate()) {
        logger.debug("Applying settings to app configuration");
        try {
            // mail configuration = portofino configuration + mail.properties defaults
            // CompositeConfiguration compositeConfiguration = (CompositeConfiguration) portofinoConfiguration;
            // FileConfiguration fileConfiguration = (FileConfiguration) compositeConfiguration.getConfiguration(0);
            // SUPERPAN ADD
            PropertiesConfiguration fileConfiguration = (PropertiesConfiguration) portofinoConfiguration;

            MailSettingsForm bean = new MailSettingsForm();
            form.writeToObject(bean);
            fileConfiguration.setProperty(MailProperties.MAIL_ENABLED, bean.mailEnabled);
            fileConfiguration.setProperty(MailProperties.MAIL_KEEP_SENT, bean.keepSent);
            fileConfiguration.setProperty(MailProperties.MAIL_QUEUE_LOCATION, bean.queueLocation);
            fileConfiguration.setProperty(MailProperties.MAIL_SMTP_HOST, bean.smtpHost);
            fileConfiguration.setProperty(MailProperties.MAIL_SMTP_PORT, bean.smtpPort);
            fileConfiguration.setProperty(MailProperties.MAIL_SMTP_SSL_ENABLED, bean.smtpSSL);
            fileConfiguration.setProperty(MailProperties.MAIL_SMTP_TLS_ENABLED, bean.smtpTLS);
            fileConfiguration.setProperty(MailProperties.MAIL_SMTP_LOGIN, bean.smtpLogin);
            fileConfiguration.setProperty(MailProperties.MAIL_SMTP_PASSWORD, bean.smtpPassword);
            fileConfiguration.save();
            logger.info("Configuration saved to " + fileConfiguration.getFile().getAbsolutePath());
        } catch (Exception e) {
            logger.error("Configuration not saved", e);
            SessionMessages
                    .addErrorMessage(ElementsThreadLocals.getText("the.configuration.could.not.be.saved"));
            return new ForwardResolution("/m/mail/admin/settings.jsp");
        }
        SessionMessages.addInfoMessage(ElementsThreadLocals.getText("configuration.updated.successfully"));
        return new RedirectResolution(this.getClass());
    } else {
        return new ForwardResolution("/m/mail/admin/settings.jsp");
    }
}

From source file:firmadigital.Parametros.java

private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
    try {//from  w  w  w. ja  v  a 2 s.  c om
        PropertiesConfiguration config = new PropertiesConfiguration("FirmaDigital.properties");
        if (config.getProperty("web.web_service") == null) {
            config.setProperty("web.web_service",
                    "https://celcer.sri.gob.ec/comprobantes-electronicos-ws/RecepcionComprobantes?wsdl");
            config.save();
        }

        if (config.getProperty("certificado.almacen") == null) {
            config.setProperty("certificado.almacen",
                    System.getProperty("java.home") + File.separator + "lib\\security\\cacerts");
            config.save();
        }
        if (config.getProperty("certificado.direccion") == null) {
            config.setProperty("certificado.direccion",
                    System.getProperty("user.home") + File.separator + "Certificado");
            config.save();
        }
        txtUbicacionAlmacenCertificado.setText((String) config.getProperty("certificado.almacen"));
        txtWebService.setText((String) config.getProperty("web.web_service"));
        txtCertificado.setText(config.getProperty("certificado.direccion").toString());
    } catch (ConfigurationException ex) {
        Logger.getLogger(Parametros.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.linkedin.pinot.tools.segment.converter.DictionaryToRawIndexConverter.java

/**
 * Helper method to update the metadata.properties for the converted segment.
 *
 * @param segmentDir Segment directory//from w  w  w.  ja v a 2  s.com
 * @param columns Converted columns
 * @param tableName New table name to be written in the meta-data. Skipped if null.
 * @throws IOException
 * @throws ConfigurationException
 */
private void updateMetadata(File segmentDir, String[] columns, String tableName)
        throws IOException, ConfigurationException {
    File metadataFile = new File(segmentDir, V1Constants.MetadataKeys.METADATA_FILE_NAME);
    PropertiesConfiguration properties = new PropertiesConfiguration(metadataFile);

    if (tableName != null) {
        properties.setProperty(V1Constants.MetadataKeys.Segment.TABLE_NAME, tableName);
    }

    for (String column : columns) {
        properties.setProperty(V1Constants.MetadataKeys.Column.getKeyFor(column,
                V1Constants.MetadataKeys.Column.HAS_DICTIONARY), false);
        properties.setProperty(V1Constants.MetadataKeys.Column.getKeyFor(column,
                V1Constants.MetadataKeys.Column.BITS_PER_ELEMENT), -1);
    }
    properties.save();
}

From source file:eu.tango.energymodeller.energypredictor.AveragePowerEnergyPredictor.java

/**
 * This creates a new average power energy predictor. The predictor when
 * running takes the last power reading and makes the assumption no change
 * will occur. An observation time window is used for taking the measurement,
 * which is set via a configuration file.
 * @param config The config to use in order to create the abstract energy
 * predictor.//w ww .  j  av a  2 s .c om
 */
public AveragePowerEnergyPredictor(PropertiesConfiguration config) {
    super(config);
    powerObservationTimeMin = config.getInt("energy.modeller.energy.predictor.cpu.utilisation.observe_time.min",
            powerObservationTimeMin);
    config.setProperty("energy.modeller.energy.predictor.cpu.utilisation.observe_time.min",
            powerObservationTimeMin);
    powerObservationTimeSec = config.getInt("energy.modeller.energy.predictor.cpu.utilisation.observe_time.sec",
            powerObservationTimeSec);
    config.setProperty("energy.modeller.energy.predictor.cpu.utilisation.observe_time.sec",
            powerObservationTimeSec);
    observationTime = powerObservationTimeSec + (int) TimeUnit.MINUTES.toSeconds(powerObservationTimeMin);
}

From source file:com.github.zdsiyan.maven.plugin.smartconfig.internal.PropertyConfigurator.java

@Override
public ByteArrayOutputStream execute(InputStream in, Charset charset, List<PointHandle> pointhandles)
        throws IOException {
    try {/*from ww  w. ja v a  2  s . c  om*/
        PropertiesConfiguration configuration = new PropertiesConfiguration();
        configuration.load(in, charset.name());

        pointhandles.forEach(point -> {
            switch (point.getMode()) {
            case insert:
                configuration.addProperty(point.getExpression(), point.getValue());
                break;
            case delete:
                configuration.setProperty(point.getExpression(), "");
                break;
            case replace:
            default:
                configuration.setProperty(point.getExpression(), point.getValue());
                break;
            }
        });

        // output
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        configuration.save(out, charset.name());
        return out;
    } catch (ConfigurationException ex) {
        // FIXME
        throw new RuntimeException(ex);
    }
}

From source file:com.ariht.maven.plugins.config.ConfigProcessorMojo.java

/**
 * Filter files contain the properties we wish to substitute in templates.
 *
 * Uses Apache Commons Configuration to load filters.
 *//* ww  w . ja  v  a2  s  . c o  m*/
private Properties readFilterIntoProperties(final FileInfo filter) throws ConfigurationException {
    final PropertiesConfiguration config = new PropertiesConfiguration(filter.getFile());
    config.setEncoding(encoding);
    // Add one more property:   filter.source=/relative/sub/dir/filenameNoExtension
    final String filterSource = filter.getRelativeSubDirectory() + filter.getNameWithoutExtension();
    config.setProperty("filter.source", FilenameUtils.separatorsToUnix(filterSource));
    return ConfigurationConverter.getProperties(config);
}

From source file:cross.datastructures.pipeline.CommandPipeline.java

@Override
public void before() {
    if (getExecutionServer() == null && !getWorkflow().isExecuteLocal()) {
        log.info("Launching execution infrastructure!");
        setExecutionServer(ComputeServerFactory.getComputeServer());
        File computeHostJarLocation = new File(System.getProperty("maltcms.home"), "maltcms.jar");
        if (!computeHostJarLocation.exists() || !computeHostJarLocation.isFile()) {
            throw new ExitVmException("Could not locate maltcms.jar in " + System.getProperty("maltcms.home"));
        }/*from ww w.java2 s.  c  om*/
        final PropertiesConfiguration cfg = new PropertiesConfiguration();
        //set execution type
        cfg.setProperty(ConfigurationKeys.KEY_EXECUTION_MODE, ExecutionType.DRMAA);
        //set location of compute host jar
        cfg.setProperty(ConfigurationKeys.KEY_PATH_TO_COMPUTEHOST_JAR, computeHostJarLocation);
        //exit to console when master server shuts down
        cfg.setProperty(ConfigurationKeys.KEY_MASTER_SERVER_EXIT_ON_SHUTDOWN, true);
        //limit the number of used compute hosts
        cfg.setProperty(ConfigurationKeys.KEY_MAX_NUMBER_OF_CHOSTS,
                workflow.getConfiguration().getInt("maltcms.pipelinethreads", 1));
        //native specs for the drmaa api
        cfg.setProperty(ConfigurationKeys.KEY_NATIVE_SPEC,
                workflow.getConfiguration().getString("mpaxs.nativeSpec", ""));
        getExecutionServer().startMasterServer(cfg);
    }
    if (getWorkflow().getOutputDirectory().exists()) {
        if (getWorkflow().getOutputDirectory().listFiles().length > 0) {
            if (getWorkflow().getConfiguration().getBoolean("output.overwrite", false)) {
                log.warn(
                        "Output in location {} already exists. Option output.overwrite=true, removing previous output!");
                try {
                    FileUtils.deleteDirectory(getWorkflow().getOutputDirectory());
                } catch (IOException ex) {
                    throw new RuntimeException(
                            "Deletion of directory " + getWorkflow().getOutputDirectory() + " failed!", ex);
                }
                getWorkflow().getOutputDirectory().mkdirs();
            } else {
                throw new ConstraintViolationException("Output exists in " + getWorkflow().getOutputDirectory()
                        + " but output.overwrite=false. Call maltcms with -Doutput.overwrite=true to override!");
            }
        }
    }
}