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:de.hybris.platform.sap.core.configuration.impl.SAPConfigurationServiceImpl.java

/**
 * Returns the base store configuration property access.
 * /*from w  w w . j a v a2s  .co  m*/
 * @return base store configuration property access
 */
private ConfigurationPropertyAccess getBaseStoreCPA() {
    final ConfigurationPropertyAccess cpa = getBaseStoreCPAInternal();
    if (cpa == null) {
        final String errorLog = "SAP Configuration service exception: No Base Store active!";
        LOG.fatal(errorLog);
        throw new ConfigurationRuntimeException(errorLog);
    }
    return cpa;
}

From source file:keel.Algorithms.Neural_Networks.NNEP_Clas.problem.classification.softmax.SoftmaxClassificationProblemEvaluator.java

/**
 * <p>/*from w w w  .  ja  v  a2  s.  c o m*/
 * Configuration parameters for NeuralNetEvaluator are:
 * Problem evaluator configuration
 *       org.ayrna.jclec.problem.ProblemEvaluator
 * 
 * error-function: complex 
 *       Error function used for evaluating individuals
 * </p>
 */

@SuppressWarnings("unchecked")
public void configure(Configuration settings) {

    // ProblemEvaluator configuration
    super.configure(settings);

    // Individual error function
    try {
        // Error function classname
        String errorFunctionClassname = settings.getString("error-function");
        // Error function class
        Class<IErrorFunction<double[][]>> errorFunctionClass = (Class<IErrorFunction<double[][]>>) Class
                .forName(errorFunctionClassname);
        // Error function instance
        IErrorFunction<double[][]> errorFunction = errorFunctionClass.newInstance();
        // Set error function
        setErrorFunction(errorFunction);
    } catch (ClassNotFoundException e) {
        throw new ConfigurationRuntimeException("Illegal error function classname");
    } catch (InstantiationException e) {
        throw new ConfigurationRuntimeException("Problems creating an instance of error function", e);
    } catch (IllegalAccessException e) {
        throw new ConfigurationRuntimeException("Problems creating an instance of error function", e);
    }

}

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

/**
 * Returns the sap configuration configuration property access.
 * /*from   w  w w.  j av  a2s  .  co  m*/
 * @return sap configuration configuration property access
 */
private ConfigurationPropertyAccess getSAPConfigurationCPA() {
    final ConfigurationPropertyAccess cpa = getSAPConfigurationCPAInternal();
    if (cpa == null) {
        final String errorLog = "SAP Configuration service exception: No SAP Base Store Configuration assigned to active Base Store!";
        LOG.fatal(errorLog);
        throw new ConfigurationRuntimeException(errorLog);
    }
    return cpa;
}

From source file:net.sf.jclal.util.mail.SenderEmail.java

/**
 *
 * @param configuration The configuration of SenderEmail.
 *
 *The XML labels supported are://  ww  w.ja  v a  2 s.c o m
 *
 * <ul>
 * <li>smtp-host= ip</li>
 * <li>smtp-port= int</li>
 * <li>to= email</li>
 * <li>from= email</li>
 * <li>attach-report-file=boolean</li>
 * <li>user=String</li>
 * <li>pass=String</li>
 * </ul>
 */
@Override
public void configure(Configuration configuration) {

    String hostT = configuration.getString("smtp-host", "");
    if (hostT.isEmpty()) {
        throw new ConfigurationRuntimeException("\nThe tag <smtp-host></smtp-host> is empty.");
    }

    setHost(hostT);

    int portT = configuration.getInt("smtp-port", 21);

    setPort(portT);

    String fromT = configuration.getString("from", "");

    if (fromT.isEmpty()) {
        throw new ConfigurationRuntimeException("\nThe tag <from></from> is empty. ");
    }

    setFrom(fromT);

    // Number of defined recipients
    int numberRecipients = configuration.getList("to").size();

    if (numberRecipients == 0) {
        throw new ConfigurationRuntimeException("\nAt least one <to></to> tag must be defined. ");
    }

    // For each recipients in list
    for (int i = 0; i < numberRecipients; i++) {

        String header = "to(" + i + ")";

        // recipient 
        String recipientName = configuration.getString(header, "");

        // Add this recipient
        toRecipients.append(recipientName).append(";");
    }

    toRecipients.deleteCharAt(toRecipients.length() - 1);

    boolean attach = configuration.getBoolean("attach-report-file", false);

    setAttachReporFile(attach);

    String userT = configuration.getString("user", "");

    if (userT.isEmpty()) {
        throw new ConfigurationRuntimeException("\nThe tag <user></user> is empty. ");
    }

    setUser(userT);

    String passT = configuration.getString("pass", "");

    if (passT.isEmpty()) {
        throw new ConfigurationRuntimeException("\nThe tag <pass></pass> is empty. ");
    }

    setPass(passT);

}

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

