⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eventexpander.java

📁 opennms得相关源码 请大家看看
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     * Expand parms in the event logmsg     */    private static void expandParms(Logmsg logmsg, Event event) {        String strRet = EventUtil.expandParms(logmsg.getContent(), event);        if (strRet != null) {            logmsg.setContent(strRet);        }    }    /**     * Expand parms in the event autoaction(s)     */    private static void expandParms(Autoaction[] autoactions, Event event) {        boolean expanded = false;        for (int index = 0; index < autoactions.length; index++) {            Autoaction action = autoactions[index];            String strRet = EventUtil.expandParms(action.getContent(), event);            if (strRet != null) {                action.setContent(strRet);                expanded = true;            }        }        if (expanded)            event.setAutoaction(autoactions);    }    /**     * Expand parms in the event operaction(s)     */    private static void expandParms(Operaction[] operactions, Event event) {        boolean expanded = false;        for (int index = 0; index < operactions.length; index++) {            Operaction action = operactions[index];            String strRet = EventUtil.expandParms(action.getContent(), event);            if (strRet != null) {                action.setContent(strRet);                expanded = true;            }        }        if (expanded)            event.setOperaction(operactions);    }    /**     * Expand parms in the event tticket     */    private static void expandParms(Tticket tticket, Event event) {        String strRet = EventUtil.expandParms(tticket.getContent(), event);        if (strRet != null) {            tticket.setContent(strRet);        }    }    /**     * Expand the element values if they have parms in one of the following     * formats     *  - %element% values are expanded to have the value of the element where     * 'element' is an element in the event DTD - %parm[values-all]% is expanded     * to a delimited list of all parmblock values - %parm[names-all]% is     * expanded to a list of all parm names - %parm[all]% is expanded to a full     * dump of all parmblocks - %parm[ <name>]% is replaced by the value of the     * parameter named 'name', if present - %parm[# <num>]% is replaced by the     * value of the parameter number 'num', if present - %parm[##]% is replaced     * by the number of parameters     */    private static void expandParms(Event event) {        String strRet = null;        // description        if (event.getDescr() != null) {            strRet = EventUtil.expandParms(event.getDescr(), event);            if (strRet != null) {                event.setDescr(strRet);                strRet = null;            }        }        // logmsg        if (event.getLogmsg() != null) {            expandParms(event.getLogmsg(), event);        }        // operinstr        if (event.getOperinstruct() != null) {            strRet = EventUtil.expandParms(event.getOperinstruct(), event);            if (strRet != null) {                event.setOperinstruct(strRet);                strRet = null;            }        }        // autoaction        if (event.getAutoaction() != null) {            expandParms(event.getAutoaction(), event);        }        // operaction        if (event.getOperaction() != null) {            expandParms(event.getOperaction(), event);        }        // tticket        if (event.getTticket() != null) {            expandParms(event.getTticket(), event);        }    }    /**     * <p>     * This method is invoked to check and configure a received event. The event     * configuration manager is consulted to find the appropriate configuration     * that is used to expand the event. In addition, the security parameters     * from the configuration manager is consulted to ensure that secure files     * are cleared out if necessary.     * </p>     *      * <p>     * Any secure fields that exists in the incomming event are cleared during     * expansion.     * </p>     *      * @param e     *            The event to expand if necesary.     *      */    public static synchronized void expandEvent(Event e) {        org.opennms.netmgt.xml.eventconf.Event econf = lookup(e);        if (econf != null) {            if (EventConfigurationManager.isSecureTag("mask"))                e.setMask(null);            if (e.getMask() == null && econf.getMask() != null) {                e.setMask(transform(econf.getMask()));            }            // Copy the UEI            //            if (e.getUei() == null)                e.setUei(econf.getUei());            // Copy the Snmp Information            //            if (e.getSnmp() == null && econf.getSnmp() != null)                e.setSnmp(transform(econf.getSnmp()));            // Copy the description            //            if (EventConfigurationManager.isSecureTag("descr"))                e.setDescr(null);            if (e.getDescr() == null && econf.getDescr() != null)                e.setDescr(econf.getDescr());            // Copy the log message if any            //            if (EventConfigurationManager.isSecureTag("logmsg"))                e.setLogmsg(null);            if (e.getLogmsg() == null && econf.getLogmsg() != null)                e.setLogmsg(transform(econf.getLogmsg()));            // Copy the severity            //            if (EventConfigurationManager.isSecureTag("severity"))                e.setSeverity(null);            if (e.getSeverity() == null && econf.getSeverity() != null)                e.setSeverity(econf.getSeverity());            // Set the correlation information            //            if (EventConfigurationManager.isSecureTag("correlation"))                e.setCorrelation(null);            if (e.getCorrelation() == null && econf.getCorrelation() != null)                e.setCorrelation(transform(econf.getCorrelation()));            // Copy the operator instruction            //            if (EventConfigurationManager.isSecureTag("operinstruct"))                e.setOperinstruct(null);            if (e.getOperinstruct() == null && econf.getOperinstruct() != null)                e.setOperinstruct(econf.getOperinstruct());            // Copy the auto actions.            //            if (EventConfigurationManager.isSecureTag("autoaction"))                e.clearAutoaction();            if (e.getAutoactionCount() == 0 && econf.getAutoactionCount() > 0) {                Enumeration eter = econf.enumerateAutoaction();                while (eter.hasMoreElements()) {                    org.opennms.netmgt.xml.eventconf.Autoaction src = (org.opennms.netmgt.xml.eventconf.Autoaction) eter.nextElement();                    e.addAutoaction(transform(src));                }            }            // Convert the operator actions            //            if (EventConfigurationManager.isSecureTag("operaction"))                e.clearOperaction();            if (e.getOperactionCount() == 0 && econf.getOperactionCount() > 0) {                Enumeration eter = econf.enumerateOperaction();                while (eter.hasMoreElements()) {                    org.opennms.netmgt.xml.eventconf.Operaction src = (org.opennms.netmgt.xml.eventconf.Operaction) eter.nextElement();                    e.addOperaction(transform(src));                }            }            // Convert the auto acknowledgement            //            if (EventConfigurationManager.isSecureTag("autoacknowledge"))                e.setAutoacknowledge(null);            if (e.getAutoacknowledge() == null && econf.getAutoacknowledge() != null)                e.setAutoacknowledge(transform(econf.getAutoacknowledge()));            // Convert the log group information            //            if (EventConfigurationManager.isSecureTag("loggroup"))                e.clearLoggroup();            if (e.getLoggroupCount() == 0 && econf.getLoggroupCount() > 0)                e.setLoggroup(econf.getLoggroup());            // Convert the trouble tickets.            //            if (EventConfigurationManager.isSecureTag("tticket"))                e.setTticket(null);            if (e.getTticket() == null && econf.getTticket() != null)                e.setTticket(transform(econf.getTticket()));            // Convert the forward entry            //            if (EventConfigurationManager.isSecureTag("forward"))                e.clearForward();            if (e.getForwardCount() == 0 && econf.getForwardCount() > 0) {                Enumeration eter = econf.enumerateForward();                while (eter.hasMoreElements()) {                    org.opennms.netmgt.xml.eventconf.Forward src = (org.opennms.netmgt.xml.eventconf.Forward) eter.nextElement();                    e.addForward(transform(src));                }            }            // Convert the script entry            //            if (EventConfigurationManager.isSecureTag("script"))                e.clearScript();            if (e.getScriptCount() == 0 && econf.getScriptCount() > 0) {                Enumeration eter = econf.enumerateScript();                while (eter.hasMoreElements()) {                    org.opennms.netmgt.xml.eventconf.Script src = (org.opennms.netmgt.xml.eventconf.Script) eter.nextElement();                    e.addScript(transform(src));                }            }            // Copy the mouse over text            //            if (EventConfigurationManager.isSecureTag("mouseovertext"))                e.setMouseovertext(null);            if (e.getMouseovertext() == null && econf.getMouseovertext() != null)                e.setMouseovertext(econf.getMouseovertext());        } // end fill of event using econf        // do the event parm expansion        expandParms(e);    } // end expandEvent()}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -