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 2006/01/09 02:03:39 UTC

svn commit: r367149 [1/4] - in /directory/trunk/ldap-common/src: main/java/org/apache/ldap/common/codec/ main/java/org/apache/ldap/common/codec/add/ main/java/org/apache/ldap/common/codec/bind/ main/java/org/apache/ldap/common/codec/compare/ main/java/...

Author: elecharny
Date: Sun Jan  8 17:02:49 2006
New Revision: 367149

URL: http://svn.apache.org/viewcvs?rev=367149&view=rev
Log:
Big DN-refactoring commit. Many things has changed :
- Twix Message now transform LdapDN and attributes to avoid OIDs
and other aliases
- Renammed some class to avoid W$ case-insensitivity problem (DNParser 
is now name LdapDnParser)
- Fixed some bugs in SearchRequest (ToString())
- Added some methods in LdapDN to stick with Jdk15 LdapName

Added:
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/name/AttributeTypeAndValue.java   (with props)
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/name/DnOidContainer.java   (with props)
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/name/LdapDN.java   (contents, props changed)
      - copied, changed from r366272, directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/util/LdapDN.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/name/LdapDnParser.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/name/Rdn.java   (with props)
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/name/RdnParser.java   (with props)
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/schema/DNNormalizer.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/schema/OidNormalizer.java   (with props)
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/util/DNUtils.java   (with props)
    directory/trunk/ldap-common/src/test/java/org/apache/ldap/common/name/AttributeTypeAndValueTest.java   (with props)
    directory/trunk/ldap-common/src/test/java/org/apache/ldap/common/name/DNParserTest.java
      - copied, changed from r366272, directory/trunk/ldap-common/src/test/java/org/apache/ldap/common/codec/util/DNParserTest.java
    directory/trunk/ldap-common/src/test/java/org/apache/ldap/common/name/LdapDNTest.java   (with props)
    directory/trunk/ldap-common/src/test/java/org/apache/ldap/common/name/RdnTest.java   (with props)
Removed:
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/AttributeTypeAndValue.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/util/DNParser.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/util/LdapDN.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/util/LdapRDN.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/util/RDNParser.java
    directory/trunk/ldap-common/src/test/java/org/apache/ldap/common/codec/util/DNParserTest.java
    directory/trunk/ldap-common/src/test/java/org/apache/ldap/common/codec/util/LdapDNTest.java
    directory/trunk/ldap-common/src/test/java/org/apache/ldap/common/codec/util/LdapRDNTest.java
Modified:
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/LdapResult.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/LdapResultGrammar.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/TwixTransformer.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/add/AddRequest.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/add/AddRequestGrammar.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/bind/BindRequest.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/bind/BindRequestGrammar.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/compare/CompareRequest.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/compare/CompareRequestGrammar.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/del/DelRequest.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/del/DelRequestGrammar.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/modify/ModifyRequest.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/modify/ModifyRequestGrammar.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/modifyDn/ModifyDNRequest.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/modifyDn/ModifyDNRequestGrammar.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/FilterGrammar.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/SearchRequest.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/SearchRequestGrammar.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/SearchResultEntry.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/SearchResultEntryGrammar.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/controls/EntryChangeControlGrammar.java
    directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/name/LdapName.java
    directory/trunk/ldap-common/src/test/java/org/apache/ldap/common/codec/search/SearchRequestTest.java
    directory/trunk/ldap-common/src/test/java/org/apache/ldap/common/name/LdapNameTest.java

Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/LdapResult.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/LdapResult.java?rev=367149&r1=367148&r2=367149&view=diff
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/LdapResult.java (original)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/LdapResult.java Sun Jan  8 17:02:49 2006
@@ -21,10 +21,10 @@
 import org.apache.asn1.ber.tlv.Length;
 import org.apache.asn1.ber.tlv.Value;
 import org.apache.asn1.ber.tlv.UniversalTag;
-import org.apache.ldap.common.codec.util.LdapDN;
 import org.apache.ldap.common.codec.util.LdapResultEnum;
 import org.apache.ldap.common.codec.util.LdapString;
 import org.apache.ldap.common.codec.util.LdapURL;
+import org.apache.ldap.common.name.LdapDN;
 
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
@@ -230,7 +230,7 @@
         ldapResultLength = 1 + 1 + 1;
 
         // The matchedDN length
-        ldapResultLength += 1 + Length.getNbBytes( matchedDN.getNbBytes() ) + matchedDN.getNbBytes();
+        ldapResultLength += 1 + Length.getNbBytes( LdapDN.getNbBytes( matchedDN ) ) + LdapDN.getNbBytes( matchedDN );
 
         // The errorMessage length
         ldapResultLength += 1 + Length.getNbBytes( errorMessage.getNbBytes() ) + errorMessage.getNbBytes();
@@ -282,7 +282,7 @@
         }
 
         // The matchedDN 
-        Value.encode( buffer, matchedDN.getBytes() );
+        Value.encode( buffer, LdapDN.getBytes( matchedDN ) );
 
         // The error message
         Value.encode( buffer, errorMessage.getBytes() );

Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/LdapResultGrammar.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/LdapResultGrammar.java?rev=367149&r1=367148&r2=367149&view=diff
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/LdapResultGrammar.java (original)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/LdapResultGrammar.java Sun Jan  8 17:02:49 2006
@@ -31,12 +31,12 @@
 import org.apache.asn1.ber.IAsn1Container;
 import org.apache.asn1.util.IntegerDecoder;
 import org.apache.asn1.util.IntegerDecoderException;
-import org.apache.ldap.common.codec.util.LdapDN;
 import org.apache.ldap.common.codec.util.LdapResultEnum;
 import org.apache.ldap.common.codec.util.LdapString;
 import org.apache.ldap.common.codec.util.LdapStringEncodingException;
 import org.apache.ldap.common.codec.util.LdapURL;
 import org.apache.ldap.common.codec.util.LdapURLEncodingException;
+import org.apache.ldap.common.name.LdapDN;
 import org.apache.ldap.common.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/TwixTransformer.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/TwixTransformer.java?rev=367149&r1=367148&r2=367149&view=diff
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/TwixTransformer.java (original)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/TwixTransformer.java Sun Jan  8 17:02:49 2006
@@ -63,7 +63,6 @@
 import org.apache.ldap.common.codec.search.SearchResultReference;
 import org.apache.ldap.common.codec.search.SubstringFilter;
 import org.apache.ldap.common.codec.search.controls.PSearchControl;
-import org.apache.ldap.common.codec.util.LdapDN;
 import org.apache.ldap.common.codec.util.LdapString;
 import org.apache.ldap.common.codec.util.LdapStringEncodingException;
 import org.apache.ldap.common.codec.util.LdapURL;
@@ -107,6 +106,7 @@
 import org.apache.ldap.common.message.UnbindRequestImpl;
 import org.apache.ldap.common.message.spi.Provider;
 import org.apache.ldap.common.message.spi.TransformerSpi;
+import org.apache.ldap.common.name.LdapDN;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/add/AddRequest.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/add/AddRequest.java?rev=367149&r1=367148&r2=367149&view=diff
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/add/AddRequest.java (original)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/add/AddRequest.java Sun Jan  8 17:02:49 2006
@@ -22,8 +22,8 @@
 import org.apache.asn1.ber.tlv.UniversalTag;
 import org.apache.ldap.common.codec.LdapConstants;
 import org.apache.ldap.common.codec.LdapMessage;
-import org.apache.ldap.common.codec.util.LdapDN;
 import org.apache.ldap.common.codec.util.LdapString;
+import org.apache.ldap.common.name.LdapDN;
 import org.apache.ldap.common.util.AttributeUtils;
 import org.apache.ldap.common.util.StringTools;
 
@@ -35,6 +35,7 @@
 import java.util.LinkedList;
 import java.util.List;
 
+import javax.naming.Name;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
@@ -67,7 +68,7 @@
     //~ Instance fields ----------------------------------------------------------------------------
 
     /** The DN to be added. */
-    private LdapDN entry;
+    private Name entry;
 
     /** The attributes list. */
     private Attributes attributes;
@@ -155,7 +156,7 @@
      */
     public String getEntry()
     {
-        return ( ( entry == null ) ? "" : entry.getString() );
+        return ( ( entry == null ) ? "" : entry.toString() );
     }
 
     /**
@@ -163,7 +164,7 @@
      * 
      * @param entry The entry to set.
      */
-    public void setEntry( LdapDN entry )
+    public void setEntry( Name entry )
     {
         this.entry = entry;
     }
