AdventNet Web NMS 4 API Specification

com.adventnet.nms.fe.common
Interface NmsTreeAPI

All Superinterfaces:
CommonModuleAPI, java.rmi.Remote
All Known Implementing Classes:
NmsTreeAPIImpl

public interface NmsTreeAPI
extends CommonModuleAPI, java.rmi.Remote

     This a RMI based API which provides methods to access and modify the user based client tree structure present in the database. This API provides mechanism to do the following tree operations for a particular/'All' user. 'All' user means, all the users for whom, Web NMS maintains the tree structure.

Tree Operations
      
  1. Addnode Operation
  2. Modifynode Operation
  3. Removenode Operation
  4. Movenode Operation
These methods operate over a database interface layer, which translate the java objects to fit into RDBMS tables.The database layer can work with any JDBC complaint RDBMS.

Accessing NmsTreeAPI
This API can be accessed either through RMI or directly from the same JVM. It is published with the RMI handle TreeAPI in the Web NMS Server. Application running in the same JVM as that of the Nms server can use the getAPI method.

The example below shows how NmsTreeAPI can be accessed by the above mentioned means from same JVM or through RMI .

 Accessing NmsTreeAPI via RMI

   NmsTreeAPI  treeAPI = (NmsTreeAPI) Naming.lookup("//hostname/TreeAPI"); //Here hostname refers to the name of the machine on which the Web NMS Server deployed (BE or FE), where the NmsTreeAPI would be bound. 
 

 Accessing NmsTreeAPI from the same JVM
 
    NmsTreeAPI treeAPI = (NmsTreeAPI)NmsUtil.getAPI("TreeAPI");

Notification mechanism
This API has the notification mechanism , which is responsible for notifying the applications about the Tree Structure changes for a particular user. For getting these notification, Application has to register with this API as a DBXMLNodeListener via register method.

This API also provides mechanism to stop this notification mechansim , by invoking deRegister method by giving user name. Web NMS Client is a default application which uses this notification mechanism to construct the tree. Web NMS client will add, modify, move and remove tree nodes based on the type of notification which is received from this API.

It should be noted that, to perform tree operations like add, modify, remove and move using the APIs provided an instance of the class PanelTreeNode has to be created to hold the tree node information and passed to the corresponding API methods.

Since:
WebNMS 2.3 SP6
See Also:
PanelTreeNode

Method Summary
 boolean addNode(PanelTreeNode panelNode)
          This method adds a node as the last child of the specified parent in the user defined tree.
 boolean deleteAllNodes(java.lang.String userName)
          This method removes all tree nodes from the user defined tree (for the specified user).
 void deRegister(java.lang.String userName, DBXMLNodeListener listener)
          Removes the listener from the listeners list so that the listener will no longer get any update for the tree node operation.
 int getChildCount(java.lang.String userName, java.lang.String parent)
          Returns the child count of the given parent for the given userName.
 java.util.Vector getChildList(java.lang.String userName, java.lang.String moduleName)
          This method returns nodeId belonging to the specified module
 int getNodeCount(java.lang.String userName)
          This method returns number of tree node that exist for a given user.
 PanelTreeNode getPanelTreeNode(java.lang.String userName, java.lang.String nodeId)
          Returns PanelTreeNode for the given nodeId and userName.
 java.lang.String getParent(java.lang.String userName, java.lang.String nodeId)
          This method returns parent NodeID for the given NodeID
 XMLNode getTree(java.lang.String userName, java.lang.String id)
          This method returns hierarchy of the given node (whose id is passed as an argument).
 boolean insertNode(PanelTreeNode panelNode)
          This method inserts a node in the specified index, under the specified parent in the user defined tree.
 boolean modifyNode(PanelTreeNode panelNode)
          This method is used to modify a tree node for a particular user or for all the users.
 boolean moveNode(java.lang.String nodeId, java.lang.String userName, java.lang.String newParent)
          This method moves the specified tree node (whose nodeId is passed as argument) under the given new parent in the user defined tree.
 boolean moveNode(java.lang.String nodeId, java.lang.String userName, java.lang.String newParent, int nodeIndex)
          This method moves the specified tree node (whose nodeId is passed as argument) to the specific position (specified by the argument index) under the given new parent in the user defined tree.
 boolean nodeExist(java.lang.String userName, java.lang.String nodeId)
          This method returns true if the tree node is present in user defined tree.
 void register(java.lang.String userName, DBXMLNodeListener listener)
          All the DBXMLNodeListeners will register with the corresponding userName for getting updates on any Node operation viz.,add,delete,modify,insert etc.,
 boolean removeNode(java.lang.String nodeId, java.lang.String userName, boolean deleteAllChild)
          This method removes a node from the user defined tree.If deleteAllChild argument is set to true,then the entire hierarchy that means all the child nodes of the specified tree node will be removed from the user defined tree.
 boolean removeNode(java.lang.String nodeId, java.lang.String userName, java.lang.String moduleName, boolean deleteAllChild)
          This method removes a node from the user defined tree.If deleteAllChild argument is set to true,then the entire hierarchy that means all the child nodes of the specified tree node will be removed from the user defined tree.
 void updateUserDetail(java.lang.String userName)
          This method creates/updates the tree in the database for a given user.
 

