Example usage for org.apache.commons.configuration ConfigurationException getMessage

List of usage examples for org.apache.commons.configuration ConfigurationException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.ihtsdo.statistics.db.importer.ImportManager.java

/**
 * Execute./*w  ww .  jav a  2s .  co m*/
 *
 * @throws IOException Signals that an I/O exception has occurred.
 * @throws Exception the exception
 */
public void execute() throws IOException, Exception {
    logger.info("Starting import manager process");

    createFolders();
    importer = new Importer();
    if (!existingTables()) {
        DbSetup dbSetup = new DbSetup(connection);
        dbSetup.execute();
        dbSetup = null;
    }
    XMLConfiguration xmlConfig;
    try {
        xmlConfig = new XMLConfiguration(configFile);
    } catch (ConfigurationException e) {
        logger.error("ClassificationRunner - Error happened getting params configFile." + e.getMessage());
        throw e;
    }

    releaseDependencies = CurrentFile.get().getReleaseDependenciesFullFolders() != null;
    this.releaseDate = xmlConfig.getString("releaseDate");
    this.previousReleaseDate = xmlConfig.getString("previousReleaseDate");

    this.reducedSnapshotFolder = new File("reducedSnapshotFolder");
    if (!reducedSnapshotFolder.exists()) {
        reducedSnapshotFolder.mkdirs();
    }
    this.previousReducedSnapshotFolder = new File("previousReducedSnapshotFolder");
    if (!previousReducedSnapshotFolder.exists()) {
        previousReducedSnapshotFolder.mkdirs();
    }

    List<HierarchicalConfiguration> fields = xmlConfig.configurationsAt("reports.reportDescriptor");

    if (fields != null) {
        for (HierarchicalConfiguration sub : fields) {

            String report = sub.getString("filename");
            String value = sub.getString("execute");

            if (value.toLowerCase().equals("true")) {
                logger.info("Getting config for report " + report);
                ReportConfig reportCfg = ResourceUtils.getReportConfig(report);

                for (TABLE table : reportCfg.getInputFile()) {
                    switch (table) {
                    case STATEDROOTDESC:
                        if (rootDesc) {
                            continue;
                        }
                        rootDesc = true;
                        break;
                    case CONCEPTS:
                        if (concepts) {
                            continue;
                        }
                        concepts = true;
                        break;

                    case DESCRIPTIONS:
                        if (descriptions) {
                            continue;
                        }
                        descriptions = true;
                        break;
                    case DESCRIPTIONS_PREVIOUS:
                        if (descriptions_pre) {
                            continue;
                        }
                        descriptions_pre = true;
                        break;

                    case RELATIONSHIPS:
                        if (relationships) {
                            continue;
                        }
                        relationships = true;
                        break;

                    case STATEDRELS:
                        if (statedRels) {
                            continue;
                        }
                        statedRels = true;
                        break;

                    case TCLOSUREINFERRED:
                        if (tClosureInferred) {
                            continue;
                        }
                        tClosureInferred = true;
                        break;

                    case TCLOSURESTATED:
                        if (tClosureStated) {
                            continue;
                        }
                        tClosureStated = true;
                        break;

                    case CONCEPTS_PREVIOUS:
                        if (concepts_pre) {
                            continue;
                        }
                        concepts_pre = true;
                        break;
                    case RELATIONSHIPS_PREVIOUS:
                        if (relationships_pre) {
                            continue;
                        }
                        relationships_pre = true;
                        break;
                    case STATEDRELS_PREVIOUS:
                        if (statedRels_pre) {
                            continue;
                        }
                        statedRels_pre = true;
                        break;

                    case TCLOSURESTATED_PREVIOUS:
                        if (tClosureStated_pre) {
                            continue;
                        }
                        tClosureStated_pre = true;
                        break;
                    case SAME_AS_ASSOCIATIONS:
                        if (same_associations) {
                            continue;
                        }
                        same_associations = true;
                        break;
                    }
                    ImportRf2Table(table);
                }
                System.out.println(report + " " + value);
            }
        }
    }
    logger.info("Updating date to " + releaseDate);
    saveNewDate(I_Constants.RELEASE_DATE, releaseDate);

    logger.info("Updating previous date to " + previousReleaseDate);
    saveNewDate(I_Constants.PREVIOUS_RELEASE_DATE, previousReleaseDate);

    fields = xmlConfig.configurationsAt("sp_params.param");

    params = new HashMap<String, String>();
    if (fields != null) {
        for (HierarchicalConfiguration sub : fields) {
            String paramName = sub.getString("name");
            String value = sub.getString("value");
            params.put(paramName, value);
        }
    }
    logger.info("End of import manager process");
}

