AdventNet Web NMS 4 API Specification

com.adventnet.nms.severity
Class SeverityInfo

java.lang.Object
  |
  +--com.adventnet.nms.severity.SeverityInfo
All Implemented Interfaces:
java.io.Serializable

public class SeverityInfo
extends java.lang.Object
implements java.io.Serializable

This class provides the API mechanism to access information about the severities configured in Web NMS. Since Web NMS Release 2.2, severities that are handled by Web NMS can be configured in a XML based configuration file namely SeverityInfo.conf present in the [WebNMSHome]/conf directory. User can add or modify or delete severities in the configuration file, which are used by the Web NMS, giving the flexibility to customize and configure severities according to their needs.

The severties are defined using custom defined XML nodes. Each of the severity is specified using an XML node of the following format.


  < SEVERITY ID="Severity-Name"   //name of the severity 
        SEV-COLOR="sev-color">       //eg.,"255-255-0"
  < /SEVERITY >

 
Each SEVERITY node will be treated as a valid severity of Web NMS system. A SEVERITY node can contain sub nodes with any number of levels. Here the Criticality of a severity is measured by the deviation of the SEVERITY node from the mandatory Clear node. The further the node is from the Clear node, the more will be its deviation and hence its criticality.

The class provides mechanism to access every information that are configured within Severity configuration file. To use these methods first the user has to create an instance of this class using any of the static getInstance() method present in this class. The instance of this class created will contain complete information about the severities configured. This information can be accessed by the users using the various methods provided by this class.

The severity information configured in the configuration file is modeled as a tree. With the tree model in place a iterator API mechanism through the class com.adventnet.nms.severity.SeverityIterator is provided to traverse the severity tree and retrieve any desired information about the severities configured.

Any code written by the developers over any of the Web NMS functionalities that directly or indirectly depend upon the severities information, have to use this class to access appropriate details about severities. The developer should notice that it is enough to get one instance of this class (using anyone of the getInstance() method present in this class) to access the entire information about the severities configured. An example user written application would be to add a new event object into Web NMS using Event API mechanism, by setting appropriate severities to the event object created.

To avoid creating multiple instances of this class, this class has a static reference of SeverityInfo and the same reference will be returned whenever the method getInstance() is called.

See Also:
SeverityNode, SeverityIterator, Serialized Form

Field Summary
static int EXCLUDE_NO_CRITICALITY
          Used in few methods to retrieve severity values
static int LEFT
          Used to refer the left portion from clear node
static int RIGHT
          Used to refer the right portion from clear node
 
Method Summary
 int compare(int firstSeverity, int secondSeverity)
          This method compares the criticality of two severities.
 int compare(java.lang.String firstSeverity, java.lang.String secondSeverity)
          This method compares the criticality of two severities.
 boolean contains(int severity)
          This method can be used to find whether a severity is valid one or not.
 boolean contains(java.lang.String severity)
          This method can be used to find whether a severity is valid one or not.
 int getClear()
          Return severity value from clear node.
 java.awt.Color getColor(int severityValue)
          This method can be used to get color value for a severity.
 java.awt.Color getColor(java.lang.String severityName)
          This method can be used to get color value for a severity.
 int getDirectionOfHighestSeverity()
          This can be used to get the direction where the highest criticality occurs.
 int getInfo()
          Return severity value from info node.
static SeverityInfo getInstance()
          This method can be used to get the instance of severityInfo.
static SeverityInfo getInstance(java.lang.String url)
          This method can be called to initialize severity values by reading data from the configuration file.
static SeverityInfo getInstanceFromHost(java.lang.String hostName)
          This method can be used to get SeverityAPI reference from another host.
static SeverityInfo getInstanceFromHost(java.lang.String hostName, int port)
          This method can be used to get SeverityAPI reference from another host.
