/** * This method saves the data represented by this object to disk. */ public synchronized void save() { if (m_surveillanceViewConfiguration == null) { load(); } try { JaxbUtils.marshal(m_surveillanceViewConfiguration, m_cfgFile); } catch (final IOException e) { final String filename = ConfigFileConstants.getFileName(ConfigFileConstants.SURVEILLANCE_VIEWS_FILE_NAME); LOG.error("Unable to save {}", filename, e); throw new IllegalStateException("Unable to save " + filename, e); } }
/** * This loads the configuration file. * * @return a Properties object representing the configuration properties * @throws java.io.IOException if any. */ public static Properties getProperties() throws IOException { if (m_properties == null) { m_properties = new Properties(System.getProperties()); InputStream in = null; String configFileName = null; // Merge the config file contents into these properties (if the file exists) try { configFileName = ConfigFileConstants.getFileName(ConfigFileConstants.RRD_CONFIG_FILE_NAME); File configFile = ConfigFileConstants.getFile(ConfigFileConstants.RRD_CONFIG_FILE_NAME); in = new FileInputStream(configFile); m_properties.load(in); } catch (FileNotFoundException e) { LOG.info("{} not found, loading RRD configuration solely from system properties", configFileName); } finally { if (in != null) { in.close(); } } } return m_properties; } }
/** * This method saves the data represented by this object to disk. */ public synchronized void save() { if (m_surveillanceViewConfiguration == null) { load(); } try { JaxbUtils.marshal(m_surveillanceViewConfiguration, m_cfgFile); } catch (final IOException e) { final String filename = ConfigFileConstants.getFileName(ConfigFileConstants.SURVEILLANCE_VIEWS_FILE_NAME); LOG.error("Unable to save {}", filename, e); throw new IllegalStateException("Unable to save " + filename, e); } }
/** * This loads the configuration file. * * @return a Properties object representing the configuration properties * @throws java.io.IOException if any. */ public static Properties getProperties() throws IOException { if (m_properties == null) { m_properties = new Properties(System.getProperties()); InputStream in = null; String configFileName = null; // Merge the config file contents into these properties (if the file exists) try { configFileName = ConfigFileConstants.getFileName(ConfigFileConstants.RRD_CONFIG_FILE_NAME); File configFile = ConfigFileConstants.getFile(ConfigFileConstants.RRD_CONFIG_FILE_NAME); in = new FileInputStream(configFile); m_properties.load(in); } catch (FileNotFoundException e) { LOG.info("{} not found, loading RRD configuration solely from system properties", configFileName); } finally { if (in != null) { in.close(); } } } return m_properties; } }
String rfile = getFileName(id); File frfile = new File(home + File.separator + "etc" + File.separator + rfile); if (!frfile.exists()) {
/** * This method loads the configuration data from disk. */ public synchronized void load() { LOG.debug("Loading surveillance view configuration."); if (m_cfgFile == null) { try { m_cfgFile = ConfigFileConstants.getFile(ConfigFileConstants.SURVEILLANCE_VIEWS_FILE_NAME); } catch (final IOException e) { LOG.error("Unable to load {}", ConfigFileConstants.getFileName(ConfigFileConstants.SURVEILLANCE_VIEWS_FILE_NAME)); m_cfgFile = new File(System.getProperty("opennms.home") + File.separator + "etc" + File.separator + "surveillance-views.xml"); } } LOG.debug("Using surveillance view file: {}", m_cfgFile); if (!m_cfgFile.exists()) { LOG.warn("Surveillance view configuration {} does not exist!", m_cfgFile); m_surveillanceViewConfiguration = new SurveillanceViewConfiguration(); } else { m_surveillanceViewConfiguration = JaxbUtils.unmarshal(SurveillanceViewConfiguration.class, m_cfgFile); } LOG.debug("Surveillance view configuration loaded: {}", m_surveillanceViewConfiguration); }
/** * This method loads the configuration data from disk. */ public synchronized void load() { LOG.debug("Loading surveillance view configuration."); if (m_cfgFile == null) { try { m_cfgFile = ConfigFileConstants.getFile(ConfigFileConstants.SURVEILLANCE_VIEWS_FILE_NAME); } catch (final IOException e) { LOG.error("Unable to load {}", ConfigFileConstants.getFileName(ConfigFileConstants.SURVEILLANCE_VIEWS_FILE_NAME)); m_cfgFile = new File(System.getProperty("opennms.home") + File.separator + "etc" + File.separator + "surveillance-views.xml"); } } LOG.debug("Using surveillance view file: {}", m_cfgFile); if (!m_cfgFile.exists()) { LOG.warn("Surveillance view configuration {} does not exist!", m_cfgFile); m_surveillanceViewConfiguration = new SurveillanceViewConfiguration(); } else { m_surveillanceViewConfiguration = JaxbUtils.unmarshal(SurveillanceViewConfiguration.class, m_cfgFile); } LOG.debug("Surveillance view configuration loaded: {}", m_surveillanceViewConfiguration); }
+ fmt.format(new java.util.Date()) + ".pdf"; xslFileName = ConfigFileConstants.getFilePathString() + ConfigFileConstants.getFileName(ConfigFileConstants.REPORT_SVG_XSL); } else if (format.equals("PDF")) { pdfFileName = ConfigFileConstants.getHome() + fmt.format(new java.util.Date()) + ".pdf"; xslFileName = ConfigFileConstants.getFilePathString() + ConfigFileConstants.getFileName(ConfigFileConstants.REPORT_PDF_XSL); } else if (format.equals("HTML")) { pdfFileName = ConfigFileConstants.getHome() + fmt.format(new java.util.Date()) + ".html"; xslFileName = ConfigFileConstants.getFilePathString() + ConfigFileConstants.getFileName(ConfigFileConstants.REPORT_HTML_XSL); } else { LOG.error("Format '{}' is unsupported. Must be one of: SVG, PDF, or HTML.", format);
+ fmt.format(new java.util.Date()) + ".pdf"; xslFileName = ConfigFileConstants.getFilePathString() + ConfigFileConstants.getFileName(ConfigFileConstants.REPORT_SVG_XSL); } else if (format.equals("PDF")) { pdfFileName = ConfigFileConstants.getHome() + fmt.format(new java.util.Date()) + ".pdf"; xslFileName = ConfigFileConstants.getFilePathString() + ConfigFileConstants.getFileName(ConfigFileConstants.REPORT_PDF_XSL); } else if (format.equals("HTML")) { pdfFileName = ConfigFileConstants.getHome() + fmt.format(new java.util.Date()) + ".html"; xslFileName = ConfigFileConstants.getFilePathString() + ConfigFileConstants.getFileName(ConfigFileConstants.REPORT_HTML_XSL); } else { LOG.error("Format '{}' is unsupported. Must be one of: SVG, PDF, or HTML.", format);
/** * Reload the config from the default config file. * @throws IOException * * @exception java.io.IOException * Thrown if the specified config file cannot be read/loaded * @throws java.io.IOException if any. */ public synchronized void reload() throws IOException { try { File cfgFile = ConfigFileConstants.getFile(ConfigFileConstants.DISCOVERY_CONFIG_FILE_NAME); LOG.debug("reload: config file path {}", cfgFile.getPath()); final FileSystemResource resource = new FileSystemResource(cfgFile); m_config = JaxbUtils.unmarshal(DiscoveryConfiguration.class, resource); try { getInitialSleepTime(); getRestartSleepTime(); getIntraPacketDelay(); getConfiguredAddresses(); } catch (final Throwable e) { throw new IOException("An error occurred while validating the configuration: " + e.getMessage(), e); } } catch (IOException e) { LOG.error("Could not unmarshal configuration file: " + ConfigFileConstants.getFileName(ConfigFileConstants.DISCOVERY_CONFIG_FILE_NAME), e); throw e; } }
final String targetFile = ConfigFileConstants.getFileName(ConfigFileConstants.POLLER_CONFIG_FILE_NAME); EventBuilder ebldr = null; try {
String thresholdsFile = ConfigFileConstants.getFileName(ConfigFileConstants.THRESHOLDING_CONF_FILE_NAME); String threshdFile = ConfigFileConstants.getFileName(ConfigFileConstants.THRESHD_CONFIG_FILE_NAME); final String targetFile = ConfigFileConstants.getFileName(ConfigFileConstants.DATA_COLLECTION_CONF_FILE_NAME); boolean isDataCollectionConfig = false; for (Parm parm : event.getParmCollection()) { final String cfgFile = ConfigFileConstants.getFileName(ConfigFileConstants.COLLECTD_CONFIG_FILE_NAME); try { m_collectdConfigFactory.reload();