/**
 * @param configuration The configuration of K-Fold cross validation.
 *The XML labels supported are:/*from  ww  w .java 2s .co m*/
 *
 * <ul>
 * <li><b>stratify= boolean</b></li>
 * <li><b>num-folds= int</b></li>
 * </ul>
 */
@Override
public void configure(Configuration configuration) {
    super.configure(configuration);

    // Set stratify (default false)
    boolean stratifyValue = configuration.getBoolean("stratify", stratify);
    setStratify(stratifyValue);

    // num folds
    int numFols = configuration.getInt("num-folds", numFolds);
    if (numFols < 1) {
        throw new ConfigurationRuntimeException("\n<num-folds>" + numFols + "</num-folds>. " + "num-folds > 0");
    }
    setNumFolds(numFols);
}

From source file:keel.Algorithms.Neural_Networks.NNEP_Regr.problem.regression.RegressionProblemEvaluator.java

/**
 * <p>/*from  ww  w. ja  v  a 2 s .c  o m*/
 * Configuration parameters for NeuralNetEvaluator are:
 * </p>
 * <ul>
 * <li>
 * <code>Problem evaluator configuration</code></p> 
 * @see net.sf.jclec.problem.ProblemEvaluator
 * </li>
 * <li>
 * <code>error-function: complex</code></p> 
 * Error function used for evaluating individuals.
 * </li>
 * </ul>
 * @param settings Settings to Configure
 */

@SuppressWarnings("unchecked")
public void configure(Configuration settings) {

    // ProblemEvaluator configuration
    super.configure(settings);

    // Individual error function
    try {
        // Error function classname
        String errorFunctionClassname = settings.getString("error-function");
        // Error function class
        Class<IErrorFunction<double[]>> errorFunctionClass = (Class<IErrorFunction<double[]>>) Class
                .forName(errorFunctionClassname);
        // Error function instance
        IErrorFunction<double[]> errorFunction = errorFunctionClass.newInstance();
        // Set error function
        setErrorFunction(errorFunction);
    } catch (ClassNotFoundException e) {
        throw new ConfigurationRuntimeException("Illegal error function classname");
    } catch (InstantiationException e) {
        throw new ConfigurationRuntimeException("Problems creating an instance of error function", e);
    } catch (IllegalAccessException e) {
        throw new ConfigurationRuntimeException("Problems creating an instance of error function", e);
    }

}

From source file:net.sf.jclal.activelearning.multilabel.querystrategy.MultiLabel3DimensionalQueryStrategy.java

/**
 *
 * @param configuration The configuration object for
 * MultiLabel3DimensionalQueryStrategy//from   w  ww . j  a v a  2s.c o m
 *
 * The XML labels supported are:
 * <ul>
 * <li>evidence-dimension: The possible values are [C, S]</li>
 * <li>class-dimension: The possible values are [M, A, R]</li>
 * <li>weight-dimension: The possible values are [N, M]</li>
 * </ul>
 */
@Override
public void configure(Configuration configuration) {

    super.configure(configuration);

    evidenceDimension = configuration.getString("evidence-dimension", "C").toCharArray()[0];
    classDimension = configuration.getString("class-dimension", "M").toCharArray()[0];
    weightDimension = configuration.getString("weight-dimension", "N").toCharArray()[0];

    switch (evidenceDimension) {

    case 'C':

        setMaximal(false);

        break;

    case 'S':

        setMaximal(true);

        break;

    default:
        throw new ConfigurationRuntimeException("For the evidence dimension the options are C and S");
    }

    switch (classDimension) {

    case 'M':

        break;

    case 'A':

        break;

    case 'R':

        break;

    default:
        throw new ConfigurationRuntimeException("For the class dimension the options are M, A and R");
    }

    switch (weightDimension) {

    case 'N':

        break;

    case 'W':

        break;

    default:
        throw new ConfigurationRuntimeException("For the weight dimension the options are N and W");
    }

}

From source file:keel.Algorithms.Neural_Networks.NNEP_Common.NeuralNetIndividualSpecies.java