From source file:org.ihtsdo.statistics.Processor.java

/**
 * Execute.//from   w  w  w .j ava  2 s  .  c o m
 *
 * @throws IOException Signals that an I/O exception has occurred.
 * @throws Exception the exception
 */
public void execute() throws IOException, Exception {
    logger.logInfo("Starting report execution");
    createFolders();
    XMLConfiguration xmlConfig;
    try {
        xmlConfig = new XMLConfiguration(configFile);
    } catch (ConfigurationException e) {
        logger.logInfo("ClassificationRunner - Error happened getting params configFile." + e.getMessage());
        throw e;
    }
    createDetails = xmlConfig.getString("createDetailReports");
    List<HierarchicalConfiguration> fields = xmlConfig.configurationsAt("reports.reportDescriptor");

    for (HierarchicalConfiguration sub : fields) {

        String report = sub.getString("filename");
        String value = sub.getString("execute");

        if (value.toLowerCase().equals("true")) {
            logger.logInfo("Getting report config for " + report);
            ReportConfig reportCfg = ResourceUtils.getReportConfig(report);
            logger.logInfo("Executing report " + report);
            long start = logger.startTime();
            executeReport(reportCfg);

            logger.logInfo("Writing report " + report);
            writeReports(reportCfg, report);

            String msg = logger.endTime(start);
            int posIni = msg.indexOf("ProcessingTime:") + 16;
            ReportInfo rInfo = new ReportInfo();
            rInfo.setName(reportCfg.getName());
            if (reportCfg.getOutputFile() != null) {
                for (OutputFileTableMap file : reportCfg.getOutputFile()) {
                    rInfo.getOutputFiles().add(file.getFile());
                }
            }
            if (reportCfg.getOutputDetailFile() != null) {
                for (OutputDetailFile file : reportCfg.getOutputDetailFile()) {
                    rInfo.getOutputDetailFiles().add(file.getFile());
                }
            }
            rInfo.setTimeTaken(msg.substring(posIni));
            OutputInfoFactory.get().getStatisticProcess().getReports().add(rInfo);
        }
        //            System.out.println(report + " " + value);
    }
}

From source file:org.ihtsdo.statistics.runner.Runner.java

/**
 * Inits the file providers./*w  w  w .  j av a 2s  .co  m*/
 *
 * @param file the file
 * @throws Exception the exception
 */
private static void initFileProviders(File file) throws Exception {
    logger.logInfo("Initializing file providers");
    XMLConfiguration xmlConfig;
    try {
        xmlConfig = new XMLConfiguration(file);
    } catch (ConfigurationException e) {
        logger.logInfo("ClassificationRunner - Error happened getting params configFile." + e.getMessage());
        throw e;
    }

    String releaseFolder = xmlConfig.getString("releaseFullFolder");
    if (releaseFolder == null || releaseFolder.trim().equals("") || !new File(releaseFolder).exists()) {
        throw new Exception("Release folder doesn't exist.");
    }

    File sourceFolder = new File(releaseFolder);

    Object prop = xmlConfig.getProperty("releaseDependencies.releaseFullFolder");
    HashSet<String> releaseDependencies = null;
    if (prop != null) {
        if (prop instanceof Collection) {
            releaseDependencies = new HashSet<String>();
            for (String loopProp : (Collection<String>) prop) {
                releaseDependencies.add(loopProp);
            }
        } else if (prop instanceof String) {
            releaseDependencies = new HashSet<String>();
            releaseDependencies.add((String) prop);
            System.out.println(prop);
        }

    }
    String releaseDate = xmlConfig.getString("releaseDate");
    String previousReleaseDate = xmlConfig.getString("previousReleaseDate");

    CurrentFile.init(sourceFolder, new File("release" + releaseDate), releaseDependencies, releaseDate);
    PreviousFile.init(sourceFolder, new File("release" + previousReleaseDate), releaseDependencies,
            previousReleaseDate);
}

