Search in sources :

Example 1 with AsteriskOriginator

use of org.opennms.netmgt.asterisk.utils.AsteriskOriginator in project opennms by OpenNMS.

the class AsteriskOriginateNotificationStrategy method buildOriginator.

private AsteriskOriginator buildOriginator(final List<Argument> arguments) throws AsteriskOriginatorException {
    final AsteriskOriginator ao = new AsteriskOriginator();
    for (final Argument arg : arguments) {
        final String argSwitch = arg.getSwitch();
        final String argValue = arg.getValue();
        if (NotificationManager.PARAM_WORK_PHONE.equals(argSwitch)) {
            LOG.debug("Found: PARAM_WORK_PHONE => {}", argValue);
            ao.setLegAExtension(argValue);
        } else if (NotificationManager.PARAM_HOME_PHONE.equals(argSwitch)) {
            LOG.debug("Found: PARAM_HOME_PHONE => {}", argValue);
            ao.setLegAExtension(argValue);
        } else if (NotificationManager.PARAM_MOBILE_PHONE.equals(argSwitch)) {
            LOG.debug("Found: PARAM_MOBILE_PHONE => {}", argValue);
            ao.setLegAExtension(argValue);
        } else if (NotificationManager.PARAM_SUBJECT.equals(argSwitch)) {
            LOG.debug("Found: PARAM_SUBJECT => {}", argValue);
            ao.setSubject(argValue);
            ao.setChannelVariable(BaseOnmsAgiScript.VAR_OPENNMS_NOTIFY_SUBJECT, argValue);
        } else if (NotificationManager.PARAM_TEXT_MSG.equals(argSwitch)) {
            LOG.debug("Found: PARAM_TEXT_MSG => {}", argValue);
            ao.setMessageText(argValue);
            ao.setChannelVariable(BaseOnmsAgiScript.VAR_OPENNMS_NOTIFY_BODY, argValue);
        } else if (NotificationManager.PARAM_TUI_PIN.equals(argSwitch)) {
            LOG.debug("Found: PARAM_TUI_PIN => {}", argValue);
            ao.setChannelVariable(BaseOnmsAgiScript.VAR_OPENNMS_USER_PIN, argValue);
        } else if (NotificationManager.PARAM_DESTINATION.equals(argSwitch)) {
            LOG.debug("Found: PARAM_DESTINATION => {}", argValue);
            ao.setChannelVariable(BaseOnmsAgiScript.VAR_OPENNMS_USERNAME, argValue);
        } else if (NotificationManager.PARAM_NODE.equals(argSwitch)) {
            LOG.debug("Found: PARAM_NODE => {}", argValue);
            ao.setChannelVariable(BaseOnmsAgiScript.VAR_OPENNMS_NODEID, argValue);
            try {
                final NodeDao nodeDao = BeanUtils.getBean("notifdContext", "nodeDao", NodeDao.class);
                ao.setChannelVariable(BaseOnmsAgiScript.VAR_OPENNMS_NODELABEL, nodeDao.get(argValue).getLabel());
            } catch (final Throwable t) {
                ao.setChannelVariable(BaseOnmsAgiScript.VAR_OPENNMS_NODELABEL, null);
            }
        } else if (NotificationManager.PARAM_INTERFACE.equals(argSwitch)) {
            LOG.debug("Found: PARAM_INTERFACE => {}", argValue);
            ao.setChannelVariable(BaseOnmsAgiScript.VAR_OPENNMS_INTERFACE, argValue);
        } else if (NotificationManager.PARAM_SERVICE.equals(argSwitch)) {
            LOG.debug("Found: PARAM_SERVICE => {}", argValue);
            ao.setChannelVariable(BaseOnmsAgiScript.VAR_OPENNMS_SERVICE, argValue);
        } else {
            LOG.debug("Unconsumed arg: {} => {}", String.valueOf(argSwitch), String.valueOf(argValue));
        }
    }
    return ao;
}
Also used : NodeDao(org.opennms.netmgt.dao.api.NodeDao) Argument(org.opennms.netmgt.model.notifd.Argument) AsteriskOriginator(org.opennms.netmgt.asterisk.utils.AsteriskOriginator)

Aggregations

AsteriskOriginator (org.opennms.netmgt.asterisk.utils.AsteriskOriginator)1 NodeDao (org.opennms.netmgt.dao.api.NodeDao)1 Argument (org.opennms.netmgt.model.notifd.Argument)1