/**
 * <p>// ww w .  j  a v a2s.c o m
 * Creates the genotype of the individual
 * @return The Genotype
 * <(p>
 */

@SuppressWarnings("unchecked")
public INeuralNet createGenotype() {
    INeuralNet result = null;

    // New neural net
    try {
        Class<INeuralNet> neuralNetClass = (Class<INeuralNet>) Class.forName(neuralNetType);

        // Range instance
        result = neuralNetClass.newInstance();

        //Generate topology
        generateTopology(result);

        //Set input layer number of neurons
        result.getInputLayer().setMaxnofneurons(nOfInputs);
    } catch (ClassNotFoundException e) {
        throw new ConfigurationRuntimeException("Illegal neural net classname");
    } catch (InstantiationException e) {
        throw new ConfigurationRuntimeException("Problems creating an instance of " + type, e);
    } catch (IllegalAccessException e) {
        throw new ConfigurationRuntimeException("Problems creating an instance of " + type, e);
    }

    return result;
}

From source file:ee.ria.xroad.signer.tokenmanager.module.ModuleConf.java

private static Set<Long> loadAllowedKeyUsageMechanisms(SubnodeConfiguration section, String key) {
    Set<Long> allowedMechanism = new HashSet<>();
    String[] mechanisms = getStringArray(section, key);

    for (String m : mechanisms) {
        Long mechamism = SUPPORTED_KEY_ALLOWED_MECHANISMS.get(StringUtils.strip(m));

        if (mechamism != null) {
            allowedMechanism.add(mechamism);
        } else {// w w w .j  av a2 s.com
            throw new ConfigurationRuntimeException(
                    String.format("Unsupported value '%s' of '%s' for module (%s), skipping...", m, key,
                            section.getSubnodeKey()));
        }
    }

    return allowedMechanism;
}

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

/**
 *
 * @param configuration The configuration object for Abstract Evaluation
 * Method.//from   w w  w .j  a  va2 s  .  co m
 *
 *The XML labels supported are:
 *
 * <ul>
 * <li>
 * <b>rand-gen-factory type= class</b>
 * <p>
 * Package: net.sf.jclal.util.random
 * </p>
 * <p>
 * Class: All
 * </p>
 * </li>
 * <li>
 * <b>sampling-method type= class</b>
 * <p>
 * Package: net.sf.jclal.sampling
 * </p>
 * <p>
 * Class: All
 * </p>
 * </li>
 * <li><b>multi-label= boolean</b></li>
 * <li><b>multi-instance= boolean</b></li>
 * <li><b>file-dataset= String</b></li>
 * <li><b>file-train= String</b></li>
 * <li><b>file-test= String</b></li>
 * <li><b>file-labeled= String</b></li>
 * <li><b>file-unlabeled= String</b></li>
 * <li><b>class-attribute= int</b></li>
 * <li>
 * <b>algorithm type= class</b>
 * <p>
 * Package: net.sf.jclal.activelearning
 * </p>
 * <p>
 * Class: All
 * </p>
 * </li>
 * <li><b>file-xml= String</b>: If the dataset is multi label</li>
 * </ul>
 */
@Override
public void configure(Configuration configuration) {

    setRandGenSettings(configuration);

    // Set multiLabel flag
    boolean multi = configuration.getBoolean("multi-label", false);
    setMultiLabel(multi);

    // 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 dataset (default "")
    String fileDatasetT = configuration.getString("file-dataset", "");
    setFileDataset(fileDatasetT);

    if (fileDataset.isEmpty()) {
        // Set file train
        String fileTrain = configuration.getString("file-train", "");
        setFileTrainDataset(fileTrain);
        // Set file test
        String fileTest = configuration.getString("file-test", "");
        setFileTestDataset(fileTest);

        if (fileTest.isEmpty()) {
            throw new ConfigurationRuntimeException("\n If <file-dataset> tag is not specified,"
                    + " then the <file-test> tags must be defined.");
        }

        if (fileTrain.isEmpty()) {

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

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

            if (fileLabeled.isEmpty() || fileUnlabeled.isEmpty()) {
                throw new ConfigurationRuntimeException(
                        "\n If <file-dataset> and " + " <file-train> tags are not specified,"
                                + " then the <file-labeled> and <file-unlabeled> tags must be defined.");
            }

        }
    }

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

    setClassAttribute(classAttributeT);

    //Set the configuration of the sampling method
    setSamplingStrategyConfiguration(configuration);

    setAlgorithmSettings(configuration);

}