You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2010/01/06 19:27:19 UTC

svn commit: r896599 [2/30] - in /directory/apacheds/trunk: ./ avl-partition/ avl-partition/src/ avl-partition/src/main/ avl-partition/src/main/java/ avl-partition/src/main/java/org/ avl-partition/src/main/java/org/apache/ avl-partition/src/main/java/or...

Propchange: directory/apacheds/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan  6 18:26:43 2010
@@ -1 +1,2 @@
 /directory/apacheds/branches/apacheds-replication:749790-764110
+/directory/apacheds/branches/apacheds-schema:806623-896441

Propchange: directory/apacheds/trunk/avl-partition/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Jan  6 18:26:43 2010
@@ -0,0 +1,17 @@
+target
+.clover
+.wtpmodules
+.settings
+.deployables
+apache.org
+.metadata
+*.md5
+*.log
+*.iml
+*.ipr
+*.iws
+.project
+.classpath
+nbproject
+schema
+

Propchange: directory/apacheds/trunk/avl-partition/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Jan  6 18:26:43 2010
@@ -0,0 +1,3 @@
+/directory/apacheds/branches/apacheds-replication/avl-partition:749790-764110
+/directory/apacheds/branches/apacheds-schema/avl-partition:806623-896441
+/directory/apacheds/trunk/avl-partition:806623-894866

Propchange: directory/apacheds/trunk/core-annotations/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Jan  6 18:26:43 2010
@@ -0,0 +1,4 @@
+target
+.classpath
+.project
+.settings

Propchange: directory/apacheds/trunk/core-api/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Jan  6 18:26:43 2010
@@ -0,0 +1,16 @@
+target
+.clover
+.wtpmodules
+.settings
+.deployables
+apache.org
+.metadata
+*.md5
+*.log
+*.iml
+*.ipr
+*.iws
+.project
+.classpath
+nbproject
+schema

Modified: directory/apacheds/trunk/core-avl/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-avl/pom.xml?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-avl/pom.xml (original)
+++ directory/apacheds/trunk/core-avl/pom.xml Wed Jan  6 18:26:43 2010
@@ -38,6 +38,12 @@
       <version>${org.apache.directory.shared.version}</version>
       <artifactId>shared-cursor</artifactId>
     </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <version>${pom.version}</version>
+      <artifactId>apacheds-xdbm-base</artifactId>
+    </dependency>
   </dependencies>
   
 </project>

Modified: directory/apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java (original)
+++ directory/apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java Wed Jan  6 18:26:43 2010
@@ -79,7 +79,7 @@
     public ArrayMarshaller( Comparator<E> comparator )
     {
         this.comparator = comparator;
-        this.keyMarshaller = DefaultMarshaller.INSTANCE;
+        this.keyMarshaller = ( Marshaller<E> ) DefaultMarshaller.INSTANCE;
     }
 
 

Modified: directory/apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTree.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTree.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTree.java (original)
+++ directory/apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTree.java Wed Jan  6 18:26:43 2010
@@ -20,52 +20,25 @@
 package org.apache.directory.server.core.avltree;
 
 
-import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
 
 
 /**
- * An AVL tree implementation
+ * The interface for an AVL Tree.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class AvlTree<K>
+public interface AvlTree<K>
 {
-    /** the root of the tree */
-    private LinkedAvlNode<K> root;
-
-    /** The Comparator used for comparing the keys */
-    private Comparator<K> comparator;
-
-    /** node representing the start of the doubly linked list formed with the tree nodes */
-    private LinkedAvlNode<K> first;
-    
-    /** node representing the end of the doubly linked list formed with the tree nodes */
-    private LinkedAvlNode<K> last;
-
 
     /**
-     * Creates a new instance of AVLTree.
-     *
-     * @param comparator the comparator to be used for comparing keys
-     */
-    public AvlTree( Comparator<K> comparator)
-    {
-        this.comparator = comparator;
-    }
-    
-    
-    /**
      * @return the comparator associated with this tree 
      */
-    public Comparator<K> getComparator()
-    {
-        return comparator;
-    }
-    
-    
+    public abstract Comparator<K> getComparator();
+
+
     /**
      * Inserts a LinkedAvlNode with the given key.
      *
@@ -73,608 +46,64 @@
      * @return the replaced key if it already exists
      * Note: Ignores if a node with the given key already exists.
      */
-    public K insert( K key )
-    {
-        LinkedAvlNode<K> node, temp;
-        LinkedAvlNode<K> parent = null;
-        int c;
-        
-        if ( root == null )
-        {
-          root = new LinkedAvlNode<K>( key );
-          first = root;
-          last = root;
-          return null;
-        }
-        
-        node = new LinkedAvlNode<K>( key );
-        
-        temp = root;
-        
-        List<LinkedAvlNode<K>> treePath = new ArrayList<LinkedAvlNode<K>>();
-
-        while( temp != null )
-        {
-            treePath.add(0, temp ); // last node first, for the sake of balance factor computation
-            parent = temp;
-            
-            c = comparator.compare( key, temp.getKey() );
-            
-            if( c == 0 )
-            {
-                return key; // key already exists
-            }
-            
-            if( c < 0 )
-            {
-                temp.isLeft = true;
-                temp = temp.getLeft();
-            }
-            else
-            {
-                temp.isLeft = false;
-                temp = temp.getRight();
-            }
-        }
-        
-        if( ( c = comparator.compare( key, parent.getKey() ) ) < 0 )
-        {
-            parent.setLeft( node );
-        }
-        else
-        {
-            parent.setRight( node );
-        }
-        
-        insertInList( node, parent, c );
-        
-        treePath.add( 0, node );
-        balance(treePath);
-        
-        return null;
-    }
-    
-    
-    private void removeFromList(LinkedAvlNode<K> node)
-    {
-        if( node.next == null && node.previous == null ) // should happen in case of tree having single node
-        {
-            first = last = null;
-        }
-        else if( node.next == null ) // last node
-        {
-            node.previous.next = null;
-            last = node.previous;
-        }
-        else if( node.previous == null ) // first node
-        {
-            node.next.previous = null;
-            first = node.next;
-        }
-        else // somewhere in middle
-        {
-            node.previous.next = node.next;
-            node.next.previous = node.previous;
-        }
-        
-    }
-    
-    
-    private void insertInList(LinkedAvlNode<K> node, LinkedAvlNode<K> parentNode, int pos)
-    {
-
-        if( pos < 0 )
-        {
-            if( last == null )
-            {
-              last = parentNode;  
-            }
-            
-            if( parentNode.previous == null )
-            {
-                first = node;
-            }
-            else
-            {
-                parentNode.previous.next = node ;
-                node.previous = parentNode.previous;
-            }
-            
-            node.next = parentNode;
-            parentNode.previous = node;
-        }
-        else if( pos > 0 )
-        {
-            if( parentNode.next == null )
-            {
-                last = node;
-            }
-            else
-            {
-                parentNode.next.previous = node;
-                node.next = parentNode.next;
-            }
-            node.previous = parentNode;
-            parentNode.next = node;
-         }
-        
-    }
-    
-    
+    public abstract K insert( K key );
+
+
     /**
      * Removes the LinkedAvlNode present in the tree with the given key value
      *
      * @param key the value of the node to be removed
      * @return the removed key, if any, or null if the key does not exist
      */
