<commit_before>/**
 * Copyright 2011 Intuit Inc. All Rights Reserved
 */
package com.intuit.tank.vm.settings;

/*
 * #%L
 * Intuit Tank Api
 * %%
 * Copyright (C) 2011 - 2015 Intuit Inc.
 * %%
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * #L%
 */

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import javax.annotation.Nonnull;

import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.commons.configuration.SubnodeConfiguration;
import org.apache.commons.lang.StringUtils;

/**
 * ReportingConfig
 * 
 * @author dangleton
 * 
 */
public class ReportingConfig implements Serializable {

    private static final long serialVersionUID = 1L;
    private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ReportingConfig.class);

    private static final String KEY_READER = "provider/reader";
    private static final String KEY_REPORTER = "provider/reporter";
    private static final String KEY_CONFIG = "provider/config";
    private static final String DEFAULT_REPORTER = "com.intuit.tank.reporting.db.DatabaseResultsReporter";
    private static final String DEFAULT_READER = "com.intuit.tank.reporting.db.DatabaseResultsReader";

    private HierarchicalConfiguration config;

    public ReportingConfig(@Nonnull HierarchicalConfiguration config) {
        this.config = config;
    }

    /**
     * @return the products
     */
    public String getReporterClass() {
        String ret = DEFAULT_REPORTER;
        if (config != null) {
            try {
                SubnodeConfiguration configurationAt = config.configurationAt(KEY_REPORTER);
                String string = configurationAt.getString("");
                if (StringUtils.isNotBlank(string)) {
                    ret = string;
                } else {
                    LOG.warn("Reporter not configured. Using default of " + ret);
                }
            } catch (Exception e) {
                LOG.warn("Reporter specified more than once. Using default of " + ret);
            }
        }
        return ret;
    }

    /**
     * @return the products
     */
    public String getReaderClass() {
        String ret = DEFAULT_READER;
        if (config != null) {
            try {
                SubnodeConfiguration configurationAt = config.configurationAt(KEY_READER);
                String string = configurationAt.getString("");
                if (StringUtils.isNotBlank(string)) {
                    ret = string;
                } else {
                    LOG.warn("Reader not configured. Using default of " + ret);
                }
            } catch (Exception e) {
                LOG.warn("Reader specified more than once. Using default of " + ret);
            }
        }
        return ret;
    }

    /**
     * @return the products
     */
    public HierarchicalConfiguration getProviderConfig() {
        HierarchicalConfiguration ret = null;
        if (config != null) {
            try {
                ret = config.configurationAt(KEY_CONFIG);
            } catch (Exception e) {
                LOG.error("Provider config specifed more than once.");
            }
        }
        return ret;
    }

}
<commit_msg>improved error message for missing config<commit_after>/**
 * Copyright 2011 Intuit Inc. All Rights Reserved
 */
package com.intuit.tank.vm.settings;

/*
 * #%L
 * Intuit Tank Api
 * %%
 * Copyright (C) 2011 - 2015 Intuit Inc.
 * %%
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * #L%
 */

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import javax.annotation.Nonnull;

import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.commons.configuration.SubnodeConfiguration;
import org.apache.commons.lang.StringUtils;

/**
 * ReportingConfig
 * 
 * @author dangleton
 * 
 */
public class ReportingConfig implements Serializable {

    private static final long serialVersionUID = 1L;
    private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ReportingConfig.class);

    private static final String KEY_READER = "provider/reader";
    private static final String KEY_REPORTER = "provider/reporter";
    private static final String KEY_CONFIG = "provider/config";
    private static final String DEFAULT_REPORTER = "com.intuit.tank.reporting.db.DatabaseResultsReporter";
    private static final String DEFAULT_READER = "com.intuit.tank.reporting.db.DatabaseResultsReader";

    private HierarchicalConfiguration config;

    public ReportingConfig(@Nonnull HierarchicalConfiguration config) {
        this.config = config;
    }

    /**
     * @return the products
     */
    public String getReporterClass() {
        String ret = DEFAULT_REPORTER;
        if (config != null) {
            try {
                SubnodeConfiguration configurationAt = config.configurationAt(KEY_REPORTER);
                String string = configurationAt.getString("");
                if (StringUtils.isNotBlank(string)) {
                    ret = string;
                } else {
                    LOG.warn("Reporter not configured. Using default of " + ret);
                }
            } catch (Exception e) {
                LOG.warn("Reporter specified more than once. Using default of " + ret);
            }
        }
        return ret;
    }

    /**
     * @return the products
     */
    public String getReaderClass() {
        String ret = DEFAULT_READER;
        if (config != null) {
            try {
                SubnodeConfiguration configurationAt = config.configurationAt(KEY_READER);
                String string = configurationAt.getString("");
                if (StringUtils.isNotBlank(string)) {
                    ret = string;
                } else {
                    LOG.warn("Reader not configured. Using default of " + ret);
                }
            } catch (Exception e) {
                LOG.warn("Reader specified more than once. Using default of " + ret);
            }
        }
        return ret;
    }

    /**
     * @return the products
     */
    public HierarchicalConfiguration getProviderConfig() {
        HierarchicalConfiguration ret = null;
        if (config != null) {
            try {
                ret = config.configurationAt(KEY_CONFIG);
            } catch (Exception e) {
                LOG.error("Provider config not specified or specifed more than once.");
            }
        }
        return ret;
    }

}

{'fraction_non_alphanumeric': 0.09167983905733583, 'fraction_numerical': 0.005460554677396178, 'mean_word_length': 2.197060174552136, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4333062', 'n_tokens_mistral': 1857, 'n_tokens_neox': 1761, 'n_words': 492}