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

📄 eventexpander.java

📁 opennms得相关源码 请大家看看
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        return dest;    }    /**     * This method is used to transform an operator action event configuration     * instance into an operator action event instance. This is used when the     * incomming event does not have any operator action information and the     * information from the configuration object is copied.     *      * @param src     *            The configuration source to transform.     *      * @return The transformed operator action information.     *      */    private static org.opennms.netmgt.xml.event.Operaction transform(org.opennms.netmgt.xml.eventconf.Operaction src) {        org.opennms.netmgt.xml.event.Operaction dest = new org.opennms.netmgt.xml.event.Operaction();        dest.setContent(src.getContent());        dest.setState(src.getState());        dest.setMenutext(src.getMenutext());        return dest;    }    /**     * This method is used to transform an auto acknowledgement event     * configuration instance into an auto acknowledgement event instance. This     * is used when the incomming event does not have any auto acknowledgement     * information and the information from the configuration object is copied.     *      * @param src     *            The configuration source to transform.     *      * @return The transformed auto acknowledgement information.     *      */    private static org.opennms.netmgt.xml.event.Autoacknowledge transform(org.opennms.netmgt.xml.eventconf.Autoacknowledge src) {        org.opennms.netmgt.xml.event.Autoacknowledge dest = new org.opennms.netmgt.xml.event.Autoacknowledge();        dest.setContent(src.getContent());        dest.setState(src.getState());        return dest;    }    /**     * This method is used to transform a trouble ticket event configuration     * instance into a trouble ticket event instance. This is used when the     * incomming event does not have any trouble ticket information and the     * information from the configuration object is copied.     *      * @param src     *            The configuration source to transform.     *      * @return The transformed trouble ticket information.     *      */    private static org.opennms.netmgt.xml.event.Tticket transform(org.opennms.netmgt.xml.eventconf.Tticket src) {        org.opennms.netmgt.xml.event.Tticket dest = new org.opennms.netmgt.xml.event.Tticket();        dest.setContent(src.getContent());        dest.setState(src.getState());        return dest;    }    /**     * This method is used to transform a forward event configuration instance     * into a forward event instance. This is used when the incomming event does     * not have any forward information and the information from the     * configuration object is copied.     *      * @param src     *            The configuration source to transform.     *      * @return The transformed forward information.     *      */    private static org.opennms.netmgt.xml.event.Forward transform(org.opennms.netmgt.xml.eventconf.Forward src) {        org.opennms.netmgt.xml.event.Forward dest = new org.opennms.netmgt.xml.event.Forward();        dest.setContent(src.getContent());        dest.setState(src.getState());        dest.setMechanism(src.getMechanism());        return dest;    }    /**     * This method is used to transform a script event configuration instance     * into a script event instance. This is used when the incoming event does     * not have any script information and the information from the     * configuration object is copied.     *      * @param src     *            The configuration source to transform.     *      * @return The transformed script information.     *      */    private static org.opennms.netmgt.xml.event.Script transform(org.opennms.netmgt.xml.eventconf.Script src) {        org.opennms.netmgt.xml.event.Script dest = new org.opennms.netmgt.xml.event.Script();        dest.setContent(src.getContent());        dest.setLanguage(src.getLanguage());        return dest;    }    /**     * <p>     * This method is used to find the matching event configuration object by     * looking at the event's SNMP information. In particular, the SNMP     * Enterprise Identifier is used first if it exist to find the matching     * record. If the enterprise identifier exists then it is compared as is, if     * that doesn't match then the enterprise prefix is stripped and the lookup     * is preformed again.     * </p>     *      * <p>     * If the enterprise identifier is not found, but the event has generic and     * specific information then the appropriate generic UEI is used to find the     * appropriate record.     * </p>     *      *      * @param snmpInfo     *            The SNMP event information.     *      * @return The matching event configuration object if found. A null     *         reference is returned if no match can be found.     *      * @exception java.lang.NullPointerException     *                Thrown if the snmpInfo parameter that was passed is null.     *      */    private static org.opennms.netmgt.xml.eventconf.Event lookup(Snmp snmpInfo) {        // Check the passed argument and make sure that        // it is valid. Throw the null pointer here instead of        // waiting for an invalid reference.        //        if (snmpInfo == null)            throw new NullPointerException("Invalid argument, the Snmp argument was null");        org.opennms.netmgt.xml.eventconf.Event eConf = null;        // Do enterprise id matching here        //        String eid = snmpInfo.getId();        // do a lookup on the fully qualified name first        //        eConf = EventConfigurationManager.getBySnmpEid(eid);        if (eConf == null && eid != null && eid.startsWith(ENTERPRISE_PRE)) {            // try partial match            //            eConf = EventConfigurationManager.getBySnmpEid(eid.substring(ENTERPRISE_PRE.length()));        } else if (eConf == null && eid != null && !eid.startsWith(ENTERPRISE_PRE)) {            // try complete match            //            eConf = EventConfigurationManager.getBySnmpEid(ENTERPRISE_PRE + eid);        }        // If no lookup has been possible yet, check the SNMP generic        // type and see if we can process it.        //        // Note: This is now changed. There are no more default generic events        // so that users can customize the Generic Traps 0-5. This does require        // an entry in eventconf.xml to catch these traps explicitly.        // return the found event base object        //        return eConf;    } // end lookup(SnmpInfo)    /**     * <p>     * This method is used to lookup the event configuration object based upon     * information in the passed information. The     * {@link EventConfigurationManager EventConfigurationManager}instance is     * consulted to find a matching configured event. The lookup algorithm     * favors SNMP information if avaialable, and then defaults to the event's     * Universal Event Identfier.     * </p>     *      * @param event     *            The event to find a configuration for.     *      * @return The matching configuration event, if any.     *      * @exception java.lang.NullPointerException     *                Thrown if the event parameter that was passed is null.     *      */    private static org.opennms.netmgt.xml.eventconf.Event lookup(Event event) {        if (event == null)            throw new NullPointerException("Invalid argument, the event parameter must not be null");        //        // The event configuration that matches the lookup        // for the passed event        //        org.opennms.netmgt.xml.eventconf.Event eConf = null;        org.opennms.netmgt.xml.eventconf.Event eSnmpConf = null;        //        // lookup based on the event mask, (defaults to UEI        // if there is no mask specified)        //        eConf = EventConfigurationManager.get(event);        //        // lookup on SNMP information if it exists.        // This lookup will return EVENT_TRAP_UEI        // if no other one can be found and it's enterprise        // specific        //        if (event.getSnmp() != null) {            eSnmpConf = lookup(event.getSnmp());        }        //        // now process        //         if (eConf == null && eSnmpConf != null) {            //            // set eConf to eSnmpConf            //            eConf = eSnmpConf;        } else if (eConf == null && eSnmpConf == null) {            //            // take the configuration of the default event            //            eConf = EventConfigurationManager.getByUei(DEFAULT_EVENT_UEI);        } else if (eConf != null && eSnmpConf != null) {            //            // If the econf not being null was a result of it not            // having an event mask(i.e defaulted to a UEI lookup),            // OR            // If the event mask lookup went through with a mask            // that does not include the SNMP EID,            // THEN            // Give precedence to the snmp lookup            //            if ((eConf.getMask() == null))                eConf = eSnmpConf;            else {                boolean snmpEidIsPartOfMask = false;                Enumeration en = eConf.getMask().enumerateMaskelement();                while (en.hasMoreElements()) {                    org.opennms.netmgt.xml.eventconf.Maskelement maskelement = (org.opennms.netmgt.xml.eventconf.Maskelement) en.nextElement();                    String name = maskelement.getMename();                    if (name.equals(org.opennms.netmgt.eventd.datablock.EventKey.TAG_SNMP_EID)) {                        snmpEidIsPartOfMask = true;                        break;                    }                }                if (!snmpEidIsPartOfMask)                    eConf = eSnmpConf;            }        }        return eConf;    }    /**

⌨️ 快捷键说明

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