-    public K remove( K key )
-    {
-        LinkedAvlNode<K> temp = null;
-        LinkedAvlNode<K> y = null;
-        
-        List<LinkedAvlNode<K>> treePath = new ArrayList<LinkedAvlNode<K>>();
-        
-        treePath = find( key, root, treePath);
-        
-        if( treePath == null )
-        {
-            return null;
-        }
-        
-        temp = treePath.remove( 0 );
-
-        // remove from the doubly linked
-        removeFromList(temp);        
-        
-        if( temp.isLeaf() )
-        {
-            if( temp == root )
-            {
-              root = null;
-              return key;
-            }
-            
-            if( !treePath.isEmpty() )
-            {
-                detachNodes( temp, treePath.get( 0 ) );
-            }
-        }
-        else
-        {
-            if( temp.left != null )
-            {
-                List<LinkedAvlNode<K>> leftTreePath = findMax( temp.left );
-                y = leftTreePath.remove( 0 );
-                
-                if( leftTreePath.isEmpty() ) // y is the left child of root and y is a leaf
-                {
-                    detachNodes( y, temp );
-                }
-                else
-                {
-                    detachNodes( y, leftTreePath.remove( 0 ) );
-                }
-                
-                leftTreePath.addAll( treePath );
-                treePath = leftTreePath;
-                
-                y.right = temp.right; // assign the right here left will be assigned in replaceNode()
-
-                if( temp == root )
-                {
-                    y.left = temp.left;
-                    root = y;
-                }
-                else
-                {
-                    replaceNode( temp, y, treePath.get( 0 ) );
-                }
-            }
-            else if( temp.right != null )
-            {
-                List<LinkedAvlNode<K>> rightTreePath = findMin( temp.right );
-                y = rightTreePath.remove( 0 );
-                
-                if( rightTreePath.isEmpty() )
-                {
-                    detachNodes( y, temp ); // y is the right child of root and y is a leaf
-                }
-                else
-                {
-                    detachNodes( y, rightTreePath.remove( 0 ) );
-                }
-                
-                rightTreePath.addAll( treePath );
-                treePath = rightTreePath;
-                
-                y.right = temp.right; // assign the right here left will be assigned in replaceNode()
-                
-                if( temp == root )
-                {
-                    y.right = temp.right;
-                    root = y;
-                }
-                else
-                {
-                    replaceNode( temp, y, treePath.get( 0 ) );
-                }
-            }
-        }
-       
-       treePath.add( 0, y ); // y can be null but getBalance returns 0 so np
-       balance( treePath );
-       
-       return key;
-    }
-    
-    
-    /**
-     * Balances the tree by visiting the nodes present in the List of nodes present in the
-     * treePath parameter.<br><br>
-     *
-     * This really does the balancing if the height of the tree is greater than 2 and the<br> 
-     * balance factor is greater than +1 or less than -1.<br><br>
-     * For an excellent info please read the 
-     * <a href="http://en.wikipedia.org/wiki/Avl_tree">Wikipedia article on AVL tree</a>.
-     * 
-     * @param treePath the traversed list of LinkedAvlNodes after performing an insert/delete operation.
-     */
-    private void balance( List<LinkedAvlNode<K>> treePath )
-    {
-        LinkedAvlNode<K> parentNode = null;
-        
-        int size = treePath.size();
-        
-        for( LinkedAvlNode<K> node: treePath )
-        {
-            int balFactor = getBalance( node );
-
-            if( node != root )
-            {
-                if( treePath.indexOf( node ) < ( size - 1 ) )
-                {
-                    parentNode = treePath.get( treePath.indexOf( node ) + 1 );
-                }
-            }
-
-            if( balFactor > 1 )
-            {
-                if( getBalance( node.right ) <= -1)
-                {
-                    //------rotate double-left--------
-                    rotateSingleRight( node.right, node );
-                    rotateSingleLeft( node, parentNode );
-                }
-                else // rotate single-left
-                {
-                   rotateSingleLeft( node, parentNode );
-                }
-            }
-            else if( balFactor < -1 )
-            {
-                if( getBalance( node.left ) >= 1)
-                {
-                   //------rotate double-right--------
-                   rotateSingleLeft( node.left, node ); 
-                   rotateSingleRight( node, parentNode );
-                }
-                else
-                {
-                    rotateSingleRight( node, parentNode );
-                }
-            }
-        }
-    }
-    
+    public abstract K remove( K key );
+
 
     /**
      * Tests if the tree is logically empty.
      * 
      * @return true if the tree is empty, false otherwise
      */
-    public boolean isEmpty()
-    {
-      return root == null;   
-    }
+    public abstract boolean isEmpty();
+
 
-    
     /**
      * returns the number of nodes present in this tree.
      * 
      * @return the number of nodes present in this tree
      */
     //NOTE: This method is internally used by AVLTreeMarshaller
-    public int getSize()
-    {
-        if ( root == null )
-        {
-            return 0;
-        }
-        
-        if( root.isLeaf() )
-        {
-            return 1;
-        }
-      
-        LinkedAvlNode<K> x = first.next;
-      
-        while( x != null )
-        {
-            x.setIndex( x.previous.getIndex() + 1 );  
-            x = x.next;
-        }
-      
-        return last.getIndex() + 1;
-    }
-    
-    
-    /**
-     * Set the root of the tree.
-     * 
-     * Note : this method is used by the deserialization method
-     *
-     * @param root the root of the tree
-     */
-    /* no protection */ void setRoot( LinkedAvlNode<K> root )
-    {
-        this.root = root;
-    }
-
-    
-    /**
-     * Set the first element of the tree
-     * 
-     * Note : this method is used by the deserialization method
-     *
-     * @param first the first element to be added
-     */
-    /* no protection */  void setFirst( LinkedAvlNode<K> first )
-    {
-        this.first = first;
-    }
-
-    
-    /**
-     * Set the last element of the tree
-     * 
-     * Note : this method is used by the deserialization method
-     *
-     * @param last the last element to be added
-     */
-    /* no protection */  void setLast( LinkedAvlNode<K> last )
-    {
-        this.last = last;
-    }
+    public abstract int getSize();
 
 
     /**
      * @return the root element of this tree (ie, not the first, but the
      * topmost element)
      */
-    public LinkedAvlNode<K> getRoot()
-    {
-        return root;
-    }
-    
-    
+    public abstract LinkedAvlNode<K> getRoot();
+
+
     /**
      * @return a list of the stored keys in this tree
      */
-    public List<K> getKeys()
-    {
-        List<K> keys = new ArrayList<K>();
-        LinkedAvlNode<K> node = first;
-        
-        while( node != null )
-        {
-            keys.add( node.key );
-            node = node.next;
-        }
-        
-        return keys;
-    }
+    public abstract List<K> getKeys();
+
 
     /**
      * Prints the contents of AVL tree in pretty format
      */
-    public void printTree() 
-    {
-        if( isEmpty() )
-        {
-            System.out.println( "Tree is empty" );
-            return;
-        }
-        
-        getRoot().setDepth( 0 );
-
-        System.out.println( getRoot() );
-        
-        visit( null, getRoot().getRight(), getRoot() );
-        
-        visit( null, getRoot().getLeft(), getRoot() );
-    }
-    
+    public abstract void printTree();
 
-    /**
-     * @return The first element of this tree
-     */
-    public LinkedAvlNode<K> getFirst()
-    {
-        return first;
-    }
 
-    
     /**
-     * @return The last element in this tree
+     * @return The first element of this tree
      */
-    public LinkedAvlNode<K> getLast()
-    {
-        return last;
-    }
+    public abstract LinkedAvlNode<K> getFirst();
 
-    
-    /**
-     * Rotate the node left side once.
-     *
-     * @param node the LinkedAvlNode to be rotated
-     * @param parentNode parent LinkedAvlNode of node
-     */
-    private void rotateSingleLeft(LinkedAvlNode<K> node, LinkedAvlNode<K> parentNode)
-    {
-        LinkedAvlNode<K> temp;
-        //------rotate single-left--------
-        
-        temp = node.right;
-        node.right = temp.left;
-        temp.left = node;
-        
-        if( node == root )
-        {
-          root = temp;  
-        }
-        else if( parentNode != null )
-        {
-            if( parentNode.left == node )
-            {
-                parentNode.left = temp;
-            }
-            else if( parentNode.right == node )
-            {
-                parentNode.right = temp;
-            }
-        }
-    }
-    
-    
-    /**
-     * Rotate the node right side once.
-     *
-     * @param node the LinkedAvlNode to be rotated
-     * @param parentNode parent LinkedAvlNode of node
-     */
-    private void rotateSingleRight(LinkedAvlNode<K> node, LinkedAvlNode<K> parentNode)
-    {
-        LinkedAvlNode<K> temp;
-        //------rotate single-right--------
-        
-        temp = node.left;
-        node.left = temp.right;
-        temp.right = node;
-       
-        if( node == root )
-        {
-          root = temp;  
-        }
-        else if( parentNode != null )
-        {
-            if( parentNode.left == node )
-            {
-                parentNode.left = temp;
-            }
-            else if( parentNode.right == node )
-            {
-                parentNode.right = temp;
-            }
-        }
-        /*
-         when the 'parentNode' param is null then the node under rotation is a child of ROOT.
-         Most likely this condition executes when the root node is deleted and balancing is required.
-         */
-        else if( root != null )
-        {
-            if( root.left == node )
-            {
-                root.left = temp;
-            }
-            // no need to check for right node
-        }
-    }
-        
 
     /**
-     * Detach a LinkedAvlNode from its parent
-     *
-     * @param node the LinkedAvlNode to be detached
-     * @param parentNode the parent LinkedAvlNode of the node
+     * @return The last element in this tree
      */