@@ -211,7 +212,7 @@
     public int computeLength()
     {
         // The entry
-        addRequestLength = 1 + Length.getNbBytes( entry.getNbBytes() ) + entry.getNbBytes();
+        addRequestLength = 1 + Length.getNbBytes( LdapDN.getNbBytes( entry ) ) + LdapDN.getNbBytes( entry );
         
         // The attributes sequence
         attributesLength = 0;
@@ -327,7 +328,7 @@
             buffer.put( Length.getBytes( addRequestLength ) ) ;
             
             // The entry
-            Value.encode( buffer, entry.getBytes() );
+            Value.encode( buffer, LdapDN.getBytes( entry ) );
             
             // The attributes sequence
             buffer.put( UniversalTag.SEQUENCE_TAG );

Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/add/AddRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/add/AddRequestGrammar.java?rev=367149&r1=367148&r2=367149&view=diff
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/add/AddRequestGrammar.java (original)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/add/AddRequestGrammar.java Sun Jan  8 17:02:49 2006
@@ -17,6 +17,8 @@
 package org.apache.ldap.common.codec.add;
 
 import javax.naming.InvalidNameException;
+import javax.naming.Name;
+import javax.naming.NamingException;
 
 import org.apache.asn1.codec.DecoderException;
 import org.apache.asn1.ber.grammar.IGrammar;
@@ -30,9 +32,10 @@
 import org.apache.ldap.common.codec.LdapMessage;
 import org.apache.ldap.common.codec.LdapMessageContainer;
 import org.apache.ldap.common.codec.LdapStatesEnum;
-import org.apache.ldap.common.codec.util.LdapDN;
 import org.apache.ldap.common.codec.util.LdapString;
 import org.apache.ldap.common.codec.util.LdapStringEncodingException;
+//import org.apache.ldap.common.name.LdapDN;
+import org.apache.ldap.common.name.LdapDN;
 import org.apache.ldap.common.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -132,16 +135,27 @@
                         }
                         else
                         {
+                        	Name entry = null;
+                        	
                             try
                             {
-                                addRequest.setEntry( new LdapDN(
-                                        tlv.getValue().getData() ) );
+                            	entry = new LdapDN( tlv.getValue().getData() );
+                            	entry = LdapDN.normalize( entry );
                             }
                             catch ( InvalidNameException ine )
                             {
-                                log.error( "The DN is invalid : " + StringTools.dumpBytes(tlv.getValue().getData()) + " : " + ine.getMessage() );
-                                throw new DecoderException( "Incorrect DN given : " + ine.getMessage() );
+                            	String msg = "The DN is invalid : " + StringTools.dumpBytes(tlv.getValue().getData()) + " : " + ine.getMessage(); 
+                                log.error( msg + " : " + ine.getMessage());
+                                throw new DecoderException( msg, ine );
                             }
+                            catch ( NamingException ne )
+                            {
+                            	String msg = "The DN is invalid : " + StringTools.dumpBytes(tlv.getValue().getData()) + " : " + ne.getMessage();
+                                log.error( msg + " : " + ne.getMessage() );
+                                throw new DecoderException( msg, ne );
+                            }
+
+                            addRequest.setEntry( entry );
                         }
                         
                         if ( log.isDebugEnabled() )
@@ -251,7 +265,7 @@
                         {
                             try
                             {
-                                type = new LdapString( tlv.getValue().getData() );
+                                type = LdapDN.normalizeAttribute( tlv.getValue().getData() );
                                 
                                 addRequest.addAttributeType( type );
                             }

Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/bind/BindRequest.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/bind/BindRequest.java?rev=367149&r1=367148&r2=367149&view=diff
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/bind/BindRequest.java (original)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/bind/BindRequest.java Sun Jan  8 17:02:49 2006
@@ -19,12 +19,14 @@
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 
+import javax.naming.Name;
+
 import org.apache.asn1.codec.EncoderException;
 import org.apache.asn1.ber.tlv.Length;
 import org.apache.asn1.ber.tlv.Value;
 import org.apache.ldap.common.codec.LdapConstants;
 import org.apache.ldap.common.codec.LdapMessage;
-import org.apache.ldap.common.codec.util.LdapDN;
+import org.apache.ldap.common.name.LdapDN;
 import org.apache.ldap.common.util.StringTools;
 
 
@@ -43,7 +45,7 @@
     private int version;
 
     /** The name of the user requesting a bind */
-    private LdapDN name;
+    private Name name;
 
     /** The authentication used to bind the user */
     private LdapAuthentication authentication;
@@ -128,7 +130,7 @@
      *
      * @param name The user name
      */
-    public void setName( LdapDN name )
+    public void setName( Name name )
     {
         this.name = name;
     }
@@ -187,7 +189,7 @@
         bindRequestLength = 1 + 1 + 1; // Initialized with version
 
         // The name
-        bindRequestLength += 1 + Length.getNbBytes( name.getNbBytes() ) + name.getNbBytes();
+        bindRequestLength += 1 + Length.getNbBytes( LdapDN.getNbBytes( name ) ) + LdapDN.getNbBytes( name );
 
         // The authentication
         bindRequestLength += authentication.computeLength();
@@ -237,7 +239,7 @@
         Value.encode( buffer, version );
 
         // The name
-        Value.encode( buffer, name.getBytes() );
+        Value.encode( buffer, LdapDN.getBytes( name ) );
 
         // The authentication
         authentication.encode( buffer );

Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/bind/BindRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/bind/BindRequestGrammar.java?rev=367149&r1=367148&r2=367149&view=diff
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/bind/BindRequestGrammar.java (original)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/bind/BindRequestGrammar.java Sun Jan  8 17:02:49 2006
@@ -17,6 +17,8 @@
 package org.apache.ldap.common.codec.bind;
 
 import javax.naming.InvalidNameException;
+import javax.naming.Name;
+import javax.naming.NamingException;
 
 import org.apache.asn1.codec.DecoderException;
 import org.apache.asn1.ber.grammar.IGrammar;
@@ -33,9 +35,9 @@
 import org.apache.ldap.common.codec.LdapMessage;
 import org.apache.ldap.common.codec.LdapMessageContainer;
 import org.apache.ldap.common.codec.LdapStatesEnum;
-import org.apache.ldap.common.codec.util.LdapDN;
 import org.apache.ldap.common.codec.util.LdapString;
 import org.apache.ldap.common.codec.util.LdapStringEncodingException;
+import org.apache.ldap.common.name.LdapDN;
 import org.apache.ldap.common.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -202,15 +204,27 @@
                         }
                         else
                         {
-                            try
+                        	Name name = LdapDN.EMPTY_LDAPDN;
+                        	
+                        	try
                             {
-                                bindRequestMessage.setName( new LdapDN( tlv.getValue().getData() ) );
+                                name = new LdapDN( tlv.getValue().getData() );
+                                name = LdapDN.normalize( name );
                             }
                             catch ( InvalidNameException ine )
                             {
-                                log.error( "Incorrect DN given : " + StringTools.dumpBytes( tlv.getValue().getData() ) + " : " + ine.getMessage() );
-                                throw new DecoderException( "Incorrect DN given : " + ine.getMessage() );
+                            	String msg = "Incorrect DN given : " + StringTools.dumpBytes( tlv.getValue().getData() ) + " : " + ine.getMessage(); 
+                                log.error( msg + " : " + ine.getMessage());
+                                throw new DecoderException( msg, ine );
                             }
+                            catch ( NamingException ne )
+                            {
+                            	String msg = "Incorrect DN given : " + StringTools.dumpBytes( tlv.getValue().getData() ) + " : " + ne.getMessage();
+                                log.error( msg + " : " + ne.getMessage() );
+                                throw new DecoderException( msg, ne );
+                            }
+
+                            bindRequestMessage.setName( name );
                         }
                         
                         if ( log.isDebugEnabled() )

Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/compare/CompareRequest.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/compare/CompareRequest.java?rev=367149&r1=367148&r2=367149&view=diff
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/compare/CompareRequest.java (original)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/compare/CompareRequest.java Sun Jan  8 17:02:49 2006
@@ -19,14 +19,16 @@
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 
+import javax.naming.Name;
+
 import org.apache.asn1.codec.EncoderException;
 import org.apache.asn1.ber.tlv.Length;
 import org.apache.asn1.ber.tlv.UniversalTag;
 import org.apache.asn1.ber.tlv.Value;
 import org.apache.ldap.common.codec.LdapConstants;
 import org.apache.ldap.common.codec.LdapMessage;
-import org.apache.ldap.common.codec.util.LdapDN;
 import org.apache.ldap.common.codec.util.LdapString;
+import org.apache.ldap.common.name.LdapDN;
 import org.apache.ldap.common.util.StringTools;
 
 
