Example usage for org.apache.commons.configuration Configuration getString

List of usage examples for org.apache.commons.configuration Configuration getString

Introduction

In this page you can find the example usage for org.apache.commons.configuration Configuration getString.

Prototype

String getString(String key);

Source Link

Document

Get a string associated with the given configuration key.

Usage

From source file:edu.lternet.pasta.portal.HarvestReportServlet.java

/**
 * Initialization of the servlet. <br>
 * /*from w  w w  .  java  2s  .  c om*/
 * @throws ServletException
 *             if an error occurs
 */
public void init() throws ServletException {
    Configuration options = ConfigurationListener.getOptions();
    harvesterPath = options.getString("harvester.path");

    /*
     * Purge old harvest reports
     */

    /*
     * Use default TTL value if the property was not specified or is 0 or
     * less
     */
    try {
        harvesterReportDaysToLive = options.getLong("harvester.report.daysToLive");
        if (harvesterReportDaysToLive <= 0) {
            harvesterReportDaysToLive = harvesterReportDaysToLiveDefault;
        }
    } catch (java.util.NoSuchElementException e) {
        harvesterReportDaysToLive = harvesterReportDaysToLiveDefault;
    }

    harvesterReportTTL = daysToMilliseconds(harvesterReportDaysToLive);
    executeHarvesterReportManager();
}

From source file:es.udc.gii.common.eaf.algorithm.operator.reproduction.mutation.de.mutationStrategy.DEMutationStrategy.java

public void configure(Configuration conf) {

    try {//from  w  ww . j  a va 2  s  .com
        if (conf.containsKey("F.Class")) {
            this.F_plugin = (Parameter) Class.forName(conf.getString("F.Class")).newInstance();
            this.F_plugin.configure(conf.subset("F"));
        } else {
            ConfWarning w = new ConfWarning(this.getClass().getSimpleName() + ".F",
                    this.F_plugin.getClass().getSimpleName());

            w.warn();
        }

        if (conf.containsKey("DiffVector")) {
            this.diffVector = conf.getInt("DiffVector");
        } else {
            ConfWarning w = new ConfWarning(this.getClass().getSimpleName() + ".DiffVector", this.diffVector);

            w.warn();
        }

    } catch (Exception ex) {
        throw new ConfigurationException(this.getClass(), ex);
    }

}

From source file:eu.scape_project.planning.manager.FileStorage.java

/**
 * Initializes class.//from   w  ww .  java  2 s  .  c  o  m
 */
@PostConstruct
public void init() {
    ConfigurationLoader configurationLoader = new ConfigurationLoader();

    Configuration config = configurationLoader.load();
    storagePath = config.getString("filestorage.path");

    if (storagePath != null) {
        storagePathFile = new File(storagePath);
        if (!storagePathFile.exists()) {
            if (storagePathFile.mkdirs()) {
                log.info("Storage path created and set to {}.", storagePathFile.getAbsoluteFile());
            } else {
                log.error("Storage path could not be created.");
            }
        } else {
            log.info("Storage path set to {}.", storagePathFile.getAbsoluteFile());
        }
    } else {
        log.error("Storage path not set.");
    }

    repositoryName = config.getString("filestorage.repository.name");
    if (repositoryName == null) {
        log.error("Repository name not set.");
    }
}

From source file:eu.scape_project.planning.plato.wf.ValidatePlan.java

public void deployTriggers() throws PlanningException {

    TriggerGenerator triggerGen = new TriggerGenerator();
    List<Trigger> triggers = triggerGen.generateTriggers(user.getEmail(), 24 * 3600 * 1000, plan);

    if (triggers.size() > 0) {
        try {//w  w w  .  j  a  v  a 2  s .  c om
            ConfigurationLoader configurationLoader = new ConfigurationLoader();
            Configuration config = configurationLoader.load();
            String watchEndpoint = config.getString("watch.rest.uri");
            String watchUser = config.getString("watch.rest.user");
            String watchPassword = config.getString("watch.rest.password");

            final ClientConfig cc = new DefaultClientConfig();
            cc.getClasses().add(JacksonJsonProvider.class);
            final Client clientWithJacksonSerializer = Client.create(cc);
            clientWithJacksonSerializer.addFilter(new LoggingFilter());
            clientWithJacksonSerializer.addFilter(new HTTPBasicAuthFilter(watchUser, watchPassword));
            WebResource resource = clientWithJacksonSerializer.resource(watchEndpoint);

            final AsyncRequest areq = new AsyncRequest("monitor plan: " + plan.getPlanProperties().getName(),
                    triggers);
            final AsyncRequest areq2 = resource.path(KBUtils.ASYNC_REQUEST + ".json/new")
                    .accept(MediaType.APPLICATION_JSON).post(AsyncRequest.class, areq);
        } catch (Exception e) {
            throw new PlanningException("Failed to access endpoint.", e);
        }
    } else {
        throw new PlanningException("No triggers to deploy.");
    }
}

From source file:dk.itst.oiosaml.sp.metadata.CRLChecker.java

private String getCRLUrl(Configuration conf, String entityId, X509Certificate certificate) {
    String url = conf.getString(Constants.PROP_CRL + entityId);
    log.debug("Checking CRL for " + entityId + " at " + url);
    if (url == null) {
        log.debug("No CRL configured for " + entityId + ". Set " + Constants.PROP_CRL + entityId
                + " in configuration");
        byte[] val = certificate.getExtensionValue("2.5.29.31");
        if (val != null) {
            try {
                CRLDistPoint point = CRLDistPoint.getInstance(X509ExtensionUtil.fromExtensionValue(val));
                for (DistributionPoint dp : point.getDistributionPoints()) {
                    if (dp.getDistributionPoint() == null)
                        continue;

                    if (dp.getDistributionPoint().getName() instanceof GeneralNames) {
                        GeneralNames gn = (GeneralNames) dp.getDistributionPoint().getName();
                        for (GeneralName g : gn.getNames()) {
                            if (g.getName() instanceof DERIA5String) {
                                url = ((DERIA5String) g.getName()).getString();
                            }//from  w  ww.  j a  va 2  s  .c om
                        }
                    }
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
    return url;
}

From source file:com.cisco.oss.foundation.message.HornetQMessageProducer.java

private String createQueueIfNeeded() {

    Configuration subset = configuration.subset(producerName);
    queueName = subset.getString("queue.name");

    if (StringUtils.isBlank(queueName)) {
        throw new QueueException(
                "Check Configuration - missing required queue name for producer: " + producerName);
    }/* www .j av  a  2s  .  c  o m*/

    String realQueueName = /*"foundation." + */queueName;

    //update expiration
    expiration = subset.getLong("queue.expiration", 1800000);
    groupId = subset.getString("queue.groupId", "");

    return realQueueName;
}

From source file:com.linkedin.pinot.common.utils.ClientSSLContextGenerator.java

public ClientSSLContextGenerator(Configuration sslConfig) {
    if (sslConfig.getBoolean(CONFIG_OF_ENABLE_SERVER_VERIFICATION, true)) {
        _serverCACertFile = sslConfig.getString(CONFIG_OF_SERVER_CA_CERT);
    } else {//  w w w . j  av  a2s  . c  o  m
        _serverCACertFile = null;
        LOGGER.warn("Https Server CA file not configured.. All servers will be trusted!");
    }
    _keyStoreFile = sslConfig.getString(CONFIG_OF_CLIENT_PKCS12_FILE);
    _keyStorePassword = sslConfig.getString(CONFIG_OF_CLIENT_PKCS12_PASSWORD);
    if ((_keyStorePassword == null && _keyStoreFile != null)
            || (_keyStorePassword != null && _keyStoreFile == null)) {
        throw new IllegalArgumentException("Invalid configuration of keystore file and passowrd");
    }
}

From source file:com.nesscomputing.config.AbstractTestConfig.java

@Test
public void loadStringValues() {
    Assert.assertThat(cfg, is(notNullValue()));
    final Configuration config = cfg.getConfiguration();

    Assert.assertThat(config, is(notNullValue()));

    final String s_cfg1 = config.getString("string-null-value");
    Assert.assertThat(s_cfg1, is(nullValue()));

    final String s_cfg2 = config.getString("string-value");
    Assert.assertThat(s_cfg2, is("the-test-value"));
}

From source file:com.nesscomputing.config.AbstractTestConfig.java

@Test
public void loadUriValues() {
    Assert.assertThat(cfg, is(notNullValue()));
    final Configuration config = cfg.getConfiguration();

    Assert.assertThat(config, is(notNullValue()));

    final String s_cfg1 = config.getString("uri-null-value");
    Assert.assertThat(s_cfg1, is(nullValue()));

    final String s_cfg2 = config.getString("uri-value");
    Assert.assertThat(s_cfg2, is("http://www.likeness.com/"));
}

From source file:com.nesscomputing.config.AbstractTestConfig.java

@Test
public void loadStringValues2() {
    Assert.assertThat(cfg2, is(notNullValue()));
    final Configuration config = cfg2.getConfiguration();

    Assert.assertThat(config, is(notNullValue()));

    final String s_cfg1 = config.getString("string-null-value");
    Assert.assertThat(s_cfg1, is(nullValue()));

    final String s_cfg2 = config.getString("string-value");
    Assert.assertThat(s_cfg2, is("the-test-value"));
}