Search in sources :

Example 1 with SyslogdConfigurationGroup

use of org.opennms.netmgt.config.syslogd.SyslogdConfigurationGroup in project opennms by OpenNMS.

the class SyslogdConfigFactory method parseIncludedFiles.

/**
 * Parse import-file tags and add all uei-matchs and hide-messages.
 *
 * @throws IOException
 */
private void parseIncludedFiles() throws IOException {
    final File configDir;
    try {
        configDir = ConfigFileConstants.getFile(ConfigFileConstants.SYSLOGD_CONFIG_FILE_NAME).getParentFile();
    } catch (final Throwable t) {
        LOG.warn("Error getting default syslogd configuration location. <import-file> directives will be ignored.  This should really only happen in unit tests.");
        return;
    }
    for (final String fileName : m_config.getImportFiles()) {
        final File configFile = new File(configDir, fileName);
        final SyslogdConfigurationGroup includeCfg = JaxbUtils.unmarshal(SyslogdConfigurationGroup.class, new FileSystemResource(configFile));
        if (includeCfg.getUeiMatches() != null) {
            for (final UeiMatch ueiMatch : includeCfg.getUeiMatches()) {
                if (m_config.getUeiMatches() == null) {
                    m_config.setUeiMatches(new ArrayList<>());
                }
                m_config.addUeiMatch(ueiMatch);
            }
        }
        if (includeCfg.getHideMatches() != null) {
            for (final HideMatch hideMatch : includeCfg.getHideMatches()) {
                if (m_config.getHideMatches() == null) {
                    m_config.setHideMatches(new ArrayList<>());
                }
                m_config.addHideMatch(hideMatch);
            }
        }
    }
}
Also used : SyslogdConfigurationGroup(org.opennms.netmgt.config.syslogd.SyslogdConfigurationGroup) FileSystemResource(org.springframework.core.io.FileSystemResource) File(java.io.File) UeiMatch(org.opennms.netmgt.config.syslogd.UeiMatch) HideMatch(org.opennms.netmgt.config.syslogd.HideMatch)

Aggregations

File (java.io.File)1 HideMatch (org.opennms.netmgt.config.syslogd.HideMatch)1 SyslogdConfigurationGroup (org.opennms.netmgt.config.syslogd.SyslogdConfigurationGroup)1 UeiMatch (org.opennms.netmgt.config.syslogd.UeiMatch)1 FileSystemResource (org.springframework.core.io.FileSystemResource)1