Example usage for org.apache.commons.configuration ConfigurationRuntimeException ConfigurationRuntimeException

List of usage examples for org.apache.commons.configuration ConfigurationRuntimeException ConfigurationRuntimeException

Introduction

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

Prototype

public ConfigurationRuntimeException(Throwable cause) 

Source Link

Document

Constructs a new ConfigurationRuntimeException with specified nested Throwable.

Usage

From source file:com.trivago.mail.pigeon.configuration.Settings.java

public static Settings create(String fileName, boolean nocache) {
    log.trace("Settings instance requested");
    if (fileName == null && instance != null && !nocache) {
        log.trace("Returning cached instance");
        return instance;
    } else if (fileName == null && instance == null) {
        log.trace("Requesting ENV PIDGEON_CONFIG as path to properties as fileName was null");

        String propertyFileName = System.getenv("PIDGEON_CONFIG");

        if (propertyFileName == null || propertyFileName.equals("")) {
            log.warn(/*from  w w w.j  a  v a  2  s. c o  m*/
                    "ENV is empty and no filename was given -> no config properties found! Using configuration.properties");
        }

        URL resource = Thread.currentThread().getContextClassLoader().getResource("configuration.properties");
        propertyFileName = resource.toExternalForm();
        instance = new Settings();

        try {
            instance.setConfiguration(new PropertiesConfiguration(propertyFileName));
        } catch (ConfigurationException e) {
            log.error(e);
            throw new ConfigurationRuntimeException(e);
        }
    } else if (fileName != null && instance == null) {
        log.trace("Requesting file properties from " + fileName);
        instance = new Settings();

        try {
            instance.setConfiguration(new PropertiesConfiguration(fileName));
        } catch (ConfigurationException e) {
            log.error(e);
            throw new ConfigurationRuntimeException(e);
        }
    }
    return instance;
}

From source file:net.sf.jclal.activelearning.batchmode.AbstractBatchMode.java

/**
 *
 * @param configuration The configuration of Abstract Batch Mode.
 *
 *The XML labels supported are://from w ww .  ja v a2 s. c  o m
 * <ul>
 * <li>batch-size= int</li>
 * </ul>
 */
@Override
public void configure(Configuration configuration) {

    // Set batchSize
    int batchT = configuration.getInt("batch-size", batchSize);
    if (batchT <= 0) {
        throw new ConfigurationRuntimeException(
                "\nIllegal batch size: <batch-size>" + batchT + "</batch-size>" + ". Batch size > 0");
    }
    setBatchSize(batchT);
}

From source file:com.linkedin.pinot.common.config.QuotaConfig.java

public void validate() {
    if (storage != null && DataSize.toBytes(storage) < 0) {
        LOGGER.error("Failed to convert storage quota config: {} to bytes", storage);
        throw new ConfigurationRuntimeException(
                "Failed to convert storage quota config: " + storage + " to bytes");
    }/*from   w ww  .ja v a2 s .c  o  m*/
}

From source file:net.sf.jclal.sampling.AbstractSampling.java

/**
 *
 * @param configuration The configuration object for Abstract sampling.
 * <p>/*w  w  w. j a v a2  s  .c om*/
 * <b>percentage-to-select= double</b></p>
 */
@Override
public void configure(Configuration configuration) {

    double percentageInstancesToLabelledTemp = configuration.getDouble("percentage-to-select", 10);
    String perc = "\n<percentage-to-select>" + percentageInstancesToLabelledTemp + "</percentage-to-select>";
    if (percentageInstancesToLabelledTemp <= 0) {
        throw new ConfigurationRuntimeException(perc + ". percentage-to-select > 0");
    }
    if (percentageInstancesToLabelledTemp > 100) {
        throw new ConfigurationRuntimeException(perc + ". percentage-to-select <= 100");
    }
    setPercentageInstancesToLabelled(percentageInstancesToLabelledTemp);

}

From source file:com.github.mbredel.commons.configuration.ConfigurationAssert.java

/**
 * Helper method for converting a file to a URL.
 *
 * @param file the file//  ww w . j a va  2  s  . com
 * @return the corresponding URL
 * @throws ConfigurationRuntimeException if the URL cannot be constructed
 */
private static URL urlFromFile(File file) {
    try {
        return file.toURI().toURL();
    } catch (MalformedURLException mex) {
        throw new ConfigurationRuntimeException(mex);
    }
}

From source file:net.sf.jclal.evaluation.method.RealScenario.java

