📄 configfileconstants.java
字号:
// // // DTDs used by reports // /** * This is the name of the path of the event report dtd */ public static final int EVENT_REPORT_DTD; /** * This is the name of the path of the event report dtd */ public static final int OUTAGE_REPORT_DTD; /** * This is the name of the path of the notification report dtd */ public static final int NOTIFY_REPORT_DTD; // // Initialize the class data. This section is used to initialize the // integer constants to their final values and to build the array // of integer identifiers to file names. // static { // Initialize the constants // DB_CONFIG_FILE_NAME = 0; JMS_CONFIG_FILE_NAME = 1; ACTIOND_CONFIG_FILE_NAME = 2; CAPSD_CONFIG_FILE_NAME = 3; DISCOVERY_CONFIG_FILE_NAME = 4; EVENTD_CONFIG_FILE_NAME = 5; NOTIFD_CONFIG_FILE_NAME = 6; OUTAGE_MANAGER_CONFIG_FILE_NAME = 7; POLLER_CONFIG_FILE_NAME = 8; POLL_OUTAGES_CONFIG_FILE_NAME = 9; RTC_CONFIG_FILE_NAME = 10; TRAPD_CONFIG_FILE_NAME = 11; MANAGER_CONFIG_FILE_NAME = 12; SERVICE_CONF_FILE_NAME = 13; EVENTS_ARCHIVER_CONFIG_FILE_NAME = 14; ADMIN_PITXML_FILE_NAME = 15; MAGIC_USERS_CONF_FILE_NAME = 16; POLLER_CONF_FILE_NAME = 17; EXCLUDE_UEI_FILE_NAME = 18; USERS_CONF_FILE_NAME = 19; VIEWS_CONF_FILE_NAME = 20; CATEGORIES_CONF_FILE_NAME = 21; GROUPS_CONF_FILE_NAME = 22; NOTIFICATIONS_CONF_FILE_NAME = 23; NOTIF_COMMANDS_CONF_FILE_NAME = 24; DESTINATION_PATHS_CONF_FILE_NAME = 25; SNMP_CONF_FILE_NAME = 26; EVENT_CONF_FILE_NAME = 27; DB_SCHEMA_FILE_NAME = 28; DATA_COLLECTION_CONF_FILE_NAME = 29; REPORT_PDF_XSL = 30; REPORT_SVG_XSL = 31; EVENT_REPORT = 32; OUTAGE_REPORT = 33; EVENT_REPORT_DTD = 34; OUTAGE_REPORT_DTD = 35; NOTIFY_REPORT_DTD = 36; NOTIFY_REPORT = 37; COLLECTD_CONFIG_FILE_NAME = 38; BASE_CONFIGURATION_FILE_NAME = 39; VULNSCAND_CONFIG_FILE_NAME = 40; THRESHD_CONFIG_FILE_NAME = 41; THRESHOLDING_CONF_FILE_NAME = 42; VIEWS_DISPLAY_CONF_FILE_NAME = 43; REPORT_HTML_XSL = 44; WEBUI_COLORS_FILE_NAME = 45; KSC_REPORT_FILE_NAME = 46; SCRIPTD_CONFIG_FILE_NAME = 47; OPENNMS_SERVER_CONFIG_FILE_NAME = 48; XMLRPCD_CONFIG_FILE_NAME = 49; DHCPD_CONFIG_FILE_NAME = 50; RRD_CONFIG_FILE_NAME = 51; JAVA_MAIL_CONFIG_FILE_NAME = 52; VACUUMD_CONFIG_FILE_NAME = 53; XMPP_CONFIG_FILE_NAME = 54; // Allocate and build the mapping of identifiers to names // FILE_ID_TO_NAME = new String[55]; FILE_ID_TO_NAME[DB_CONFIG_FILE_NAME] = "opennms-database.xml"; FILE_ID_TO_NAME[JMS_CONFIG_FILE_NAME] = "opennms-jms.xml"; FILE_ID_TO_NAME[ACTIOND_CONFIG_FILE_NAME] = "actiond-configuration.xml"; FILE_ID_TO_NAME[CAPSD_CONFIG_FILE_NAME] = "capsd-configuration.xml"; FILE_ID_TO_NAME[DISCOVERY_CONFIG_FILE_NAME] = "discovery-configuration.xml"; FILE_ID_TO_NAME[EVENTD_CONFIG_FILE_NAME] = "eventd-configuration.xml"; FILE_ID_TO_NAME[NOTIFD_CONFIG_FILE_NAME] = "notifd-configuration.xml"; FILE_ID_TO_NAME[OUTAGE_MANAGER_CONFIG_FILE_NAME] = "outage-configuration.xml"; FILE_ID_TO_NAME[POLLER_CONFIG_FILE_NAME] = "poller-configuration.xml"; FILE_ID_TO_NAME[POLL_OUTAGES_CONFIG_FILE_NAME] = "poll-outages.xml"; FILE_ID_TO_NAME[RTC_CONFIG_FILE_NAME] = "rtc-configuration.xml"; FILE_ID_TO_NAME[TRAPD_CONFIG_FILE_NAME] = "trapd-configuration.xml"; FILE_ID_TO_NAME[MANAGER_CONFIG_FILE_NAME] = "manager-configuration.xml"; FILE_ID_TO_NAME[SERVICE_CONF_FILE_NAME] = "service-configuration.xml"; FILE_ID_TO_NAME[EVENTS_ARCHIVER_CONFIG_FILE_NAME] = "events-archiver-configuration.xml"; FILE_ID_TO_NAME[ADMIN_PITXML_FILE_NAME] = "pitXML.xml"; FILE_ID_TO_NAME[MAGIC_USERS_CONF_FILE_NAME] = "magic-users.properties"; FILE_ID_TO_NAME[POLLER_CONF_FILE_NAME] = "poller-config.properties"; FILE_ID_TO_NAME[EXCLUDE_UEI_FILE_NAME] = "exclude-ueis.properties"; FILE_ID_TO_NAME[USERS_CONF_FILE_NAME] = "users.xml"; FILE_ID_TO_NAME[VIEWS_CONF_FILE_NAME] = "views.xml"; FILE_ID_TO_NAME[CATEGORIES_CONF_FILE_NAME] = "categories.xml"; FILE_ID_TO_NAME[GROUPS_CONF_FILE_NAME] = "groups.xml"; FILE_ID_TO_NAME[NOTIFICATIONS_CONF_FILE_NAME] = "notifications.xml"; FILE_ID_TO_NAME[NOTIF_COMMANDS_CONF_FILE_NAME] = "notificationCommands.xml"; FILE_ID_TO_NAME[DESTINATION_PATHS_CONF_FILE_NAME] = "destinationPaths.xml"; FILE_ID_TO_NAME[SNMP_CONF_FILE_NAME] = "snmp-config.xml"; FILE_ID_TO_NAME[EVENT_CONF_FILE_NAME] = "eventconf.xml"; FILE_ID_TO_NAME[DB_SCHEMA_FILE_NAME] = "database-schema.xml"; FILE_ID_TO_NAME[DATA_COLLECTION_CONF_FILE_NAME] = "datacollection-config.xml"; FILE_ID_TO_NAME[REPORT_PDF_XSL] = "PDFAvailReport.xsl"; FILE_ID_TO_NAME[REPORT_SVG_XSL] = "SVGAvailReport.xsl"; FILE_ID_TO_NAME[REPORT_HTML_XSL] = "AvailabilityReports.xsl"; FILE_ID_TO_NAME[EVENT_REPORT] = "EventReport.xsl"; FILE_ID_TO_NAME[OUTAGE_REPORT] = "OutageReport.xsl"; FILE_ID_TO_NAME[EVENT_REPORT_DTD] = "eventreport.dtd"; FILE_ID_TO_NAME[OUTAGE_REPORT_DTD] = "outagereport.dtd"; FILE_ID_TO_NAME[NOTIFY_REPORT_DTD] = "notifications.dtd"; FILE_ID_TO_NAME[NOTIFY_REPORT] = "NotifyReport.xsl"; FILE_ID_TO_NAME[BASE_CONFIGURATION_FILE_NAME] = "baseConfiguration.xml"; FILE_ID_TO_NAME[COLLECTD_CONFIG_FILE_NAME] = "collectd-configuration.xml"; FILE_ID_TO_NAME[THRESHD_CONFIG_FILE_NAME] = "threshd-configuration.xml"; FILE_ID_TO_NAME[THRESHOLDING_CONF_FILE_NAME] = "thresholds.xml"; FILE_ID_TO_NAME[VULNSCAND_CONFIG_FILE_NAME] = "vulnscand-configuration.xml"; FILE_ID_TO_NAME[VIEWS_DISPLAY_CONF_FILE_NAME] = "viewsdisplay.xml"; FILE_ID_TO_NAME[WEBUI_COLORS_FILE_NAME] = "webui-colors.xml"; FILE_ID_TO_NAME[KSC_REPORT_FILE_NAME] = "ksc-performance-reports.xml"; FILE_ID_TO_NAME[SCRIPTD_CONFIG_FILE_NAME] = "scriptd-configuration.xml"; FILE_ID_TO_NAME[OPENNMS_SERVER_CONFIG_FILE_NAME] = "opennms-server.xml"; FILE_ID_TO_NAME[XMLRPCD_CONFIG_FILE_NAME] = "xmlrpcd-configuration.xml"; FILE_ID_TO_NAME[DHCPD_CONFIG_FILE_NAME] = "dhcpd-configuration.xml"; FILE_ID_TO_NAME[RRD_CONFIG_FILE_NAME] = "rrd-configuration.properties"; FILE_ID_TO_NAME[JAVA_MAIL_CONFIG_FILE_NAME] = "javamail-configuration.properties"; FILE_ID_TO_NAME[VACUUMD_CONFIG_FILE_NAME] = "vacuumd-configuration.xml"; FILE_ID_TO_NAME[XMPP_CONFIG_FILE_NAME] = "xmpp-configuration.properties"; } /** * Returns the base name of the identified file as defined by the passed * integer value. This name has not yet been resolved and is only the name * of the file with no path location information prepended. If the fully * qualified name of the file is needed then use * {@link #getFile(int) getFile()}to returned the {@link java.io.File File} * object. The java File object can be queried to get more detailed * information on the file. * * @param id * The identifier of the desired file. * * @return The base name of the file that matches the identifier. * */ public static final String getFileName(int id) { return FILE_ID_TO_NAME[id]; } /** * <p> * Returns the java {@link java.io.File File}information for the file * identified by the passed integer identifier. If the file cannot be * located by the search algorithm then an excption is generated. * </p> * * <p> * The file is looked for in the <em>etc</em> directory of the OpenNMS * home location identified by the System property <em>opennms.home</em>. * If the file is not found in the <em>etc</em> directory then an attempt * is made to find it in the root OpenNMS directory. If it still cannot be * found then a {@link java.io.FileNotFoundException FileNotFoundException} * is generated by the method. * </p> * * @param id * The identifer for the configuration file. * * @return The File handle to the passed identifier. * * @throws java.io.FileNotFoundException * Thrown if the file cannot be located. * @throws java.io.IOException * Thrown if an error occurs accessing the file system. * */ public static final File getFile(int id) throws IOException { Category log = ThreadCategory.getInstance(ConfigFileConstants.class); // Recover the home directory from the system properties. // String home = getHome(); // Check to make sure that the home directory exists // File fhome = new File(home); if (!fhome.exists()) { log.warn("getFile: The specified home directory does not exist"); throw new FileNotFoundException("The OpenNMS home directory \"" + home + "\" does not exist"); } String rfile = getFileName(id); File frfile = new File(home + File.separator + "etc" + File.separator + rfile); if (!frfile.exists()) { frfile = new File(home + File.separator + rfile); if (!frfile.exists()) { throw new FileNotFoundException("The requested file could not be found"); } } return frfile; } /** * <p> * Returns the java {@link java.io.File File}information for the file * identified by the passed base file name. If the file cannot be located by * the search algorithm then an excption is generated. * </p> * * <p> * The file is looked for in the <em>etc</em> directory of the OpenNMS * home location identified by the System property <em>opennms.home</em>. * If the file is not found in the <em>etc</em> directory then an attempt * is made to find it in the root OpenNMS directory. If it still cannot be * found then a {@link java.io.FileNotFoundException FileNotFoundException} * is generated by the method. * </p> * * @param fname * The base file name of the configuration file. * * @return The File handle to the named file. * * @throws java.io.FileNotFoundException * Thrown if the file cannot be located. * @throws java.io.IOException * Thrown if an error occurs accessing the file system. * */ public static final File getConfigFileByName(String fname) throws IOException { Category log = ThreadCategory.getInstance(ConfigFileConstants.class); // Recover the home directory from the system properties. // String home = getHome(); // Check to make sure that the home directory exists // File fhome = new File(home); if (!fhome.exists()) { log.warn("getConfigFileByName: The specified home directory does not exist"); throw new FileNotFoundException("The OpenNMS home directory \"" + home + "\" does not exist"); } File frfile = new File(home + File.separator + "etc" + File.separator + fname); if (!frfile.exists()) { frfile = new File(home + File.separator + fname); if (!frfile.exists()) { throw new FileNotFoundException("The requested file could not be found"); } } return frfile; } public static final String getHome() { String home = System.getProperty("opennms.home"); if (home == null) { ThreadCategory.getInstance(ConfigFileConstants.class).warn("getConfigFileByName: The \"opennms.home\" property was not set, falling back to /opt/OpenNMS"); home = File.separator + "opt" + File.separator + "OpenNMS"; } // Remove the trailing slash if necessary // if (home.endsWith("/") || home.endsWith(File.separator)) home = home.substring(0, home.length() - 1); return home; } /** * Method to return the string for the managed address include files for * discovery, capsd and polling. * * @return String, the file url for the include file */ public static final String getIncludeFileString() { return "file:" + getHome() + File.separator + "etc" + File.separator + "include"; } /** * Method to return the string for path of the etc directory. * * @return String, the file url for the include file */ public static final String getFilePathString() { return getHome() + File.separator + "etc" + File.separator; } /** * */ public static final String getTimezoneFileDir() { return File.separator + "usr" + File.separator + "share" + File.separator + "zoneinfo" + File.separator + "US"; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -