// Path: home-core/src/main/java/com/sismics/home/core/util/ConfigUtil.java
// public class ConfigUtil {
//     /**
//      * Returns the textual value of a configuration parameter.
//      * 
//      * @param configType Type of the configuration parameter
//      * @return Textual value of the configuration parameter
//      * @throws IllegalStateException Configuration parameter undefined
//      */
//     public static String getConfigStringValue(ConfigType configType) {
//         ConfigDao configDao = new ConfigDao();
//         Config config = configDao.getById(configType);
//         if (config == null) {
//             throw new IllegalStateException("Config parameter not found: " + configType);
//         }
//         return config.getValue();
//     }
// 
//     /**
//      * Returns the configuration resource bundle.
//      * 
//      * @return Resource bundle
//      */
//     public static ResourceBundle getConfigBundle() {
//         return ResourceBundle.getBundle("config");
//     }
// 
//     /**
//      * Returns the integer value of a configuration parameter.
//      * 
//      * @param configType Type of the configuration parameter
//      * @return Integer value of the configuration parameter
//      * @throws IllegalStateException Configuration parameter undefined
//      */
//     public static int getConfigIntegerValue(ConfigType configType) {
//         String value = getConfigStringValue(configType);
//         
//         return Integer.parseInt(value);
//     }
// 
//     /**
//      * Returns the boolean value of a configuration parameter.
//      * 
//      * @param configType Type of the configuration parameter
//      * @return Boolean value of the configuration parameter
//      * @throws IllegalStateException Configuration parameter undefined
//      */
//     public static boolean getConfigBooleanValue(ConfigType configType) {
//         String value = getConfigStringValue(configType);
//         
//         return Boolean.parseBoolean(value);
//     }
// }


import com.google.common.base.Strings;
import com.google.common.io.CharStreams;
import com.sismics.home.core.util.ConfigUtil;
import com.sismics.util.ResourceUtil;
import org.skife.jdbi.v2.Handle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FilenameFilter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.MessageFormat;
import java.util.*;
            }
            
            // Execute update script
            ResourceBundle configBundle = ConfigUtil.getConfigBundle();
            Integer currentVersion = Integer.parseInt(configBundle.getString("db.version"));
            log.info(MessageFormat.format("Found database version {0}, new version is {1}, executing database incremental update scripts", oldVersion, currentVersion));
            onUpgrade(oldVersion, currentVersion);
            log.info("Database upgrade complete");
        } catch (Exception e) {
            exceptions.add(e);
            log.error("Unable to complete schema update", e);
        }
    }

    /**
     * Execute all upgrade scripts in ascending order for a given version.
     * 
     * @param version Version number
     * @throws Exception
     */
    protected void executeAllScript(final int version) throws Exception {
        List<String> fileNameList = ResourceUtil.list(getClass(), "/db/update/", new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {
                String versionString = String.format("%03d", version);
                return name.matches("dbupdate-" + versionString + "-\\d+\\.sql");
            }
        });
        Collections.sort(fileNameList);
        
// Path: home-core/src/main/java/com/sismics/home/core/util/ConfigUtil.java
// public class ConfigUtil {
//     /**
//      * Returns the textual value of a configuration parameter.
//      * 
//      * @param configType Type of the configuration parameter
//      * @return Textual value of the configuration parameter
//      * @throws IllegalStateException Configuration parameter undefined
//      */
//     public static String getConfigStringValue(ConfigType configType) {
//         ConfigDao configDao = new ConfigDao();
//         Config config = configDao.getById(configType);
//         if (config == null) {
//             throw new IllegalStateException("Config parameter not found: " + configType);
//         }
//         return config.getValue();
//     }
// 
//     /**
//      * Returns the configuration resource bundle.
//      * 
//      * @return Resource bundle
//      */
//     public static ResourceBundle getConfigBundle() {
//         return ResourceBundle.getBundle("config");
//     }
// 
//     /**
//      * Returns the integer value of a configuration parameter.
//      * 
//      * @param configType Type of the configuration parameter
//      * @return Integer value of the configuration parameter
//      * @throws IllegalStateException Configuration parameter undefined
//      */
//     public static int getConfigIntegerValue(ConfigType configType) {
//         String value = getConfigStringValue(configType);
//         
//         return Integer.parseInt(value);
//     }
// 
//     /**
//      * Returns the boolean value of a configuration parameter.
//      * 
//      * @param configType Type of the configuration parameter
//      * @return Boolean value of the configuration parameter
//      * @throws IllegalStateException Configuration parameter undefined
//      */
//     public static boolean getConfigBooleanValue(ConfigType configType) {
//         String value = getConfigStringValue(configType);
//         
//         return Boolean.parseBoolean(value);
//     }
// }


// Path: home-core/src/main/java/com/sismics/util/dbi/DbOpenHelper.java
import com.google.common.base.Strings;
import com.google.common.io.CharStreams;
import com.sismics.home.core.util.ConfigUtil;
import com.sismics.util.ResourceUtil;
import org.skife.jdbi.v2.Handle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FilenameFilter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.MessageFormat;
import java.util.*;

            }
            
            // Execute update script
            ResourceBundle configBundle = ConfigUtil.getConfigBundle();
            Integer currentVersion = Integer.parseInt(configBundle.getString("db.version"));
            log.info(MessageFormat.format("Found database version {0}, new version is {1}, executing database incremental update scripts", oldVersion, currentVersion));
            onUpgrade(oldVersion, currentVersion);
            log.info("Database upgrade complete");
        } catch (Exception e) {
            exceptions.add(e);
            log.error("Unable to complete schema update", e);
        }
    }

    /**
     * Execute all upgrade scripts in ascending order for a given version.
     * 
     * @param version Version number
     * @throws Exception
     */
    protected void executeAllScript(final int version) throws Exception {
        List<String> fileNameList = ResourceUtil.list(getClass(), "/db/update/", new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {
                String versionString = String.format("%03d", version);
                return name.matches("dbupdate-" + versionString + "-\\d+\\.sql");
            }
        });
        Collections.sort(fileNameList);
        
        for (String fileName : fileNameList) {