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:de.unigoettingen.sub.search.opac.ConfigOpac.java

private static XMLConfiguration getConfig() throws FileNotFoundException {
    if (Objects.nonNull(config)) {
        return config;
    }/*from   ww  w. j  a v a 2 s .  c o  m*/

    KitodoConfigFile opacConfiguration = KitodoConfigFile.OPAC_CONFIGURATION;

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

From source file:com.zavakid.mushroom.impl.MetricsConfig.java

/**
 * Load configuration from a list of files until the first successful load
 * /*from ww w  . ja  va 2 s.  c om*/
 * @param conf the configuration object
 * @param files the list of filenames to try
 * @return the configuration object
 */
static MetricsConfig loadFirst(String prefix, String... fileNames) {
    for (String fname : fileNames) {
        try {
            Configuration cf = new PropertiesConfiguration(fname).interpolatedConfiguration();
            LOG.info("loaded properties from " + fname);
            return new MetricsConfig(cf, prefix);
        } catch (ConfigurationException e) {
            if (e.getMessage().startsWith("Cannot locate configuration")) {
                continue;
            }
            throw new MetricsConfigException(e);
        }
    }
    throw new MetricsConfigException("Cannot locate configuration: tried " + StringUtils.join(fileNames, ", "));
}

From source file:eu.optimis.tf.ip.service.utils.PropertiesUtils.java

public static PropertiesConfiguration getPropertiesConfiguration(String configFile) {
    String filePath = null;/*from  w ww .  j  a  v a  2  s  .  c om*/
    PropertiesConfiguration config = null;
    filePath = file4OS(configFile);
    try {
        config = new PropertiesConfiguration(filePath);
    } catch (ConfigurationException e) {
        log.error("TRUST: Error reading " + filePath + " configuration file: " + e.getMessage());
        log.error(e.getCause().getMessage());
    }
    return config;
}

From source file:eu.optimis.tf.sp.service.utils.PropertiesUtils.java

public static PropertiesConfiguration getPropertiesConfiguration(String configFile) {
    String filePath = null;//from  www  .java  2  s  .  c o  m
    PropertiesConfiguration config = null;
    filePath = file4OS(configFile);
    try {
        config = new PropertiesConfiguration(filePath);
    } catch (ConfigurationException e) {
        log.error("TRUST: Error reading " + filePath + " configuration file: " + e.getMessage());
        e.printStackTrace();
    }
    return config;
}

From source file:lh.api.showcase.server.config.ConfigurationUtils.java

public static synchronized XMLConfiguration getConfig() {

    XMLConfiguration config = null;/*from   w w  w. j a v a2 s  .  c  om*/
    InputStream in = Thread.currentThread().getContextClassLoader()
            .getResourceAsStream("lh/api/showcase/Showcase-settings.xml");
    if (in != null) {
        logger.info("Load configuration");
        config = new XMLConfiguration();
        try {
            config.load(in);
        } catch (ConfigurationException e) {
            logger.severe("Error occurred while opeing config file");
        } catch (Exception e) {
            logger.severe("Error occurred while opeing config file: " + e.getMessage());
            throw e;
        } finally {
            try {
                in.close();
            } catch (IOException e) {
            }
        }
    } else {
        logger.info("NO configuration file found");
    }
    return config;
}

From source file:cd.what.DutchBot.AccessList.java

/**
 * Delete a user from the access list/*  w ww  . j  a  v a2  s . co  m*/
 * 
 * @param login
 * @param hostname
 * @throws AccessListException
 */
public static void delUser(String login, String hostname) throws AccessListException {
    login = login.toLowerCase();
    hostname = hostname.toLowerCase();

    accessList.remove(login + "@" + hostname);
    config.clearProperty(login + "@" + hostname);
    try {
        config.save();
    } catch (ConfigurationException e) {
        throw new AccessListException(e.getMessage());
    }
}

From source file:cd.what.DutchBot.AccessList.java

/**
 * Add a user to the access list//w  w  w .  ja  v a  2s  .  c o m
 * 
 * @param login
 * @param hostname
 * @param level
 */
public static void addUser(String login, String hostname, Privileges level) {

    String user = login + "@" + hostname;
    user = user.toLowerCase();

    // make sure to update the alias:
    if (aliasList.containsKey(user)) {
        user = aliasList.get(user);
    }
    accessList.put(user, level);
    System.out.println("Registered " + user);
    // update config
    if (config.containsKey("acl.user." + user))
        config.clearProperty("acl.user." + user);
    config.addProperty("acl.user." + user, level.getValue());
    try {
        config.save();
    } catch (ConfigurationException e) {
        bot.logMessage("Failed to write config " + e.getMessage(), true);
    }

}

From source file:info.extensiblecatalog.OAIToolkit.utils.ConfigUtil.java

public static PropertiesConfiguration load(String configFileName) throws Exception {
    prglog.info("[PRG] ConfigUtil::load(" + configFileName + ")");
    ClassLoader cloader = ConfigUtil.class.getClassLoader();
    URL configFile = cloader.getResource(configFileName);
    if (null == configFile) {
        File f = new File(configFileName);
        prglog.info("[PRG] load from file: " + f.getAbsolutePath());
        configFile = new URL("file", "", f.getAbsolutePath());
    }/*  ww  w  . j  a  v  a2s .  c  om*/
    prglog.info("config file: " + configFile.getPath());
    //System.out.println("The config file is " + configFile);
    //System.out.println("The config file name is " + configFileName);

    if (!(new File(configFile.getPath()).exists())) {
        prglog.error("[PRG] Inexistent configuration file: " + configFileName);
        throw new Exception("Inexistent configuration file: " + configFileName);
    }

    BufferedReader re = new BufferedReader(new FileReader(configFile.getPath()));
    /*        String tmpfile = "tmpfile.txt";
            // Create new file
            File temp = new File(tmpfile);
            
            boolean success = temp.createNewFile();
            if (success) {
     System.out.println("Its success");
    //File did not exist and was created
            } else {
     System.out.println("File already exists");
     //File already exists
            }
            
            
             if (!temp.exists())
    throw new IllegalArgumentException("no such file or directory: " + temp);
            
            if (!temp.canWrite())
    throw new IllegalArgumentException("Write protected: " + temp);
            
            System.out.println("Temporary file created. File is " + temp);
            //System.out.println("Temporary file created. Path is " + temp.getPath());
            
            BufferedWriter out = new BufferedWriter(new FileWriter(temp));
            while(true)
            {
    String s = re.readLine();
    //System.out.println(s);
    if(s!=null) {
        s = s.replaceAll("\\\\", "/");
        //System.out.println(s);
        out.write(s + System.getProperty("line.separator"));
        out.flush();
    }
    else
        break;
            }
            out.close();
    */
    try {
        //PropertiesConfiguration prop = new PropertiesConfiguration(temp);
        PropertiesConfiguration prop = new PropertiesConfiguration(configFile.getPath());
        prglog.info("[PRG] successful ConfigUtil::load");
        //temp.deleteOnExit();
        /*boolean dsuccess = temp.delete();
        if (!dsuccess)
        throw new IllegalArgumentException("Delete: deletion failed");*/
        return prop;
    } catch (ConfigurationException e) {
        prglog.error("[PRG] Unable to load properties from configuration file: " + configFileName + ". "
                + e.getMessage());
        throw new Exception(
                "Unable to load properties from configuration file: " + configFileName + ". " + e.getMessage());
    }
}

From source file:eu.betaas.taas.taasvmmanager.configuration.TaaSVMMAnagerConfiguration.java

private static void loadClouds() {
    int iter;/*from   www  .j a v  a2s  .com*/
    String type;
    String url;
    String user;
    String pass;
    String[] cloudData;

    if (clouds == null) {
        clouds = new HashMap<String, String[]>();

        try {
            XMLConfiguration config = new XMLConfiguration("vmmanager.conf");

            iter = 0;
            while (config.getProperty("clouds.cloud(" + iter + ")") != null) {
                type = config.getString("clouds.cloud(" + iter + ")[@type]");
                url = config.getString("clouds.cloud(" + iter + ").url");
                user = config.getString("clouds.cloud(" + iter + ").user");
                pass = config.getString("clouds.cloud(" + iter++ + ").password");

                cloudData = new String[3];
                cloudData[0] = type;
                cloudData[1] = user;
                cloudData[2] = pass;

                clouds.put(url, cloudData);
            }
        } catch (ConfigurationException e) {
            logger.error(e.getMessage());
        }
    }
}

From source file:es.bsc.autonomic.powermodeller.configuration.CoreConfiguration.java

public static PropertiesConfiguration getPropertiesConfiguration(String configFile) {
    String filePath = null;/*from  ww w  .j av a  2s. com*/
    PropertiesConfiguration config = null;

    try {
        filePath = getFilePath(configFile);
        config = new PropertiesConfiguration(filePath);
    } catch (ConfigurationException ex) {
        logger.error("Error reading " + filePath + " configuration file: " + ex.getMessage());
        logger.error(ex.getMessage());
    }

    return config;
}