@Override
protected void setDataConfiguration(Configuration configuration) {
    // Set multiLabel flag
    boolean multi = configuration.getBoolean("multi-label", false);
    setMultiLabel(multi);/*from  www .ja  va2s. c om*/

    // Set multiInstance flag
    boolean multiInstance = configuration.getBoolean("multi-instance", false);
    setMultiInstance(multiInstance);

    // Set the xml file, it is used in the case of a multi-label
    // dataset
    String xml = configuration.getString("file-xml", "");
    setXmlPath(xml);

    // the multi-label elements are verified
    if (multi && xml.isEmpty()) {
        throw new ConfigurationRuntimeException(
                "\nThe multi-label flag is " + "enabled and the xml path is empty. "
                        + "<multi-label>true</multi-label>" + " <file-xml></file-xml>");
    }

    // Set file labeled
    String fileLabeled = configuration.getString("file-labeled", "");
    setFileLabeledDataset(fileLabeled);

    // Set file unlabeled
    String fileUnlabeled = configuration.getString("file-unlabeled", "");
    setFileUnlabeledDataset(fileUnlabeled);

    if (fileLabeled.isEmpty() || fileUnlabeled.isEmpty()) {
        throw new ConfigurationRuntimeException("\n <file-labeled> and <file-unlabeled> tags must be defined.");
    }

    // Set file test
    String fileTest = configuration.getString("file-test", "");

    if (fileTest.isEmpty()) {
        /*
         * Logger.getLogger(RealScenario.class.getName()).log(Level.INFO,
         * "The param <file-test> is empty, the active learning algorithm require this property "
         * +
         * "for evaluating the constructed model, but in real scenario is not really necessary. In this case, "
         * + "we assign the <file-unlabeled> as <file-test>.");
         */
        fileTest = fileUnlabeled;
    }

    setFileTestDataset(fileTest);

    // Set class attribute
    int classAttributeT = configuration.getInt("class-attribute", -1);

    setClassAttribute(classAttributeT);
}

From source file:de.hybris.platform.sap.core.configuration.global.impl.SAPGlobalConfigurationServiceImpl.java

/**
 * Returns the sap configuration configuration property access.
 * /* www .jav  a 2 s  .  c om*/
 * @return sap configuration configuration property access
 */
protected ConfigurationPropertyAccess getSAPGlobalConfigurationCPA() {
    final SAPGlobalConfigurationModel sapGlobalConfiguration = globalConfigurationDAO
            .getSAPGlobalConfiguration();
    ConfigurationPropertyAccessImpl cpa = (ConfigurationPropertyAccessImpl) threadLocalBaseStoreConfigurationPropertyAccess
            .get();
    if (cpa != null && cpa.getConfigurationModel() != sapGlobalConfiguration) {
        cpa = null;
    }
    if (cpa == null && sapGlobalConfiguration != null) {
        cpa = new ConfigurationPropertyAccessImpl(sapGlobalConfiguration);
    }
    if (cpa == null || cpa.getConfigurationModel() == null) {
        LOG.fatal("SAP Configuration exception: no SAP Global Configuration exists!");
        throw new ConfigurationRuntimeException(
                "SAP Configuration exception: no SAP Global Configuration exists!");
    }
    return cpa;
}

From source file:de.hybris.platform.sap.core.configuration.impl.SAPConfigurationServiceImpl.java

@Override
public String getBackendType() {
    final String backendType = getRFCDestination().getBackendType();
    if (backendType == null || backendType.isEmpty()) {
        throw new ConfigurationRuntimeException("No Backend type is defined for RFC Destination '"
                + getRFCDestination().getRfcDestinationName() + "'!");
    }//from  w w w  .j  a  va  2  s.  co  m
    return backendType;
}

From source file:de.hybris.platform.sap.core.configuration.impl.SAPConfigurationServiceImpl.java

@Override
public RFCDestination getRFCDestination() {
    final ConfigurationPropertyAccessImpl cpaSAPRFCDestination = (ConfigurationPropertyAccessImpl) getSAPConfigurationCPA()
            .getPropertyAccess(SAPConfigurationModel.SAPRFCDESTINATION);
    if (cpaSAPRFCDestination == null || cpaSAPRFCDestination.getConfigurationModel() == null) {
        final String errorLog = "SAP Configuration service exception: No RFC Destination is maintained for SAP Base Store Configuration '"
                + getSAPConfigurationName() + "'!";
        LOG.fatal(errorLog);/*from   w w  w. ja  v a  2s  .  c o m*/
        throw new ConfigurationRuntimeException(errorLog);
    }
    return new RFCDestinationImpl((SAPRFCDestinationModel) cpaSAPRFCDestination.getConfigurationModel());
}

From source file:net.sf.jclal.evaluation.method.HoldOut.java

/**
 * @param configuration The configuration of Hold Out.
 *
 *The XML labels supported are://from  www  .  j  a v  a2  s  .c om
 *
 * <ul>
 * <li><b>percentage-split= double</b></li>
 * </ul>
 */
@Override
public void configure(Configuration configuration) {

    super.configure(configuration);

    // the percent of instances used to train
    double percentTrain = configuration.getDouble("percentage-split", percentageToSplit);

    String perc = "\n<percentage-split>" + percentTrain + "</percentage-split>";

    if (percentTrain <= 0) {
        throw new ConfigurationRuntimeException(perc + ". percentage-split > 0");
    }
    if (percentTrain >= 100) {
        throw new ConfigurationRuntimeException(perc + ". percentage-split < 100");
    }

    setPercentageToSplit(percentTrain);
}