-    private void detachNodes(LinkedAvlNode<K> node, LinkedAvlNode<K> parentNode)
-    {
-        if( parentNode != null )
-        {
-            if( node == parentNode.left )
-            {
-                parentNode.left = node.left;
-            }
-            else if( node == parentNode.right )
-            {
-                parentNode.right = node.left;
-            }
-        }
-    }
-
-
-    /**
-     * 
-     * Replace a LinkedAvlNode to be removed with a new existing LinkedAvlNode 
-     *
-     * @param deleteNode the LinkedAvlNode to be deleted
-     * @param replaceNode the LinkedAvlNode to replace the deleteNode
-     * @param parentNode the parent LinkedAvlNode of deleteNode
-     */
-    private void replaceNode(LinkedAvlNode<K> deleteNode, LinkedAvlNode<K> replaceNode, LinkedAvlNode<K> parentNode)
-    {
-        if( parentNode != null )
-        {
-            replaceNode.left = deleteNode.left;
-            
-            if( deleteNode == parentNode.left )
-            {
-                parentNode.left = replaceNode;
-            }
-            else if( deleteNode == parentNode.right )
-            {
-                parentNode.right = replaceNode;
-            }
-        }
-    }
-    
-    
-    /**
-     * 
-     * Find a LinkedAvlNode with the given key value in the tree starting from the startNode.
-     *
-     * @param key the key to find
-     * @param startNode starting node of a subtree/tree
-     * @param path the list to be filled with traversed nodes
-     * @return the list of traversed LinkedAvlNodes.
-     */
-    private List<LinkedAvlNode<K>> find( K key, LinkedAvlNode<K> startNode, List<LinkedAvlNode<K>> path )
-    {
-        int c;
-        
-        if( startNode == null )
-        {
-            return null;
-        }
-        
-        path.add( 0, startNode );
-        c = comparator.compare( key, startNode.key );
-        
-        if( c == 0 )
-        {
-            return path;
-        }
-        else if( c > 0 )
-        {
-            return find( key, startNode.right, path );
-        }
-        else if( c < 0 )
-        {
-            return find( key, startNode.left, path );
-        }
-        
-        return null;
-    }
+    public abstract LinkedAvlNode<K> getLast();
 
 
     /**
@@ -684,21 +113,7 @@
      * @return the LinkedAvlNode<K> whose key is greater than the given key ,<br>
      *         null if there is no node with a higher key than the given key.
      */
-    public LinkedAvlNode<K> findGreater( K key )
-    {
-        LinkedAvlNode<K> result = fetchNonNullNode( key, root, root);
-
-        if( result == null )
-        {
-            return null;
-        }
-        else if( comparator.compare( key, result.key ) < 0 )
-        {
-            return result;
-        }
-
-        return result.next;
-    }
+    public abstract LinkedAvlNode<K> findGreater( K key );
 
 
     /**
@@ -708,21 +123,7 @@
      * @return the LinkedAvlNode<K> whose key is greater than the given key ,<br>
      *         null if there is no node with a higher key than the given key.
      */
-    public LinkedAvlNode<K> findGreaterOrEqual( K key )
-    {
-        LinkedAvlNode<K> result = fetchNonNullNode( key, root, root);
-
-        if( result == null )
-        {
-            return null;
-        }
-        else if( comparator.compare( key, result.key ) <= 0 )
-        {
-            return result;
-        }
-
-        return result.next;
-    }
+    public abstract LinkedAvlNode<K> findGreaterOrEqual( K key );
 
 
     /**
@@ -732,21 +133,7 @@
      * @return the LinkedAvlNode<K> whose key is lower than the given key ,<br>
      *         null if there is no node with a lower key than the given key.
      */
-    public LinkedAvlNode<K> findLess( K key )
-    {
-        LinkedAvlNode<K> result = fetchNonNullNode( key, root, root);
-
-        if( result == null )
-        {
-            return null;
-        }
-        else if( comparator.compare( key, result.key ) > 0 )
-        {
-            return result;
-        }
-
-        return result.previous;
-    }
+    public abstract LinkedAvlNode<K> findLess( K key );
 
 
     /**
@@ -756,52 +143,9 @@
      * @return the LinkedAvlNode<K> whose key is lower than the given key ,<br>
      *         null if there is no node with a lower key than the given key.
      */
-    public LinkedAvlNode<K> findLessOrEqual( K key )
-    {
-        LinkedAvlNode<K> result = fetchNonNullNode( key, root, root);
-
-        if( result == null )
-        {
-            return null;
-        }
-        else if( comparator.compare( key, result.key ) >= 0 )
-        {
-            return result;
-        }
-
-        return result.previous;
-    }
-
-
-    /*
-     * This method returns the last visited non-null node in case if the node with the given key
-     * is not present. This method should not be used as general purpose lookup method.
-     * This is written to assist the findGreater, findLess methods. 
-     */
-    private LinkedAvlNode<K> fetchNonNullNode( K key, LinkedAvlNode<K> startNode, LinkedAvlNode<K> parent )
-    {
-        
-        if( startNode == null )
-        {
-            return parent;
-        }
-        
-        int c = comparator.compare( key, startNode.key );
-        
-        parent = startNode;
-
-        if( c > 0 )
-        {
-            return fetchNonNullNode( key, startNode.right, parent );
-        }
-        else if( c < 0 )
-        {
-            return fetchNonNullNode( key, startNode.left, parent );
-        }
-        
-        return startNode;
-    }
-    
+    public abstract LinkedAvlNode<K> findLessOrEqual( K key );
+
+
     /**
      * 
      * Find a LinkedAvlNode with the given key value in the tree.
@@ -809,211 +153,6 @@
      * @param key the key to find
      * @return the list of traversed LinkedAvlNode.
      */
-    public LinkedAvlNode<K> find( K key )
-    {
-        return find( key, root);
-    }
-    
-
-    private LinkedAvlNode<K> find( K key, LinkedAvlNode<K> startNode)
-    {
-        int c;
-        
-        if( startNode == null )
-        {
-            return null;
-        }
-        
-        c = comparator.compare( key, startNode.key );
-        
-        if( c > 0 )
-        {
-            startNode.isLeft = false;
-            return find( key, startNode.right );
-        }
-        else if( c < 0 )
-        {
-            startNode.isLeft = true;
-            return find( key, startNode.left );
-        }
-        
-        return startNode;
-    }
-    
-    
-    /**
-     * Find the LinkedAvlNode having the max key value in the tree starting from the startNode.
-     *
-     * @param startNode starting node of a subtree/tree
-     * @return the list of traversed LinkedAvlNodes.
-     */
-    private List<LinkedAvlNode<K>> findMax( LinkedAvlNode<K> startNode )
-    {
-        LinkedAvlNode<K> x = startNode;
-        LinkedAvlNode<K> y = null;
-        List<LinkedAvlNode<K>> path;
-        
-        if( x == null )
-        {
-            return null;
-        }
-        
-        while( x.right != null )
-        {
-            x.isLeft = false;
-            y = x;
-            x = x.right;
-        }
-        
-        path = new ArrayList<LinkedAvlNode<K>>(2);
-        path.add( x );
-        
-        if ( y != null )
-        {
-          path.add( y );  
-        }
-        
-        return path;
-    }
+    public abstract LinkedAvlNode<K> find( K key );
 
-    
-    /**
-     * Find the LinkedAvlNode having the min key value in the tree starting from the startNode.
-     *
-     * @param startNode starting node of a subtree/tree
-     * @return the list of traversed LinkedAvlNodes.
-     */
-    private List<LinkedAvlNode<K>> findMin( LinkedAvlNode<K> startNode )
-    {
-        LinkedAvlNode<K> x = startNode;
-        LinkedAvlNode<K> y = null;
-        List<LinkedAvlNode<K>> path;
-       
-        if( x == null )
-        {
-            return null;
-        }
-       
-        while( x.left != null )
-        {
-            x.isLeft = true;
-            y = x;
-            x = x.left;
-        }
-        
-        path = new ArrayList<LinkedAvlNode<K>>(2);
-        path.add( x );
-        
-        if ( y != null )
-        {
-          path.add( y );  
-        }
-        
-        return path;
-    }
-   
-    
-    /**
-     * Get balance-factor of the given LinkedAvlNode.
-     *
-     * @param node a LinkedAvlNode 
-     * @return balance-factor of the node
-     */
-    private int getBalance( LinkedAvlNode<K> node )
-    {
-        if( node == null)
-        {
-            return 0;
-        }
-        
-        return node.getBalance();
-    }
-    
-    
-    /**
-     * Checks that the tree is correct. It must be balanced, and the prev/next
-     * chain must be equivalent to a depth-first descent on the tree
-     * 
-     * @return true if the tree is balanced and correct
-     */
-    public boolean checkTree()
-    {
-        return true;
-    }
-    
-    
-    private void visit( StringBuilder sb, LinkedAvlNode<K> node, LinkedAvlNode<K> parentNode ) 
-    {
-        if( node == null )
-        {
-            return;
-        }
-        
-        if( !node.isLeaf() )
-        {
-            node.setDepth( parentNode.getDepth() + 1 );
-        }
-        
-        for( int i=0; i < parentNode.getDepth(); i++ )
-        {
-            if ( sb != null )
-            {
-                sb.append( "|  " );
-            }
-            else
-            {
-                System.out.print( "|  " );
-            }
-        }
-
-        String type = "";
-        
-        if( node == parentNode.left )
-        {
-            type = "L";
-        }
-        else if( node == parentNode.right )
-        {
-            type = "R";
-        }
-        
-        if ( sb != null )
-        {
-            sb.append( "|--" ).append( node ).append( type ).append( '\n' );
-        }
-        else
-        {
-            System.out.println( "|--" + node + type );
-        }
-        
-        if ( node.getRight() != null )
-        {
-            visit( sb, node.getRight(), node );
-        }
-        
-        if( node.getLeft() != null )
-        {
-            visit( sb, node.getLeft(), node );
-        }
-    }
-    
-    public String toString()
-    {
-        if( isEmpty() )
-        {
-            return "[]";
-        }
-        
-        getRoot().setDepth( 0 );
-
-        StringBuilder sb = new StringBuilder();
-        
-        sb.append( getRoot() );
-        
-        visit( sb, getRoot().getRight(), getRoot() );
-        
-        visit( sb, getRoot().getLeft(), getRoot() );
-        
-        return sb.toString();
-    }
-}
+}
\ No newline at end of file

Modified: directory/apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeCursor.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeCursor.java (original)
+++ directory/apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeCursor.java Wed Jan  6 18:26:43 2010
@@ -19,12 +19,11 @@
  */
 package org.apache.directory.server.core.avltree;
 
+
 import org.apache.directory.shared.ldap.cursor.AbstractCursor;
 import org.apache.directory.shared.ldap.cursor.InvalidCursorPositionException;
 
 
-
-
 /**
  * A Cursor for an AvlTree.
  *

Modified: directory/apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMarshaller.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMarshaller.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMarshaller.java (original)
+++ directory/apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMarshaller.java Wed Jan  6 18:26:43 2010
@@ -27,12 +27,6 @@
 import java.io.IOException;
 import java.util.Comparator;
 
-import org.apache.directory.shared.ldap.util.StringTools;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import sun.reflect.Reflection;
-
 
 /**
  * Class to serialize the AvlTree node data.
@@ -43,9 +37,6 @@
 @SuppressWarnings("unchecked")
 public class AvlTreeMarshaller<E> implements Marshaller<AvlTree<E>>
 {
-    /** static logger */
-    private static final Logger LOG = LoggerFactory.getLogger( AvlTreeMarshaller.class );
-
     /** used for serialized form of an empty AvlTree */
     private static final byte[] EMPTY_TREE = new byte[1];
 
@@ -113,18 +104,6 @@
             writeTree( tree.getRoot(), out );
             out.flush();
             data = byteStream.toByteArray();
-            
-            // Try to deserialize, just to see
-            try
-            {
-                deserialize( data );
-            }
-            catch (NullPointerException npe )
-            {
-                System.out.println( "Bad serialization, tree : [" + StringTools.dumpBytes( data ) + "]");
-                throw npe;
-            }
-
             out.close();
         }
         catch( IOException e )
@@ -185,59 +164,52 @@
      */
     public AvlTree<E> deserialize( byte[] data ) throws IOException
     {
-        LOG.debug( "Deserializing the tree, called by {}", Reflection.getCallerClass( 2 ).getSimpleName() );
+        if ( data == null || data.length == 0 )
+        {
+            throw new IOException( "Null or empty data array is invalid." );
+        }
 
-        try
+        if ( data.length == 1 && data[0] == 0 )
         {
-            if ( data == null || data.length == 0 )
-            {
-                throw new IOException( "Null or empty data array is invalid." );
-            }
-    
-            if ( data.length == 1 && data[0] == 0 )
-            {
-                return new AvlTree<E>( comparator );
-            }
-    
-            ByteArrayInputStream bin = new ByteArrayInputStream( data );
-            DataInputStream din = new DataInputStream( bin );
-            
-            byte startByte = din.readByte();
-            
-            if( startByte != 0 )
-            {
-                throw new IOException("wrong AvlTree serialized data format");
-            }
-            
-            int size = din.readInt();
-            
-            LinkedAvlNode[] nodes = new LinkedAvlNode[ size ];
-            LinkedAvlNode<E> root = readTree( din, null, nodes );
-            
-            AvlTree<E> tree = new AvlTree<E>( comparator );
-            
-            tree.setRoot( root );
-            
-            tree.setFirst( nodes[0] );
-            
-            if( nodes.length >= 1 )
-            {
-                tree.setLast( nodes[ nodes.length - 1 ] );
-            }
-            
-            for( int i = 0; i < nodes.length - 1; i++ )
-            {
-                nodes[ i ].setNext( nodes[ i + 1] );
-                nodes[ i + 1].setPrevious( nodes[ i ] );
-            }
-    
-            return tree;
+            return new AvlTreeImpl<E>( comparator );
+        }
+
+        ByteArrayInputStream bin = new ByteArrayInputStream( data );
+        DataInputStream din = new DataInputStream( bin );
+        
+        byte startByte = din.readByte();
+        
+        if( startByte != 0 )
+        {
+            throw new IOException("wrong AvlTree serialized data format");
         }
-        catch (NullPointerException npe )
+        
+        int size = din.readInt();
+        
+        LinkedAvlNode[] nodes = new LinkedAvlNode[ size ];
+        LinkedAvlNode<E> root = readTree( din, null, nodes );
+        
+        AvlTreeImpl<E> tree = new AvlTreeImpl<E>( comparator );
+        
+        tree.setRoot( root );
+        
+        tree.setFirst( nodes[0] );
+        
+        // Update the size
+        tree.setSize( size );
+        
+        if( nodes.length >= 1 )
+        {
+            tree.setLast( nodes[ nodes.length - 1 ] );
+        }
+        
+        for( int i = 0; i < nodes.length - 1; i++ )
         {
-            System.out.println( "Bad tree : [" + StringTools.dumpBytes( data ) + "]");
-            throw npe;
+            nodes[ i ].setNext( nodes[ i + 1] );
+            nodes[ i + 1].setPrevious( nodes[ i ] );
         }
+
+        return tree;
     }
 
     