From source file:org.investovator.core.commons.configuration.TestConfigLoader.java

public void testConfigLoader() {
    try {// w ww.j a v a2s.c  om
        ConfigLoader.loadProperties("src" + File.separator + "test" + File.separator + "resources"
                + File.separator + "resource.properties");
    } catch (ConfigurationException e) {
        assertFalse(e.getMessage(), true);
    }

    assertEquals("localhost:9171", System.getProperty("org.investovator.core.data.cassandra.url"));
    assertEquals("admin", System.getProperty("org.investovator.core.data.cassandra.username"));
    assertEquals("admin", System.getProperty("org.investovator.core.data.cassandra.password"));
}

From source file:org.jenkinsci.test.acceptance.utils.pluginreporter.TextFileExercisedPluginReporter.java

@Override
public void log(String testName, String pluginName, String pluginVersion) {

    PropertiesConfiguration config = null;
    try {//from   w ww .  j  a v a2  s . c  o m
        config = new PropertiesConfiguration(file);
    } catch (ConfigurationException e) {
        LOGGER.error(e.getMessage());
        return;
    }

    config.setProperty(testName + "$" + pluginName, pluginVersion);
    try {
        config.save();
    } catch (ConfigurationException e) {
        LOGGER.error(e.getMessage());
        return;
    }
}

From source file:org.jhub1.agent.configuration.PropertiesImpl.java

public PropertiesImpl() throws ConfigurationException {
    reloadingStrategy = new ManagedReloadingStrategy();
    config = new CompositeConfiguration();
    config.addConfiguration(new SystemConfiguration());
    config.addConfiguration(new PropertiesConfiguration("agent.properties"));
    config.addConfiguration(new PropertiesConfiguration("agent.internal.properties"));
    try {//from  w w w .  jav a2s.c  om
        XMLConfiguration fromFile = new XMLConfiguration("settings.xml");
        fromFile.setReloadingStrategy(reloadingStrategy);
        reloadFlag = true;
        config.addConfiguration(fromFile);
    } catch (ConfigurationException ce) {
        log.error("Problem with loading custom configuration: " + ce.getMessage());
    }
    config.addConfiguration(new XMLConfiguration("settings.default.xml"));
}

From source file:org.jhub1.agent.run.Driver.java

private static void systemInit() {
    Thread.currentThread().setName("Jhub1OnlineAgent");
    Registry.getInstance().setEventTimestamp(Driver.class, "start");
    Path path = Paths.get(".");
    if (!Files.isWritable(path)) {
        log.error("The directory is not writable. Can't start!");
        System.exit(0);//from  www  .j ava 2 s  .  c om
    }
    // construct configuration object
    try {
        config = new PropertiesImpl();
    } catch (ConfigurationException e1) {
        log.error("Configuration can't be red. " + e1.getMessage());
        System.exit(0);
    }
    // construct data exchange object
    dex = new DataExchangeImpl(config);

    log.info("Environment initiated! OS: " + config.getSysOsName() + ", Version: " + config.getSysOsVersion()
            + ", Arch: " + config.getSysOsArch());
}

From source file:org.jspare.core.config.CommonsConfigImpl.java

