/** * Gets the configuration file. * * @param destinationName the destination name * @return the configuration file */ private File getConfigFile(String destinationName) { try { return ConfigFileConstants.getConfigFileByName("syslog-eventforwarder-" + destinationName + ".xml"); } catch (IOException e) { return null; } }
/** * Load properties. * * @param properties the properties * @param fileName the file name * @throws Exception the exception */ private static void loadProperties(Properties properties, String fileName) throws Exception { File propertiesFile = ConfigFileConstants.getConfigFileByName(fileName); properties.load(new FileInputStream(propertiesFile)); }
/** * Load properties. * * @param properties the properties * @param fileName the file name * @throws OnmsUpgradeException the OpenNMS upgrade exception */ protected void loadProperties(Properties properties, String fileName) throws OnmsUpgradeException { try { File propertiesFile = ConfigFileConstants.getConfigFileByName(fileName); properties.load(new FileInputStream(propertiesFile)); } catch (Exception e) { throw new OnmsUpgradeException("Can't load " + fileName); } }
public synchronized void update() throws IOException { File cfgFile = ConfigFileConstants.getConfigFileByName(ACCESS_POINT_MONITOR_CONFIG_FILE_NAME); if (cfgFile.lastModified() > m_currentVersion) { m_currentVersion = cfgFile.lastModified(); LOG.debug("init: config file path: {}", cfgFile.getPath()); InputStream is = null; try { is = new FileInputStream(cfgFile); m_accessPointMonitorConfig = unmarshall(is); } finally { if (is != null) { IOUtils.closeQuietly(is); } } LOG.debug("init: finished loading config file: {}", cfgFile.getPath()); } }
private void checkFileForSyntax(String fileName) { File file; try { file = ConfigFileConstants.getConfigFileByName(fileName); checkFileForSyntax(file.toPath()); } catch (IOException e) { throw new ConfigCheckValidationException(e); } }
public static synchronized void init() throws IOException { if (m_loaded) { // init already called - return // to reload, reload() will need to be called return; } File cfgFile = ConfigFileConstants.getConfigFileByName(ACCESS_POINT_MONITOR_CONFIG_FILE_NAME); LOG.debug("init: config file path: {}", cfgFile.getPath()); InputStream is = null; try { is = new FileInputStream(cfgFile); setInstance(new AccessPointMonitorConfigFactory(cfgFile.lastModified(), is)); } finally { if (is != null) { IOUtils.closeQuietly(is); } } }
/** * @throws OnmsUpgradeException the OpenNMS upgrade exception */ public MonitoringLocationsMigratorOffline() throws OnmsUpgradeException { super(); try { // Parse the existing config file configFile = ConfigFileConstants.getConfigFileByName("monitoring-locations.xml"); if (configFile.exists() && configFile.isFile()) { monitoringLocationsConfig = JaxbUtils.unmarshal(MonitoringLocationsConfiguration.class, configFile); } else { monitoringLocationsConfig = null; } } catch (FileNotFoundException e) { log("No monitoring-locations.xml file found, skipping migration to database\n"); monitoringLocationsConfig = null; } catch (IOException e) { throw new OnmsUpgradeException("Unexpected exception while reading monitoring-locations.xml", e); } }