Modified: directory/apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltree/DefaultMarshaller.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltree/DefaultMarshaller.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltree/DefaultMarshaller.java (original)
+++ directory/apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltree/DefaultMarshaller.java Wed Jan  6 18:26:43 2010
@@ -20,16 +20,20 @@
 package org.apache.directory.server.core.avltree;
 
 
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 
 
 /**
- * A marshaller which uses default Java Serialization.
+ * A Marshaller which uses default Java Serialization.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class DefaultMarshaller implements Marshaller
+public class DefaultMarshaller implements Marshaller<Object>
 {
     public static final DefaultMarshaller INSTANCE = new DefaultMarshaller();
 

Modified: directory/apacheds/trunk/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeCursorTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeCursorTest.java (original)
+++ directory/apacheds/trunk/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeCursorTest.java Wed Jan  6 18:26:43 2010
@@ -42,7 +42,7 @@
     @Test
     public void testEmptyCursor() throws Exception
     {
-        AvlTree<Integer> tree = new AvlTree<Integer>( new IntegerComparator() );
+        AvlTree<Integer> tree = new AvlTreeImpl<Integer>( new IntegerComparator() );
         AvlTreeCursor<Integer> cursor = new AvlTreeCursor<Integer>( tree );
         
         assertFalse( cursor.isClosed() );
@@ -91,7 +91,7 @@
     @Test
     public void testOneEntryCursor() throws Exception
     {
-        AvlTree<Integer> tree = new AvlTree<Integer>( new IntegerComparator() );
+        AvlTree<Integer> tree = new AvlTreeImpl<Integer>( new IntegerComparator() );
         tree.insert( 7 );
         AvlTreeCursor<Integer> cursor = new AvlTreeCursor<Integer>( tree );
         
@@ -155,7 +155,7 @@
     @Test
     public void testManyEntriesCursor() throws Exception
     {
-        AvlTree<Integer> tree = new AvlTree<Integer>( new IntegerComparator() );
+        AvlTree<Integer> tree = new AvlTreeImpl<Integer>( new IntegerComparator() );
         tree.insert( 3 );
         tree.insert( 7 );
         tree.insert( 10 );

Modified: directory/apacheds/trunk/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMarshallerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMarshallerTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMarshallerTest.java (original)
+++ directory/apacheds/trunk/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMarshallerTest.java Wed Jan  6 18:26:43 2010
@@ -110,7 +110,7 @@
         };
         
       
-        tree = new AvlTree<Integer>( comparator );
+        tree = new AvlTreeImpl<Integer>( comparator );
         treeMarshaller = new AvlTreeMarshaller<Integer>( comparator, new IntegerKeyMarshaller() );
     }
 
@@ -164,7 +164,7 @@
     @Test
     public void testMarshalEmptyTree() throws IOException
     {
-        byte[] bites = treeMarshaller.serialize( new AvlTree<Integer>( comparator ) );
+        byte[] bites = treeMarshaller.serialize( new AvlTreeImpl<Integer>( comparator ) );
         AvlTree<Integer> tree = treeMarshaller.deserialize( bites );
         assertNotNull( tree );
     }
@@ -173,7 +173,7 @@
     @Test
     public void testRoundTripEmpty() throws IOException
     {
-        AvlTree<Integer> original = new AvlTree<Integer>( comparator );
+        AvlTree<Integer> original = new AvlTreeImpl<Integer>( comparator );
         byte[] bites = treeMarshaller.serialize( original );
         AvlTree<Integer> deserialized = treeMarshaller.deserialize( bites );
         assertTrue( deserialized.isEmpty() );
@@ -183,7 +183,7 @@
     @Test
     public void testRoundTripOneEntry() throws IOException
     {
-        AvlTree<Integer> original = new AvlTree<Integer>( comparator );
+        AvlTree<Integer> original = new AvlTreeImpl<Integer>( comparator );
         original.insert( 0 );
         byte[] bites = treeMarshaller.serialize( original );
         AvlTree<Integer> deserialized = treeMarshaller.deserialize( bites );
@@ -196,7 +196,7 @@
     @Test
     public void testRoundTripOneEntryFirstLast() throws IOException
     {
-        AvlTree<Integer> original = new AvlTree<Integer>( comparator );
+        AvlTree<Integer> original = new AvlTreeImpl<Integer>( comparator );
         original.insert( 0 );
         byte[] bites = treeMarshaller.serialize( original );
         AvlTree<Integer> deserialized = treeMarshaller.deserialize( bites );
@@ -222,7 +222,7 @@
     @Test
     public void testRoundTripTwoEntries() throws IOException
     {
-        AvlTree<Integer> original = new AvlTree<Integer>( comparator );
+        AvlTree<Integer> original = new AvlTreeImpl<Integer>( comparator );
         original.insert( 0 );
         original.insert( 1 );
         byte[] bites = treeMarshaller.serialize( original );
@@ -237,7 +237,7 @@
     @Test
     public void testRoundTripTwoEntriesFirstLast() throws IOException
     {
-        AvlTree<Integer> original = new AvlTree<Integer>( comparator );
+        AvlTree<Integer> original = new AvlTreeImpl<Integer>( comparator );
         original.insert( 0 );
         original.insert( 1 );
         byte[] bites = treeMarshaller.serialize( original );
@@ -265,7 +265,7 @@
     @Test
     public void testRoundTripManyEntries() throws Exception
     {
-        AvlTree<Integer> original = new AvlTree<Integer>( comparator );
+        AvlTree<Integer> original = new AvlTreeImpl<Integer>( comparator );
         for ( int ii = 0; ii < 100; ii++ )
         {
             original.insert( ii );
@@ -288,7 +288,7 @@
     @Test
     public void testRoundTripManyEntriesFirstLast() throws Exception
     {
-        AvlTree<Integer> original = new AvlTree<Integer>( comparator );
+        AvlTree<Integer> original = new AvlTreeImpl<Integer>( comparator );
         for ( int ii = 0; ii < 100; ii++ )
         {
             original.insert( ii );
@@ -331,7 +331,7 @@
             }
         };
 
-        AvlTree<Bar> original = new AvlTree<Bar>( barComparator );
+        AvlTree<Bar> original = new AvlTreeImpl<Bar>( barComparator );
 
         for ( int ii = 0; ii < 100; ii++ )
         {

Modified: directory/apacheds/trunk/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreePerfTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreePerfTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreePerfTest.java (original)
+++ directory/apacheds/trunk/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreePerfTest.java Wed Jan  6 18:26:43 2010
@@ -74,7 +74,7 @@
     @Before
     public void createTree()
     {
-      tree = new AvlTree<Integer>( new Comparator<Integer>() 
+      tree = new AvlTreeImpl<Integer>( new Comparator<Integer>() 
           {
 
             public int compare( Integer i1, Integer i2 )

Modified: directory/apacheds/trunk/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java (original)
+++ directory/apacheds/trunk/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java Wed Jan  6 18:26:43 2010
@@ -50,7 +50,7 @@
     @Before
     public void createTree()
     {
-      tree = new AvlTree<Integer>( new Comparator<Integer>() 
+      tree = new AvlTreeImpl<Integer>( new Comparator<Integer>() 
           {
 
             public int compare( Integer i1, Integer i2 )
@@ -294,7 +294,7 @@
         assertNotNull( tree.find( 11 ) );
         assertNull( tree.find( 0 ));
         
-        tree.setRoot( null );
+        ( ( AvlTreeImpl ) tree ).setRoot( null );
         assertNull( tree.find( 3 ));
     }
     

Modified: directory/apacheds/trunk/core-avl/src/test/java/org/apache/directory/server/core/avltree/DefaultMarshallerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-avl/src/test/java/org/apache/directory/server/core/avltree/DefaultMarshallerTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-avl/src/test/java/org/apache/directory/server/core/avltree/DefaultMarshallerTest.java (original)
+++ directory/apacheds/trunk/core-avl/src/test/java/org/apache/directory/server/core/avltree/DefaultMarshallerTest.java Wed Jan  6 18:26:43 2010
@@ -22,7 +22,9 @@
 
 import org.junit.Test;
 import org.apache.directory.shared.ldap.util.ArrayUtils;
-import static junit.framework.Assert.*;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
 
 import java.io.Serializable;
 

Modified: directory/apacheds/trunk/core-avl/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-avl/src/test/resources/log4j.properties?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-avl/src/test/resources/log4j.properties (original)
+++ directory/apacheds/trunk/core-avl/src/test/resources/log4j.properties Wed Jan  6 18:26:43 2010
@@ -14,7 +14,7 @@
 #    See the License for the specific language governing permissions and
 #    limitations under the License.
 #############################################################################
-log4j.rootCategory=ERROR, stdout
+log4j.rootCategory=OFF, stdout
 
 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

Modified: directory/apacheds/trunk/core-constants/src/main/java/org/apache/directory/server/constants/ServerDNConstants.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-constants/src/main/java/org/apache/directory/server/constants/ServerDNConstants.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-constants/src/main/java/org/apache/directory/server/constants/ServerDNConstants.java (original)
+++ directory/apacheds/trunk/core-constants/src/main/java/org/apache/directory/server/constants/ServerDNConstants.java Wed Jan  6 18:26:43 2010
@@ -36,43 +36,46 @@
     }
     
     /** The administrators group DN */