@Override
public void store() {

    try {// w ww .ja v a  2 s .  c o  m

        PropertiesConfiguration targetConfiguration = new PropertiesConfiguration(this.fileToLoad);
        configuration.getKeys()
                .forEachRemaining(k -> targetConfiguration.setProperty(k, configuration.getProperties(k)));
        targetConfiguration.save();

    } catch (ConfigurationException e) {

        log.error("Error when trying to save a configuration [{}] - Message [{}]", this.fileToLoad,
                e.getMessage());
    }
}

From source file:org.jwebsocket.sso.Main.java

/**
 *
 * @param args/*from   w ww.  j av a 2  s.  c  o  m*/
 */
public static void main(String[] args) {

    // set up log4j logging
    // later this should be read from a shared log4j properties or xml file!
    Properties lProps = new Properties();
    lProps.setProperty("log4j.rootLogger", "INFO, console");
    lProps.setProperty("log4j.logger.org.apache.activemq.spring", "WARN");
    lProps.setProperty("log4j.logger.org.apache.activemq.web.handler", "WARN");
    lProps.setProperty("log4j.logger.org.springframework", "WARN");
    lProps.setProperty("log4j.logger.org.apache.xbean", "WARN");
    lProps.setProperty("log4j.logger.org.apache.camel", "INFO");
    lProps.setProperty("log4j.logger.org.eclipse.jetty", "WARN");
    lProps.setProperty("log4j.appender.console", "org.apache.log4j.ConsoleAppender");
    lProps.setProperty("log4j.appender.console.layout", "org.apache.log4j.PatternLayout");
    lProps.setProperty("log4j.appender.console.layout.ConversionPattern",
            // "%p: %m%n"
            "%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p - %C{1}: %m%n");
    // set here the jWebSocket log level:
    lProps.setProperty("log4j.logger.org.jwebsocket", "DEBUG");
    lProps.setProperty("log4j.appender.console.threshold", "DEBUG");
    PropertyConfigurator.configure(lProps);

    mLog.info("jWebSocket SSO (OAuth) Demo Client");

    Configuration lConfig = null;
    boolean lConfigLoaded;
    try {
        // loading properties files
        lConfig = new PropertiesConfiguration("/private/SSO.properties");
    } catch (ConfigurationException ex) {
    }

    if (null == lConfig) {
        mLog.info("Configuration file could not be opened.");
        return;
    }

    final String lSMHost = lConfig.getString("SMHost");
    final String lOAuthHost = lConfig.getString("OAuthHost");
    final String lOAuthAppId = lConfig.getString("OAuthAppId");
    final String lOAuthAppSecret = lConfig.getString("OAuthAppSecret");
    final String lOAuthUsername = lConfig.getString("OAuthUsername");
    final String lOAuthPassword = lConfig.getString("OAuthPassword");
    long lOAuthTimeout = lConfig.getLong("OAuthTimeout", 5000);

    // TODO: Validate config data here!
    lConfigLoaded = true;

    if (!lConfigLoaded) {
        mLog.error("Config not loaded.");
        System.exit(1);
    }

    OAuth lOAuth = new OAuth();

    lOAuth.setOAuthHost(lOAuthHost);
    lOAuth.setOAuthAppId(lOAuthAppId);
    lOAuth.setOAuthAppSecret(lOAuthAppSecret);

    //      SiteMinder.setSMHost(lSMHost);
    //      String lSMSession = SiteMinder.getSSOSession(5000);
    //      mLog.info("Getting SM Session: " + lSMSession);
    //
    //      if (true) {
    //         return;
    //      }
    int lMaxTotalProcesses = 1;
    int lMaxUserRequests = 2;
    int lLoopDelay = 1;
    int lRequestDelay = 1;
    Map<String, Object> lJSON;
    for (int lCount = 0; lCount < lMaxTotalProcesses; lCount++) {
        mLog.info("================== " + (lCount + 1) + "/" + lMaxTotalProcesses + " ==================");
        String lSessionCookie = lOAuth.getSSOSession(lOAuthUsername, lOAuthPassword, 5000);
        mLog.info("Getting Session Cookie: " + (null == lSessionCookie ? "[null]"
                : lSessionCookie.replace("\r", "\\r").replace("\n", "\\n")));
        try {
            lJSON = lOAuth.parseJSON(lSessionCookie);
        } catch (IOException ex) {
            mLog.error(ex.getMessage());
            break;
        }
        String lAuthSession = lOAuth.authSession(lOAuth.getSessionId(), 5000);
        mLog.info("Authenticate Session: "
                + (null == lAuthSession ? "[null]" : lAuthSession.replace("\r", "\\r").replace("\n", "\\n")));
        try {
            lJSON = lOAuth.parseJSON(lAuthSession);
        } catch (IOException ex) {
            mLog.error(ex.getMessage());
            break;
        }
        // mLog.info("JSON Direct Authentication: " + lOAuth.authDirect(lOAuthUsername, lOAuthPassword));
        String lAccessToken = lOAuth.getAccessToken();
        mLog.info("JSON Obtaining Bearer Token: " + lAccessToken);
        for (int lGetUserIdx = 0; lGetUserIdx < lMaxUserRequests; lGetUserIdx++) {
            // intentionally cause a failure at last loop iteration
            if (lMaxUserRequests == lGetUserIdx + 1) {
                lAccessToken += "xx";
            }
            try {
                String lUsername = lOAuth.getUser(lAccessToken);
                mLog.info((lGetUserIdx + 1) + " of " + lMaxUserRequests + ": JSON User from Access Token: "
                        + (null == lUsername ? "[null]" : lUsername.replace("\r", "\\r").replace("\n", "\\n")));
                try {
                    lJSON = lOAuth.parseJSON(lUsername);
                } catch (IOException ex) {
                    mLog.error("Parsing JSON: " + ex.getMessage());
                    break;
                }

                /*
                try {
                   String lRes = lOAuth.refreshAccessToken(lOAuthTimeout);
                   mLog.info("JSON Refresh Access Token: "
                + (null == lRes ? "[null]"
                      : lRes.replace("\r", "\\r").replace("\n", "\\n")));
                } catch (Exception ex) {
                   mLog.error("Refreshing Access Token: " + ex.getMessage());
                   break;
                }
                */
                try {
                    Thread.currentThread().sleep(lRequestDelay);
                } catch (InterruptedException lEx) {
                }
            } catch (Exception ex) {
                mLog.error(ex.getMessage());
                break;
            }
        }
    }
}