Method Detail

register

public void register(java.lang.String userName,
                     DBXMLNodeListener listener)
              throws java.rmi.RemoteException
All the DBXMLNodeListeners will register with the corresponding userName for getting updates on any Node operation viz.,add,delete,modify,insert etc.,
Parameters:
userName - the userName for which the updates are to be received.
listener - the listener registering for the updates.

deRegister

public void deRegister(java.lang.String userName,
                       DBXMLNodeListener listener)
                throws java.rmi.RemoteException
Removes the listener from the listeners list so that the listener will no longer get any update for the tree node operation.
Parameters:
userName - the userName for which the updates were received.
listener - the listener which has to be deregistered for the updates.

addNode

public boolean addNode(PanelTreeNode panelNode)
                throws java.rmi.RemoteException,
                       NmsStorageException,
                       UserTransactionException
This method adds a node as the last child of the specified parent in the user defined tree.
Parameters:
panelNode - a PanelTreeNode which contains data for the nodeid to be added
Throws:
NmsStorageException - if any problem occurs when adding the node.
UserTransactionException - If any error occurs inside the User Transaction block. This is applicable only when this API is executed within the context of a User Transaction.
See Also:
UserTransactionException

insertNode

public boolean insertNode(PanelTreeNode panelNode)
                   throws java.rmi.RemoteException,
                          NmsStorageException,
                          UserTransactionException
This method inserts a node in the specified index, under the specified parent in the user defined tree.
Parameters:
panelNode - a PanelTreeNode which contains data for the nodeid to be added
Throws:
NmsStorageException - if any problem occurs when inserting the node
UserTransactionException - If any error occurs inside the User Transaction block. This is applicable only when this API is executed within the context of a User Transaction.
See Also:
UserTransactionException

removeNode

public boolean removeNode(java.lang.String nodeId,
                          java.lang.String userName,
                          boolean deleteAllChild)
                   throws java.rmi.RemoteException,
                          NmsStorageException,
                          UserTransactionException
This method removes a node from the user defined tree.If deleteAllChild argument is set to true,then the entire hierarchy that means all the child nodes of the specified tree node will be removed from the user defined tree. If deleteAllChild argument is set to false then it moves the children of deleted node as children to the parent of deleted node.
Parameters:
nodeId - the unique identification for the node being removed.
userName - the name of the user.
deleteAllChild - if true delete all the children's of the deleted node else it moves the children as children to the parent of deleted node
Throws:
com.adventnet.nms.util.NmsStorageException - if any problem occurs when removing the node.
UserTransactionException - If any error occurs inside the User Transaction block. This is applicable only when this API is executed within the context of a User Transaction.
See Also:
UserTransactionException

removeNode

public boolean removeNode(java.lang.String nodeId,
                          java.lang.String userName,
                          java.lang.String moduleName,
                          boolean deleteAllChild)
                   throws java.rmi.RemoteException,
                          NmsStorageException,
                          UserTransactionException