-    public static final String ADMINISTRATORS_GROUP_DN = "cn=Administrators,ou=groups,ou=system";
+    public static final String ADMINISTRATORS_GROUP_DN      = "cn=Administrators,ou=groups,ou=system";
 
     /** The system DN */
-    public static final String SYSTEM_DN = "ou=system";
+    public static final String SYSTEM_DN                    = "ou=system";
     
     /** the default user principal or DN */
-    public static final String ADMIN_SYSTEM_DN = "uid=admin,ou=system";
+    public static final String ADMIN_SYSTEM_DN              = "uid=admin,ou=system";
     
     /** the normalized user principal or DN */
-    public static final String ADMIN_SYSTEM_DN_NORMALIZED = "0.9.2342.19200300.100.1.1=admin,2.5.4.11=system";
+    public static final String ADMIN_SYSTEM_DN_NORMALIZED   = "0.9.2342.19200300.100.1.1=admin,2.5.4.11=system";
 
     /** the DN for the global schema subentry */
-    public static final String CN_SCHEMA_DN = "cn=schema";
+    public static final String CN_SCHEMA_DN                 = "cn=schema";
     
     /** The DN for the gloval schema subentry normalized */
-    public static final String CN_SCHEMA_DN_NORMALIZED = "2.5.4.3=schema";
+    public static final String CN_SCHEMA_DN_NORMALIZED      = "2.5.4.3=schema";
    
-    /** the DN for the global schema subentry */
-    public static final String OU_SCHEMA_DN = "ou=schema";
+    /** the DN for the schema in dit area */
+    //public static final String OU_SCHEMA_DN                 = "ou=schema";
+
+    /** the normalized DN for the schema in DIT area */
+    //public static final String OU_SCHEMA_DN_NORMALIZED      = "2.5.4.11=schema";
     
-    /** The DN for the schema modification's timestamp */
-    public static final String SCHEMA_TIMESTAMP_ENTRY_DN = "cn=schemaModifications,ou=schema";
+    /** The DN for the schema modifications */
+    public static final String SCHEMA_MODIFICATIONS_DN      = "cn=schemaModifications,ou=schema";
     
     /** the base dn under which all users reside */
-    public static final String USERS_SYSTEM_DN = "ou=users,ou=system";
+    public static final String USERS_SYSTEM_DN              = "ou=users,ou=system";
     
     /** The default change password base DN. */
-    public static final String USER_EXAMPLE_COM_DN = "ou=users,dc=example,dc=com";
+    public static final String USER_EXAMPLE_COM_DN          = "ou=users,dc=example,dc=com";
     
     
     /** the base dn under which all groups reside */
-    public static final String GROUPS_SYSTEM_DN = "ou=groups,ou=system";
+    public static final String GROUPS_SYSTEM_DN             = "ou=groups,ou=system";
     
     /** the dn base of the system preference hierarchy */
-    public static final String SYSPREFROOT_SYSTEM_DN = "prefNodeName=sysPrefRoot,ou=system";
+    public static final String SYSPREFROOT_SYSTEM_DN        = "prefNodeName=sysPrefRoot,ou=system";
     
     /** The ldifDile base which stores the name of the loaded ldif files */
-    public static final String LDIF_FILES_DN = "ou=loadedLdifFiles,ou=configuration,ou=system";
+    public static final String LDIF_FILES_DN                = "ou=loadedLdifFiles,ou=configuration,ou=system";
 
 }

Propchange: directory/apacheds/trunk/core-entry/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Jan  6 18:26:43 2010
@@ -7,6 +7,7 @@
 .metadata
 *.md5
 *.log
+*.log.*
 *.iml
 *.ipr
 *.iws

Modified: directory/apacheds/trunk/core-entry/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-entry/pom.xml?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-entry/pom.xml (original)
+++ directory/apacheds/trunk/core-entry/pom.xml Wed Jan  6 18:26:43 2010
@@ -39,30 +39,46 @@
     <dependency>
       <groupId>${pom.groupId}</groupId>
       <version>${pom.version}</version>
-      <artifactId>apacheds-schema-registries</artifactId>
+      <artifactId>apacheds-jdbm</artifactId>
     </dependency>
     
     <dependency>
-      <groupId>${pom.groupId}</groupId>
-      <version>${pom.version}</version>
-      <artifactId>apacheds-schema-bootstrap</artifactId>
+      <groupId>org.apache.directory.shared</groupId>
+      <version>${org.apache.directory.shared.version}</version>
+      <artifactId>shared-ldap-schema-manager</artifactId>
       <scope>test</scope>
-    </dependency>
+    </dependency>    
     
     <dependency>
-      <groupId>${pom.groupId}</groupId>
-      <version>${pom.version}</version>
-      <artifactId>apacheds-schema-extras</artifactId>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
       <scope>test</scope>
     </dependency>
-
+      
     <dependency>
-      <groupId>${pom.groupId}</groupId>
-      <version>${pom.version}</version>
-      <artifactId>apacheds-jdbm</artifactId>
-    </dependency>
-    
+      <groupId>org.apache.directory.shared</groupId>
+      <version>${org.apache.directory.shared.version}</version>
+      <artifactId>shared-ldap-schema</artifactId>
+      <scope>test</scope>
+    </dependency>    
   </dependencies>
   
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <groupId>org.apache.maven.plugins</groupId>
+        <configuration>
+          <systemProperties>
+            <property>
+              <name>workingDirectory</name>
+              <value>${basedir}/target</value>
+            </property>
+          </systemProperties>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 </project>
 

Modified: directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/ClonedServerEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/ClonedServerEntry.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/ClonedServerEntry.java (original)
+++ directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/ClonedServerEntry.java Wed Jan  6 18:26:43 2010
@@ -63,7 +63,7 @@
      */
     public ClonedServerEntry( ServerEntry originalEntry )
     {
-        this.originalEntry = originalEntry;
+        this.originalEntry = ( ServerEntry )originalEntry.clone();
         this.clonedEntry = ( ServerEntry ) originalEntry.clone();
     }
     

Modified: directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java (original)
+++ directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java Wed Jan  6 18:26:43 2010
@@ -19,6 +19,7 @@
 package org.apache.directory.server.core.entry;
 
 