From source file:org.kitodo.config.ConfigProject.java

/**
 * Constructor for ConfigProject.// w  w w  .  j  a v a 2 s  .  c o m
 * 
 * @param projectTitle
 *            for which configuration is going to be read
 * @throws IOException
 *             if config file not found
 */
public ConfigProject(String projectTitle) throws IOException {
    KitodoConfigFile configFile = KitodoConfigFile.PROJECT_CONFIGURATION;

    if (!configFile.exists()) {
        throw new IOException("File not found: " + configFile.getAbsolutePath());
    }
    try {
        this.config = new XMLConfiguration(configFile.getAbsolutePath());
    } catch (ConfigurationException e) {
        logger.error(e.getMessage(), e);
        this.config = new XMLConfiguration();
    }
    this.config.setListDelimiter('&');
    this.config.setReloadingStrategy(new FileChangedReloadingStrategy());

    int countProjects = this.config.getMaxIndex("project");
    for (int i = 0; i <= countProjects; i++) {
        String title = this.config.getString("project(" + i + ")[@name]");
        if (title.equals(projectTitle)) {
            this.projectTitle = "project(" + i + ").";
            break;
        }
    }

    try {
        this.config.getBoolean(this.projectTitle + "createNewProcess.opac[@use]");
    } catch (NoSuchElementException e) {
        this.projectTitle = "project(0).";
    }
}