static SeverityInfo getInstanceFromHost(java.lang.String hostName, int port, java.lang.String userName, AuthTicket ticket)
          This method takes in username and ticket for getting the instance of the SeverityInfo when BE is in Secure RMI mode.
 SeverityIterator getIterator()
          SeverityIterator can be used to traverse leaf nodes which are having criticality.
 java.lang.String getName(int severityValue)
          This method can be used to get severity name for a severity value.
 java.util.Vector getNames()
          This method can be used to get the severity names in criticality descending order.
 java.util.Vector getNames(int type)
          This method can be used to get the severity names in criticality descending order.
 SeverityNode getRootNode()
          This method returns root node.
 int getSeverityCount()
          This method can be used to get total count of all severities.
 int getSeverityCount(int type)
          This method can be used to get total count of severities based on a type.
 SeverityNode getSeverityNode(int severity)
          This method can be used to get SeverityNode of given severity value.
 SeverityNode getSeverityNode(java.lang.String severity)
          This method can be used to get SeverityNode of given severity name.
 int getSpecialPurposeSeverity()
          Web NMS uses one special kind of severity called as specialPurposeSeverity.
 int getUnknown()
          Return severity value from unknown node.
 int getValue(java.lang.String severityName)
          This method can be used to get severity value for a severity name.
 boolean isClear(int severity)
          This method can be used to find the given severity is a clear severity or not.
 boolean isDescending()
          This method is find out the order of the SEV-VALUE.
 boolean isInfo(int severity)
          This method can be used to find the given severity is a info severity or not.
 boolean isNoCriticality(int severity)
          This method can be used to find whether a severity having criticality or not.
 boolean isNoCriticality(java.lang.String severity)
          This method can be used to find whether a severity having criticality or not.
 boolean isUnknown(int severity)
          This method can be used to find the given severity is a unknown severity or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEFT

public static final int LEFT
Used to refer the left portion from clear node

RIGHT

public static final int RIGHT
Used to refer the right portion from clear node

EXCLUDE_NO_CRITICALITY

public static final int EXCLUDE_NO_CRITICALITY
Used in few methods to retrieve severity values
Method Detail

getInstanceFromHost

public static SeverityInfo getInstanceFromHost(java.lang.String hostName)
This method can be used to get SeverityAPI reference from another host. This method should be called only once for the initialization of severity values. The method getInstance() to be used for the rest.
Parameters:
HostName - The name of the host for look up the SeverityAPI reference.
Returns:
instance of SeverityInfo as a result of RMI lookup to the specified host.
See Also:
getInstance(String url)

getInstanceFromHost

public static SeverityInfo getInstanceFromHost(java.lang.String hostName,
                                               int port)
This method can be used to get SeverityAPI reference from another host. This method should be called only once for the initialization of severity values. The method getInstance() to be used for the rest.
Parameters:
hostName - The name of the host for look up the SeverityAPI reference.
port - The port number to which we need to do RMI lookup. This port number refers to the port to which the SeverityAPI would have been bound in the Server.
Returns:
instance of SeverityInfo as a result of RMI lookup to the specified host.
See Also:
getInstance(String url)

getInstance

public static SeverityInfo getInstance(java.lang.String url)
This method can be called to initialize severity values by reading data from the configuration file. This method should be called only once for the initialization of severity values. The method getInstance() to be used for the rest.
Parameters:
UrlString - The urlstring for the configuration file name. To read a conf file from a local disk, the file protocol can be used as follows.

 String url = "file:" + new File(fileName).getAbsolutePath();
 
Returns:
instance of SeverityInfo with the data read from the configuration file mentioned in the url string.
See Also:
getInstance()

getInstance

public static SeverityInfo getInstance()
This method can be used to get the instance of severityInfo. If this method called before initializing the severity values (ie, before calling getInstane(url) OR getInstanceFromHost(hostName) once) will return a new instance of SeverityInfo with default severities. The default severities are as follows.

 Critical - 1;	Major - 2; Minor - 3; Warning - 4; Clear - 5; 
 Info - 6; Unknown - 7
 
Returns:
instance of SeverityInfo.
See Also:
getInstance(String url)

getNames

public java.util.Vector getNames()
This method can be used to get the severity names in criticality descending order. ie. higher the criticality, placed more beginning in the return vector.
Returns:
Vector containing all the severity names arranged according to criticality in descending order

getNames

public java.util.Vector getNames(int type)
This method can be used to get the severity names in criticality descending order. ie. higher the criticality, placed more beginning in the return vector.
Parameters:
type - Type to denote what kind of names to be returned. Presently the only possible value of type is EXCLUDE_NO_CRITICALITY.

EXCLUDE_NO_CRITICALITY - This will return only the names of severities which are having criticality. ie., If a severity node contains an attribute NO-CRITICALITY with the value true, this method will not include such a severity in the vector to be returned.

Returns:
Vector containing severity names. Return null if the type is invalid.

getColor

public java.awt.Color getColor(java.lang.String severityName)
This method can be used to get color value for a severity.
Parameters:
severityName - Name of the severity as specified in the configuration file.
Returns:
color value for the specified severity name. Return null if the severity name is invalid.