+import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
@@ -109,15 +110,7 @@
         else
         {
             
-            try
-            {
-                isHR = attributeType.getSyntax().isHumanReadable();
-            }
-            catch ( NamingException ne )
-            {
-                // Do nothing : the syntax should always exist ...
-            }
-            
+            isHR = attributeType.getSyntax().isHumanReadable();
 
             // Copy all the values
             for ( Value<?> clientValue:attribute )
@@ -429,94 +422,86 @@
         
         for ( Value<?> val:vals )
         {
-            try
+            if ( attributeType.getSyntax().isHumanReadable() )
             {
-                if ( attributeType.getSyntax().isHumanReadable() )
+                if ( ( val == null ) || val.isNull() )
                 {
-                    if ( ( val == null ) || val.isNull() )
+                    Value<String> nullSV = new ServerStringValue( attributeType, (String)null );
+                    
+                    if ( !values.contains( nullSV ) )
                     {
-                        Value<String> nullSV = new ServerStringValue( attributeType, (String)null );
-                        
-                        if ( !values.contains( nullSV ) )
-                        {
-                            values.add( nullSV );
-                            nbAdded++;
-                        }
+                        values.add( nullSV );
+                        nbAdded++;
                     }
-                    else if ( val instanceof ServerStringValue )
+                }
+                else if ( val instanceof ServerStringValue )
+                {
+                    if ( !values.contains( val ) )
                     {
-                        if ( !values.contains( val ) )
+                        if ( values.add( val ) )
                         {
-                            if ( values.add( val ) )
-                            {
-                                nbAdded++;
-                            }
+                            nbAdded++;
                         }
                     }
-                    else if ( val instanceof ClientStringValue )
+                }
+                else if ( val instanceof ClientStringValue )
+                {
+                    // If we get a Client value, convert it to a Server value first 
+                    Value<String> serverStringValue = new ServerStringValue( attributeType, val.getString() ); 
+                    
+                    if ( !values.contains( serverStringValue ) )
                     {
-                        // If we get a Client value, convert it to a Server value first 
-                        Value<String> serverStringValue = new ServerStringValue( attributeType, val.getString() ); 
-                        
-                        if ( !values.contains( serverStringValue ) )
+                        if ( values.add( serverStringValue ) )
                         {
-                            if ( values.add( serverStringValue ) )
-                            {
-                                nbAdded++;
-                            }
+                            nbAdded++;
                         }
                     }
-                    else
-                    {
-                        String message = "The value must be a String, as its AttributeType is H/R";
-                        LOG.error( message );
-                    }
                 }
                 else
                 {
-                    if ( val == null )
+                    String message = "The value must be a String, as its AttributeType is H/R";
+                    LOG.error( message );
+                }
+            }
+            else
+            {
+                if ( val == null )
+                {
+                    Value<byte[]> nullSV = new ServerBinaryValue( attributeType, (byte[])null );
+                    
+                    if ( !values.contains( nullSV ) )
                     {
-                        Value<byte[]> nullSV = new ServerBinaryValue( attributeType, (byte[])null );
-                        
-                        if ( !values.contains( nullSV ) )
-                        {
-                            values.add( nullSV );
-                            nbAdded++;
-                        }
+                        values.add( nullSV );
+                        nbAdded++;
                     }
-                    else if ( ( val instanceof ClientBinaryValue ) )
+                }
+                else if ( ( val instanceof ClientBinaryValue ) )
+                {
+                    Value<byte[]> serverBinaryValue = new ServerBinaryValue( attributeType, val.getBytes() ); 
+                    
+                    if ( !values.contains( serverBinaryValue ) )
                     {
-                        Value<byte[]> serverBinaryValue = new ServerBinaryValue( attributeType, val.getBytes() ); 
-                        
-                        if ( !values.contains( serverBinaryValue ) )
+                        if ( values.add( serverBinaryValue ) )
                         {
-                            if ( values.add( serverBinaryValue ) )
-                            {
-                                nbAdded++;
-                            }
+                            nbAdded++;
                         }
                     }
-                    else if ( val instanceof ServerBinaryValue )
+                }
+                else if ( val instanceof ServerBinaryValue )
+                {
+                    if ( !values.contains( val ) )
                     {
-                        if ( !values.contains( val ) )
+                        if ( values.add( val ) )
                         {
-                            if ( values.add( val ) )
-                            {
-                                nbAdded++;
-                            }
+                            nbAdded++;
                         }
                     }
-                    else
-                    {
-                        String message = "The value must be a byte[], as its AttributeType is not H/R";
-                        LOG.error( message );
-                    }
                 }
-            }
-            catch ( NamingException ne )
-            {
-                String message = "Error while adding value '" + val.toString() +"' : " + ne.getMessage();
-                LOG.error( message );
+                else
+                {
+                    String message = "The value must be a byte[], as its AttributeType is not H/R";
+                    LOG.error( message );
+                }
             }
         }
         
@@ -722,7 +707,7 @@
         
         String normId = StringTools.lowerCaseAscii( trimmedId );
         
-        for ( String name:attributeType.getNamesRef() )
+        for ( String name:attributeType.getNames() )
         {
             if ( normId.equalsIgnoreCase( name ) )
             {
@@ -750,11 +735,17 @@
     {
         // First check if the attribute has more than one value
         // if the attribute is supposed to be SINGLE_VALUE
-        if ( attributeType.isSingleValue() && ( values.size() > 1 ) )
+        if ( attributeType.isSingleValued() && ( values.size() > 1 ) )
         {
             return false;
         }
 
+        // Check that we can have no value for this attributeType
+        if ( values.size() == 0 )
+        {
+            return attributeType.getSyntax().getSyntaxChecker().isValidSyntax( null );
+        }
+
         for ( Value<?> value : values )
         {
             if ( ! value.isValid() )
@@ -762,7 +753,7 @@
                 return false;
             }
         }
-
+        
         return true;
     }
 
@@ -893,21 +884,12 @@
         this.attributeType = attributeType;
         setUpId( null, attributeType );
         
-        try
+        if ( attributeType.getSyntax().isHumanReadable() )
         {
-            if ( attributeType.getSyntax().isHumanReadable() )
-            {
-                isHR = true;
-            }
-            else
-            {
-                isHR = false;
-            }
+            isHR = true;
         }
-        catch ( NamingException ne )
+        else
         {
-            // If we have an exception while trying to get the Syntax for this attribute
-            // just set it as Binary
             isHR = false;
         }
     }
@@ -965,7 +947,7 @@
                 // In this case, it must be equals to the attributeType OID.
                 String normId = StringTools.lowerCaseAscii( StringTools.trim( id ) );
                 
-                for ( String atName:attributeType.getNamesRef() )
+                for ( String atName:attributeType.getNames() )
                 {
                     if ( atName.equalsIgnoreCase( normId ) )
                     {
@@ -1034,7 +1016,7 @@
                 // In this case, it must be equals to the attributeType OID.
                 String normUpId = StringTools.lowerCaseAscii( StringTools.trim( upId ) );
                 
-                for ( String atId:attributeType.getNamesRef() )
+                for ( String atId:attributeType.getNames() )
                 {
                     if ( atId.equalsIgnoreCase( normUpId ) )
                     {
@@ -1112,7 +1094,7 @@
                 // In this case, it must be equals to the attributeType OID.
                 String normUpId = StringTools.lowerCaseAscii( StringTools.trim( upId ) );
                 
-                for ( String atId:attributeType.getNamesRef() )
+                for ( String atId:attributeType.getNames() )
                 {
                     if ( atId.equalsIgnoreCase( normUpId ) )
                     {

Modified: directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java (original)
+++ directory/apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java Wed Jan  6 18:26:43 2010
@@ -30,8 +30,6 @@
 
 import javax.naming.NamingException;
 
-import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.NotImplementedException;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.AbstractEntry;
@@ -42,6 +40,7 @@
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.name.LdapDNSerializer;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -64,14 +63,14 @@
     /** The logger for this class */
     private static final Logger LOG = LoggerFactory.getLogger( DefaultServerEntry.class );
 
-    /** The AttributeType registries */
-    private final transient AttributeTypeRegistry atRegistry;
-    
     /** A speedup to get the ObjectClass attribute */
     private static transient AttributeType OBJECT_CLASS_AT;
     
     /** A mutex to manage synchronization*/
     private static transient Object MUTEX = new Object();
+    
+    /** The SchemaManager */
+    private SchemaManager schemaManager;
 
 
     //-------------------------------------------------------------------------
@@ -89,7 +88,7 @@
             throw new IllegalArgumentException( message );
         }
         
-        return atRegistry.lookup( upId );
+        return schemaManager.lookupAttributeTypeRegistry( upId );
     }
 
     
@@ -134,7 +133,7 @@
      * We can't do it once as a static part in the body of this class, because
      * the access to the registries is mandatory to get back the AttributeType.
      */
-    private void initObjectClassAT( Registries registries )
+    private void initObjectClassAT( SchemaManager schemaManager )
     {
         try
         {
@@ -142,7 +141,7 @@
             {
                 synchronized ( MUTEX )
                 {
-                    OBJECT_CLASS_AT = atRegistry.lookup( SchemaConstants.OBJECT_CLASS_AT );
+                    OBJECT_CLASS_AT = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT );
                 }
             }
         }
@@ -208,7 +207,7 @@
      */
     /* no protection ! */ DefaultServerEntry()
     {
-        atRegistry = null;
+        schemaManager = null;
         dn = LdapDN.EMPTY_LDAPDN;
     }
 
@@ -223,13 +222,13 @@
      * 
      * @param registries The reference to the global registries
      */
-    public DefaultServerEntry( Registries registries )
+    public DefaultServerEntry( SchemaManager schemaManager )
     {
-        atRegistry = registries.getAttributeTypeRegistry();
+        this.schemaManager = schemaManager;
         dn = LdapDN.EMPTY_LDAPDN;
 
         // Initialize the ObjectClass object
-        initObjectClassAT( registries );
+        initObjectClassAT( schemaManager );
     }
 
 
@@ -245,12 +244,12 @@
      * @param registries The reference to the global registries
      * @param entry the entry to copy
      */
-    public DefaultServerEntry( Registries registries, Entry entry )
+    public DefaultServerEntry( SchemaManager schemaManager, Entry entry )
     {
-        atRegistry = registries.getAttributeTypeRegistry();
+        this.schemaManager = schemaManager;
 
         // Initialize the ObjectClass object
-        initObjectClassAT( registries );
+        initObjectClassAT( schemaManager );
 
         // We will clone the existing entry, because it may be normalized
         if ( entry.getDn() != null )
@@ -267,7 +266,7 @@
             try
             {
                 // The dn must be normalized
-                dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
+                dn.normalize( schemaManager.getNormalizerMapping() );
             }
             catch ( NamingException ne )
             {
@@ -292,7 +291,7 @@
                 }
                 else
                 {
-                    attributeType = registries.getAttributeTypeRegistry().lookup( attribute.getId() );
+                    attributeType = schemaManager.lookupAttributeTypeRegistry( attribute.getId() );
                 }
                 
                 // Create a new ServerAttribute.
@@ -322,7 +321,7 @@
      * @param registries The reference to the global registries
      * @param dn The DN for this serverEntry. Can be null.
      */
-    public DefaultServerEntry( Registries registries, LdapDN dn )
+    public DefaultServerEntry( SchemaManager schemaManager, LdapDN dn )
     {
         if ( dn == null )
         {
@@ -333,10 +332,10 @@
             this.dn = dn;
         }
         
-        atRegistry = registries.getAttributeTypeRegistry();
+        this.schemaManager = schemaManager;
 
         // Initialize the ObjectClass object
-        initObjectClassAT( registries );
+        initObjectClassAT( schemaManager );
     }
 
 
@@ -357,7 +356,7 @@
      * @param dn The DN for this serverEntry. Can be null.
      * @param attributeTypes The list of attributes to create, without value.
      */
-    public DefaultServerEntry( Registries registries, LdapDN dn, AttributeType... attributeTypes )
+    public DefaultServerEntry( SchemaManager schemaManager, LdapDN dn, AttributeType... attributeTypes )
     {
         if ( dn == null )
         {
@@ -368,10 +367,10 @@
             this.dn = dn;
         }
 
-        atRegistry = registries.getAttributeTypeRegistry();
+        this.schemaManager = schemaManager;
 
         // Initialize the ObjectClass object
-        initObjectClassAT( registries );
+        initObjectClassAT( schemaManager );
 
         // Add the attributeTypes
         set( attributeTypes );
@@ -399,7 +398,7 @@
      * @param attributeType The attribute to create, without value.
      * @param upId The User Provided ID fro this AttributeType
      */
-    public DefaultServerEntry( Registries registries, LdapDN dn, AttributeType attributeType, String upId )
+    public DefaultServerEntry( SchemaManager schemaManager, LdapDN dn, AttributeType attributeType, String upId )
     {
         if ( dn == null )
         {
@@ -410,11 +409,11 @@
             this.dn = dn;
         }
         
-        atRegistry = registries.getAttributeTypeRegistry();
+        this.schemaManager = schemaManager;
         // Initialize the ObjectClass object
 
         // Initialize the ObjectClass object
-        initObjectClassAT( registries );
+        initObjectClassAT( schemaManager );
 
         try
         {
@@ -441,7 +440,7 @@
      * @param dn The DN for this serverEntry. Can be null.
      * @param upIds The list of attributes to create.
      */
-    public DefaultServerEntry( Registries registries, LdapDN dn, String... upIds )
+    public DefaultServerEntry( SchemaManager schemaManager, LdapDN dn, String... upIds )
     {
         if ( dn == null )
         {
@@ -452,9 +451,9 @@
             this.dn = dn;
         }
         
-        atRegistry = registries.getAttributeTypeRegistry();
+        this.schemaManager = schemaManager;
 
-        initObjectClassAT( registries );
+        initObjectClassAT( schemaManager );
 
         set( upIds );
     }
@@ -473,7 +472,7 @@
      * @param dn The DN for this serverEntry. Can be null
      * @param attributes The list of attributes to create
      */
-    public DefaultServerEntry( Registries registries, LdapDN dn, ServerAttribute... attributes )
+    public DefaultServerEntry( SchemaManager schemaManager, LdapDN dn, ServerAttribute... attributes )
     {
         if ( dn == null )
         {
@@ -484,9 +483,9 @@
             this.dn = dn;
         }
         
-        atRegistry = registries.getAttributeTypeRegistry();
+        this.schemaManager = schemaManager;
 
-        initObjectClassAT( registries );
+        initObjectClassAT( schemaManager );
 
         for ( ServerAttribute attribute:attributes )
         {
@@ -991,7 +990,7 @@
         
         try
         {
-            AttributeType attributeType = atRegistry.lookup( id );
+            AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( id );
             
             if ( attributeType == null )
             {
@@ -1033,7 +1032,7 @@
         
         try
         {
-            AttributeType attributeType = atRegistry.lookup( id );
+            AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( id );
             
             if ( attributeType == null )
             {
@@ -1075,7 +1074,7 @@
         
         try
         {
-            AttributeType attributeType = atRegistry.lookup( id );
+            AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( id );
             
             if ( attributeType == null )
             {
@@ -1180,7 +1179,7 @@
     {
         try
         {
-            return get( atRegistry.lookup( alias ) );
+            return get( schemaManager.lookupAttributeTypeRegistry( StringTools.trim( StringTools.toLowerCase( alias ) ) ) );
         }
         catch ( NamingException ne )
         {
@@ -2104,7 +2103,7 @@
             
             try
             {
-                attributeType = atRegistry.lookup( attribute );
+                attributeType = schemaManager.lookupAttributeTypeRegistry( attribute );
             }
             catch ( NamingException ne )
             {
@@ -2283,10 +2282,10 @@
         // now clone all the servrAttributes
         clone.attributes.clear();
         
-        for ( AttributeType key:attributes.keySet() )
+        for ( EntryAttribute entryAttribute : attributes.values() )
         {
-            EntryAttribute value = (ServerAttribute)attributes.get( key ).clone();
-            clone.attributes.put( key, value );
+            ServerAttribute value = (ServerAttribute)entryAttribute.clone();
+            clone.attributes.put( value.getAttributeType(), value );
         }
         
         // We are done !
@@ -2385,7 +2384,7 @@
             
             try
             {
-                AttributeType attributeType = atRegistry.lookup( oid );
+                AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( oid );
                 
                 // Create the attribute we will read
                 DefaultServerAttribute attribute = new DefaultServerAttribute( attributeType );
@@ -2495,7 +2494,7 @@
         if ( dn.isNormalized() )
         {
             sb.append( "[n]: " );
-            sb.append( dn.getUpName() );
+            sb.append( dn.getName() );
         }
         else
         {