com.ca.commons.jndi
Class AdvancedOps

java.lang.Object
  |
  +--com.ca.commons.jndi.BasicOps
        |
        +--com.ca.commons.jndi.AdvancedOps
Direct Known Subclasses:
DXOps

public class AdvancedOps
extends BasicOps

The AdvancedOps class extends BasicOps to allow for complex directory operations such as manipulating entire trees.

It requires initialisation with a Directory Context, through which all the low level directory calls are passed (basicOps is a wrapper to jndi). It contains a number of functions (pop(), push() and inc() ) that may be over-ridden by classes derived from this that with to track progress.


Field Summary
protected  javax.naming.NameParser parser
           
 
Fields inherited from class com.ca.commons.jndi.BasicOps
ALWAYSLOG, CHANGELOG, connectionData, ctx, DONTLOG, ldapVersion, VERBOSELOG
 
Constructor Summary
AdvancedOps(javax.naming.directory.DirContext c)
          Initialise the AdvancedOps object with a BasicOps object.
 
Method Summary
 void close()
          overload this method for progress tracker.
 boolean copyTree(javax.naming.Name oldNodeDN, javax.naming.Name newNodeDN)
          Copies a DN representing a subtree to a new subtree, including copying all subordinate entries.
 boolean deleteTree(javax.naming.Name nodeDN)
           
static BasicOps getInstance(ConnectionData cData)
          Factory Method to create BasicOps objects, initialised with an ldap context created from the connectionData, and maintaining a reference to that connectionData.
 void inc()
          overload this method for progress tracker.
 boolean moveTree(javax.naming.Name oldNodeDN, javax.naming.Name newNodeDN)
          Moves a DN to a new DN, including all subordinate entries.
 void open(java.lang.String heading, java.lang.String operationName)
          overload this method for progress tracker.
 void pop()
          overload this method for progress tracker.
 javax.naming.NamingEnumeration push(javax.naming.NamingEnumeration elements)
          overload this method for progress tracker.
 boolean recCopyTree(javax.naming.Name from, javax.naming.Name to)
          Takes two DNs, and goes through the first, copying each element from the top down to the new DN.
 boolean recDeleteTree(javax.naming.Name dn)
          deletes a subtree by recursively deleting sub-sub trees.
 boolean recMoveTree(javax.naming.Name from, javax.naming.Name to)
          Moves a tree.
 
Methods inherited from class com.ca.commons.jndi.BasicOps
addAttribute, addAttributes, addObject, copyObject, deleteAttribute, deleteAttributes, deleteObject, error, exists, getBaseNameParser, getContext, getLdapVersion, getSchema, list, log, modifyAttributes, modifyAttributes, openContext, openContext, openContext, openContext, openContext, openContext, postParse, postParseNameClassPairs, preParse, read, read, renameObject, searchBaseObject, searchBaseObject, searchOneLevel, searchOneLevel, searchSubTree, searchSubTree, setConnectionData, updateAttribute, updateAttributes, updateObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parser

protected javax.naming.NameParser parser
Constructor Detail

AdvancedOps

public AdvancedOps(javax.naming.directory.DirContext c)
Initialise the AdvancedOps object with a BasicOps object.

Warning: the basic ops object is used to obtain a Name Parser for the current context, which is asumed to be homogenous: AdvancedOps does *not* support tree operations across multiple name spaces.

Method Detail

getInstance

public static BasicOps getInstance(ConnectionData cData)
                            throws javax.naming.NamingException
Factory Method to create BasicOps objects, initialised with an ldap context created from the connectionData, and maintaining a reference to that connectionData.

Parameters:
cData - the details of the directory to connect to
Returns:
an AdvancedOps object (although it must be cast to this from the BasicOps required by the method sig - is there a better way of doing this?).
javax.naming.NamingException

open

public void open(java.lang.String heading,
                 java.lang.String operationName)
overload this method for progress tracker.


close

public void close()
overload this method for progress tracker.

Overrides:
close in class BasicOps

pop

public void pop()
overload this method for progress tracker.


push

public javax.naming.NamingEnumeration push(javax.naming.NamingEnumeration elements)
overload this method for progress tracker. Note that elements is passed to allow determination of the number of objects - but the Enumeration must be returned without being reset, so be carefull when using it...


inc

public void inc()
overload this method for progress tracker.


deleteTree

public boolean deleteTree(javax.naming.Name nodeDN)

recDeleteTree

public boolean recDeleteTree(javax.naming.Name dn)
deletes a subtree by recursively deleting sub-sub trees.

Parameters:
dn - the distinguished name of the sub-tree apex to delete.
Returns:
true if the tree was deleted, false otherwise.

moveTree

public boolean moveTree(javax.naming.Name oldNodeDN,
                        javax.naming.Name newNodeDN)
Moves a DN to a new DN, including all subordinate entries. (nb it is up to the implementer how this is done; e.g. if it is an ldap broker, it may choose rename, or copy-and-delete, as appropriate)

Returns:
the operation's success status

recMoveTree

public boolean recMoveTree(javax.naming.Name from,
                           javax.naming.Name to)
Moves a tree. If the new position is a sibling of the current position a rename is performed, otherwise a new tree must be created, with all its children, and then the old tree deleted.

If the new tree creation fails during creation, an attempt is made to delete the new tree, and the operation fails. If the new tree creation succeeds, but the old tree deletion fails, the operation fails, leaving the new tree and the partial old tree in existence. (This last should be unlikely.)

Returns:
the success status of the operation.

copyTree

public boolean copyTree(javax.naming.Name oldNodeDN,
                        javax.naming.Name newNodeDN)
Copies a DN representing a subtree to a new subtree, including copying all subordinate entries.

Parameters:
oldNodeDN - the original DN of the sub tree root to be copied (may be a single entry).
newNodeDN - the target DN for the tree to be moved to.
Returns:
the operation's success status

recCopyTree

public boolean recCopyTree(javax.naming.Name from,
                           javax.naming.Name to)
Takes two DNs, and goes through the first, copying each element from the top down to the new DN.

Parameters:
from - the ldap Name dn to copy the tree from
to - the ldap Name dn to copy the tree to
Returns:
true if the operation was successfull, false otherwise