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 2012/01/24 18:27:12 UTC

svn commit: r1235364 [27/27] - in /directory/shared/trunk: asn1/api/src/main/java/org/apache/directory/shared/asn1/util/ asn1/api/src/test/java/org/apache/directory/shared/asn1/util/ asn1/ber/src/main/java/org/apache/directory/shared/asn1/actions/ asn1...

Modified: directory/shared/trunk/ldap/extras/trigger/src/main/java/org/apache/directory/shared/ldap/trigger/StoredProcedureParameter.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/trigger/src/main/java/org/apache/directory/shared/ldap/trigger/StoredProcedureParameter.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/trigger/src/main/java/org/apache/directory/shared/ldap/trigger/StoredProcedureParameter.java (original)
+++ directory/shared/trunk/ldap/extras/trigger/src/main/java/org/apache/directory/shared/ldap/trigger/StoredProcedureParameter.java Tue Jan 24 17:27:00 2012
@@ -34,46 +34,50 @@ public abstract class StoredProcedurePar
     public static final class Generic_LDAP_CONTEXT extends StoredProcedureParameter
     {
         private Dn ctxName;
-        
+
+
         private Generic_LDAP_CONTEXT( Dn ctxName )
         {
             super( "$ldapContext" );
             this.ctxName = ctxName;
         }
-        
+
+
         public static StoredProcedureParameter instance( Dn ctxName )
         {
             return new Generic_LDAP_CONTEXT( ctxName );
         }
-        
+
+
         public Dn getCtxName()
         {
             return ctxName;
         }
-        
+
+
         public String toString()
         {
             return name + " \"" + ctxName.getName() + "\"";
         }
     }
 
-    
     public static final class Generic_OPERATION_PRINCIPAL extends StoredProcedureParameter
     {
         private static Generic_OPERATION_PRINCIPAL instance = new Generic_OPERATION_PRINCIPAL( "$operationPrincipal" );
-        
+
+
         private Generic_OPERATION_PRINCIPAL( String identifier )
         {
             super( identifier );
         }
-        
+
+
         public static StoredProcedureParameter instance()
         {
             return instance;
         }
     }
 
-    
     protected final String name;
 
 
@@ -96,7 +100,7 @@ public abstract class StoredProcedurePar
     {
         return name;
     }