This method removes a node from the user defined tree.If deleteAllChild argument is set to true,then the entire hierarchy that means all the child nodes of the specified tree node will be removed from the user defined tree. If deleteAllChild argument is set to false then it moves the children of deleted node as children to the parent of deleted node.
Parameters:
nodeId - the unique identification for the node being removed.
userName - the name of the user.
moduleName - the name of the table, from which the node is to be removed in addition to PanelTree and PanelProps tables.
deleteAllChild - if true delete all the children's of the deleted node else it moves the children as children to the parent of deleted node
Throws:
java.rmi.RemoteException - if an error occurs when removing the node
NmsStorageException - if an error occurs when removing the node
UserTransactionException - If any error occurs inside the User Transaction block. This is applicable only when this API is executed within the context of a User Transaction.
See Also:
UserTransactionException

modifyNode

public boolean modifyNode(PanelTreeNode panelNode)
                   throws java.rmi.RemoteException,
                          NmsStorageException,
                          UserTransactionException
This method is used to modify a tree node for a particular user or for all the users. This is to modify the tree node in the server side and send the updates to the client.
Parameters:
panelNode - a PanelTreeNode which contains data for the tree node to be modified. A PanelTreeNode object is used to define how and which tree node is to be modified.
 Example PanelTreeNode Object :

      // To set the panel properties

      PanelTreeNode panelNode = new PanelTreeNode("Events"); // to 
      modify "Network Events" tree node

      panelNode.setUserName("root"); // to modify "Network Events" 
      tree node of user "root" 

      Properties panelProperties = new Properties(); 
      panelProperties.put("TREE-NAME","My Network Events"); 
      panelProperties.put("ICON-FILE","images/pc.png"); 
      panelProperties.put("MENU-FILE-NAME","alertsmenu.xml"); 
      panelProperties.put("<UPDATE_ONLY>","true"); // This attribute is 
      very important to specify whether the given properites are to be updated 
      or overwritten

      panelNode.setPanelProperties(panelProperties); 

 After constructing the PanelTreeNode object, invoke NmsTreeAPI.modifyNode() 
 API to modify the tree node.

 Sample Code Snippet :

 NmsTreeAPI.modifyNode(panelNode);

 
Throws:
NmsStorageException - if any problem occurs when modifying the node
UserTransactionException - If any error occurs inside the User Transaction block. This is applicable only when this API is executed within the context of a User Transaction.
See Also:
UserTransactionException, PanelTreeNode

moveNode

public boolean moveNode(java.lang.String nodeId,
                        java.lang.String userName,
                        java.lang.String newParent)
                 throws java.rmi.RemoteException,
                        NmsStorageException,
                        UserTransactionException
This method moves the specified tree node (whose nodeId is passed as argument) under the given new parent in the user defined tree.
Parameters:
nodeId - the unique identification for the node being modified.
userName - the name of the user.
newParent - the parent under which the node is to be moved.
Throws:
NmsStorageException - if any problem
UserTransactionException - If any error occurs inside the User Transaction block. This is applicable only when this API is executed within the context of a User Transaction.
See Also:
UserTransactionException

moveNode

public boolean moveNode(java.lang.String nodeId,
                        java.lang.String userName,
                        java.lang.String newParent,
                        int nodeIndex)
                 throws java.rmi.RemoteException,
                        NmsStorageException,
                        UserTransactionException
This method moves the specified tree node (whose nodeId is passed as argument) to the specific position (specified by the argument index) under the given new parent in the user defined tree.
Parameters:
nodeId - the unique identification for the node being modified.
userName - the name of the user.
newNodeIndex - the node index to which node is to be moved.
newParent - the parent under which the node is to be moved.
Throws:
NmsStorageException - if any problem
UserTransactionException - If any error occurs inside the User Transaction block. This is applicable only when this API is executed within the context of a User Transaction.
See Also:
UserTransactionException

getChildCount

public int getChildCount(java.lang.String userName,
                         java.lang.String parent)
                  throws java.rmi.RemoteException,
                         NmsStorageException,
                         UserTransactionException
Returns the child count of the given parent for the given userName.
Parameters:
userName - the name of the user
parent - the parent for you need the child count
Throws:
UserTransactionException - If any error occurs inside the User Transaction block. This is applicable only when this API is executed within the context of a User Transaction.
See Also:
UserTransactionException

getParent

public java.lang.String getParent(java.lang.String userName,
                                  java.lang.String nodeId)
                           throws java.rmi.RemoteException,
                                  NmsStorageException,
                                  UserTransactionException