@@ -51,7 +53,7 @@
     //~ Instance fields ----------------------------------------------------------------------------
 
     /** The entry to be compared */
-    private LdapDN entry;
+    private Name entry;
 
     /** The attribute to be compared */
     private LdapString attributeDesc;
@@ -94,7 +96,7 @@
      */
     public String getEntry()
     {
-        return ( ( entry == null ) ? "" : entry.getString() );
+        return ( ( entry == null ) ? "" : entry.toString() );
     }
 
     /**
@@ -102,7 +104,7 @@
      *
      * @param entry The entry to set.
      */
-    public void setEntry( LdapDN entry )
+    public void setEntry( Name entry )
     {
         this.entry = entry;
     }
@@ -172,7 +174,7 @@
     {
 
         // The entry
-        compareRequestLength = 1 + Length.getNbBytes( entry.getNbBytes() ) + entry.getNbBytes();
+        compareRequestLength = 1 + Length.getNbBytes( LdapDN.getNbBytes( entry ) ) + LdapDN.getNbBytes( entry );
 
         // The attribute value assertion
         avaLength =
@@ -223,7 +225,7 @@
             buffer.put( Length.getBytes( compareRequestLength ) ) ;
 
             // The entry
-            Value.encode( buffer, entry.getBytes() );
+            Value.encode( buffer, LdapDN.getBytes( entry ) );
 
             // The attributeValueAssertion sequence Tag
             buffer.put( UniversalTag.SEQUENCE_TAG );

Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/compare/CompareRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/compare/CompareRequestGrammar.java?rev=367149&r1=367148&r2=367149&view=diff
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/compare/CompareRequestGrammar.java (original)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/compare/CompareRequestGrammar.java Sun Jan  8 17:02:49 2006
@@ -17,6 +17,8 @@
 package org.apache.ldap.common.codec.compare;
 
 import javax.naming.InvalidNameException;
+import javax.naming.Name;
+import javax.naming.NamingException;
 
 import org.apache.asn1.codec.DecoderException;
 import org.apache.asn1.ber.grammar.IGrammar;
@@ -30,9 +32,10 @@
 import org.apache.ldap.common.codec.LdapMessage;
 import org.apache.ldap.common.codec.LdapMessageContainer;
 import org.apache.ldap.common.codec.LdapStatesEnum;
-import org.apache.ldap.common.codec.util.LdapDN;
 import org.apache.ldap.common.codec.util.LdapString;
 import org.apache.ldap.common.codec.util.LdapStringEncodingException;
+//import org.apache.ldap.common.name.LdapDN;
+import org.apache.ldap.common.name.LdapDN;
 import org.apache.ldap.common.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -126,7 +129,7 @@
 
                         // Get the Value and store it in the CompareRequest
                         TLV tlv = ldapMessageContainer.getCurrentTLV();
-                        LdapDN entry = null;
+                        Name entry = null;
 
                         // We have to handle the special case of a 0 length matched DN
                         if ( tlv.getLength().getLength() == 0 )
@@ -138,13 +141,22 @@
                             try
                             {
                                 entry = new LdapDN( tlv.getValue().getData() );
-                                compareRequest.setEntry( entry );
+                                entry = LdapDN.normalize( entry );
                             }
                             catch ( InvalidNameException ine )
                             {
-                                log.error( "The DN to compare  (" + StringTools.dumpBytes( tlv.getValue().getData() ) + ") is invalid" );
-                                throw new DecoderException( "Invalid DN " + StringTools.dumpBytes( tlv.getValue().getData() ) + ", : " + ine.getMessage() );
+                            	String msg = "The DN to compare  (" + StringTools.dumpBytes( tlv.getValue().getData() ) + ") is invalid"; 
+                                log.error( msg + " : " + ine.getMessage());
+                                throw new DecoderException( msg, ine );
                             }
+                            catch ( NamingException ne )
+                            {
+                            	String msg = "The DN to compare  (" + StringTools.dumpBytes( tlv.getValue().getData() ) + ") is invalid";
+                                log.error( msg + " : " + ne.getMessage() );
+                                throw new DecoderException( msg, ne );
+                            }
+
+                            compareRequest.setEntry( entry );
                         }
 
                         if ( log.isDebugEnabled() )