-    
+
 
     /**
      * @see java.lang.Object#hashCode()
@@ -105,9 +109,9 @@ public abstract class StoredProcedurePar
     public int hashCode()
     {
         int h = 37;
-        
-        h = h*17 + ( ( name == null ) ? 0 : name.hashCode() );
-        
+
+        h = h * 17 + ( ( name == null ) ? 0 : name.hashCode() );
+
         return h;
     }
 
@@ -144,240 +148,255 @@ public abstract class StoredProcedurePar
         return true;
     }
 
-    
     public static final class Modify_OBJECT extends StoredProcedureParameter
     {
         private static Modify_OBJECT instance = new Modify_OBJECT( "$object" );
-        
+
+
         private Modify_OBJECT( String identifier )
         {
             super( identifier );
         }
-        
+
+
         public static StoredProcedureParameter instance()
         {
             return instance;
         }
     }
-    
-    
+
     public static final class Modify_MODIFICATION extends StoredProcedureParameter
     {
         private static Modify_MODIFICATION instance = new Modify_MODIFICATION( "$modification" );
-        
+
+
         private Modify_MODIFICATION( String identifier )
         {
             super( identifier );
         }
-        
+
+
         public static StoredProcedureParameter instance()
         {
             return instance;
         }
     }
-    
-    
+
     public static final class Modify_OLD_ENTRY extends StoredProcedureParameter
     {
         private static Modify_OLD_ENTRY instance = new Modify_OLD_ENTRY( "$oldEntry" );
-        
+
+
         private Modify_OLD_ENTRY( String identifier )
         {
             super( identifier );
         }
-        
+
+
         public static StoredProcedureParameter instance()
         {
             return instance;
         }
     }
-    
-    
+
     public static final class Modify_NEW_ENTRY extends StoredProcedureParameter
     {
         private static Modify_NEW_ENTRY instance = new Modify_NEW_ENTRY( "$newEntry" );
-        
+
+
         private Modify_NEW_ENTRY( String identifier )
         {
             super( identifier );
         }
-        
+
+
         public static StoredProcedureParameter instance()
         {
             return instance;
         }
     }
 
-    
     public static final class Add_ENTRY extends StoredProcedureParameter
     {
         private static Add_ENTRY instance = new Add_ENTRY( "$entry" );
-        
+
+
         private Add_ENTRY( String identifier )
         {
             super( identifier );
         }
-        
+
+
         public static StoredProcedureParameter instance()
         {
             return instance;
         }
     }
-    
-    
+
     public static final class Add_ATTRIBUTES extends StoredProcedureParameter
     {
         private static Add_ATTRIBUTES instance = new Add_ATTRIBUTES( "$attributes" );
-        
+
+
         private Add_ATTRIBUTES( String identifier )
         {
             super( identifier );
         }
-        
+
+
         public static StoredProcedureParameter instance()
         {
             return instance;
         }
     }
 
-    
     public static final class Delete_NAME extends StoredProcedureParameter
     {
         private static Delete_NAME instance = new Delete_NAME( "$name" );
-        
+
+
         private Delete_NAME( String identifier )
         {
             super( identifier );
         }
-        
+
+
         public static StoredProcedureParameter instance()
         {
             return instance;
         }
     }
-    
-    
+
     public static final class Delete_DELETED_ENTRY extends StoredProcedureParameter
     {
         private static Delete_DELETED_ENTRY instance = new Delete_DELETED_ENTRY( "$deletedEntry" );
-        
+
+
         private Delete_DELETED_ENTRY( String identifier )
         {
             super( identifier );
         }
-        
+
+
         public static StoredProcedureParameter instance()
         {
             return instance;
         }
     }
 
-    
     public static final class ModifyDN_ENTRY extends StoredProcedureParameter
     {
         private static ModifyDN_ENTRY instance = new ModifyDN_ENTRY( "$entry" );
-        
+
+
         private ModifyDN_ENTRY( String identifier )
         {
             super( identifier );
         }
-        
+
+
         public static StoredProcedureParameter instance()
         {
             return instance;
         }
     }
-    
-    
+
     public static final class ModifyDN_NEW_RDN extends StoredProcedureParameter
     {
         private static ModifyDN_NEW_RDN instance = new ModifyDN_NEW_RDN( "$newrdn" );
-        
+
+
         private ModifyDN_NEW_RDN( String identifier )
         {
             super( identifier );
         }
-        
+
+
         public static StoredProcedureParameter instance()
         {
             return instance;
         }
     }
-    
-    
+
     public static final class ModifyDN_DELETE_OLD_RDN extends StoredProcedureParameter
     {
         private static ModifyDN_DELETE_OLD_RDN instance = new ModifyDN_DELETE_OLD_RDN( "$deleteoldrdn" );
-        
+
+
         private ModifyDN_DELETE_OLD_RDN( String identifier )
         {
             super( identifier );
         }
-        
+
+
         public static StoredProcedureParameter instance()
         {
             return instance;
         }
     }
-    
-    
+
     public static final class ModifyDN_NEW_SUPERIOR extends StoredProcedureParameter
     {
         private static ModifyDN_NEW_SUPERIOR instance = new ModifyDN_NEW_SUPERIOR( "$newSuperior" );
-        
+
+
         private ModifyDN_NEW_SUPERIOR( String identifier )
         {
             super( identifier );
         }
-        
+
+
         public static StoredProcedureParameter instance()
         {
             return instance;
         }
     }
-    
-    
+
     public static final class ModifyDN_OLD_RDN extends StoredProcedureParameter
     {
         private static ModifyDN_OLD_RDN instance = new ModifyDN_OLD_RDN( "$oldRDN" );
-        
+
+
         private ModifyDN_OLD_RDN( String identifier )
         {
             super( identifier );
         }
-        
+
+
         public static StoredProcedureParameter instance()
         {
             return instance;
         }
     }
-    
-    
+
     public static final class ModifyDN_OLD_SUPERIOR_DN extends StoredProcedureParameter
     {
         private static ModifyDN_OLD_SUPERIOR_DN instance = new ModifyDN_OLD_SUPERIOR_DN( "$oldRDN" );
-        
+
+
         private ModifyDN_OLD_SUPERIOR_DN( String identifier )
         {
             super( identifier );
         }
-        
+
+
         public static StoredProcedureParameter instance()
         {
             return instance;
         }
     }
-    
-    
+
     public static final class ModifyDN_NEW_DN extends StoredProcedureParameter
     {
         private static ModifyDN_NEW_DN instance = new ModifyDN_NEW_DN( "$oldRDN" );
-        
+
+
         private ModifyDN_NEW_DN( String identifier )
         {
             super( identifier );
         }
-        
+
+
         public static StoredProcedureParameter instance()
         {
             return instance;

Modified: directory/shared/trunk/ldap/extras/trigger/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/trigger/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParser.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/trigger/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParser.java (original)
+++ directory/shared/trunk/ldap/extras/trigger/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParser.java Tue Jan 24 17:27:00 2012
@@ -129,7 +129,7 @@ public class TriggerSpecificationParser
             String msg = I18n.err( I18n.ERR_04333, spec, e.getLocalizedMessage() );
             throw new ParseException( msg, e.getColumn() );
         }
-        
+
         return triggerSpecification;
 
     }

Modified: directory/shared/trunk/ldap/extras/trigger/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/trigger/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerUtils.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/trigger/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerUtils.java (original)
+++ directory/shared/trunk/ldap/extras/trigger/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerUtils.java Tue Jan 24 17:27:00 2012
@@ -18,9 +18,9 @@
  *
  */
 
-
 package org.apache.directory.shared.ldap.trigger;
 
+
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
@@ -32,6 +32,7 @@ import javax.naming.ldap.LdapContext;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.entry.AttributeUtils;
 
+
 /**
  * A utility class for working with Triggers Execution Administrative Points
  * Trigger Execution Subentries and Trigger Specifications.
@@ -56,12 +57,14 @@ public final class TriggerUtils
 
     public static void defineTriggerExecutionSpecificPoint( LdapContext apCtx ) throws NamingException
     {
-        Attributes ap = apCtx.getAttributes( "", new String[] { SchemaConstants.ADMINISTRATIVE_ROLE_AT } );
+        Attributes ap = apCtx.getAttributes( "", new String[]
+            { SchemaConstants.ADMINISTRATIVE_ROLE_AT } );
         Attribute administrativeRole = ap.get( SchemaConstants.ADMINISTRATIVE_ROLE_AT );
         if ( administrativeRole == null
-            || !AttributeUtils.containsValueCaseIgnore(administrativeRole, TRIGGER_EXECUTION_SPECIFIC_AREA_VALUE) )
+            || !AttributeUtils.containsValueCaseIgnore( administrativeRole, TRIGGER_EXECUTION_SPECIFIC_AREA_VALUE ) )
         {
-            Attributes changes = new BasicAttributes( SchemaConstants.ADMINISTRATIVE_ROLE_AT, TRIGGER_EXECUTION_SPECIFIC_AREA_VALUE, true );
+            Attributes changes = new BasicAttributes( SchemaConstants.ADMINISTRATIVE_ROLE_AT,
+                TRIGGER_EXECUTION_SPECIFIC_AREA_VALUE, true );
             apCtx.modifyAttributes( "", DirContext.ADD_ATTRIBUTE, changes );
         }
     }

Modified: directory/shared/trunk/ldap/extras/trigger/src/test/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/trigger/src/test/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParserTest.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/trigger/src/test/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParserTest.java (original)
+++ directory/shared/trunk/ldap/extras/trigger/src/test/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParserTest.java Tue Jan 24 17:27:00 2012
@@ -50,7 +50,7 @@ public class TriggerSpecificationParserT
     /** The Trigger Specification parser */
     TriggerSpecificationParser parser;
 