This method returns parent NodeID for the given NodeID
Parameters:
NODEID: - ID
userName -  
Returns:
String it returns the parent NodeID of the given NodeID.
Throws:
NmsStorageException - for any database error
UserTransactionException - If any error occurs inside the User Transaction block. This is applicable only when this API is executed within the context of a User Transaction.
See Also:
UserTransactionException

getPanelTreeNode

public PanelTreeNode getPanelTreeNode(java.lang.String userName,
                                      java.lang.String nodeId)
                               throws java.rmi.RemoteException,
                                      NmsStorageException,
                                      UserTransactionException
Returns PanelTreeNode for the given nodeId and userName.
Parameters:
NODEID: - ID
userName -  
Returns:
PanelTreeNode which contains details regarding the node
Throws:
NmsStorageException - for any database error
UserTransactionException - If any error occurs inside the User Transaction block. This is applicable only when this API is executed within the context of a User Transaction.
See Also:
UserTransactionException

deleteAllNodes

public boolean deleteAllNodes(java.lang.String userName)
                       throws java.rmi.RemoteException,
                              NmsStorageException,
                              UserTransactionException
This method removes all tree nodes from the user defined tree (for the specified user).
Parameters:
userName - represents the name of the user
Returns:
boolean true if operation is successful else false
Throws:
NmsStorageException - for any database error
UserTransactionException - If any error occurs inside the User Transaction block. This is applicable only when this API is executed within the context of a User Transaction.
See Also:
UserTransactionException

getChildList

public java.util.Vector getChildList(java.lang.String userName,
                                     java.lang.String moduleName)
                              throws java.rmi.RemoteException,
                                     NmsStorageException,
                                     UserTransactionException
This method returns nodeId belonging to the specified module
Parameters:
userName -  
moduleName - for which nodeId list is required
Returns:
Vector of nodeIds.
Throws:
NmsStorageException - for any database error
UserTransactionException - If any error occurs inside the User Transaction block. This is applicable only when this API is executed within the context of a User Transaction.
See Also:
UserTransactionException

getNodeCount

public int getNodeCount(java.lang.String userName)
                 throws java.rmi.RemoteException,
                        NmsStorageException,
                        UserTransactionException
This method returns number of tree node that exist for a given user.
Parameters:
userName -  
Returns:
count as integer
Throws:
NmsStorageException - for any database error
UserTransactionException - If any error occurs inside the User Transaction block. This is applicable only when this API is executed within the context of a User Transaction.
See Also:
UserTransactionException

nodeExist

public boolean nodeExist(java.lang.String userName,
                         java.lang.String nodeId)
                  throws java.rmi.RemoteException,
                         NmsStorageException,
                         UserTransactionException
This method returns true if the tree node is present in user defined tree.
Parameters:
NODEID: - ID
userName -  
Returns:
booleam true: if NodeID exist and false: if NodeID doesn't exist
Throws:
NmsStorageException - for any database error
UserTransactionException - If any error occurs inside the User Transaction block. This is applicable only when this API is executed within the context of a User Transaction.
See Also:
UserTransactionException

getTree

public XMLNode getTree(java.lang.String userName,
                       java.lang.String id)
                throws java.rmi.RemoteException,
                       NmsStorageException,
                       UserTransactionException
This method returns hierarchy of the given node (whose id is passed as an argument).
Parameters:
userName -  
NODEID: - ID
Returns:
XMLNode: root node that gives the full hierachy of its child nodes
Throws:
NmsStorageException - for any database error
UserTransactionException - If any error occurs inside the User Transaction block. This is applicable only when this API is executed within the context of a User Transaction.
See Also:
UserTransactionException

updateUserDetail

public void updateUserDetail(java.lang.String userName)
                      throws java.rmi.RemoteException,
                             com.adventnet.nms.fe.common.CustomViewException,
                             UserTransactionException
This method creates/updates the tree in the database for a given user. Data for constructing / Modifying the user defined tree will be taken from the Tree.xml which will be present under WebNMS_HOME/users/USER NAME/ directory.
Parameters:
userName -  
Throws:
UserTransactionException - If any error occurs inside the User Transaction block. This is applicable only when this API is executed within the context of a User Transaction.
See Also:
UserTransactionException

AdventNet Web NMS 4 API Specification