class Configuration {

    public static void loadConfig() throws ConfigurationItemException {
    	LoggingService.logInfo(MODULE_NAME, "Start load Config");
    	
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = null;
        try {
			builder = factory.newDocumentBuilder();
		} catch (ParserConfigurationException e) {
			LoggingService.logError(MODULE_NAME, "Error while parsing config xml", new ConfigurationItemException(e.getMessage(), e));
			throw new ConfigurationItemException(e.getMessage(), e);
		}

        try {
        	configFile = builder.parse(getCurrentConfigPath());
		} catch (SAXException e) {
			LoggingService.logError(MODULE_NAME, "Error while parsing config xml", new ConfigurationItemException(e.getMessage(), e));
			throw new ConfigurationItemException("Error while parsing config xml");
		} catch (IOException e) {
			LoggingService.logError(MODULE_NAME, "Error while parsing config xml", new ConfigurationItemException(e.getMessage(), e));
			throw new ConfigurationItemException(e.getMessage(), e);
		}
        
        configFile.getDocumentElement().normalize();

        configElement = (Element) getFirstNodeByTagName("config", configFile);

        setIofogUuid(getNode(IOFOG_UUID, configFile));
        setAccessToken(getNode(ACCESS_TOKEN, configFile));
        setControllerUrl(getNode(CONTROLLER_URL, configFile));
        setControllerCert(getNode(CONTROLLER_CERT, configFile));
        setNetworkInterface(getNode(NETWORK_INTERFACE, configFile));
        setDockerUrl(getNode(DOCKER_URL, configFile));
        setDiskLimit(Float.parseFloat(getNode(DISK_CONSUMPTION_LIMIT, configFile)));
        setDiskDirectory(getNode(DISK_DIRECTORY, configFile));
        setMemoryLimit(Float.parseFloat(getNode(MEMORY_CONSUMPTION_LIMIT, configFile)));
        setCpuLimit(Float.parseFloat(getNode(PROCESSOR_CONSUMPTION_LIMIT, configFile)));
        setLogDiskDirectory(getNode(LOG_DISK_DIRECTORY, configFile));
        setLogDiskLimit(Float.parseFloat(getNode(LOG_DISK_CONSUMPTION_LIMIT, configFile)));
        setLogFileCount(Integer.parseInt(getNode(LOG_FILE_COUNT, configFile)));
        setLogLevel(getNode(LOG_LEVEL, configFile));       
        configureGps(getNode(GPS_MODE, configFile), getNode(GPS_COORDINATES, configFile));
        setChangeFrequency(Integer.parseInt(getNode(CHANGE_FREQUENCY, configFile)));
        setDeviceScanFrequency(Integer.parseInt(getNode(DEVICE_SCAN_FREQUENCY, configFile)));
        setStatusFrequency(Integer.parseInt(getNode(STATUS_FREQUENCY, configFile)));
        setPostDiagnosticsFreq(Integer.parseInt(getNode(POST_DIAGNOSTICS_FREQ, configFile)));
        setWatchdogEnabled(!getNode(WATCHDOG_ENABLED, configFile).equals("off"));
        configureFogType(getNode(FOG_TYPE, configFile));
        setDeveloperMode(!getNode(DEV_MODE, configFile).equals("off"));
        setIpAddressExternal(GpsWebHandler.getExternalIp());
        setRouterHost(getNode(ROUTER_HOST, configFile));
        setRouterPort(!getNode(ROUTER_PORT, configFile).equals("") ? Integer.parseInt(getNode(ROUTER_PORT, configFile)) : 0);

        setDockerPruningFrequency(Long.parseLong(getNode(DOCKER_PRUNING_FREQUENCY, configFile)));
        setAvailableDiskThreshold(Long.parseLong(getNode(AVAILABLE_DISK_THRESHOLD, configFile)));
        setReadyToUpgradeScanFrequency(Integer.parseInt(getNode(READY_TO_UPGRADE_SCAN_FREQUENCY, configFile)));

        LoggingService.logInfo(MODULE_NAME, "Finished load Config");
    }

}