-    
+
     /**
      * Creates a TriggerSpecificationParserTest instance.
      */
@@ -63,13 +63,13 @@ public class TriggerSpecificationParserT
 
     @Test
     public void testWithOperationParameters() throws Exception
-    {        
+    {
         TriggerSpecification triggerSpecification = null;
-        
+
         String spec = "AFTER Delete CALL \"BackupUtilities.backupDeletedEntry\" ($name, $deletedEntry);";
 
         triggerSpecification = parser.parse( spec );
-        
+
         assertNotNull( triggerSpecification );
         assertEquals( triggerSpecification.getActionTime(), ActionTime.AFTER );
         assertEquals( triggerSpecification.getLdapOperation(), LdapOperation.DELETE );
@@ -85,16 +85,17 @@ public class TriggerSpecificationParserT
         assertTrue( theSpec.getParameters().contains(
             StoredProcedureParameter.Delete_DELETED_ENTRY.instance() ) );
     }
-    
+
+
     @Test
     public void testWithGenericParameters() throws Exception
-    {        
+    {
         TriggerSpecification triggerSpecification = null;
-        
+
         String spec = "AFTER Add CALL \"Logger.logAddOperation\" ($entry, $attributes, $operationPrincipal);";
 
         triggerSpecification = parser.parse( spec );
-        
+
         assertNotNull( triggerSpecification );
         assertEquals( triggerSpecification.getActionTime(), ActionTime.AFTER );
         assertEquals( triggerSpecification.getLdapOperation(), LdapOperation.ADD );
@@ -102,26 +103,27 @@ public class TriggerSpecificationParserT
         assertTrue( spSpecs != null );
         assertTrue( spSpecs.size() == 1 );
         SPSpec theSpec = spSpecs.get( 0 );
-        assertEquals( theSpec.getName(), "Logger.logAddOperation" );        
+        assertEquals( theSpec.getName(), "Logger.logAddOperation" );
         assertEquals( theSpec.getOptions().size(), 0 );
         assertEquals( theSpec.getParameters().size(), 3 );
         assertTrue( theSpec.getParameters().contains(
             StoredProcedureParameter.Add_ENTRY.instance() ) );
-        assertTrue(theSpec.getParameters().contains(
-            StoredProcedureParameter.Add_ATTRIBUTES.instance()) );
+        assertTrue( theSpec.getParameters().contains(
+            StoredProcedureParameter.Add_ATTRIBUTES.instance() ) );
         assertTrue( theSpec.getParameters().contains(
             StoredProcedureParameter.Generic_OPERATION_PRINCIPAL.instance() ) );
     }
-    
+
+
     @Test
     public void testWithLanguageSchemeOption() throws Exception
-    {        
+    {
         TriggerSpecification triggerSpecification = null;
-        
+
         String spec = "AFTER Modify CALL \"Logger.logModifyOperation\" {languageScheme \"Java\"}();";
 
         triggerSpecification = parser.parse( spec );
-        
+
         assertNotNull( triggerSpecification );
         assertEquals( triggerSpecification.getActionTime(), ActionTime.AFTER );
         assertEquals( triggerSpecification.getLdapOperation(), LdapOperation.MODIFY );
@@ -133,20 +135,21 @@ public class TriggerSpecificationParserT
         assertEquals( theSpec.getOptions().size(), 1 );
         assertTrue( theSpec.getOptions().contains(
             new StoredProcedureLanguageSchemeOption( "Java" ) ) );
-        assertEquals( theSpec.getParameters().size(),  0 );
+        assertEquals( theSpec.getParameters().size(), 0 );
     }
-    
+
+
     @Test
     public void testWithSearchContextOption() throws Exception
-    {        
+    {
         TriggerSpecification triggerSpecification = null;
-        
+
         String spec = "AFTER ModifyDN.Rename CALL \"Logger.logModifyDNRenameOperation\" \n" +
             "{ searchContext { scope one } \"cn=Logger,ou=Stored Procedures,ou=system\" } \n" +
             "($entry, $newrdn);  # Stored Procedure Parameter(s)";
 
         triggerSpecification = parser.parse( spec );
-        
+
         assertNotNull( triggerSpecification );
         assertEquals( triggerSpecification.getActionTime(), ActionTime.AFTER );
         assertEquals( triggerSpecification.getLdapOperation(), LdapOperation.MODIFYDN_RENAME );
@@ -165,16 +168,17 @@ public class TriggerSpecificationParserT
         assertTrue( theSpec.getParameters().contains(
             StoredProcedureParameter.ModifyDN_NEW_RDN.instance() ) );
     }
-    
+
+
     @Test
     public void testWithLdapContextParameter() throws Exception
-    {        
+    {
         TriggerSpecification triggerSpecification = null;
-        
+
         String spec = "AFTER Delete CALL \"BackupUtilities.backupDeletedEntry\" ($ldapContext \"ou=Backup,ou=System\", $name, $deletedEntry);";
 
         triggerSpecification = parser.parse( spec );
-        
+
         assertNotNull( triggerSpecification );
         assertEquals( triggerSpecification.getActionTime(), ActionTime.AFTER );
         assertEquals( triggerSpecification.getLdapOperation(), LdapOperation.DELETE );
@@ -192,18 +196,21 @@ public class TriggerSpecificationParserT
         assertTrue( theSpec.getParameters().contains(
             StoredProcedureParameter.Generic_LDAP_CONTEXT.instance( new Dn( "ou=Backup,ou=System" ) ) ) );
     }
-    
+
+
     @Test
     public void testMultipleSPCalls() throws Exception
-    {        
+    {
         TriggerSpecification triggerSpecification = null;
-        
-        String spec = "AFTER Delete " +
-            "CALL \"BackupUtilities.backupDeletedEntry\" ($ldapContext \"ou=Backup,ou=System\", $name, $deletedEntry); " +
+
+        String spec = "AFTER Delete "
+            +
+            "CALL \"BackupUtilities.backupDeletedEntry\" ($ldapContext \"ou=Backup,ou=System\", $name, $deletedEntry); "
+            +
             "CALL \"BackupUtilities.recreateDeletedEntry\" ($name, $deletedEntry);";
 
         triggerSpecification = parser.parse( spec );
-        
+
         assertNotNull( triggerSpecification );
         assertEquals( triggerSpecification.getActionTime(), ActionTime.AFTER );
         assertEquals( triggerSpecification.getLdapOperation(), LdapOperation.DELETE );
@@ -229,5 +236,5 @@ public class TriggerSpecificationParserT
         assertTrue( secondSpec.getParameters().contains(
             StoredProcedureParameter.Delete_DELETED_ENTRY.instance() ) );
     }
-    
+
 }

Modified: directory/shared/trunk/ldap/extras/util/src/main/java/org/apache/directory/shared/ldap/util/JndiUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/util/src/main/java/org/apache/directory/shared/ldap/util/JndiUtils.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/util/src/main/java/org/apache/directory/shared/ldap/util/JndiUtils.java (original)
+++ directory/shared/trunk/ldap/extras/util/src/main/java/org/apache/directory/shared/ldap/util/JndiUtils.java Tue Jan 24 17:27:00 2012
@@ -94,7 +94,7 @@ public final class JndiUtils
 
 
     // @TODO not really needed and can be moved out
-    public static javax.naming.ldap.Control toJndiControl( LdapApiService codec, Control control ) 
+    public static javax.naming.ldap.Control toJndiControl( LdapApiService codec, Control control )
         throws EncoderException
     {
         return codec.toJndiControl( control );
@@ -102,8 +102,8 @@ public final class JndiUtils
 
 
     // @TODO not really needed and can be moved out
-    public static javax.naming.ldap.Control[] toJndiControls( LdapApiService codec, Control... controls ) 
-         throws EncoderException
+    public static javax.naming.ldap.Control[] toJndiControls( LdapApiService codec, Control... controls )
+        throws EncoderException
     {
         if ( controls != null )
         {
@@ -125,7 +125,7 @@ public final class JndiUtils
 
 
     // @TODO not really needed and can be moved out
-    public static Control fromJndiControl( LdapApiService codec, javax.naming.ldap.Control jndiControl ) 
+    public static Control fromJndiControl( LdapApiService codec, javax.naming.ldap.Control jndiControl )
         throws DecoderException
     {
         return codec.fromJndiControl( jndiControl );
@@ -164,7 +164,7 @@ public final class JndiUtils
 
         NamingException ne = null;
 
-        if ( t instanceof LdapAffectMultipleDsaException)
+        if ( t instanceof LdapAffectMultipleDsaException )
         {
             ne = new NamingException( t.getLocalizedMessage() );
         }
@@ -220,7 +220,7 @@ public final class JndiUtils
         {
             ne = new NoPermissionException( t.getLocalizedMessage() );
         }
-        else if ( t instanceof LdapNoSuchAttributeException)
+        else if ( t instanceof LdapNoSuchAttributeException )
         {
             ne = new NoSuchAttributeException( t.getLocalizedMessage() );
         }
@@ -252,7 +252,7 @@ public final class JndiUtils
         {
             ne = new SchemaViolationException( t.getLocalizedMessage() );
         }
-        else if ( t instanceof LdapServiceUnavailableException)
+        else if ( t instanceof LdapServiceUnavailableException )
         {
             ne = new ServiceUnavailableException( t.getLocalizedMessage() );
         }

Modified: directory/shared/trunk/ldap/extras/util/src/main/java/org/apache/directory/shared/ldap/util/tree/DnNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/util/src/main/java/org/apache/directory/shared/ldap/util/tree/DnNode.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/util/src/main/java/org/apache/directory/shared/ldap/util/tree/DnNode.java (original)
+++ directory/shared/trunk/ldap/extras/util/src/main/java/org/apache/directory/shared/ldap/util/tree/DnNode.java Tue Jan 24 17:27:00 2012
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.shared.ldap.util.tree;
 
+
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -69,6 +70,7 @@ public class DnNode<N> implements Clonea
     /** Stores the list of all the descendant */
     private Map<Rdn, DnNode<N>> children;
 
+
     //-------------------------------------------------------------------------
     // Helper methods
     //-------------------------------------------------------------------------
@@ -85,6 +87,7 @@ public class DnNode<N> implements Clonea
         }
     }
 
+
     /**
      * Create a new DnNode, recursively creating all the intermediate nodes.
      */
@@ -129,7 +132,7 @@ public class DnNode<N> implements Clonea
         return rootNode;
     }
 
-    
+
     /**
      * Store the given element into the node
      */
@@ -137,8 +140,8 @@ public class DnNode<N> implements Clonea
     {
         this.nodeElement = element;
     }
-    
-    
+
+
     //-------------------------------------------------------------------------
     // Constructors
     //-------------------------------------------------------------------------
@@ -245,7 +248,7 @@ public class DnNode<N> implements Clonea
         int size = 1;
 
         // Iterate through the children if any
-        if ( children.size() !=0 )
+        if ( children.size() != 0 )
         {
             for ( DnNode<N> node : children.values() )
             {
@@ -282,7 +285,7 @@ public class DnNode<N> implements Clonea
         return node.nodeElement;
     }
 
-    
+
     /**
      * @return True if the Node stores an element. BranchNode may not hold any
      * element.
@@ -310,7 +313,7 @@ public class DnNode<N> implements Clonea
         return node.nodeElement != null;
     }
 
-    
+
     /**
      * recursively check if the node has a descendant having an element
      */
@@ -320,12 +323,12 @@ public class DnNode<N> implements Clonea
         {
             return false;
         }
-        
+
         if ( node.hasElement() )
         {
             return true;
         }
-        
+
         for ( DnNode<N> child : node.getChildren().values() )
         {
             if ( hasDescendantElement( child ) )
@@ -338,7 +341,7 @@ public class DnNode<N> implements Clonea
         return false;
     }
 
-    
+
     /**
      * @return True if one of the node below the current node has one element, 
      * False otherwise
@@ -352,7 +355,7 @@ public class DnNode<N> implements Clonea
         {
             return false;
         }
-        
+
         // We must be at the right place in the tree
         if ( node.getDn().size() != dn.size() )
         {
@@ -369,11 +372,11 @@ public class DnNode<N> implements Clonea
                 }
             }
         }
-        
+
         return false;
     }
 
-    
+
     /**
      * recursively get all the elements from nodes having an element
      */
@@ -383,22 +386,22 @@ public class DnNode<N> implements Clonea
         {
             return;
         }
-        
+
         if ( node.hasElement() )
         {
             descendants.add( node.getElement() );
-            
+
             // Stop here
             return;
         }
-        
+
         for ( DnNode<N> child : node.getChildren().values() )
         {
             getDescendantElements( child, descendants );
         }
     }
 
-    
+
     /**
      * @return True if one of the node below the current node has one element, 
      * False otherwise
@@ -407,14 +410,14 @@ public class DnNode<N> implements Clonea
     public synchronized List<N> getDescendantElements( Dn dn )
     {
         List<N> descendants = new ArrayList<N>();
-        
+
         DnNode<N> node = getNode( dn );
 
         if ( node == null )
         {
             return descendants;
         }
-        
+
         // We must be at the right place in the tree
         if ( node.getDn().size() != dn.size() )
         {
@@ -428,7 +431,7 @@ public class DnNode<N> implements Clonea
                 getDescendantElements( child, descendants );
             }
         }
-        
+
         return descendants;
     }
 
@@ -531,7 +534,7 @@ public class DnNode<N> implements Clonea
             }
         }
 
-        return( parentNode != null );
+        return ( parentNode != null );
     }
 
 
@@ -599,7 +602,7 @@ public class DnNode<N> implements Clonea
             else
             {
                 DnNode<N> rootNode = createNode( dn, element, nbRdns );
-    
+
                 // done. now, add the newly created tree to the parent node
                 rootNode.parent = parentNode;
                 parentNode.children.put( rootNode.nodeRdn, rootNode );
@@ -829,7 +832,7 @@ public class DnNode<N> implements Clonea
         return element;
     }
 
-    
+
     /**
      * Get the closest Node for a given Dn which has an element, if present in the tree.<br>
      * For instance, if we have stored dc=acme, dc=org into the tree,
@@ -850,14 +853,14 @@ public class DnNode<N> implements Clonea
             {
                 return currentNode;
             }
-            
+
             currentNode = currentNode.parent;
         }
-        
+
         return null;
     }
 
-    
+
     /**
      * rename the DnNode's Dn
      * 
@@ -870,20 +873,20 @@ public class DnNode<N> implements Clonea
         temp = temp.add( newRdn );
 
         Rdn oldRdn = nodeRdn;
-        
+
         nodeRdn = temp.getRdn();
         nodeDn = temp;
-        
+
         if ( parent != null )
         {
             parent.children.remove( oldRdn );
             parent.children.put( nodeRdn, this );
         }
-        
+
         updateAfterModDn( nodeDn );
     }
-    
-    
+
+
     /**
      * move the DnNode's Dn
      *
@@ -895,21 +898,21 @@ public class DnNode<N> implements Clonea
         DnNode<N> tmp = null;
 
         Dn tmpDn = null;
-       
+
         // check if the new parent Dn is child of the parent
-        if( newParent.isDescendantOf( parent.nodeDn ) )
+        if ( newParent.isDescendantOf( parent.nodeDn ) )
         {
             tmp = parent;
             tmpDn = parent.nodeDn;
         }
-        
+
         // if yes, then drill for the new parent node
         if ( tmpDn != null )
         {
             int parentNodeSize = tmpDn.size();
             int count = newParent.size() - parentNodeSize;
-            
-            while( count-- > 0 )
+
+            while ( count-- > 0 )
             {
                 tmp = tmp.getChild( newParent.getRdn( parentNodeSize++ ) );
             }
@@ -920,27 +923,27 @@ public class DnNode<N> implements Clonea
         if ( tmp == null )
         {
             tmp = this;
-            while( tmp.parent != null )
+            while ( tmp.parent != null )
             {
                 tmp = tmp.parent;
             }
-            
+
             tmp = tmp.getNode( newParent );
         }
-        
+
         nodeDn = newParent.add( nodeRdn );
         updateAfterModDn( nodeDn );
-        
-        if( parent != null )
+
+        if ( parent != null )
         {
             parent.children.remove( nodeRdn );
         }
-        
+
         parent = tmp;
         parent.children.put( nodeRdn, this );
     }
-    
-    
+
+
     /**
      * update the children's Dn based on the new parent Dn created
      * after a rename or move operation
@@ -951,15 +954,15 @@ public class DnNode<N> implements Clonea
     {
         if ( children != null )
         {
-            for( DnNode<N> child : children.values() )
+            for ( DnNode<N> child : children.values() )
             {
                 child.nodeDn = newParentDn.add( child.nodeRdn );
                 child.updateAfterModDn( child.nodeDn );
             }
         }
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -1035,6 +1038,7 @@ public class DnNode<N> implements Clonea
         return sb.toString();
     }
 
+
     /**
      * {@inheritDoc}
      */

Modified: directory/shared/trunk/ldap/extras/util/src/test/java/org/apache/directory/shared/ldap/util/tree/TestDnNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/util/src/test/java/org/apache/directory/shared/ldap/util/tree/TestDnNode.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/util/src/test/java/org/apache/directory/shared/ldap/util/tree/TestDnNode.java (original)
+++ directory/shared/trunk/ldap/extras/util/src/test/java/org/apache/directory/shared/ldap/util/tree/TestDnNode.java Tue Jan 24 17:27:00 2012
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.shared.ldap.util.tree;
 
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -53,7 +54,7 @@ public class TestDnNode
     /**
      * Test the addition of a null Dn
      */
-    @Test( expected=LdapUnwillingToPerformException.class)
+    @Test(expected = LdapUnwillingToPerformException.class)
     public void testAddNullDNNoElem() throws LdapException
     {
         DnNode<Dn> tree = new DnNode<Dn>();
@@ -169,7 +170,7 @@ public class TestDnNode
     /**
      * Test the addition of two equal DNs
      */
-    @Test( expected=LdapUnwillingToPerformException.class)
+    @Test(expected = LdapUnwillingToPerformException.class)
     public void testAdd2EqualDNsNoElem() throws LdapException
     {
         DnNode<Dn> tree = new DnNode<Dn>();
@@ -187,12 +188,12 @@ public class TestDnNode
     /**
      * Test the addition of a null Dn
      */
-    @Test( expected=LdapUnwillingToPerformException.class)
+    @Test(expected = LdapUnwillingToPerformException.class)
     public void testAddNullDN() throws LdapException
     {
         DnNode<Dn> tree = new DnNode<Dn>();
 
-        tree.add( (Dn)null, null );
+        tree.add( ( Dn ) null, null );
     }
 
 
@@ -303,7 +304,7 @@ public class TestDnNode
     /**
      * Test the addition of two equal DNs
      */
-    @Test( expected=LdapUnwillingToPerformException.class)
+    @Test(expected = LdapUnwillingToPerformException.class)
     public void testAdd2EqualDNs() throws LdapException
     {
         DnNode<Dn> tree = new DnNode<Dn>();
@@ -673,6 +674,7 @@ public class TestDnNode
         assertTrue( child.contains( rdnC ) );
     }
 
+
     /**
      * test the deletion of elements in a tree
      */
@@ -704,7 +706,7 @@ public class TestDnNode
         assertTrue( dnLookupTree.hasParent( dn5 ) );
         assertTrue( dnLookupTree.hasParent( dn6 ) );
         assertTrue( dnLookupTree.hasParent( new Dn( "dc=nothing,dc=empty" ) ) );
-        assertFalse( dnLookupTree.hasParent( new Dn(  "dc=directory,dc=apache,dc=root" ) ) );
+        assertFalse( dnLookupTree.hasParent( new Dn( "dc=directory,dc=apache,dc=root" ) ) );
 
         dnLookupTree.remove( dn6 );
         assertEquals( 9, dnLookupTree.size() );
@@ -713,7 +715,7 @@ public class TestDnNode
         assertTrue( dnLookupTree.hasParent( dn4 ) );
         assertTrue( dnLookupTree.hasParent( dn5 ) );
         assertFalse( dnLookupTree.hasParent( new Dn( "dc=nothing,dc=empty" ) ) );
-        assertFalse( dnLookupTree.hasParent( new Dn(  "dc=directory,dc=apache,dc=root" ) ) );
+        assertFalse( dnLookupTree.hasParent( new Dn( "dc=directory,dc=apache,dc=root" ) ) );
 
         dnLookupTree.remove( dn1 );
         assertEquals( 8, dnLookupTree.size() );
@@ -721,7 +723,7 @@ public class TestDnNode
         assertTrue( dnLookupTree.hasParent( dn4 ) );
         assertTrue( dnLookupTree.hasParent( dn5 ) );
         assertFalse( dnLookupTree.hasParent( new Dn( "dc=nothing,dc=empty" ) ) );
-        assertFalse( dnLookupTree.hasParent( new Dn(  "dc=directory,dc=apache,dc=root" ) ) );
+        assertFalse( dnLookupTree.hasParent( new Dn( "dc=directory,dc=apache,dc=root" ) ) );
 
         // Should not change anything
         dnLookupTree.remove( dn3 );
@@ -730,28 +732,28 @@ public class TestDnNode
         assertTrue( dnLookupTree.hasParent( dn4 ) );
         assertTrue( dnLookupTree.hasParent( dn5 ) );
         assertFalse( dnLookupTree.hasParent( new Dn( "dc=nothing,dc=empty" ) ) );
-        assertFalse( dnLookupTree.hasParent( new Dn(  "dc=directory,dc=apache,dc=root" ) ) );
+        assertFalse( dnLookupTree.hasParent( new Dn( "dc=directory,dc=apache,dc=root" ) ) );
 
         dnLookupTree.remove( dn5 );
         assertEquals( 6, dnLookupTree.size() );
         assertTrue( dnLookupTree.hasParent( dn2 ) );
         assertTrue( dnLookupTree.hasParent( dn4 ) );
         assertFalse( dnLookupTree.hasParent( new Dn( "dc=nothing,dc=empty" ) ) );
-        assertFalse( dnLookupTree.hasParent( new Dn(  "dc=directory,dc=apache,dc=root" ) ) );
+        assertFalse( dnLookupTree.hasParent( new Dn( "dc=directory,dc=apache,dc=root" ) ) );
 
         dnLookupTree.remove( dn2 );
         assertEquals( 3, dnLookupTree.size() );
         assertTrue( dnLookupTree.hasParent( dn4 ) );
         assertFalse( dnLookupTree.hasParent( new Dn( "dc=nothing,dc=empty" ) ) );
-        assertFalse( dnLookupTree.hasParent( new Dn(  "dc=directory,dc=apache,dc=root" ) ) );
+        assertFalse( dnLookupTree.hasParent( new Dn( "dc=directory,dc=apache,dc=root" ) ) );
 
         dnLookupTree.remove( dn4 );
         assertEquals( 1, dnLookupTree.size() );
         assertFalse( dnLookupTree.hasParent( new Dn( "dc=nothing,dc=empty" ) ) );
-        assertFalse( dnLookupTree.hasParent( new Dn(  "dc=directory,dc=apache,dc=root" ) ) );
+        assertFalse( dnLookupTree.hasParent( new Dn( "dc=directory,dc=apache,dc=root" ) ) );
     }
-    
-    
+
+
     //---------------------------------------------------------------------------
     // Test the hasParentElement(Dn) method
     //---------------------------------------------------------------------------
@@ -765,44 +767,45 @@ public class TestDnNode
         Dn dn4 = new Dn( "dc=acme,dc=com" );
         Dn dn5 = new Dn( "dc=acme,c=us,dc=com" );
         Dn dn6 = new Dn( "dc=empty" );
-        
+
         Dn org = new Dn( "dc=org" );
-    
+
         dnLookupTree.add( dn1, dn1 );
         dnLookupTree.add( dn2, dn2 );
         dnLookupTree.add( dn3, dn3 );
         dnLookupTree.add( dn4, dn4 );
         dnLookupTree.add( dn5 );
         dnLookupTree.add( dn6, dn6 );
-        
+
         // Inject some intermediary nodes
         dnLookupTree.add( org, org );
-        
+
         assertTrue( dnLookupTree.hasParentElement( new Dn( "dc=apache,dc=org" ) ) );
-        
+
         // Check that org has at least one descendant containing an element
         assertTrue( dnLookupTree.hasDescendantElement( org ) );
-        
+
         // check that for one node which has no children with any element, we get false
         assertFalse( dnLookupTree.hasDescendantElement( new Dn( "c=us,dc=com" ) ) );
-        
+
         // Check that we correctly get back all the children
         Dn dn7 = new Dn( "dc=elem,dc=mina,dc=apache,dc=org" );
         dnLookupTree.add( dn7, dn7 );
-        
+
         // With dc=org, we should get back dn1 and dn3
         List<Dn> dns = dnLookupTree.getDescendantElements( org );
-        
+
         assertNotNull( dns );
         assertEquals( 2, dns.size() );
         assertTrue( dns.contains( dn1 ) );
         assertTrue( dns.contains( dn2 ) );
-        
+
         // Same, with a node not having any descendants
         dns = dnLookupTree.getDescendantElements( dn6 );
         assertEquals( 0, dns.size() );
     }
 
+
     //---------------------------------------------------------------------------
     // Test the getParentElement(DN) method
     //---------------------------------------------------------------------------
@@ -816,36 +819,36 @@ public class TestDnNode
         Dn dn4 = new Dn( "dc=acme,dc=com" );
         Dn dn5 = new Dn( "dc=acme,c=us,dc=com" );
         Dn dn6 = new Dn( "dc=empty" );
-        
+
         Dn org = new Dn( "dc=org" );
-        Dn apache =  new Dn( "dc=apache,dc=org" );
-        Dn test =  new Dn( "dc=test,dc=directory,dc=apache,dc=org" );
-    
+        Dn apache = new Dn( "dc=apache,dc=org" );
+        Dn test = new Dn( "dc=test,dc=directory,dc=apache,dc=org" );
+
         dnLookupTree.add( dn1, dn1 );
         dnLookupTree.add( dn2, dn2 );
         dnLookupTree.add( dn3, dn3 );
         dnLookupTree.add( dn4, dn4 );
         dnLookupTree.add( dn5 );
         dnLookupTree.add( dn6, dn6 );
-        
+
         // Inject some intermediary nodes
         dnLookupTree.add( org, org );
-        
+
         assertTrue( dnLookupTree.hasParentElement( apache ) );
         assertEquals( org, dnLookupTree.getParentWithElement( dn1 ).getElement() );
         assertEquals( org, dnLookupTree.getParentWithElement( apache ).getElement() );
         assertEquals( dn1, dnLookupTree.getParentWithElement( test ).getElement() );
         assertNull( dnLookupTree.getParentWithElement( org ) );
     }
-    
-    
+
+
     @Test
     public void testRename() throws Exception
     {
         DnNode<Dn> rootNode = new DnNode<Dn>();
         Dn dn = new Dn( "dc=directory,dc=apache,dc=org" );
         rootNode.add( dn );
-        
+
         Rdn childRdn = new Rdn( "dc=org" );
 
         DnNode<Dn> child = rootNode.getChild( childRdn );
@@ -856,12 +859,13 @@ public class TestDnNode
         child.rename( newChildRdn );
         assertNull( rootNode.getChild( childRdn ) );
         assertEquals( new Dn( "dc=neworg" ), child.getDn() );
-        
+
         DnNode<Dn> child2 = child.getChild( new Rdn( "dc=apache" ) );
         assertEquals( new Dn( "dc=apache,dc=neworg" ), child2.getDn() );
-        
-        assertEquals( new Dn( "dc=directory,dc=apache,dc=neworg" ), child2.getChild( new Rdn( "dc=directory" ) ).getDn() );
-        
+
+        assertEquals( new Dn( "dc=directory,dc=apache,dc=neworg" ), child2.getChild( new Rdn( "dc=directory" ) )
+            .getDn() );
+
         assertNotNull( rootNode.getChild( newChildRdn ) );
     }
 
@@ -871,62 +875,66 @@ public class TestDnNode
     {
         DnNode<Dn> rootNode = new DnNode<Dn>();
         Dn dn = new Dn( "dc=vysper,dc=mina,dc=directory,dc=apache,dc=org" );
-        
+
         rootNode.add( dn );
 
         Rdn minaRdn = new Rdn( "dc=mina" );
         DnNode<Dn> apacheNode = rootNode.getChild( new Rdn( "dc=org" ) ).getChild( new Rdn( "dc=apache" ) );
-        DnNode<Dn> directoryNode = apacheNode.getChild( new Rdn( "dc=directory" ) ); 
+        DnNode<Dn> directoryNode = apacheNode.getChild( new Rdn( "dc=directory" ) );
         DnNode<Dn> minaNode = directoryNode.getChild( minaRdn );
         assertNotNull( minaNode );
         assertEquals( directoryNode, minaNode.getParent() );
         assertTrue( directoryNode.contains( minaRdn ) );
-        
+
         Dn newParent = new Dn( "dc=apache,dc=org" );
         minaNode.move( newParent );
-        
+
         minaNode = apacheNode.getChild( minaRdn );
         assertNotNull( minaNode );
         assertNull( directoryNode.getChild( minaRdn ) );
         assertNotNull( apacheNode.getChild( minaRdn ) );
         assertFalse( directoryNode.contains( minaRdn ) );
         assertTrue( apacheNode.contains( minaRdn ) );
-        
+
         assertEquals( new Dn( "dc=mina,dc=apache,dc=org" ), minaNode.getDn() );
-        assertEquals( new Dn( "dc=vysper,dc=mina,dc=apache,dc=org" ), minaNode.getChild( new Rdn( "dc=vysper" ) ).getDn());
+        assertEquals( new Dn( "dc=vysper,dc=mina,dc=apache,dc=org" ), minaNode.getChild( new Rdn( "dc=vysper" ) )
+            .getDn() );
     }
 
-    
+
     @Test
     public void testMoveToSiblingBranch() throws Exception
     {
         DnNode<Dn> rootNode = new DnNode<Dn>();
         Dn dn1 = new Dn( "dc=vysper,dc=mina,dc=directory,dc=apache,dc=org" );
-        
+
         Dn dn2 = new Dn( "dc=kayyagari,dc=apache,dc=org" );
         rootNode.add( dn1 );
         rootNode.add( dn2 );
 
         Rdn directoryRdn = new Rdn( "dc=directory" );
-        
+
         DnNode<Dn> apacheNode = rootNode.getChild( new Rdn( "dc=org" ) ).getChild( new Rdn( "dc=apache" ) );
-        DnNode<Dn> directoryNode = apacheNode.getChild( new Rdn( "dc=directory" ) ); 
+        DnNode<Dn> directoryNode = apacheNode.getChild( new Rdn( "dc=directory" ) );
         assertNotNull( directoryNode );
         assertEquals( apacheNode, directoryNode.getParent() );
         assertTrue( apacheNode.contains( directoryRdn ) );
-        
+
         directoryNode.move( dn2 );
-        
-        DnNode<Dn> newParentNode = rootNode.getChild( new Rdn( "dc=org" ) ).getChild( new Rdn( "dc=apache" ) ).getChild( new Rdn( "dc=kayyagari" ) );
+
+        DnNode<Dn> newParentNode = rootNode.getChild( new Rdn( "dc=org" ) ).getChild( new Rdn( "dc=apache" ) )
+            .getChild( new Rdn( "dc=kayyagari" ) );
         directoryNode = newParentNode.getChild( directoryRdn );
         assertNotNull( directoryNode );
         assertNull( apacheNode.getChild( directoryRdn ) );
         assertNotNull( newParentNode.getChild( directoryRdn ) );
         assertFalse( apacheNode.contains( directoryRdn ) );
         assertTrue( newParentNode.contains( directoryRdn ) );
-        
+
         assertEquals( new Dn( "dc=directory,dc=kayyagari,dc=apache,dc=org" ), directoryNode.getDn() );
-        assertEquals( new Dn( "dc=mina,dc=directory,dc=kayyagari,dc=apache,dc=org" ), directoryNode.getChild( new Rdn( "dc=mina" ) ).getDn());
-        assertEquals( new Dn( "dc=vysper,dc=mina,dc=directory,dc=kayyagari,dc=apache,dc=org" ), directoryNode.getChild( new Rdn( "dc=mina" ) ).getChild( new Rdn( "dc=vysper" ) ).getDn());
+        assertEquals( new Dn( "dc=mina,dc=directory,dc=kayyagari,dc=apache,dc=org" ),
+            directoryNode.getChild( new Rdn( "dc=mina" ) ).getDn() );
+        assertEquals( new Dn( "dc=vysper,dc=mina,dc=directory,dc=kayyagari,dc=apache,dc=org" ),
+            directoryNode.getChild( new Rdn( "dc=mina" ) ).getChild( new Rdn( "dc=vysper" ) ).getDn() );
     }
 }