org.opennms.netmgt.linkd
Class EventUtils

java.lang.Object
  extended by org.opennms.netmgt.linkd.EventUtils

public class EventUtils
extends Object

Provides a collection of utility methods used by the DeleteEvent Processor for dealing with Events

Author:
brozow

Constructor Summary
EventUtils()
           
 
Method Summary
static void addEventListener(EventListener listener, List ueiList)
          Make the given listener object a listener for the list of events referenced in the ueiList.
static void checkEventId(Event e)
          Ensures that the event has a database eventId
static void checkHost(Event e)
          Ensures the given event has a host
static void checkInterface(Event e)
          Ensures the given event has an interface
static void checkNodeId(Event e)
          Ensures that the given Event has a node id
static void checkService(Event e)
          Ensures that the given event has a service parameter
static long getEventID(Event e)
          Get the eventId for the given event
static long getLongParm(Event e, String parmName, long defaultValue)
          Retrieve the value associated with an event parameter and parse it to a long.
static long getNodeId(Event e)
          Return the nodeId of the node associated with and event, or -1 of no node is associated.
static String getParm(Event e, String parmName)
          Return the value of an event parameter of null if it does not exist.
static String getParm(Event e, String parmName, String defaultValue)
          Retrieve a parameter from and event, returning defaultValue of the parameter is not set.
static void requireParm(Event e, String parmName)
          Throw an exception if an event does have the required parameter
static void sendEvent(Event newEvent, String callerUei, long txNo, boolean isXmlRpcEnabled)
          Send an event to the Event manager to be broadcast to interested listeners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventUtils

public EventUtils()
Method Detail

addEventListener

public static void addEventListener(EventListener listener,
                                    List ueiList)
Make the given listener object a listener for the list of events referenced in the ueiList.

Parameters:
listener - the lister to add
ueiList - the list of events the listener is interested

checkEventId

public static void checkEventId(Event e)
                         throws InsufficientInformationException
Ensures that the event has a database eventId

Parameters:
e - the event
Throws:
InsufficientInformationException - if an event id is not evailable

checkInterface

public static void checkInterface(Event e)
                           throws InsufficientInformationException
Ensures the given event has an interface

Parameters:
e - the event
Throws:
InsufficientInformationException - if an interface is not available

checkHost

public static void checkHost(Event e)
                      throws InsufficientInformationException
Ensures the given event has a host

Parameters:
e - the event
Throws:
InsufficientInformationException - if an interface is not available

checkNodeId

public static void checkNodeId(Event e)
                        throws InsufficientInformationException
Ensures that the given Event has a node id

Parameters:
e - the event
Throws:
InsufficientInformationException - if a node id is not available

checkService

public static void checkService(Event e)
                         throws InsufficientInformationException
Ensures that the given event has a service parameter

Parameters:
e - the event to check
Throws:
InsufficientInformationException - if the event does not have a service

getEventID

public static long getEventID(Event e)
Get the eventId for the given event

Parameters:
e - the event to get the eventId for
Returns:
the eventId of the event or -1 of no eventId is assigned

getLongParm

public static long getLongParm(Event e,
                               String parmName,
                               long defaultValue)
Retrieve the value associated with an event parameter and parse it to a long. If the value can not be found, return a default value.

Parameters:
e - the Event to retrieve the parameter from
parmName - the name of the parameter to retrieve
defaultValue - the value to return if the paramter can not be retrieved or parsed
Returns:
the value of the parameter as a long

getNodeId

public static long getNodeId(Event e)
Return the nodeId of the node associated with and event, or -1 of no node is associated.

Parameters:
e - the event
Returns:
the nodeId or -1 if no nodeId is set

getParm

public static String getParm(Event e,
                             String parmName)
Return the value of an event parameter of null if it does not exist.

Parameters:
e - the Event to get the parameter for
parmName - the name of the parameter to retrieve
Returns:
the value of the parameter, or null of the parameter is not set

getParm

public static String getParm(Event e,
                             String parmName,
                             String defaultValue)
Retrieve a parameter from and event, returning defaultValue of the parameter is not set.

Parameters:
e - The Event to retrieve the parameter from
parmName - the name of the parameter to retrieve
defaultValue - the default value to return if the parameter is not set
Returns:
the value of the parameter, or defalutValue if the parameter is not set

requireParm

public static void requireParm(Event e,
                               String parmName)
                        throws InsufficientInformationException
Throw an exception if an event does have the required parameter

Parameters:
e - the event the parameter must reside on
parmname - the name of the parameter
Throws:
InsufficientInformationException - if the paramter is not set on the event or if its value has no content

sendEvent

public static void sendEvent(Event newEvent,
                             String callerUei,
                             long txNo,
                             boolean isXmlRpcEnabled)
Send an event to the Event manager to be broadcast to interested listeners

Parameters:
newEvent - the event to send
isXmlRpcEnabled - FIXME


Copyright © 2009. All Rights Reserved.