getColor

public java.awt.Color getColor(int severityValue)
This method can be used to get color value for a severity.
Parameters:
severityValue - Value of the severity as specified in the configuration file.
Returns:
color value for the specified severity value. Return null if the severity value is invalid.

getValue

public int getValue(java.lang.String severityName)
This method can be used to get severity value for a severity name.
Parameters:
severityName - Name of the severity as specified in the configuration file.
Returns:
severity value of the given severity name. If the name is invalid, returns the value of specialPurposeSeverity.

getName

public java.lang.String getName(int severityValue)
This method can be used to get severity name for a severity value.
Parameters:
severityValue - Value of a severity as specified in the configuration file.
Returns:
name of the severity for the specified severity value. Return null if the severity value is invalid.

getClear

public int getClear()
Return severity value from clear node. If the clear node contains number of child nodes, the return value will be taken from the node which contains the optional attribute called SEV-TYPE with the value as clear. If there is no sub node contains the above attribute, the value for clear will be taken from the first leaf node from the LEFT direction.
Returns:
value of clear severity.

getInfo

public int getInfo()
Return severity value from info node. If the info node contains number of child nodes, the return value will be taken from the node which contains the optional attribute called SEV-TYPE with the value as info. If there is no sub node contains the above attribute, the value for info will be taken from the first leaf node from the LEFT direction.
Returns:
value of info severity.

getUnknown

public int getUnknown()
Return severity value from unknown node. If the unknown node contains number of child nodes, the return value will be taken from the node which contains the attribute called SEV-TYPE with the value as unknown. Any one of the child nodes should contains the SEV-TYPE with the value as unknown.
Returns:
value of unknown severity.

getSeverityCount

public int getSeverityCount()
This method can be used to get total count of all severities.
Returns:
the total count of all severities.
See Also:
getSeverityCount(int type)

getSeverityCount

public int getSeverityCount(int type)
This method can be used to get total count of severities based on a type.
Parameters:
type - Type is to denote what kind of severities to be counted. Presently the only possible value of type is EXCLUDE_NO_CRITICALITY.

EXCLUDE_NO_CRITICALITY - This will count only the severities which are having criticality. ie., if a severity node contains an attribute NO-CRITICALITY with the value true, this method will not count such a severity in the result to be returned.

Returns:
total count of all severities for the specified type.
See Also:
getSeverityCount()

compare

public int compare(int firstSeverity,
                   int secondSeverity)
This method compares the criticality of two severities. This method can be used to compare only the severities which are having criticality. Severity values which are having no criticality like info, unknown cannot be compared using this method.

If both the severity values are having equal criticality then it returns 0. If the first severity is having greater criticality than second one, it returns +1. Or if the second severity is having greater criticality than first one, it returns -1.

Parameters:
firstSeverity - a valid severity value.
secondSeverity - a valid severity value.
Returns:
one of the values from +1, 0, -1.
Throws:
java.util.NoSuchElementException - if both or one of the severities are invalid.
java.lang.IllegalArgumentException - if both or one of the severities are having no criticality.

compare

public int compare(java.lang.String firstSeverity,
                   java.lang.String secondSeverity)
This method compares the criticality of two severities. This method can be used to compare only the severities which are having criticality. Severity values which are having no criticality like info, unknown cannot be compared using this method.

If both the severity values are having equal criticality then it returns 0. If the first severity is having greater criticality than second one, it returns +1. Or if the second severity is having greater criticality than first one, it returns -1.

Parameters:
firstSeverity - a valid severity name.
secondSeverity - a valid severity name.
Returns:
one of the values from +1, 0, -1.
Throws:
java.util.NoSuchElementException - if both or one of the severities are invalid.
java.lang.IllegalArgumentException - if both or one of the severities are having no criticality.

getIterator

public SeverityIterator getIterator()
SeverityIterator can be used to traverse leaf nodes which are having criticality. Nodes which are having NO-CRITICALITY with the value true can not be traversed using SeverityIterator .
Returns:
instance of SeverityIterator.
See Also:
SeverityIterator

getDirectionOfHighestSeverity

public int getDirectionOfHighestSeverity()
This can be used to get the direction where the highest criticality occurs.
Returns:
LEFT if the highest criticality occur in LEFT direction. OR returns RIGHT if the highest criticality occur in RIGHT direction. If both the directions having equal highest criticality, it returns LEFT by default.

isNoCriticality