@@ -211,7 +223,8 @@
                         {
                             try
                             {
-                                compareRequest.setAttributeDesc( new LdapString( tlv.getValue().getData() ) );
+                            	LdapString type = LdapDN.normalizeAttribute( tlv.getValue().getData() );
+                                compareRequest.setAttributeDesc( type );
                             }
                             catch ( LdapStringEncodingException lsee )
                             {

Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/del/DelRequest.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/del/DelRequest.java?rev=367149&r1=367148&r2=367149&view=diff
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/del/DelRequest.java (original)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/del/DelRequest.java Sun Jan  8 17:02:49 2006
@@ -19,11 +19,13 @@
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 
+import javax.naming.Name;
+
 import org.apache.asn1.codec.EncoderException;
 import org.apache.asn1.ber.tlv.Length;
 import org.apache.ldap.common.codec.LdapConstants;
 import org.apache.ldap.common.codec.LdapMessage;
-import org.apache.ldap.common.codec.util.LdapDN;
+import org.apache.ldap.common.name.LdapDN;
 
 
 /**
@@ -37,7 +39,7 @@
     //~ Instance fields ----------------------------------------------------------------------------
 
     /** The entry to be deleted */
-    private LdapDN entry;
+    private Name entry;
 
     //~ Constructors -------------------------------------------------------------------------------
 
@@ -68,7 +70,7 @@
      */
     public String getEntry()
     {
-        return ( ( entry == null ) ? "" : entry.getString() );
+        return ( ( entry == null ) ? "" : entry.toString() );
     }
 
     /**
@@ -76,7 +78,7 @@
      *
      * @param entry The entry to set.
      */
-    public void setEntry( LdapDN entry )
+    public void setEntry( Name entry )
     {
         this.entry = entry;
     }
@@ -95,7 +97,7 @@
     public int computeLength()
     {
         // The entry
-        return 1 + Length.getNbBytes( entry.getNbBytes() ) + entry.getNbBytes();
+        return 1 + Length.getNbBytes( LdapDN.getNbBytes( entry ) ) + LdapDN.getNbBytes( entry );
     }
 
     /**
@@ -121,8 +123,8 @@
             buffer.put( LdapConstants.DEL_REQUEST_TAG );
 
             // The entry
-            buffer.put( Length.getBytes( entry.getNbBytes() ) );
-            buffer.put( entry.getBytes() );
+            buffer.put( Length.getBytes( LdapDN.getNbBytes( entry ) ) );
+            buffer.put( LdapDN.getBytes( entry ) );
         }
         catch ( BufferOverflowException boe )
         {

Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/del/DelRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/del/DelRequestGrammar.java?rev=367149&r1=367148&r2=367149&view=diff
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/del/DelRequestGrammar.java (original)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/del/DelRequestGrammar.java Sun Jan  8 17:02:49 2006
@@ -17,6 +17,8 @@
 package org.apache.ldap.common.codec.del;
 
 import javax.naming.InvalidNameException;
+import javax.naming.Name;
+import javax.naming.NamingException;
 
 import org.apache.asn1.codec.DecoderException;
 import org.apache.asn1.ber.grammar.AbstractGrammar;
@@ -29,7 +31,8 @@
 import org.apache.ldap.common.codec.LdapMessage;
 import org.apache.ldap.common.codec.LdapMessageContainer;
 import org.apache.ldap.common.codec.LdapStatesEnum;
-import org.apache.ldap.common.codec.util.LdapDN;
+//import org.apache.ldap.common.name.LdapDN;
+import org.apache.ldap.common.name.LdapDN;
 import org.apache.ldap.common.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -97,7 +100,7 @@
                         TLV tlv = ldapMessageContainer.getCurrentTLV();
 
                         // We have to handle the special case of a 0 length matched DN
-                        LdapDN entry = null;
+                        Name entry = null;
                         
                         if ( tlv.getLength().getLength() == 0 )
                         {
@@ -107,14 +110,23 @@
                         {
                             try
                             {
-                                entry = new LdapDN( tlv.getValue().getData() );
-                                delRequest.setEntry( entry );
+                            	entry = new LdapDN( tlv.getValue().getData() );
+                            	entry = LdapDN.normalize( entry );
                             }
                             catch ( InvalidNameException ine )
                             {
-                                log.error( "The DN to delete  (" + StringTools.dumpBytes( tlv.getValue().getData() ) + ") is invalid" );
-                                throw new DecoderException( "Invalid DN " + StringTools.dumpBytes( tlv.getValue().getData() ) + ", : " + ine.getMessage() );
+                            	String msg = "The DN to delete  (" + StringTools.dumpBytes( tlv.getValue().getData() ) + ") is invalid"; 
+                                log.error( msg + " : " + ine.getMessage());
+                                throw new DecoderException( msg, ine );
                             }
+                            catch ( NamingException ne )
+                            {
+                            	String msg = "The DN to delete  (" + StringTools.dumpBytes( tlv.getValue().getData() ) + ") is invalid";
+                                log.error( msg + " : " + ne.getMessage() );
+                                throw new DecoderException( msg, ne );
+                            }
+
+                            delRequest.setEntry( entry );
                         }
 
                         // then we associate it to the ldapMessage Object

Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/modify/ModifyRequest.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/modify/ModifyRequest.java?rev=367149&r1=367148&r2=367149&view=diff
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/modify/ModifyRequest.java (original)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/modify/ModifyRequest.java Sun Jan  8 17:02:49 2006
@@ -22,8 +22,8 @@
 import org.apache.asn1.ber.tlv.Value;
 import org.apache.ldap.common.codec.LdapConstants;
 import org.apache.ldap.common.codec.LdapMessage;
-import org.apache.ldap.common.codec.util.LdapDN;
 import org.apache.ldap.common.codec.util.LdapString;
+import org.apache.ldap.common.name.LdapDN;
 import org.apache.ldap.common.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -35,6 +35,7 @@
 import java.util.LinkedList;
 import java.util.List;
 
+import javax.naming.Name;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
@@ -72,7 +73,7 @@
     //~ Instance fields ----------------------------------------------------------------------------
 
     /** The DN to be modified. */
-    private LdapDN object;
+    private Name object;
 
     /** The modifications list. This is an array of ModificationItem. */
     private ArrayList modifications;
@@ -209,7 +210,7 @@
      */
     public String getObject()
     {
-        return ( ( object == null ) ? "" : object.getString() );
+        return ( ( object == null ) ? "" : object.toString() );
     }
 
     /**
@@ -217,7 +218,7 @@
      * 
      * @param object The DN to set.
      */
-    public void setObject( LdapDN object )
+    public void setObject( Name object )
     {
         this.object = object;
     }
@@ -287,7 +288,7 @@
     public int computeLength()
     {
         // Initialized with object
-        modifyRequestLength = 1 + Length.getNbBytes( object.getNbBytes() ) + object.getNbBytes();
+        modifyRequestLength = 1 + Length.getNbBytes( LdapDN.getNbBytes( object ) ) + LdapDN.getNbBytes( object );
         
         // Modifications
         modificationsLength = 0;
@@ -404,7 +405,7 @@
             buffer.put( Length.getBytes( modifyRequestLength ) ) ;
             
             // The entry
-            Value.encode( buffer, object.getBytes() );
+            Value.encode( buffer, LdapDN.getBytes( object ) );
             
             // The modifications sequence
             buffer.put( UniversalTag.SEQUENCE_TAG );

Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/modify/ModifyRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/modify/ModifyRequestGrammar.java?rev=367149&r1=367148&r2=367149&view=diff
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/modify/ModifyRequestGrammar.java (original)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/modify/ModifyRequestGrammar.java Sun Jan  8 17:02:49 2006
@@ -17,6 +17,8 @@
 package org.apache.ldap.common.codec.modify;
 
 import javax.naming.InvalidNameException;
+import javax.naming.Name;
+import javax.naming.NamingException;
 
 import org.apache.asn1.codec.DecoderException;
 import org.apache.asn1.ber.grammar.IGrammar;
@@ -32,9 +34,9 @@
 import org.apache.ldap.common.codec.LdapMessage;
 import org.apache.ldap.common.codec.LdapMessageContainer;
 import org.apache.ldap.common.codec.LdapStatesEnum;
-import org.apache.ldap.common.codec.util.LdapDN;
 import org.apache.ldap.common.codec.util.LdapString;
 import org.apache.ldap.common.codec.util.LdapStringEncodingException;
+import org.apache.ldap.common.name.LdapDN;
 import org.apache.ldap.common.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -130,24 +132,36 @@
 
                         TLV                  tlv                  =
                             ldapMessageContainer.getCurrentTLV();
+                        
+                        Name object = LdapDN.EMPTY_LDAPDN;
 
                         // Store the value.
                         if ( tlv.getLength().getLength() == 0 )
                         {
-                            modifyRequest.setObject( LdapDN.EMPTY_LDAPDN );
+                            modifyRequest.setObject( object );
                         }
                         else
                         {
+                        	
                             try
                             {
-                                modifyRequest.setObject( new LdapDN(
-                                        tlv.getValue().getData() ) );
+                                object = new LdapDN( tlv.getValue().getData() );
+                                object = LdapDN.normalize( object );
                             }
                             catch ( InvalidNameException ine )
                             {
-                                log.error( "Invalid DN " + StringTools.dumpBytes( tlv.getValue().getData() ) + ", : " + ine.getMessage() );
-                                throw new DecoderException( "Invalid object DN : " + ine.getMessage() );
+                            	String msg = "Invalid DN " + StringTools.dumpBytes( tlv.getValue().getData() ) + ", : " + ine.getMessage(); 
+                                log.error( msg + " : " + ine.getMessage());
+                                throw new DecoderException( msg, ine );
+                            }
+                            catch ( NamingException ne )
+                            {
+                            	String msg = "Invalid DN " + StringTools.dumpBytes( tlv.getValue().getData() ) + ", : " + ne.getMessage();
+                                log.error( msg + " : " + ne.getMessage() );
+                                throw new DecoderException( msg, ne );
                             }
+
+                            modifyRequest.setObject( object );
                         }
                         
                         if ( log.isDebugEnabled() )
@@ -361,7 +375,7 @@
                         {
                             try
                             {
-                                type = new LdapString( tlv.getValue().getData() );
+                                type = LdapDN.normalizeAttribute(tlv.getValue().getData() );
                                 modifyRequest.addAttributeTypeAndValues( type );
                             }
                             catch ( LdapStringEncodingException lsee )

Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/modifyDn/ModifyDNRequest.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/modifyDn/ModifyDNRequest.java?rev=367149&r1=367148&r2=367149&view=diff
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/modifyDn/ModifyDNRequest.java (original)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/modifyDn/ModifyDNRequest.java Sun Jan  8 17:02:49 2006
@@ -19,13 +19,16 @@
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 
+import javax.naming.Name;
+
 import org.apache.asn1.codec.EncoderException;
 import org.apache.asn1.ber.tlv.Length;
 import org.apache.asn1.ber.tlv.Value;
 import org.apache.ldap.common.codec.LdapConstants;
 import org.apache.ldap.common.codec.LdapMessage;
-import org.apache.ldap.common.codec.util.LdapDN;
-import org.apache.ldap.common.codec.util.LdapRDN;
+import org.apache.ldap.common.name.Rdn;
+import org.apache.ldap.common.name.LdapDN;
+import org.apache.ldap.common.util.StringTools;
 
 
 /**
@@ -43,16 +46,16 @@
     //~ Instance fields ----------------------------------------------------------------------------
 
     /** The DN to be modified. */
-    private LdapDN entry;
+    private Name entry;
 
     /** The new RDN to be added to the RDN or to the new superior, if present */
-    private LdapRDN newRDN;
+    private Rdn newRDN;
 
     /** If the previous RDN is to be deleted, this flag will be set to true */
     private boolean deleteOldRDN;
 
     /** The optional superior, which will be concatened to the newRdn */
-    private LdapDN newSuperior;
+    private Name newSuperior;
 
     /** The modify DN request length */
     private transient int modifyDNRequestLength;
@@ -85,14 +88,14 @@
      */
     public String getEntry()
     {
-        return ( ( entry == null ) ? "" : entry.getString() );
+        return ( ( entry == null ) ? "" : entry.toString() );
     }
 
     /**
      * Set the modification DN.
      * @param entry The entry to set.
      */
-    public void setEntry( LdapDN entry )
+    public void setEntry( Name entry )
     {
         this.entry = entry;
     }
@@ -124,7 +127,7 @@
      */
     public String getNewRDN()
     {
-        return ( ( newRDN == null ) ? "" : newRDN.getString() );
+        return ( ( newRDN == null ) ? "" : newRDN.toString() );
     }
 
     /**
@@ -132,7 +135,7 @@
      *
      * @param newRDN The newRDN to set.
      */
-    public void setNewRDN( LdapRDN newRDN )
+    public void setNewRDN( Rdn newRDN )
     {
         this.newRDN = newRDN;
     }
@@ -144,7 +147,7 @@
      */
     public String getNewSuperior()
     {
-        return ( ( newSuperior == null ) ? "" : newSuperior.getString() );
+        return ( ( newSuperior == null ) ? "" : newSuperior.toString() );
     }
 
     /**
@@ -152,7 +155,7 @@
      *
      * @param newSuperior The newSuperior to set.
      */
-    public void setNewSuperior( LdapDN newSuperior )
+    public void setNewSuperior( Name newSuperior )
     {
         this.newSuperior = newSuperior;
     }
@@ -179,16 +182,16 @@
     */
     public int computeLength()
     {
-
+    	int newRdnlength = StringTools.getBytesUtf8( newRDN.toString() ).length;
         modifyDNRequestLength =
-            1 + Length.getNbBytes( entry.getNbBytes() ) + entry.getNbBytes() +
-            1 + Length.getNbBytes( newRDN.getNbBytes() ) + newRDN.getNbBytes() +
+            1 + Length.getNbBytes( LdapDN.getNbBytes( entry ) ) + LdapDN.getNbBytes( entry ) +
+            1 + Length.getNbBytes( newRdnlength ) + newRdnlength +
             1 + 1 + 1; // deleteOldRDN
 
         if ( newSuperior != null )
         {
-            modifyDNRequestLength += 1 + Length.getNbBytes( newSuperior.getNbBytes() ) +
-                newSuperior.getNbBytes();
+            modifyDNRequestLength += 1 + Length.getNbBytes( LdapDN.getNbBytes( newSuperior ) ) +
+            	LdapDN.getNbBytes( newSuperior );
         }
 
         return 1 + Length.getNbBytes( modifyDNRequestLength ) + modifyDNRequestLength;
@@ -222,10 +225,11 @@
             buffer.put( Length.getBytes( modifyDNRequestLength ) ) ;
 
             // The entry
-            Value.encode( buffer, entry.getBytes() );
+            
+            Value.encode( buffer, LdapDN.getBytes( entry ) );
 
             // The newRDN
-            Value.encode( buffer, newRDN.getBytes() );
+            Value.encode( buffer, newRDN.toString() );
 
             // The flag deleteOldRdn
             Value.encode( buffer, deleteOldRDN );
@@ -235,11 +239,14 @@
             {
                 // Encode the reference
                 buffer.put( (byte) LdapConstants.MODIFY_DN_REQUEST_NEW_SUPERIOR_TAG );
-                buffer.put( Length.getBytes( newSuperior.getNbBytes() ) );
+                
+                int newSuperiorLength = LdapDN.getNbBytes( newSuperior ); 
+                
+                buffer.put( Length.getBytes( newSuperiorLength ) );
 
-                if ( newSuperior.getNbBytes() != 0 )
+                if ( newSuperiorLength != 0 )
                 {
-                    buffer.put( newSuperior.getBytes() );
+                    buffer.put( LdapDN.getBytes( newSuperior ) );
                 }
             }
         }

Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/modifyDn/ModifyDNRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/modifyDn/ModifyDNRequestGrammar.java?rev=367149&r1=367148&r2=367149&view=diff
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/modifyDn/ModifyDNRequestGrammar.java (original)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/modifyDn/ModifyDNRequestGrammar.java Sun Jan  8 17:02:49 2006
@@ -17,6 +17,8 @@
 package org.apache.ldap.common.codec.modifyDn;
 
 import javax.naming.InvalidNameException;
+import javax.naming.Name;
+import javax.naming.NamingException;
 
 import org.apache.asn1.codec.DecoderException;
 import org.apache.asn1.ber.grammar.IGrammar;
@@ -33,8 +35,8 @@
 import org.apache.ldap.common.codec.LdapMessage;
 import org.apache.ldap.common.codec.LdapMessageContainer;
 import org.apache.ldap.common.codec.LdapStatesEnum;
-import org.apache.ldap.common.codec.util.LdapDN;
-import org.apache.ldap.common.codec.util.LdapRDN;
+import org.apache.ldap.common.name.LdapDN;
+import org.apache.ldap.common.name.Rdn;
 import org.apache.ldap.common.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -134,7 +136,7 @@
                         TLV tlv = ldapMessageContainer.getCurrentTLV();
 
                         // We have to handle the special case of a 0 length matched DN
-                        LdapDN entry = null;
+                        Name entry = null;
 
                         if ( tlv.getLength().getLength() == 0 )
                         {
@@ -144,14 +146,23 @@
                         {
                             try
                             {
-                                entry = new LdapDN( tlv.getValue().getData() );
-                                modifyDNRequest.setEntry( entry );
+                            	entry = new LdapDN( tlv.getValue().getData() );
+                            	entry = LdapDN.normalize( entry );
                             }
                             catch ( InvalidNameException ine )
                             {
-                                log.error( "The DN to modify  (" + StringTools.dumpBytes( tlv.getValue().getData() ) + ") is invalid" );
-                                throw new DecoderException( "Invalid DN " + StringTools.dumpBytes( tlv.getValue().getData() ) + ", : " + ine.getMessage() );
+                            	String msg = "The DN to modify  (" + StringTools.dumpBytes( tlv.getValue().getData() ) + ") is invalid"; 
+                                log.error( msg + " : " + ine.getMessage());
+                                throw new DecoderException( msg, ine );
                             }
+                            catch ( NamingException ne )
+                            {
+                            	String msg = "The DN to modify  (" + StringTools.dumpBytes( tlv.getValue().getData() ) + ") is invalid";
+                                log.error( msg + " : " + ne.getMessage() );
+                                throw new DecoderException( msg, ne );
+                            }
+
+                            modifyDNRequest.setEntry( entry );
                         }
 
                         if ( log.isDebugEnabled() )
@@ -199,7 +210,7 @@
                         TLV tlv = ldapMessageContainer.getCurrentTLV();
 
                         // We have to handle the special case of a 0 length matched newDN
-                        LdapRDN newRdn = null;
+                        Rdn newRdn = null;
                         
                         if ( tlv.getLength().getLength() == 0 )
                         {
@@ -209,14 +220,24 @@
                         {
                             try
                             {
-                                newRdn = new LdapRDN( tlv.getValue().getData() );
-                                modifyDNRequest.setNewRDN( newRdn );
+                            	Name dn = new LdapDN( tlv.getValue().getData() );
+                            	dn = LdapDN.normalize( dn );
+                            	newRdn = ((LdapDN)dn).getRdn( 0 );
                             }
                             catch ( InvalidNameException ine )
                             {
-                                log.error( "The new RDN (" + StringTools.dumpBytes( tlv.getValue().getData() ) + ") is invalid" );
-                                throw new DecoderException( "Invalid RDN " + StringTools.dumpBytes( tlv.getValue().getData() ) + ", : " + ine.getMessage() );
+                            	String msg = "The new RDN (" + StringTools.dumpBytes( tlv.getValue().getData() ) + ") is invalid"; 
+                                log.error( msg + " : " + ine.getMessage());
+                                throw new DecoderException( msg, ine );
+                            }
+                            catch ( NamingException ne )
+                            {
+                            	String msg = "The new RDN (" + StringTools.dumpBytes( tlv.getValue().getData() ) + ") is invalid";
+                                log.error( msg + " : " + ne.getMessage() );
+                                throw new DecoderException( msg, ne );
                             }
+
+                            modifyDNRequest.setNewRDN( newRdn );
                         }
 
                         if ( log.isDebugEnabled() )
@@ -326,7 +347,7 @@
                         TLV tlv = ldapMessageContainer.getCurrentTLV();
 
                         // We have to handle the special case of a 0 length matched DN
-                        LdapDN newSuperior = LdapDN.EMPTY_LDAPDN;
+                        Name newSuperior = LdapDN.EMPTY_LDAPDN;
 
                         if ( tlv.getLength().getLength() == 0 )
                         {
@@ -348,14 +369,23 @@
                         {
                             try
                             {
-                                newSuperior = new LdapDN( tlv.getValue().getData() );
-                                modifyDNRequest.setNewSuperior( newSuperior );
+                            	newSuperior = new LdapDN( tlv.getValue().getData() );
+                            	newSuperior = LdapDN.normalize( newSuperior );
                             }
                             catch ( InvalidNameException ine )
                             {
-                                log.error( "The new superior DN (" + StringTools.dumpBytes( tlv.getValue().getData() ) + ") is invalid" );
-                                throw new DecoderException( "Invalid DN " + StringTools.dumpBytes( tlv.getValue().getData() ) + ", : " + ine.getMessage() );
+                            	String msg = "The new superior DN (" + StringTools.dumpBytes( tlv.getValue().getData() ) + ") is invalid"; 
+                                log.error( msg + " : " + ine.getMessage());
+                                throw new DecoderException( msg, ine );
+                            }
+                            catch ( NamingException ne )
+                            {
+                            	String msg = "The new superior DN (" + StringTools.dumpBytes( tlv.getValue().getData() ) + ") is invalid";
+                                log.error( msg + " : " + ne.getMessage() );
+                                throw new DecoderException( msg, ne );
                             }
+
+                            modifyDNRequest.setNewSuperior( newSuperior );
                         }
 
                         if ( log.isDebugEnabled() )

Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/FilterGrammar.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/FilterGrammar.java?rev=367149&r1=367148&r2=367149&view=diff
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/FilterGrammar.java (original)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/FilterGrammar.java Sun Jan  8 17:02:49 2006
@@ -34,6 +34,7 @@
 import org.apache.ldap.common.codec.LdapStatesEnum;
 import org.apache.ldap.common.codec.util.LdapString;
 import org.apache.ldap.common.codec.util.LdapStringEncodingException;
+import org.apache.ldap.common.name.LdapDN;
 import org.apache.ldap.common.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -433,7 +434,8 @@
                         
                         try
                         {
-                            assertion.setAttributeDesc( new LdapString( tlv.getValue().getData() ) );
+                        	LdapString type = LdapDN.normalizeAttribute( tlv.getValue().getData() );
+                            assertion.setAttributeDesc( type );
                         }
                         catch ( LdapStringEncodingException lsee )
                         {
@@ -523,7 +525,8 @@
                         
                         try
                         {
-                            assertion.setAttributeDesc( new LdapString( tlv.getValue().getData() ) );
+                        	LdapString type = LdapDN.normalizeAttribute( tlv.getValue().getData() );
+                            assertion.setAttributeDesc( type );
                         }
                         catch ( LdapStringEncodingException lsee )
                         {
@@ -585,7 +588,8 @@
                         // Store the value.
                         try
                         {
-                            presentFilter.setAttributeDescription( new LdapString( tlv.getValue().getData() ) );
+                        	LdapString type = LdapDN.normalizeAttribute( tlv.getValue().getData() );
+                            presentFilter.setAttributeDescription( type );
                         }
                         catch ( LdapStringEncodingException lsee )
                         {
@@ -684,7 +688,8 @@
                         
                         try
                         {
-                            substringFilter.setType(new LdapString(tlv.getValue().getData()));
+                        	LdapString type = LdapDN.normalizeAttribute( tlv.getValue().getData() );
+                            substringFilter.setType( type );
                         }
                         catch ( LdapStringEncodingException lsee )
                         {
@@ -1158,7 +1163,8 @@
                         
                         try
                         {
-                            extensibleMatchFilter.setType(new LdapString(tlv.getValue().getData()));
+                        	LdapString type = LdapDN.normalizeAttribute( tlv.getValue().getData() );
+                            extensibleMatchFilter.setType( type );
                         }
                         catch ( LdapStringEncodingException lsee )
                         {

Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/SearchRequest.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/SearchRequest.java?rev=367149&r1=367148&r2=367149&view=diff
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/SearchRequest.java (original)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/SearchRequest.java Sun Jan  8 17:02:49 2006
@@ -22,14 +22,15 @@
 import org.apache.asn1.ber.tlv.UniversalTag;
 import org.apache.ldap.common.codec.LdapConstants;
 import org.apache.ldap.common.codec.LdapMessage;
-import org.apache.ldap.common.codec.util.LdapDN;
 import org.apache.ldap.common.codec.util.LdapString;
+import org.apache.ldap.common.name.LdapDN;
 import org.apache.ldap.common.util.StringTools;
 
 import java.io.UnsupportedEncodingException;
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 
+import javax.naming.Name;
 import javax.naming.NamingEnumeration;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
@@ -48,7 +49,7 @@
     //~ Instance fields ----------------------------------------------------------------------------
 
     /** The base DN */
-    private LdapDN baseObject;
+    private Name baseObject;
 
     /** The scope. It could be baseObject, singleLevel or wholeSubtree. */
     private int scope;
@@ -144,7 +145,7 @@
      */
     public String getBaseObject()
     {
-        return ( ( baseObject == null ) ? null : baseObject.getString() );
+        return ( ( baseObject == null ) ? null : baseObject.toString() );
     }
 
     /**
@@ -152,7 +153,7 @@
      *
      * @param baseObject The baseObject to set.
      */
-    public void setBaseObject( LdapDN baseObject )
+    public void setBaseObject( Name baseObject )
     {
         this.baseObject = baseObject;
     }
@@ -326,7 +327,7 @@
         searchRequestLength = 0;
         
         // The baseObject
-        searchRequestLength += 1 + Length.getNbBytes( baseObject.getNbBytes() ) + baseObject.getNbBytes();
+        searchRequestLength += 1 + Length.getNbBytes( LdapDN.getNbBytes( baseObject ) ) + LdapDN.getNbBytes( baseObject );
         
         // The scope
         searchRequestLength += 1 + 1 + 1;
@@ -418,7 +419,7 @@
             buffer.put( Length.getBytes( searchRequestLength ) ) ;
             
             // The baseObject
-            Value.encode( buffer, baseObject.getBytes() );
+            Value.encode( buffer, LdapDN.getBytes( baseObject ) );
             
             // The scope
             Value.encodeEnumerated( buffer, scope );
@@ -486,6 +487,35 @@
     }
     
     /**
+     * @return A string that represent the atributes list
+     */
+    private String buildAttributes()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        NamingEnumeration attrs = attributes.getAll();
+        boolean isFirst = true;
+        
+        while ( attrs.hasMoreElements() )
+        {
+        	Attribute attr = (BasicAttribute)attrs.nextElement();
+        	
+        	if ( isFirst )
+        	{
+        		isFirst = false;
+        	}
+        	else
+        	{
+        		sb.append( ", " );
+        	}
+        	
+        	sb.append( attr.getID() );
+        }
+        
+        return sb.toString();
+    }
+    
+    /**
      * Return a string the represent a SearchRequest
      */
     public String toString()
@@ -565,6 +595,10 @@
         sb.append( "        Types Only : " ).append( typesOnly ).append( "\n" );
         sb.append( "        Filter : '" ).append( buildFilter() ).append( "'\n" );
         
+        if ( ( attributes != null ) && ( attributes.size() != 0 ) )
+        {
+        	sb.append( "        Attributes : " ).append( buildAttributes() ).append( "\n" );
+        }
         return sb.toString();
     }
 }

Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/SearchRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/SearchRequestGrammar.java?rev=367149&r1=367148&r2=367149&view=diff
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/SearchRequestGrammar.java (original)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/SearchRequestGrammar.java Sun Jan  8 17:02:49 2006
@@ -17,6 +17,8 @@
 package org.apache.ldap.common.codec.search;
 
 import javax.naming.InvalidNameException;
+import javax.naming.Name;
+import javax.naming.NamingException;
 
 import org.apache.asn1.codec.DecoderException;
 import org.apache.asn1.ber.grammar.IGrammar;
@@ -35,9 +37,9 @@
 import org.apache.ldap.common.codec.LdapMessage;
 import org.apache.ldap.common.codec.LdapMessageContainer;
 import org.apache.ldap.common.codec.LdapStatesEnum;
-import org.apache.ldap.common.codec.util.LdapDN;
 import org.apache.ldap.common.codec.util.LdapString;
 import org.apache.ldap.common.codec.util.LdapStringEncodingException;
+import org.apache.ldap.common.name.LdapDN;
 import org.apache.ldap.common.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -134,7 +136,7 @@
                         TLV                  tlv = ldapMessageContainer.getCurrentTLV();
 
                         // We have to check that this is a correct DN
-                        LdapDN baseObject = LdapDN.EMPTY_LDAPDN;
+                        Name baseObject = LdapDN.EMPTY_LDAPDN;
                         
                         // We have to handle the special case of a 0 length base object,
                         // which means that the search is done from the default root.
@@ -143,11 +145,19 @@
                             try
                             {
                                 baseObject = new LdapDN( tlv.getValue().getData() );
+                                baseObject = LdapDN.normalize( baseObject );
                             }
                             catch ( InvalidNameException ine )
                             {
-                                log.error( "The root DN " + baseObject.toString() + " is invalid" );
-                                throw new DecoderException( "The root DN " + baseObject.toString() + " is invalid" );
+                            	String msg = "The root DN " + baseObject.toString() + " is invalid"; 
+                                log.error( msg + " : " + ine.getMessage());
+                                throw new DecoderException( msg, ine );
+                            }
+                            catch ( NamingException ne )
+                            {
+                            	String msg = "The root DN " + baseObject.toString() + " cannot be modified";
+                                log.error( msg + " : " + ne.getMessage() );
+                                throw new DecoderException( msg, ne );
                             }
                         }
                         

Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/SearchResultEntry.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/SearchResultEntry.java?rev=367149&r1=367148&r2=367149&view=diff
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/SearchResultEntry.java (original)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/SearchResultEntry.java Sun Jan  8 17:02:49 2006
@@ -22,8 +22,8 @@
 import org.apache.asn1.ber.tlv.UniversalTag;
 import org.apache.ldap.common.codec.LdapConstants;
 import org.apache.ldap.common.codec.LdapMessage;
-import org.apache.ldap.common.codec.util.LdapDN;
 import org.apache.ldap.common.codec.util.LdapString;
+import org.apache.ldap.common.name.LdapDN;
 import org.apache.ldap.common.util.AttributeUtils;
 import org.apache.ldap.common.util.StringTools;
 
@@ -32,6 +32,7 @@
 import java.util.LinkedList;
 import java.util.List;
 
+import javax.naming.Name;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
@@ -65,7 +66,7 @@
     //~ Instance fields ----------------------------------------------------------------------------
 
     /** The DN of the returned entry */
-    private LdapDN objectName;
+    private Name objectName;
 
     /** The attributes list. It contains javax.naming.directory.Attribute */
     private Attributes partialAttributeList;
@@ -114,7 +115,7 @@
      */
     public String getObjectName()
     {
-        return ( ( objectName == null ) ? null : objectName.getString() );
+        return ( ( objectName == null ) ? null : objectName.toString() );
     }
 
     /**
@@ -122,7 +123,7 @@
      *
      * @param objectName The objectName to set.
      */
-    public void setObjectName( LdapDN objectName )
+    public void setObjectName( Name objectName )
     {
         this.objectName = objectName;
     }
@@ -224,7 +225,7 @@
     public int computeLength()
     {
         // The entry
-        searchResultEntryLength = 1 + Length.getNbBytes( objectName.getNbBytes() ) + objectName.getNbBytes();
+        searchResultEntryLength = 1 + Length.getNbBytes( LdapDN.getNbBytes( objectName ) ) + LdapDN.getNbBytes( objectName );
         
         // The attributes sequence
         attributesLength = 0;
@@ -345,7 +346,7 @@
             buffer.put( Length.getBytes( searchResultEntryLength ) ) ;
             
             // The objectName
-            Value.encode( buffer, objectName.getBytes() );
+            Value.encode( buffer, LdapDN.getBytes( objectName ) );
             
             // The attributes sequence
             buffer.put( UniversalTag.SEQUENCE_TAG );

Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/SearchResultEntryGrammar.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/SearchResultEntryGrammar.java?rev=367149&r1=367148&r2=367149&view=diff
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/SearchResultEntryGrammar.java (original)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/SearchResultEntryGrammar.java Sun Jan  8 17:02:49 2006
@@ -17,6 +17,8 @@
 package org.apache.ldap.common.codec.search;
 
 import javax.naming.InvalidNameException;
+import javax.naming.Name;
+import javax.naming.NamingException;
 
 import org.apache.asn1.codec.DecoderException;
 import org.apache.asn1.ber.grammar.IGrammar;
@@ -30,9 +32,10 @@
 import org.apache.ldap.common.codec.LdapMessage;
 import org.apache.ldap.common.codec.LdapMessageContainer;
 import org.apache.ldap.common.codec.LdapStatesEnum;
-import org.apache.ldap.common.codec.util.LdapDN;
 import org.apache.ldap.common.codec.util.LdapString;
 import org.apache.ldap.common.codec.util.LdapStringEncodingException;
+//import org.apache.ldap.common.name.LdapDN;
+import org.apache.ldap.common.name.LdapDN;
 import org.apache.ldap.common.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -141,22 +144,34 @@
                         TLV                  tlv                  =
                             ldapMessageContainer.getCurrentTLV();
 
-                        // Store the value.
+                    	Name objectName = LdapDN.EMPTY_LDAPDN;
+
+                    	// Store the value.
                         if ( tlv.getLength().getLength() == 0 )
                         {
-                            searchResultEntry.setObjectName( LdapDN.EMPTY_LDAPDN );
+                            searchResultEntry.setObjectName( objectName );
                         }
                         else
                         {
                             try
                             {
-                                searchResultEntry.setObjectName( new LdapDN( tlv.getValue().getData() ) );
+                            	objectName = new LdapDN( tlv.getValue().getData() );
+                            	objectName = LdapDN.normalize( objectName );
                             }
                             catch ( InvalidNameException ine )
                             {
-                                log.error(" The DN " + StringTools.dumpBytes( tlv.getValue().getData() ) + "is invalid : " + ine.getMessage() );
-                                throw new DecoderException( "The Dn is invalid : " + ine.getMessage() );
+                            	String msg = "The DN " + StringTools.dumpBytes( tlv.getValue().getData() ) + "is invalid : " + ine.getMessage(); 
+                                log.error( msg + " : " + ine.getMessage());
+                                throw new DecoderException( msg, ine );
+                            }
+                            catch ( NamingException ne )
+                            {
+                            	String msg = "The DN " + StringTools.dumpBytes( tlv.getValue().getData() ) + "is invalid : " + ne.getMessage();
+                                log.error( msg + " : " + ne.getMessage() );
+                                throw new DecoderException( msg, ne );
                             }
+
+                            searchResultEntry.setObjectName( objectName );
                         }
 
                         if ( log.isDebugEnabled() )
@@ -270,7 +285,7 @@
                         {
                             try
                             {
-                                type = new LdapString( tlv.getValue().getData() );
+                            	type = LdapDN.normalizeAttribute( tlv.getValue().getData() );
                                 searchResultEntry.addAttributeValues( type );
                             }
                             catch ( LdapStringEncodingException lsee )

Modified: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/controls/EntryChangeControlGrammar.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/controls/EntryChangeControlGrammar.java?rev=367149&r1=367148&r2=367149&view=diff
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/controls/EntryChangeControlGrammar.java (original)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/codec/search/controls/EntryChangeControlGrammar.java Sun Jan  8 17:02:49 2006
@@ -29,7 +29,7 @@
 import org.apache.asn1.codec.DecoderException;
 import org.apache.asn1.util.IntegerDecoder;
 import org.apache.asn1.util.IntegerDecoderException;
-import org.apache.ldap.common.codec.util.LdapDN;
+import org.apache.ldap.common.name.LdapDN;
 import org.apache.ldap.common.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

Added: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/name/AttributeTypeAndValue.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/name/AttributeTypeAndValue.java?rev=367149&view=auto
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/name/AttributeTypeAndValue.java (added)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/name/AttributeTypeAndValue.java Sun Jan  8 17:02:49 2006
@@ -0,0 +1,347 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.ldap.common.name;
+
+import java.io.Serializable;
+
+import javax.naming.InvalidNameException;
+
+import org.apache.ldap.common.util.StringTools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A Attribute Type And Value, which is the basis of all RDN.
+ * It contains a type, and a value.
+ * 
+ * The type must not be case sensitive. Superfluous leading
+ * and trailing spaces MUST have been trimmed before.
+ * 
+ * The value MUST be in UTF8 format, according to RFC 2253. If the type 
+ * is in OID form, then the value must be a hexadecimal string prefixed 
+ * by a '#' character. Otherwise, the string must respect the RC 2253
+ * grammar. No further normalization will be done, because we don't
+ * have any knowledge of the Schema definition in the parser. 
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AttributeTypeAndValue implements Cloneable, Comparable, Serializable
+{
+    /**
+     * Declares the Serial Version Uid.
+     * 
+     * @see <a href="http://c2.com/cgi/wiki?AlwaysDeclareSerialVersionUid">Always Declare Serial Version Uid</a>
+     */
+    private static final long serialVersionUID = 1L;
+
+    /** The LoggerFactory used by this class */
+    private static Logger log = LoggerFactory.getLogger( AttributeTypeAndValue.class );
+
+    /** The Name type */
+    private String type;
+    
+    /** The name value */
+    private String value;
+    
+    /** Two values used for comparizon */
+    private static final boolean CASE_SENSITIVE = true;
+    private static final boolean CASE_INSENSITIVE = false;
+    
+    /**
+     * Construct an empty AttributeTypeAndValue
+     */ 
+    public AttributeTypeAndValue()
+    {
+        type = null;
+        value = null;
+    }
+    
+    /**
+     * Construct an AttributeTypeAndValue. The type and value are normalized :
+     * - the type is trimmed and lowercased
+     * - the value is trimmed
+     * 
+     * @param type The type
+     * @param value the value
+     */ 
+    public AttributeTypeAndValue( String type, String value ) throws InvalidNameException
+    {
+    	if ( StringTools.isEmpty( type ) || StringTools.isEmpty( type.trim() ) )
+    	{
+    		log.error( "The type cannot be empty or null" );
+    		throw new InvalidNameException( "Null or empty type is not allowed" );
+    	}
+    	
+        this.type = type;
+        this.value = StringTools.isEmpty( value ) ? "" : value;
+    }
+    
+    /**
+     * Get the type of a AttributeTypeAndValue
+     * 
+     * @return The type
+     */
+    public String getType()
+    {
+        return type;
+    }
+    
+    /**
+     * Store the type 
+     * 
+     * @param type The AttributeTypeAndValue type 
+     */
+    public void setType( String type ) throws InvalidNameException
+    {
+        if ( StringTools.isEmpty( type ) )
+        {
+            throw new InvalidNameException( "The AttributeTypeAndValue type cannot be null : " );
+        }
+        
+        this.type = type;
+    }
+    
+    /**
+     * Store the type, after having trimmed and lowercased it.
+     * 
+     * @param type The AttributeTypeAndValue type 
+     */
+    public void setTypeNormalized( String type ) throws InvalidNameException
+    {
+        this.type = StringTools.lowerCase( StringTools.trim( type ) );
+
+        if ( StringTools.isEmpty( this.type ) )
+        {
+            throw new InvalidNameException( "The AttributeTypeAndValue type cannot be null : " );
+        }
+    }
+    
+    /**
+     * Get the Value of a AttributeTypeAndValue
+     * 
+     * @return The value
+     */
+    public String getValue()
+    {
+        return value;
+    }
+    
+    /**
+     * Store the value of a AttributeTypeAndValue.
+     * 
+     * @param value The value of the AttributeTypeAndValue
+     */
+    public void setValue( String value )
+    {
+        this.value = StringTools.isEmpty( value ) ? "" : value;
+    }
+
+    /**
+     * Store the value of a AttributeTypeAndValue, after having trimmed it. 
+     * 
+     * @param value The value of the AttributeTypeAndValue
+     */
+    public void setValueNormalized( String value )
+    {
+    	String newValue = StringTools.trim( value );
+
+        if ( StringTools.isEmpty( newValue ) )
+        {
+            this.value = "";
+        }
+        else
+        {
+        	this.value = newValue; 
+        }
+    }
+    
+    /**
+     * Implements the cloning.
+     * 
+     * @return a clone of this object
+     */
+    public Object clone() 
+    {
+        try 
+        {
+            return super.clone();
+        }
+        catch ( CloneNotSupportedException cnse )
+        {
+            throw new Error( "Assertion failure" );
+        }
+    }
+    
+    /**
+     * Compares two NameComponents. They are equals if :
+     * - types are equals, case insensitive,
+     * - values are equals, case sensitive
+     * 
+     * @param object
+     * @return 0 if both NC are equals, otherwise a positive value if
+     * the original NC is superior to the second one, a negative value 
+     * if the second NC is superior.
+     */
+    public int compareTo( Object object )
+    {
+        if ( object instanceof AttributeTypeAndValue )
+        {
+            AttributeTypeAndValue nc = (AttributeTypeAndValue)object;
+            
+            int res = compareType( type, nc.type );
+            
+            if ( res != 0 )
+            {
+            	return res;
+            }
+            else
+            {
+            	return compareValue( value, nc.value, CASE_SENSITIVE );
+            }
+        }
+        else
+        {
+            return 1;
+        }
+    }
+    
+    /**
+     * Compares two NameComponents. They are equals if :
+     * - types are equals, case insensitive,
+     * - values are equals, case insensitive
+     * 
+     * @param object
+     * @return 0 if both NC are equals, otherwise a positive value if
+     * the original NC is superior to the second one, a negative value 
+     * if the second NC is superior.
+     */
+    public int compareToIgnoreCase( Object object )
+    {
+        if ( object instanceof AttributeTypeAndValue )
+        {
+            AttributeTypeAndValue nc = (AttributeTypeAndValue)object;
+            
+            int res = compareType( type, nc.type );
+            
+            if ( res != 0 )
+            {
+            	return res;
+            }
+            else
+            {
+            	return compareValue( value, nc.value, CASE_INSENSITIVE );
+            }
+        }
+        else
+        {
+            return 1;
+        }
+    }
+    
+    /**
+     * Compare two types, trimed and case insensitive
+     * @param val1 First String
+     * @param val2 Second String
+     * @return true if both strings are equals or null.
+     */
+    private int compareType( String val1, String val2 )
+    {
+        if ( StringTools.isEmpty( val1 ) )
+        {
+            return StringTools.isEmpty( val2 ) ? 0 : -1;
+        }
+        else if ( StringTools.isEmpty( val2 ) )
+        {
+            return 1;
+        }
+        else
+        {
+            return ( StringTools.trim( val1 ) ).compareToIgnoreCase( StringTools.trim( val2 ) );
+        }
+    }
+
+    /**
+     * Compare two values
+     * @param val1 First String
+     * @param val2 Second String
+     * @return true if both strings are equals or null.
+     */
+    private int compareValue( String val1, String val2, boolean sensitivity )
+    {
+        if ( StringTools.isEmpty( val1 ) )
+        {
+            return StringTools.isEmpty( val2 ) ? 0 : -1;
+        }
+        else if ( StringTools.isEmpty( val2 ) )
+        {
+            return 1;
+        }
+        else
+        {
+        	int res = 0;
+        	
+        	if ( sensitivity == CASE_SENSITIVE )
+        	{
+        		res = ( StringTools.trim( val1 ) ).compareTo( StringTools.trim( val2 ) );
+        	}
+        	else
+        	{
+        		res = ( StringTools.trim( val1 ) ).compareToIgnoreCase( StringTools.trim( val2 ) );
+        	}
+        	
+    		return (res < 0 ? -1 : res > 0 ? 1 : 0 );
+        }
+    }
+
+    /**
+     * A Normalized String representation of a AttributeTypeAndValue :
+     * - type is trimed and lowercased
+     * - value is trimed and lowercased
+     * 
+     * @return A normalized string representing a AttributeTypeAndValue
+     */
+    public String normalize()
+    {
+        return StringTools.lowerCase( StringTools.trim( type ) ) + '=' +
+        StringTools.trim( value );
+    }
+
+    /**
+     * A String representation of a AttributeTypeAndValue.
+     * 
+     * @return A string representing a AttributeTypeAndValue
+     */
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+        
+        if ( StringTools.isEmpty( type ) || StringTools.isEmpty( type.trim() ) )
+        {
+        	return "";
+        }
+        
+        sb.append( type ).append( "=" );
+        
+        if ( value != null )
+        {
+        	sb.append( value );
+        }
+        
+        return sb.toString();
+    }
+}
+

Propchange: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/name/AttributeTypeAndValue.java
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/name/DnOidContainer.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/name/DnOidContainer.java?rev=367149&view=auto
==============================================================================
--- directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/name/DnOidContainer.java (added)
+++ directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/name/DnOidContainer.java Sun Jan  8 17:02:49 2006
@@ -0,0 +1,82 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.ldap.common.name;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * The DnOidContainer is a class which ill contain a global Map associating
+ * names to thier OIDs and Normalizer. 
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ *
+ */
+public class DnOidContainer 
+{
+	/** The internaml map containing the name, Oid, Normalizer */ 
+	private static Map oidByName = new HashMap();
+	
+	private static DnOidContainer instance;
+	
+	static
+	{
+		instance = new DnOidContainer();
+	}
+	/**
+	 * Private constructor. This class cannot be constructed
+	 *
+	 */
+	private DnOidContainer()
+	{
+		// Empty private constructor
+	}
+	
+	public static DnOidContainer getInstance()
+	{
+		return instance;
+	}
+
+	/**
+	 * Get the OID/Normalizer associated with the given name
+	 * @param name The type which OID is asked for
+	 * @return The couple OID/Normalizer correspondning to the given name
+	 */
+	public static Object getOidByName( String name ) 
+	{
+		return oidByName.get( name );
+	}
+	
+	/** 
+	 * Get the Map
+	 * @return The Oid Map
+	 */
+	public static Map getOids()
+	{
+		return oidByName;
+	}
+
+	/**
+	 * Set the Map
+	 * @param oids The Map to store
+	 */
+	public static void setOids(Map oids) 
+	{
+		DnOidContainer.oidByName = oids;
+	}
+}

Propchange: directory/trunk/ldap-common/src/main/java/org/apache/ldap/common/name/DnOidContainer.java
------------------------------------------------------------------------------
    svn:executable = *