Search in sources :

Example 1 with NotificationCommands

use of org.opennms.netmgt.config.notificationCommands.NotificationCommands in project opennms by OpenNMS.

the class NotificationCommandManager method parseXML.

/**
     * Populate the internal list of notification commands from an XML file.
     *
     * @param reader contains the XML file to be parsed
     * @throws IOException 
     */
protected void parseXML(InputStream stream) throws IOException {
    final NotificationCommands config;
    try (final Reader reader = new InputStreamReader(stream)) {
        config = JaxbUtils.unmarshal(NotificationCommands.class, reader);
    }
    Map<String, Command> commands = new HashMap<String, Command>();
    for (Command curCommand : getCommandsFromConfig(config)) {
        if (curCommand != null && curCommand.getName() != null) {
            commands.put(curCommand.getName(), curCommand);
        } else {
            LOG.warn("invalid notification command: {}", curCommand);
        }
    }
    m_commands = commands;
}
Also used : InputStreamReader(java.io.InputStreamReader) HashMap(java.util.HashMap) Command(org.opennms.netmgt.config.notificationCommands.Command) NotificationCommands(org.opennms.netmgt.config.notificationCommands.NotificationCommands) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader)

Aggregations

InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 HashMap (java.util.HashMap)1 Command (org.opennms.netmgt.config.notificationCommands.Command)1 NotificationCommands (org.opennms.netmgt.config.notificationCommands.NotificationCommands)1