public boolean isNoCriticality(int severity)
This method can be used to find whether a severity having criticality or not. For example if a severity node say A contains an optional attribute NO-CRITICALITY with value set to true , then the severity for the particular node has no criticality. This method will return true for the above example severity A.
Parameters:
severity - a valid severity value.
Returns:
true if the severity has no criticality or if the severity value is invalid. Or return false if the severity has criticality.

isNoCriticality

public boolean isNoCriticality(java.lang.String severity)
This method can be used to find whether a severity having criticality or not. For example if a severity node say A contains an optional attribute NO-CRITICALITY with value set to true , then the severity for the particular node has no criticality. This method will return true for the above example severity A.
Parameters:
severity - a valid severity name.
Returns:
true if the severity has no criticality or if the severity name is invalid. Or return false if the severity has criticality.

contains

public boolean contains(int severity)
This method can be used to find whether a severity is valid one or not. This method will check whether the given severity is present in the configuration file. If the severity is not present in the configuration file, then the severity is invalid severity.
Parameters:
severity - a severity value to find the validity.
Returns:
true if the severity is a valid. Or return false if the severity is invalid.

contains

public boolean contains(java.lang.String severity)
This method can be used to find whether a severity is valid one or not. This method will check whether the given severity is present in the configuration file. If the severity is not present in the configuration file, then the severity is invalid severity.
Parameters:
severity - a severity name to find the validity.
Returns:
true if the severity is a valid. Or return false if the severity is invalid.

getSpecialPurposeSeverity

public int getSpecialPurposeSeverity()
Web NMS uses one special kind of severity called as specialPurposeSeverity. This severity is internally used to notify delete an alert, etc. By default it has the value -1. If there is a need to use -1 as one of the severity value, a new value (which is not used as a severity value in any of the nodes) to be assigned to SEV-VALUE of SPECIAL-SEVERITY node.
Returns:
the value of specialPurposeSeverity.

isClear

public boolean isClear(int severity)
This method can be used to find the given severity is a clear severity or not.
Parameters:
severity - a valid severity value.
Returns:
true if the severity is a clear severity. Or return false if it is not a clear severity.

isInfo

public boolean isInfo(int severity)
This method can be used to find the given severity is a info severity or not.
Parameters:
severity - a valid severity value.
Returns:
true if the severity is a info severity. Or return false if it is not a info severity.

isUnknown

public boolean isUnknown(int severity)
This method can be used to find the given severity is a unknown severity or not.
Parameters:
severity - a valid severity value.
Returns:
true if the severity is a unknown severity. Or return false if it is not a unknown severity.

getRootNode

public SeverityNode getRootNode()
This method returns root node. By using this root node one can traverse all the severity nodes.
Returns:
root node which contains all the severity nodes as its children.
See Also:
SeverityNode

getSeverityNode

public SeverityNode getSeverityNode(int severity)
This method can be used to get SeverityNode of given severity value.
Parameters:
severity - a valid severity value to get its SeverityNode.
Returns:
the SeverityNode of given severity value. Or return null if the given severity is invalid.
See Also:
SeverityNode

getSeverityNode

public SeverityNode getSeverityNode(java.lang.String severity)
This method can be used to get SeverityNode of given severity name.
Parameters:
severity - a valid severity name to get its SeverityNode.
Returns:
the SeverityNode of given severity value. Or return null if the given severity is invalid.
See Also:
SeverityNode

isDescending

public boolean isDescending()
This method is find out the order of the SEV-VALUE. If the SEV-VALUE order not in descending from clear to high criticality, returns false otherwise returns true isDescending method here.
Returns:
a boolean If SEV-VALUE order is descending, return true, otherwise return false.

getInstanceFromHost

public static SeverityInfo getInstanceFromHost(java.lang.String hostName,
                                               int port,
                                               java.lang.String userName,
                                               AuthTicket ticket)
                                        throws java.lang.Exception
This method takes in username and ticket for getting the instance of the SeverityInfo when BE is in Secure RMI mode. The RMIAccessAPI is looked up from the server and used for getting the SeverityAPI from which the instance of the SeverityInfo is obtained.
Parameters:
hostName - The name of the host for lookup the SeverityAPI reference.
port - The RMI registry port
userName - A valid user for the server.
ticket - The user's ticket (
Returns:
a SeverityInfo instance
Throws:
java.lang.Exception - if an error occurs during either lookup or during the getAPI method of RMIAccessAPI.

AdventNet Web NMS 4 API Specification