org.dsmltools
Class DSMLLDAPConverter

java.lang.Object
  extended by org.dsmltools.DSMLLDAPConverter

public class DSMLLDAPConverter
extends java.lang.Object


Constructor Summary
DSMLLDAPConverter()
           
 
Method Summary
(package private) static org.w3c.dom.Element attrTypeToNode(LDAPAttributeSchema xiAttrSchema, org.w3c.dom.Document xiOwnerDoc)
          This function converts an LDAPAttributeSchema into the equivalent Document representation.
(package private) static org.w3c.dom.Element entryToNode(LDAPEntry xiEntry, org.w3c.dom.Document xiOwnerDoc, LDAPSchema xiSchema)
          This function converts an LDAPEntry into the equivalent Document representation.
(package private) static java.lang.String getSubText(org.w3c.dom.Node xiNode)
          This method gets the value of the first sub node of the passed in node that is a Text node.
(package private) static DSMLLdapEntry nodeToEntry(org.w3c.dom.Node xiNode)
          This function converts a Node representation of a directory entry into an LDAPEntry one.
(package private) static LDAPSchema nodeToSchema(org.w3c.dom.Node xiSchemaNode)
          This method converts a Document representation of a schema, the contents of a <directory-schema> tag, to an LDAPSchema object.
(package private) static org.w3c.dom.Element objectclassToNode(LDAPObjectClassSchema xiOCSchema, org.w3c.dom.Document xiOwnerDoc)
          This function converts an LDAPObjectClassSchema into the equivalent Document representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DSMLLDAPConverter

public DSMLLDAPConverter()
Method Detail

nodeToSchema

static LDAPSchema nodeToSchema(org.w3c.dom.Node xiSchemaNode)
                        throws DSMLRefException
This method converts a Document representation of a schema, the contents of a <directory-schema> tag, to an LDAPSchema object.

Parameters:
xiSchemaNode - The <directory-schema> node to convert
Returns:
The LDAPSchema object equivalent to the passed-in node
Throws:
DSMLRefException - Thrown if, in the course of validation, we encounter a reference to an external schema. This makes continuing with validation impossible, as we might remove valid data.

nodeToEntry

static DSMLLdapEntry nodeToEntry(org.w3c.dom.Node xiNode)
This function converts a Node representation of a directory entry into an LDAPEntry one. The format of a Node entry is as follows:
                              |<oc-value>----"top"
            |<objectclass>----|<oc-value>----"person"
            |                 |<oc-value>----"organization"
            |                  ...
            |
 [xiNode]   | (name)   |<value>----"fred@flintstone.com"
 <entry ----|<attr ----|<value>----"fflintstone@quarry.com"
  dn="">    | name=""> |
            |<attr>    |<value>----"fred@somepub.com"
            |<attr>     ...
             ...
    

Parameters:
xiNode - The node representing the <entry> tag in the above diagram
Returns:
An LDAPEntry representing the data in the node passed in

attrTypeToNode

static org.w3c.dom.Element attrTypeToNode(LDAPAttributeSchema xiAttrSchema,
                                          org.w3c.dom.Document xiOwnerDoc)
This function converts an LDAPAttributeSchema into the equivalent Document representation. The representation we are creating is as follows:
                        |<name>----"cn"
                        |<object-identifier>----"2.5.4.3"
 <attribute-type -------|   [and, optionally:]
  id="", superior="">   |<description>----"Common name"
                         ...
    

Parameters:
xiAttrSchema - The LDAPAttributeSchema to convert
xiOwnerDoc - The owner of the new node (nodes must have an owner)
Returns:
The attribute-type Element at the root of the tree

objectclassToNode

static org.w3c.dom.Element objectclassToNode(LDAPObjectClassSchema xiOCSchema,
                                             org.w3c.dom.Document xiOwnerDoc)
This function converts an LDAPObjectClassSchema into the equivalent Document representation. The representation we are creating is as follows:
               |<name>----"person"
 <class -------|<description>----"A person"
  id="",       |<object-identifier>----"2.5.6.6"
  superior="", |<attribute ----
  type="">       ref="",
                 required=""/>
    

Parameters:
xiOCSchema - The LDAPObjectClassSchema to convert
xiOwnerDoc - The owner of the new node (nodes must have an owner)
Returns:
The class Element at the root of the tree representing this the tree anywhere.

entryToNode

static org.w3c.dom.Element entryToNode(LDAPEntry xiEntry,
                                       org.w3c.dom.Document xiOwnerDoc,
                                       LDAPSchema xiSchema)
This function converts an LDAPEntry into the equivalent Document representation. The representation we are creating is as follows:
                             |<oc-value>----"top"
            |<objectclass>---|<oc-value>----"person"
 <entry ----|                 ...
  dn="">    |
            |<attr -----|<value>----"peterr@home.com"
              name="">  |<value>----"peter@dsml.org"
                         ...
    
We need the schema to check whether a given attribute has String or binary data.

Parameters:
xiEntry - The LDAPEntry to convert
xiOwnerDoc - The owner of the new node (nodes must have an owner)
xiSchema - The schema relating to these entries
Returns:
The entry Element at the root of the tree representing this entry, in a state such that it has not been inserted into the tree anywhere.

getSubText

static java.lang.String getSubText(org.w3c.dom.Node xiNode)
This method gets the value of the first sub node of the passed in node that is a Text node. This is a common occurrence in XML, and looks like: <wibble>Fred</wibble>. Given the <wibble> Node, this function returns the string "Fred".

Parameters:
xiNode - The node to search below
Returns:
A String representing the value, or "" if none is found (i.e.