verinec.data.repository
Interface IVerinecRepository

All Known Implementing Classes:
FileRepository, VerinecRepository, VerinecStudio.StudioRepository

public interface IVerinecRepository

Interface for access to XML repository.

This abstraction allows to use any back end to store the XML data created and used in VeriNec (i.e. File System, CVS, XML-Database).

The repository must ensure that all xml saved or loaded is valid with the schemas. To allow validation checks, the nodes must be saved before the network is saved, because otherwise some of the interfaces referenced from networks might not be defined.

Implementations support more than one project, that is, completely independent set of configuration files. The projects are distinguished by project names.
The creation of repositories is not coverd by this interface. Use the RepositoryFactory to instantiate repositories.

Version:
$Revision: 675 $
Author:
david.buchmann at unifr.ch

Method Summary
 void drop()
          Drop this repository, that is remove all data associated with it.
 Element getGlobals()
          Get the nodes tag with only the global variables and eventual metadata from other namespaces, but no <node> children.
 Element getNode(String name)
          Get a network node of that project.
 String[] getNodeNames()
          Get the names of all existing nodes in this project.
 Element getNodes()
          Get the complete tree starting with the <nodes> element.
 List getNodesWithInterfaceIp(String ip)
          A method to search for nodes having a certain interface.
 Element getPhysicalNetworks()
          Get the networks data of this project.
 String getProjectName()
          Query for the project name of the currently opened project.
 String[] getProjectNames()
          Get the names of all existing projects that can be opened with openProject().
 void removeNode(String name)
          Remove an existing node from the configuration.
 void setGlobals(Element globals)
          Set the global elements without touching the nodes.
 void setNode(Element node)
          Set a network Node.
 void setNodes(Element nodes)
          Replace node and global data by the ones under the <nodes> element.
 void setPhysicalNetworks(Element networks)
          Set the networks of this project.
 

Method Detail

getProjectNames

String[] getProjectNames()
                         throws VerinecException
Get the names of all existing projects that can be opened with openProject(). There is no defined order for the names.

All implementations should also contain a similar method sgetProjectNames which is static, for use in the factory. (As Java does not allow static methods to be declared in an Interface, this feature can not be enforced.)

Returns:
Array of Strings with the names of all existing projects.
Throws:
VerinecException - if some error occurs while trying to collect the project names.

getProjectName

String getProjectName()
                      throws VerinecException
Query for the project name of the currently opened project.

Returns:
Name of the project.
Throws:
VerinecException - if the project name is not valid.

drop

void drop()
          throws VerinecException
Drop this repository, that is remove all data associated with it. The repository is invalid after this operation and may not be used any more, or strange things could happen. (If you need a new repository with the deleted name, create one using the factory.)

Throws:
VerinecException - If the project could not be deleted.

getNodeNames

String[] getNodeNames()
                      throws VerinecException
Get the names of all existing nodes in this project.
There is no defined order for the names. todo: Would a search pattern be needed?

Returns:
Array of Strings with names of all nodes that can be retreived using getNode()
Throws:
VerinecException - if an error occurs during retreiving the node names.

getNode

Element getNode(String name)
                throws VerinecException
Get a network node of that project. The element remains attached to the JDOM tree. Permanent storing of modifications is a task outside this interface. Node names are unique within one project.

Parameters:
name - Name of network node to retreived.
Returns:
The Jdom Element containing the specified node.
Throws:
VerinecException - If no node with that name exists in this project.

getNodesWithInterfaceIp

List getNodesWithInterfaceIp(String ip)
                             throws VerinecException
A method to search for nodes having a certain interface. The elements remain attached to the JDOM tree.

Parameters:
ip - The IP the interface of the nodes must have.
Returns:
A list of Element, the nodes with that IP on an interface.
Throws:
VerinecException - If anything goes wrong.

setNode

void setNode(Element node)
             throws VerinecException
Set a network Node. If there is already a node with that name, it is overwritten. The node name is retreived from the passed XML structure. The node parameter is attached to the JDOM tree and it is thus an error to pass elements having a parent.

Be aware that this limits us to not allowing two nodes with the same name within one project - a situation that could occur as soon as you design two subnets.

Parameters:
node - The Jdom Element of the node, which must not have a parent.
Throws:
VerinecException - if the node is not valid or can not be stored.

removeNode

void removeNode(String name)
                throws VerinecException
Remove an existing node from the configuration.

Parameters:
name - The name of the node.
Throws:
VerinecException - if the node is not existing.

getNodes

Element getNodes()
                 throws VerinecException
Get the complete tree starting with the <nodes> element.

Returns:
All node elements under nodes
Throws:
VerinecException - if retreiving the nodes fails.

setNodes

void setNodes(Element nodes)
              throws VerinecException
Replace node and global data by the ones under the <nodes> element.

Note that this overrides all existing nodes in the project, you have to pass a nodes element containing the complete node collection and all global data.

The individual nodes will be cloned before attaching to the JDOM tree, the parameter remains unchanged.

Note that you can alter individual nodes using setNode(Element) and removeNode(String), the globals using setGlobals(Element).

Parameters:
nodes - The element containing the new node and global data.
Throws:
VerinecException - if the nodes can not be saved.

setGlobals

void setGlobals(Element globals)
                throws VerinecException
Set the global elements without touching the nodes.
Use to set global variables or metadata from other namespaces. This methods overwrites the current globals with the children of the parameter. Children named 'node' are ignored.

Parameters:
globals - A nodes tag with all global elements as children.
Throws:
VerinecException - if globals is not a valid nodes element or the data can not be stored.

getGlobals

Element getGlobals()
                   throws VerinecException
Get the nodes tag with only the global variables and eventual metadata from other namespaces, but no <node> children.

Returns:
Globals under the nodes element
Throws:
VerinecException - if invalid database prevents returning the globals of project this repository is set to.

getPhysicalNetworks

Element getPhysicalNetworks()
                            throws VerinecException
Get the networks data of this project. todo: What should we do if the network is invalid because a node has been deleted? We do not want to loose the whole network.

Returns:
The networks element, containing the definition of the network of this project.
Throws:
VerinecException - if the networks can not be retreived.

setPhysicalNetworks

void setPhysicalNetworks(Element networks)
                         throws VerinecException
Set the networks of this project. The element networks is cloned before attaching.

Parameters:
networks - The network definition for this project.
Throws:
VerinecException - if the networks can not be stored.

Copyright © 2005 Verinec, DIUF