/** * <p>getViewsDisplayFile</p> * * @return a {@link java.io.File} object. * @throws java.io.IOException if any. */ public File getViewsDisplayFile() throws IOException { if (m_viewsDisplayFile == null) { m_viewsDisplayFile = ConfigFileConstants.getFile(ConfigFileConstants.VIEWS_DISPLAY_CONF_FILE_NAME); } return m_viewsDisplayFile; }
/** * Gets the home directory. * * @return the home directory */ protected String getHomeDirectory() { return ConfigFileConstants.getHome(); }
/** * Gets the requisition directory. * * @return the requisition directory */ private File getRequisitionDir() { if (requisitionDir == null) { requisitionDir = new File(ConfigFileConstants.getFilePathString() + "imports"); } return requisitionDir; }
/** * Instantiates a new magic users migrator offline. * * @throws OnmsUpgradeException the OpenNMS upgrade exception */ public MagicUsersMigratorOffline() throws OnmsUpgradeException { super(); try { magicUsersFile = new File(ConfigFileConstants.getHome(), "etc" + File.separator + "magic-users.properties"); magicUsersFileRPM = new File(magicUsersFile.getAbsolutePath() + ".rpmsave"); magicUsersFileDEB = new File(magicUsersFile.getAbsolutePath() + ".dpkg-remove"); usersFile = ConfigFileConstants.getFile(ConfigFileConstants.USERS_CONF_FILE_NAME); } catch (Exception 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; } }
@Override public void execute() throws OnmsUpgradeException { try { // Fixing JRB/RRD files final boolean isRrdtool = isRrdToolEnabled(); final boolean storeByGroup = isStoreByGroupEnabled(); for (File jmxResourceDir : getJmxResourceDirectories()) { if (storeByGroup) { processGroupFiles(jmxResourceDir, isRrdtool); } else { processSingleFiles(jmxResourceDir, isRrdtool); } } // Fixing JMX Configuration File File jmxConfigFile = null; try { jmxConfigFile = ConfigFileConstants.getFile(ConfigFileConstants.JMX_DATA_COLLECTION_CONF_FILE_NAME); } catch (IOException e) { throw new OnmsUpgradeException("Can't find JMX Configuration file (ignoring processing)"); } fixJmxConfigurationFile(jmxConfigFile); // List Bad Metrics: log("Found %s Bad Metrics: %s\n", badMetrics.size(), badMetrics); // Fixing Graph Templates File jmxGraphsFile = new File(ConfigFileConstants.getFilePathString(), "snmp-graph.properties"); fixJmxGraphTemplateFile(jmxGraphsFile); } catch (Exception e) { throw new OnmsUpgradeException("Can't upgrade the JRBs because " + e.getMessage(), e); } }
String xslFileName; if (format.equals("SVG")) { pdfFileName = ConfigFileConstants.getHome() + "/share/reports/AVAIL-SVG-" + catFileName + fmt.format(new java.util.Date()) + ".pdf"; xslFileName = ConfigFileConstants.getFilePathString() + ConfigFileConstants.getFileName(ConfigFileConstants.REPORT_SVG_XSL); } else if (format.equals("PDF")) { pdfFileName = ConfigFileConstants.getHome() + "/share/reports/AVAIL-PDF-" + catFileName + fmt.format(new java.util.Date()) + ".pdf"; xslFileName = ConfigFileConstants.getFilePathString() + ConfigFileConstants.getFileName(ConfigFileConstants.REPORT_PDF_XSL); } else if (format.equals("HTML")) { pdfFileName = ConfigFileConstants.getHome() + "/share/reports/AVAIL-HTML-" + catFileName + 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);
String home = getHome(); String rfile = getFileName(id); File frfile = new File(home + File.separator + "etc" + File.separator + rfile); if (!frfile.exists()) {
/** * 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; } }
/** * 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 xslFileName; if (format.equals("SVG")) { pdfFileName = ConfigFileConstants.getHome() + "/share/reports/AVAIL-SVG-" + catFileName + fmt.format(new java.util.Date()) + ".pdf"; xslFileName = ConfigFileConstants.getFilePathString() + ConfigFileConstants.getFileName(ConfigFileConstants.REPORT_SVG_XSL); } else if (format.equals("PDF")) { pdfFileName = ConfigFileConstants.getHome() + "/share/reports/AVAIL-PDF-" + catFileName + fmt.format(new java.util.Date()) + ".pdf"; xslFileName = ConfigFileConstants.getFilePathString() + ConfigFileConstants.getFileName(ConfigFileConstants.REPORT_PDF_XSL); } else if (format.equals("HTML")) { pdfFileName = ConfigFileConstants.getHome() + "/share/reports/AVAIL-HTML-" + catFileName + 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);
/** * 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)); }
/** * 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); } }
/** * Load the config from the default config file and create the singleton * instance of this factory. * * @exception java.io.IOException * Thrown if the specified config file cannot be read * @throws java.io.IOException if any. * @throws java.lang.ClassNotFoundException if any. */ protected DatabaseChecker() throws IOException, ClassNotFoundException { this(ConfigFileConstants.getFile(ConfigFileConstants.OPENNMS_DATASOURCE_CONFIG_FILE_NAME).getPath()); }
/** * 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); }
/** * Method to return the string for path of the etc directory. * * @return String, the file url for the include file */ public static String getFilePathString() { return getHome() + File.separator + "etc" + File.separator; }
/** * Instantiates a new upgrade status. * * @throws OnmsUpgradeException the OpenNMS upgrade exception */ public UpgradeStatus() throws OnmsUpgradeException { this(new File(ConfigFileConstants.getFilePathString() + STATUS_FILE)); }
/** * 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); } }
final String targetFile = ConfigFileConstants.getFileName(ConfigFileConstants.POLLER_CONFIG_FILE_NAME); EventBuilder ebldr = null; try {