directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1708486 [2/2] - in /directory/shared/trunk: integ/src/test/java/org/apache/directory/api/ldap/model/name/ ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/ ldap/model/src/main/antlr/ ldap/model/src/main/java/org/apache/di...
Date Tue, 13 Oct 2015 18:56:51 GMT
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java?rev=1708486&r1=1708485&r2=1708486&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java Tue Oct 13 18:56:51 2015
@@ -77,11 +77,8 @@ public class Ava implements Externalizab
     /** The user provided Name type */
     private String upType;
 
-    /** The name value. It can be a String or a byte array */
-    private Value<?> normValue;
-
-    /** The name user provided value. It can be a String or a byte array */
-    private Value<?> upValue;
+    /** The value. It can be a String or a byte array */
+    private Value<?> value;
 
     /** The user provided Ava */
     private String upName;
@@ -114,8 +111,7 @@ public class Ava implements Externalizab
     {
         normType = null;
         upType = null;
-        normValue = null;
-        upValue = null;
+        value = null;
         upName = "";
         this.schemaManager = schemaManager;
         this.attributeType = null;
@@ -260,39 +256,17 @@ public class Ava implements Externalizab
      *
      * @param schemaManager The SchemaManager instance
      * @param upType The User Provided type
-     * @param upValue The User Provided value
+     * @param value The value
      * 
      * @throws LdapInvalidDnException If the given type or value are invalid
      */
-    private void createAva( SchemaManager schemaManager, String upType, Value<?> upValue )
+    private void createAva( SchemaManager schemaManager, String upType, Value<?> value )
         throws LdapInvalidDnException
     {
         normType = attributeType.getOid();
         this.upType = upType;
-
-        try
-        {
-            MatchingRule equalityMatchingRule = attributeType.getEquality();
-
-            if ( equalityMatchingRule != null )
-            {
-                this.normValue = equalityMatchingRule.getNormalizer().normalize( upValue );
-            }
-            else
-            {
-                this.normValue = upValue;
-            }
-        }
-        catch ( LdapException le )
-        {
-            String message = I18n.err( I18n.ERR_04188 );
-            LOG.error( message );
-            throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, message, le );
-        }
-
-        this.upValue = upValue;
-
-        upName = this.upType + '=' + ( this.upValue == null ? "" : Rdn.escapeValue( this.upValue.getString() ) );
+        this.value = value;
+        upName = this.upType + '=' + ( value == null ? "" : Rdn.escapeValue( value.getString() ) );
         hashCode();
     }
 
@@ -343,10 +317,9 @@ public class Ava implements Externalizab
 
         }
 
-        this.normValue = upValue;
-        this.upValue = upValue;
+        value = upValue;
 
-        upName = this.upType + '=' + ( this.upValue == null ? "" : Rdn.escapeValue( this.upValue.getString() ) );
+        upName = this.upType + '=' + ( value == null ? "" : Rdn.escapeValue( value.getString() ) );
         hashCode();
     }
 
@@ -362,23 +335,20 @@ public class Ava implements Externalizab
      * @param schemaManager The SchemaManager
      * @param upType The User Provided type
      * @param normType The normalized type
-     * @param upValue The User Provided value
-     * @param normValue The normalized value
+     * @param value The value
      * 
      * @throws LdapInvalidDnException If the given type or value are invalid
      */
     // WARNING : The protection level is left unspecified intentionally.
     // We need this method to be visible from the DnParser class, but not
     // from outside this package.
-    /* Unspecified protection */Ava( SchemaManager schemaManager, String upType, String normType, Value<?> upValue,
-        Value<?> normValue )
+    /* Unspecified protection */Ava( SchemaManager schemaManager, String upType, String normType, Value<?> value )
         throws LdapInvalidDnException
     {
         this.upType = upType;
         this.normType = normType;
-        this.upValue = upValue;
-        this.normValue = normValue;
-        upName = this.upType + '=' + ( this.upValue == null ? "" : this.upValue.getString() );
+        this.value = value;
+        upName = this.upType + '=' + ( this.value == null ? "" : this.value.getString() );
 
         if ( schemaManager != null )
         {
@@ -399,8 +369,7 @@ public class Ava implements Externalizab
      *
      * @param upType The User Provided type
      * @param normType The normalized type
-     * @param upValue The User Provided value
-     * @param normValue The normalized value
+     * @param value The User Provided value
      * @param upName The User Provided name (may be escaped)
      * 
      * @throws LdapInvalidDnException If the given type or value are invalid
@@ -408,10 +377,36 @@ public class Ava implements Externalizab
     // WARNING : The protection level is left unspecified intentionally.
     // We need this method to be visible from the DnParser class, but not
     // from outside this package.
-    /* Unspecified protection */Ava( String upType, String normType, Value<?> upValue, Value<?> normValue,
-        String upName )
+    /* Unspecified protection */Ava( String upType, String normType, Value<?> value, String upName )
         throws LdapInvalidDnException
     {
+        this( null, upType, normType, value, upName );
+    }
+    
+    
+    /**
+     * Construct an Ava. The type and value are normalized :
+     * <li> the type is trimmed and lowercased </li>
+     * <li> the value is trimmed </li>
+     * <p>
+     * Note that the upValue should <b>not</b> be null or empty, or resolved
+     * to an empty string after having trimmed it.
+     *
+     * @param attributeType The AttributeType for this value
+     * @param upType The User Provided type
+     * @param normType The normalized type
+     * @param value The value
+     * @param upName The User Provided name (may be escaped)
+     * 
+     * @throws LdapInvalidDnException If the given type or value are invalid
+     */
+    // WARNING : The protection level is left unspecified intentionally.
+    // We need this method to be visible from the DnParser class, but not
+    // from outside this package.
+    /* Unspecified protection */Ava( AttributeType attributeType, String upType, String normType, Value<?> value, String upName )
+        throws LdapInvalidDnException
+    {
+        this.attributeType = attributeType;
         String upTypeTrimmed = Strings.trim( upType );
         String normTypeTrimmed = Strings.trim( normType );
 
@@ -442,8 +437,7 @@ public class Ava implements Externalizab
             this.upType = upType;
         }
 
-        this.normValue = normValue;
-        this.upValue = upValue;
+        this.value = value;
         this.upName = upName;
         hashCode();
     }
@@ -489,24 +483,9 @@ public class Ava implements Externalizab
 
             normType = tmpAttributeType.getOid();
 
-            if ( normValue != null )
-            {
-                return;
-            }
-
             try
             {
-                // We use the Equality matching rule to normalize the value
-                MatchingRule equalityMatchingRule = tmpAttributeType.getEquality();
-
-                if ( equalityMatchingRule != null )
-                {
-                    this.normValue = equalityMatchingRule.getNormalizer().normalize( upValue );
-                }
-                else
-                {
-                    this.normValue = upValue;
-                }
+                this.value.apply( tmpAttributeType );
             }
             catch ( LdapException le )
             {
@@ -547,20 +526,9 @@ public class Ava implements Externalizab
      *
      * @return The value
      */
-    public Value<?> getNormValue()
-    {
-        return normValue.clone();
-    }
-
-
-    /**
-     * Get the User Provided Value of a Ava
-     *
-     * @return The value
-     */
     public Value<?> getValue()
     {
-        return upValue.clone();
+        return value.clone();
     }
 
 
@@ -596,8 +564,7 @@ public class Ava implements Externalizab
         try
         {
             Ava clone = ( Ava ) super.clone();
-            clone.upValue = upValue.clone();
-            clone.normValue = normValue.clone();
+            clone.value = value.clone();
 
             return clone;
         }
@@ -612,15 +579,14 @@ public class Ava implements Externalizab
      * A Normalized String representation of a Ava :
      * <ul>
      * <li>type is trimed and lowercased</li>
-     * <li>value is trimed and lowercased, and special characters</li>
+     * <li>value is trimed and lowercased, and special characters are escaped if needed.</li>
      * </ul>
-     * are escaped if needed.
      *
      * @return A normalized string representing an Ava
      */
     public String normalize()
     {
-        if ( normValue.isHumanReadable() )
+        if ( value.isHumanReadable() )
         {
             // The result will be gathered in a stringBuilder
             StringBuilder sb = new StringBuilder();
@@ -628,9 +594,9 @@ public class Ava implements Externalizab
             // First, store the type and the '=' char
             sb.append( normType ).append( '=' );
 
-            String normalizedValue = normValue.getString();
+            String normalizedValue = ( String ) value.getNormValue();
 
-            if ( normalizedValue.length() > 0 )
+            if ( ( normalizedValue != null ) && ( normalizedValue.length() > 0 ) )
             {
                 sb.append( Rdn.escapeValue( normalizedValue ) );
             }
@@ -640,7 +606,7 @@ public class Ava implements Externalizab
         else
         {
             return normType + "=#"
-                + Strings.dumpHexPairs( normValue.getBytes() );
+                + Strings.dumpHexPairs( value.getBytes() );
         }
     }
 
@@ -658,7 +624,7 @@ public class Ava implements Externalizab
             h = 37;
 
             h = h * 17 + ( normType != null ? normType.hashCode() : 0 );
-            h = h * 17 + ( normValue != null ? normValue.hashCode() : 0 );
+            h = h * 17 + ( value != null ? value.hashCode() : 0 );
         }
 
         return h;
@@ -699,9 +665,9 @@ public class Ava implements Externalizab
         }
 
         // Compare the values
-        if ( normValue.isNull() )
+        if ( value.isNull() )
         {
-            return instance.normValue.isNull();
+            return instance.value.isNull();
         }
         else
         {
@@ -711,25 +677,25 @@ public class Ava implements Externalizab
 
                 if ( equalityMatchingRule != null )
                 {
-                    return equalityMatchingRule.getLdapComparator().compare( normValue.getValue(),
-                        instance.normValue.getValue() ) == 0;
+                    return equalityMatchingRule.getLdapComparator().compare( value.getValue(),
+                        instance.value.getValue() ) == 0;
                 }
                 else
                 {
                     // No Equality MR, use a direct comparison
-                    if ( normValue instanceof BinaryValue )
+                    if ( value instanceof BinaryValue )
                     {
-                        return Arrays.equals( normValue.getBytes(), instance.normValue.getBytes() );
+                        return Arrays.equals( value.getBytes(), instance.value.getBytes() );
                     }
                     else
                     {
-                        return normValue.getString().equals( instance.normValue.getString() );
+                        return value.getString().equals( instance.value.getString() );
                     }
                 }
             }
             else
             {
-                return normValue.equals( instance.normValue );
+                return value.equals( instance.value );
             }
         }
     }
@@ -747,8 +713,8 @@ public class Ava implements Externalizab
         if ( Strings.isEmpty( upName )
             || Strings.isEmpty( upType )
             || Strings.isEmpty( normType )
-            || ( upValue.isNull() )
-            || ( normValue.isNull() ) )
+            || ( value.isNull() )
+            || ( value.isNull() ) )
         {
             String message = "Cannot serialize an wrong ATAV, ";
 
@@ -764,11 +730,7 @@ public class Ava implements Externalizab
             {
                 message += "the normType should not be null or empty";
             }
-            else if ( upValue.isNull() )
-            {
-                message += "the upValue should not be null";
-            }
-            else if ( normValue.isNull() )
+            else if ( value.isNull() )
             {
                 message += "the value should not be null";
             }
@@ -852,7 +814,7 @@ public class Ava implements Externalizab
         }
 
         // Write the isHR flag
-        if ( normValue.isHumanReadable() )
+        if ( value.isHumanReadable() )
         {
             buffer[pos++] = Serialize.TRUE;
         }
@@ -862,15 +824,9 @@ public class Ava implements Externalizab
         }
 
         // Write the upValue
-        if ( upValue.isHumanReadable() )
+        if ( value.isHumanReadable() )
         {
-            pos = ( ( StringValue ) upValue ).serialize( buffer, pos );
-        }
-
-        // Write the normValue
-        if ( normValue.isHumanReadable() )
-        {
-            pos = ( ( StringValue ) normValue ).serialize( buffer, pos );
+            pos = ( ( StringValue ) value ).serialize( buffer, pos );
         }
 
         // Write the hash code
@@ -949,12 +905,8 @@ public class Ava implements Externalizab
         if ( isHR )
         {
             // Read the upValue
-            upValue = new StringValue( attributeType );
-            pos = ( ( StringValue ) upValue ).deserialize( buffer, pos );
-
-            // Read the normValue
-            normValue = new StringValue( attributeType );
-            pos = ( ( StringValue ) normValue ).deserialize( buffer, pos );
+            value = new StringValue( attributeType );
+            pos = ( ( StringValue ) value ).deserialize( buffer, pos );
         }
 
         // Read the hashCode
@@ -993,26 +945,17 @@ public class Ava implements Externalizab
      * if the value is a String :
      * <ul>
      *   <li>
-     *     <b>upValue</b> The User Provided value
-     *   </li>
-     *   <li>
-     *     <b>value</b> The normalized value
+     *     <b>value</b> The value
      *   </li>
      * </ul>
      * <br/>
      * if the value is binary :
      * <ul>
      *   <li>
-     *     <b>upValueLength</b>
-     *   </li>
-     *   <li>
-     *     <b>upValue</b> The User Provided value
-     *   </li>
-     *   <li>
      *     <b>valueLength</b>
      *   </li>
      *   <li>
-     *     <b>value</b> The normalized value
+     *     <b>value</b> The value
      *   </li>
      * </ul>
      * 
@@ -1025,10 +968,9 @@ public class Ava implements Externalizab
         if ( Strings.isEmpty( upName )
             || Strings.isEmpty( upType )
             || Strings.isEmpty( normType )
-            || ( upValue.isNull() )
-            || ( normValue.isNull() ) )
+            || ( value.isNull() ) )
         {
-            String message = "Cannot serialize an wrong ATAV, ";
+            String message = "Cannot serialize a wrong ATAV, ";
 
             if ( Strings.isEmpty( upName ) )
             {
@@ -1042,11 +984,7 @@ public class Ava implements Externalizab
             {
                 message += "the normType should not be null or empty";
             }
-            else if ( upValue.isNull() )
-            {
-                message += "the upValue should not be null";
-            }
-            else if ( normValue.isNull() )
+            else if ( value.isNull() )
             {
                 message += "the value should not be null";
             }
@@ -1085,12 +1023,11 @@ public class Ava implements Externalizab
             out.writeBoolean( false );
         }
 
-        boolean isHR = normValue.isHumanReadable();
+        boolean isHR = value.isHumanReadable();
 
         out.writeBoolean( isHR );
 
-        upValue.writeExternal( out );
-        normValue.writeExternal( out );
+        value.writeExternal( out );
 
         // Write the hashCode
         out.writeInt( h );
@@ -1148,13 +1085,11 @@ public class Ava implements Externalizab
 
         if ( isHR )
         {
-            upValue = StringValue.deserialize( attributeType, in );
-            normValue = StringValue.deserialize( attributeType, in );
+            value = StringValue.deserialize( attributeType, in );
         }
         else
         {
-            upValue = BinaryValue.deserialize( attributeType, in );
-            normValue = BinaryValue.deserialize( attributeType, in );
+            value = BinaryValue.deserialize( attributeType, in );
         }
 
         h = in.readInt();
@@ -1190,16 +1125,16 @@ public class Ava implements Externalizab
     {
         int comp = 0;
 
-        if ( normValue.getNormValue() instanceof String )
+        if ( value.getNormValue() instanceof String )
         {
-            comp = ( ( String ) normValue.getNormValue() ).compareTo( ( ( String ) that.normValue.getNormValue() ) );
+            comp = ( ( String ) value.getNormValue() ).compareTo( ( ( String ) that.value.getNormValue() ) );
 
             return comp;
         }
         else
         {
-            byte[] bytes1 = ( byte[] ) normValue.getNormValue();
-            byte[] bytes2 = ( byte[] ) that.normValue.getNormValue();
+            byte[] bytes1 = ( byte[] ) value.getNormValue();
+            byte[] bytes2 = ( byte[] ) that.value.getNormValue();
 
             for ( int pos = 0; pos < bytes1.length; pos++ )
             {
@@ -1246,9 +1181,9 @@ public class Ava implements Externalizab
             }
 
             // and compare the values
-            if ( normValue == null )
+            if ( value == null )
             {
-                if ( that.normValue == null )
+                if ( that.value == null )
                 {
                     return 0;
                 }
@@ -1259,21 +1194,21 @@ public class Ava implements Externalizab
             }
             else
             {
-                if ( that.normValue == null )
+                if ( that.value == null )
                 {
                     return 1;
                 }
                 else
                 {
-                    if ( normValue instanceof StringValue )
+                    if ( value instanceof StringValue )
                     {
-                        comp = ( ( StringValue ) normValue ).compareTo( ( StringValue ) that.normValue );
+                        comp = ( ( StringValue ) value ).compareTo( ( StringValue ) that.value );
 
                         return comp;
                     }
                     else
                     {
-                        comp = ( ( BinaryValue ) normValue ).compareTo( ( BinaryValue ) that.normValue );
+                        comp = ( ( BinaryValue ) value ).compareTo( ( BinaryValue ) that.value );
 
                         return comp;
                     }
@@ -1312,7 +1247,7 @@ public class Ava implements Externalizab
 
                 if ( comparator != null )
                 {
-                    comp = comparator.compare( normValue.getNormValue(), that.normValue.getNormValue() );
+                    comp = comparator.compare( value.getNormValue(), that.value.getNormValue() );
 
                     return comp;
                 }
@@ -1331,8 +1266,8 @@ public class Ava implements Externalizab
             }
         }
     }
-
-
+    
+    
     /**
      * A String representation of an Ava, as provided by the user.
      *

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Dn.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Dn.java?rev=1708486&r1=1708485&r2=1708486&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Dn.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Dn.java Tue Oct 13 18:56:51 2015
@@ -36,9 +36,13 @@ import java.util.TreeSet;
 
 import org.apache.commons.collections.list.UnmodifiableList;
 import org.apache.directory.api.i18n.I18n;
+import org.apache.directory.api.ldap.model.entry.BinaryValue;
+import org.apache.directory.api.ldap.model.entry.StringValue;
+import org.apache.directory.api.ldap.model.entry.Value;
 import org.apache.directory.api.ldap.model.exception.LdapException;
 import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.api.ldap.model.schema.AttributeType;
 import org.apache.directory.api.ldap.model.schema.SchemaManager;
 import org.apache.directory.api.ldap.model.schema.normalizers.OidNormalizer;
 import org.apache.directory.api.util.Strings;
@@ -1069,7 +1073,7 @@ public class Dn implements Iterable<Rdn>
                 return atav;
             }
 
-            type = Strings.toLowerCase( type );
+            type = Strings.toLowerCaseAscii( type );
 
             // Check that we have an existing AttributeType for this type
             if ( !oidsMap.containsKey( type ) )
@@ -1086,13 +1090,33 @@ public class Dn implements Iterable<Rdn>
             {
                 try
                 {
+                    AttributeType attributeType = schemaManager.getAttributeType( type );
+                    Value<?> atavValue = null;
+                    Value<?> value = atav.getValue();
+                    
+                    if ( value instanceof StringValue )
+                    {
+                        if ( attributeType.getSyntax().isHumanReadable() )
+                        {
+                            atavValue = new StringValue( attributeType, value.getString() );
+                        }
+                        else
+                        {
+                            // This is a binary variable, transaform the StringValue to a BinaryValye
+                            atavValue = new BinaryValue( attributeType, value.getBytes() );
+                        }
+                    }
+                    else
+                    {
+                        atavValue = new BinaryValue( attributeType, atav.getValue().getBytes() );
+                    }
+                    
                     Ava newAva = new Ava(
+                        attributeType,
                         atav.getType(),
                         oidNormalizer.getAttributeTypeOid(),
-                        atav.getValue(),
-                        oidNormalizer.getNormalizer().normalize( atav.getNormValue() ),
+                        atavValue,
                         atav.getName() );
-                    newAva.apply( schemaManager );
 
                     return newAva;
                 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/FastDnParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/FastDnParser.java?rev=1708486&r1=1708485&r2=1708486&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/FastDnParser.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/FastDnParser.java Tue Oct 13 18:56:51 2015
@@ -174,8 +174,7 @@ import org.apache.directory.api.util.Str
 
         String upName = name.substring( rdnStart, pos.start );
 
-        Ava ava = new Ava( type, type, new StringValue( upValue ),
-            new StringValue( value ), upName );
+        Ava ava = new Ava( type, type, new StringValue( upValue ), upName );
         rdn.addAVA( null, ava );
 
         rdn.setUpName( upName );

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Rdn.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Rdn.java?rev=1708486&r1=1708485&r2=1708486&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Rdn.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Rdn.java Tue Oct 13 18:56:51 2015
@@ -34,12 +34,10 @@ import org.apache.commons.collections.ma
 import org.apache.directory.api.i18n.I18n;
 import org.apache.directory.api.ldap.model.entry.StringValue;
 import org.apache.directory.api.ldap.model.entry.Value;
-import org.apache.directory.api.ldap.model.exception.LdapException;
 import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException;
 import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.api.ldap.model.schema.AttributeType;
 import org.apache.directory.api.ldap.model.schema.SchemaManager;
-import org.apache.directory.api.ldap.model.schema.normalizers.OidNormalizer;
 import org.apache.directory.api.util.Chars;
 import org.apache.directory.api.util.Hex;
 import org.apache.directory.api.util.Serialize;
@@ -295,7 +293,7 @@ public class Rdn implements Cloneable, E
      */
     public Rdn( SchemaManager schemaManager, String upType, String upValue ) throws LdapInvalidDnException
     {
-        addAVA( schemaManager, upType, upType, new StringValue( upValue ), new StringValue( upValue ) );
+        addAVA( schemaManager, upType, upType, new StringValue( upValue ) );
 
         upName = upType + '=' + upValue;
 
@@ -424,13 +422,13 @@ public class Rdn implements Cloneable, E
             case 1:
                 // We have a single Ava
                 // We will trim and lowercase type and value.
-                if ( ava.getNormValue().isHumanReadable() )
+                if ( ava.getValue().isHumanReadable() )
                 {
                     normName = ava.getNormName();
                 }
                 else
                 {
-                    normName = ava.getNormType() + "=#" + Strings.dumpHexPairs( ava.getNormValue().getBytes() );
+                    normName = ava.getNormType() + "=#" + Strings.dumpHexPairs( ava.getValue().getBytes() );
                 }
 
                 break;
@@ -501,26 +499,24 @@ public class Rdn implements Cloneable, E
      * @throws LdapInvalidDnException
      *             If the Rdn is invalid
      */
-    private void addAVA( SchemaManager schemaManager, String upType, String type, Value<?> upValue,
-        Value<?> value ) throws LdapInvalidDnException
+    private void addAVA( SchemaManager schemaManager, String upType, String type, Value<?> value ) throws LdapInvalidDnException
     {
         // First, let's normalize the type
-        Value<?> normalizedValue = value;
+        AttributeType attributeType = null;
         String normalizedType = Strings.lowerCaseAscii( type );
         this.schemaManager = schemaManager;
 
         if ( schemaManager != null )
         {
-            OidNormalizer oidNormalizer = schemaManager.getNormalizerMapping().get( normalizedType );
-            normalizedType = oidNormalizer.getAttributeTypeOid();
-
+            attributeType = schemaManager.getAttributeType( normalizedType );
+            
             try
             {
-                normalizedValue = oidNormalizer.getNormalizer().normalize( value );
+                value.apply( attributeType );
             }
-            catch ( LdapException e )
+            catch ( LdapInvalidAttributeValueException liave )
             {
-                throw new LdapInvalidDnException( e.getMessage(), e );
+                throw new LdapInvalidDnException( liave.getMessage(), liave );
             }
         }
 
@@ -528,7 +524,7 @@ public class Rdn implements Cloneable, E
         {
             case 0:
                 // This is the first Ava. Just stores it.
-                ava = new Ava( schemaManager, upType, normalizedType, upValue, normalizedValue );
+                ava = new Ava( schemaManager, upType, normalizedType, value );
                 nbAvas = 1;
                 avaType = normalizedType;
                 hashCode();
@@ -553,7 +549,7 @@ public class Rdn implements Cloneable, E
 
             default:
                 // add a new Ava
-                Ava newAva = new Ava( schemaManager, upType, normalizedType, upValue, normalizedValue );
+                Ava newAva = new Ava( schemaManager, upType, normalizedType, value );
                 avas.add( newAva );
                 avaTypes.put( normalizedType, newAva );
                 nbAvas++;
@@ -694,11 +690,11 @@ public class Rdn implements Cloneable, E
 
 
     /**
-     * Get the Value of the Ava which type is given as an
+     * Get the value of the Ava which type is given as an
      * argument.
      *
      * @param type the type of the NameArgument
-     * @return the Value to be returned, or null if none found.
+     * @return the value to be returned, or null if none found.
      * @throws LdapInvalidDnException if the Rdn is invalid
      */
     public Object getValue( String type ) throws LdapInvalidDnException
@@ -724,7 +720,73 @@ public class Rdn implements Cloneable, E
             case 1:
                 if ( Strings.equals( ava.getNormType(), normalizedType ) )
                 {
-                    return ava.getNormValue().getValue();
+                    return ava.getValue().getValue();
+                }
+
+                return "";
+
+            default:
+                if ( avaTypes.containsKey( normalizedType ) )
+                {
+                    @SuppressWarnings("unchecked")
+                    Collection<Ava> atavList = ( Collection<Ava> ) avaTypes.get( normalizedType );
+                    StringBuffer sb = new StringBuffer();
+                    boolean isFirst = true;
+
+                    for ( Ava elem : atavList )
+                    {
+                        if ( isFirst )
+                        {
+                            isFirst = false;
+                        }
+                        else
+                        {
+                            sb.append( ',' );
+                        }
+
+                        sb.append( elem.getValue() );
+                    }
+
+                    return sb.toString();
+                }
+
+                return "";
+        }
+    }
+
+
+    /**
+     * Get the normalized value of the Ava which type is given as an
+     * argument.
+     *
+     * @param type the type of the NameArgument
+     * @return the normalized value to be returned, or null if none found.
+     * @throws LdapInvalidDnException if the Rdn is invalid
+     */
+    public Object getNormValue( String type ) throws LdapInvalidDnException
+    {
+        // First, let's normalize the type
+        String normalizedType = Strings.lowerCaseAscii( Strings.trim( type ) );
+
+        if ( schemaManager != null )
+        {
+            AttributeType attributeType = schemaManager.getAttributeType( normalizedType );
+
+            if ( attributeType != null )
+            {
+                normalizedType = attributeType.getOid();
+            }
+        }
+
+        switch ( nbAvas )
+        {
+            case 0:
+                return "";
+
+            case 1:
+                if ( Strings.equals( ava.getNormType(), normalizedType ) )
+                {
+                    return ava.getValue().getNormValue();
                 }
 
                 return "";
@@ -748,7 +810,7 @@ public class Rdn implements Cloneable, E
                             sb.append( ',' );
                         }
 
-                        sb.append( elem.getNormValue() );
+                        sb.append( elem.getValue().getNormValue() );
                     }
 
                     return sb.toString();
@@ -985,11 +1047,11 @@ public class Rdn implements Cloneable, E
 
 
     /**
-     * Return the User Provided value
+     * Return the User Provided value, as a String
      *
      * @return The first User provided value of this Rdn
      */
-    public Value<?> getValue()
+    public String getValue()
     {
         switch ( nbAvas )
         {
@@ -997,20 +1059,20 @@ public class Rdn implements Cloneable, E
                 return null;
 
             case 1:
-                return ava.getValue();
+                return ava.getValue().getString();
 
             default:
-                return avas.get( 0 ).getValue();
+                return avas.get( 0 ).getValue().getString();
         }
     }
 
 
     /**
-     * Return the normalized value, or the first one of we have more than one (the lowest)
+     * Return the Normalized value, as a String
      *
-     * @return The first normalized value of this Rdn
+     * @return The first Normalized value of this Rdn
      */
-    public Value<?> getNormValue()
+    public String getNormValue()
     {
         switch ( nbAvas )
         {
@@ -1018,10 +1080,10 @@ public class Rdn implements Cloneable, E
                 return null;
 
             case 1:
-                return ava.getNormValue();
+                return ava.getValue().getNormValue().toString();
 
             default:
-                return avas.get( 0 ).getNormValue();
+                return avas.get( 0 ).getValue().getNormValue().toString();
         }
     }
 
@@ -1131,11 +1193,15 @@ public class Rdn implements Cloneable, E
      * Unescape the given string according to RFC 2253 If in <string> form, a
      * LDAP string representation asserted value can be obtained by replacing
      * (left-to-right, non-recursively) each <pair> appearing in the <string> as
-     * follows: replace <ESC><ESC> with <ESC>; replace <ESC><special> with
-     * <special>; replace <ESC><hexpair> with the octet indicated by the
-     * <hexpair> If in <hexstring> form, a BER representation can be obtained
-     * from converting each <hexpair> of the <hexstring> to the octet indicated
-     * by the <hexpair>
+     * follows: 
+     * <ul>
+     * <li>replace &lt;ESC&gt;&lt;ESC&gt; with &lt;ESC&gt;</li>
+     * <li>replace &lt;ESC&gt;&lt;special&gt; with &lt;special&gt;</li>
+     * <li>replace &lt;ESC&gt;&lt;hexpair&gt; with the octet indicated by the &lt;hexpair&gt;</li>
+     * </ul>
+     * If in &lt;hexstring&gt; form, a BER representation can be obtained
+     * from converting each &lt;hexpair&gt; of the &lt;hexstring&gt; to the octet indicated
+     * by the &lt;hexpair&gt;
      *
      * @param value The value to be unescaped
      * @return Returns a string value as a String, and a binary value as a byte
@@ -1154,7 +1220,7 @@ public class Rdn implements Cloneable, E
         // If the value is contained into double quotes, return it as is.
         if ( ( chars[0] == '\"' ) && ( chars[chars.length - 1] == '\"' ) )
         {
-            return value;
+            return new String( chars, 1, chars.length - 2 );
         }
 
         if ( chars[0] == '#' )
@@ -1237,6 +1303,7 @@ public class Rdn implements Cloneable, E
                             pair += Hex.getHexValue( chars[i] );
                             bytes[pos++] = pair;
                             isHex = false;
+                            pair = 0;
                         }
                     }
                     else

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/PrepareString.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/PrepareString.java?rev=1708486&r1=1708485&r2=1708486&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/PrepareString.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/PrepareString.java Tue Oct 13 18:56:51 2015
@@ -4803,7 +4803,6 @@ public final class PrepareString
 
 
     /**
-     * 
      * Remove all insignificant spaces in a string.
      * 
      * This method use a finite state machine to parse
@@ -4830,21 +4829,20 @@ public final class PrepareString
         // three chars.
         // TODO : we have to find a way to prevent this waste of space.
         char[] target = new char[str.length() * 3 + 2];
-
+        
         int pos = 0;
         char lowerCase = ( char ) ( caseSensitive ? 0x00 : 0x20 );
 
-        // First pass to map the chars
-        //System.arraycopy( array, 0, target, 0, array.length );
+        // First pass to map the chars. This will copy the array into the target
         int limit = map( array, target, lowerCase );
         pos = 0;
 
         // Second pass to remove spaces. We work on the target
-        int i = 0;
+        int start = 0;
         char c = '\0';
 
         // First remove starting spaces
-        for ( i = 0; i < limit; i++ )
+        for ( int i = 0; i < limit; i++ )
         {
             c = target[i];
 
@@ -4853,12 +4851,11 @@ public final class PrepareString
                 checkProhibited( c );
                 break;
             }
+            
+            start++;
         }
 
-        // Now, 'i' will be the starting point. We will just handle the special
-        // case of a combining character
-        int start = i;
-
+        // We will just handle the special case of a combining character
         if ( start == limit )
         {
             // we only have spaces, we keep only one
@@ -4885,9 +4882,37 @@ public final class PrepareString
         }
 
         // Now remove the spaces at the end
-        for ( i = limit - 1; i > start; i-- )
+        int i = 0;
+        
+        for ( i = limit - 1; i >= start; i-- )
         {
-            if ( target[i] != ' ' )
+            if ( target[i] == ' ' )
+            {
+                // Check if we have a preceding '\' 
+                if ( i - 1 >= start )
+                {
+                    // Break only if the space is preceded by a single ESC
+                    if ( i - 2 >= start )
+                    {
+                        if ( ( target[i - 1] == '\\' ) && ( target[i - 2] != '\\' ) )
+                        {
+                            target[i - 1] = ' ';
+                            i--;
+                            break;
+                        }
+                    }
+                    else
+                    {
+                        if ( target[i - 1] == '\\' )
+                        {
+                            target[i - 1] = ' ';
+                            i--;
+                            break;
+                        }
+                    }
+                }
+            }
+            else
             {
                 break;
             }
@@ -4895,13 +4920,15 @@ public final class PrepareString
 
         limit = i + 1;
 
-        // Let's deal with the following chars. It will be
-        // a list of chars and spaces. We will consider that
-        // we have couples of chars and spaces :
-        // (char * space*)*. We have a special case :
-        // a space followed by a combining char.
+        // Remove the " around the string if any
+        if ( target[start] == '"' )
+        {
+            start++;
+            limit--;
+        }
+
         boolean spaceSeen = false;
-        boolean space2Seen = false;
+        boolean escapeSeen = false;
 
         for ( i = start; i < limit; i++ )
         {
@@ -4909,35 +4936,33 @@ public final class PrepareString
 
             checkProhibited( c );
 
-            if ( isCombiningMark( c ) )
+            if ( c == ' ' )
             {
-                if ( spaceSeen )
+                if ( escapeSeen )
                 {
-                    if ( space2Seen )
-                    {
-                        target[pos++] = ' ';
-                    }
-
                     target[pos++] = ' ';
-                    target[pos++] = c;
-                    spaceSeen = false;
-                    space2Seen = false;
                 }
                 else
                 {
-                    target[pos++] = c;
+                    spaceSeen = true;
                 }
+
+                escapeSeen = false;
             }
-            else if ( c == ' ' )
+            else if ( c == '\\' )
             {
-                if ( spaceSeen )
+                if ( escapeSeen )
                 {
-                    space2Seen = true;
+                    target[pos++] = '\\';
+                    target[pos++] = '\\';
                 }
-                else
+                else if ( spaceSeen )
                 {
-                    spaceSeen = true;
+                    target[pos++] = ' ';
                 }
+                
+                escapeSeen = !escapeSeen;
+                spaceSeen = false;
             }
             else
             {
@@ -4945,19 +4970,38 @@ public final class PrepareString
                 {
                     target[pos++] = ' ';
                     spaceSeen = false;
-                    space2Seen = false;
                 }
-
+                else if ( escapeSeen )
+                {
+                    target[pos++] = '\\';
+                }
+                
                 target[pos++] = c;
+                escapeSeen = false;
             }
         }
 
-        return new String( target, 0, pos );
+        // A special case : we have seen a space at the end of the array : it must be added back
+        // because it's an escaped space, otherwise it would have been discarded by the previous 
+        // end of String's space removal
+        if ( spaceSeen )
+        {
+            target[pos++] = ' ';
+        }
+        // Same for the escape
+        else if ( escapeSeen )
+        {
+            target[pos++] = '\\';
+        }
+        // Ends by unescaping the escaped elements
+        String result = unescape( target, pos );
+
+        return result;
     }
 
 
     /**
-     * Remove all insignificant spaces in a Ascii string.
+     * Remove all insignificant spaces in a Ascii string. We don't remove escaped spaces.
      * 
      * This method use a finite state machine to parse
      * the text.
@@ -4975,7 +5019,7 @@ public final class PrepareString
             // Special case : an empty strings is replaced by 2 spaces
             return "";
         }
-
+        
         char[] array = str.toCharArray();
 
         int pos = 0;
@@ -4985,12 +5029,12 @@ public final class PrepareString
         int limit = map( array, array, lowerCase );
         pos = 0;
 
-        // Second pass to remove spaces. We work on the target
-        int i = 0;
+        // Second pass to remove spaces (except the escaped ones). We work on the target
+        int start = 0;
         char c = '\0';
 
         // First remove starting spaces
-        for ( i = 0; i < limit; i++ )
+        for ( int i = 0; i < limit; i++ )
         {
             c = array[i];
 
@@ -4999,12 +5043,11 @@ public final class PrepareString
                 checkProhibited( c );
                 break;
             }
+            
+            start++;
         }
 
-        // Now, 'i' will be the starting point. We will just handle the special
-        // case of a combining character
-        int start = i;
-
+        // We will just handle the special case of a combining character
         if ( start == limit )
         {
             // we only have spaces, we keep only one
@@ -5022,16 +5065,39 @@ public final class PrepareString
                 throw new InvalidCharacterException( c );
             }
         }
-        else
-        {
-            array[pos++] = c;
-            start++;
-        }
 
         // Now remove the spaces at the end
-        for ( i = limit - 1; i > start; i-- )
+        int i = 0;
+        
+        for ( i = limit - 1; i >= start; i-- )
         {
-            if ( array[i] != ' ' )
+            if ( array[i] == ' ' )
+            {
+                // Check if we have a preceding '\' 
+                if ( i - 1 >= start )
+                {
+                    // Break only if the space is preceded by a single ESC
+                    if ( i - 2 >= start )
+                    {
+                        if ( ( array[i - 1] == '\\' ) && ( array[i - 2] != '\\' ) )
+                        {
+                            array[i - 1] = ' ';
+                            i--;
+                            break;
+                        }
+                    }
+                    else
+                    {
+                        if ( array[i - 1] == '\\' )
+                        {
+                            array[i - 1] = ' ';
+                            i--;
+                            break;
+                        }
+                    }
+                }
+            }
+            else
             {
                 break;
             }
@@ -5039,12 +5105,15 @@ public final class PrepareString
 
         limit = i + 1;
 
-        // Let's deal with the following chars. It will be
-        // a list of chars and spaces. We will consider that
-        // we have couples of chars and spaces :
-        // (char* space*)*. We have a special case :
-        // a space followed by a combining char.
+        // Remove the " around the string if any
+        if ( array[start] == '"' )
+        {
+            start++;
+            limit--;
+        }
+        
         boolean spaceSeen = false;
+        boolean escapeSeen = false;
 
         for ( i = start; i < limit; i++ )
         {
@@ -5052,13 +5121,37 @@ public final class PrepareString
 
             checkProhibited( c );
 
-            if ( isCombiningMark( c ) )
+            /*if ( isCombiningMark( c ) )
             {
                 throw new InvalidCharacterException( c );
             }
-            else if ( c == ' ' )
+            else*/ if ( c == ' ' )
+            {
+                if ( escapeSeen )
+                {
+                    array[pos++] = ' ';
+                }
+                else
+                {
+                    spaceSeen = true;
+                }
+
+                escapeSeen = false;
+            }
+            else if ( c == '\\' )
             {
-                spaceSeen = true;
+                if ( escapeSeen )
+                {
+                    array[pos++] = '\\';
+                    array[pos++] = '\\';
+                }
+                else if ( spaceSeen )
+                {
+                    array[pos++] = ' ';
+                }
+                
+                escapeSeen = !escapeSeen;
+                spaceSeen = false;
             }
             else
             {
@@ -5067,11 +5160,196 @@ public final class PrepareString
                     array[pos++] = ' ';
                     spaceSeen = false;
                 }
-
+                else if ( escapeSeen )
+                {
+                    array[pos++] = '\\';
+                }
+                
                 array[pos++] = c;
+                escapeSeen = false;
             }
         }
 
-        return new String( array, 0, pos );
+        // A special case : we have seen a space at the end of the array : it must be added back
+        // because it's an escaped space, otherwise it would have been discarded by the previous 
+        // end of String's space removal
+        if ( spaceSeen )
+        {
+            array[pos++] = ' ';
+        }
+        // Same for the escape
+        else if ( escapeSeen )
+        {
+            array[pos++] = '\\';
+        }
+        
+        // Ends by unescaping the escaped elements
+        String result = unescape( array, pos );
+        
+        return result;
+    }
+    
+    
+    private static String unescape( char[] array, int end )
+    {
+        byte[] bytes = new byte[end * 3];
+        boolean escapeSeen = false;
+        int pos = 0;
+            
+        for ( int i = 0; i < end; i++ )
+        {
+            char c = array[i];
+            
+            if ( c == '\\' )
+            {
+                if ( escapeSeen )
+                {
+                    bytes[pos++] = '\\';
+                }
+                
+                escapeSeen = !escapeSeen;
+            }
+            else
+            {
+                if ( escapeSeen )
+                {
+                    switch ( c )
+                    {
+                        // Various form of space
+                        case 0x0A :
+                        case 0x0B :
+                        case 0x0C :
+                        case 0x0D :
+                        case 0x85 :
+                        case 0xA0 :
+                        case ' ' :
+                            bytes[pos++] = ' ';
+                            break;
+                        
+                        // Special chars
+                        case '#' :
+                        case '=' :
+                        case '+' :
+                        case '"' :
+                        case ',' :
+                        case ';' :
+                        case '<' :
+                        case '>' : 
+                            bytes[pos++] = ( byte ) c;
+                            break;
+                        
+                        // Hexpair
+                        case '0' :
+                        case '1' :
+                        case '2' :
+                        case '3' :
+                        case '4' :
+                        case '5' :
+                        case '6' :
+                        case '7' :
+                        case '8' :
+                        case '9' :
+                            bytes[pos++] = ( byte ) ( ( ( byte ) ( array[i] - '0' ) << 4 ) + toByte( array[i + 1] ) );
+                            i++;
+                            break;
+                            
+                        case 'a' :
+                        case 'b' :
+                        case 'c' :
+                        case 'd' :
+                        case 'e' :
+                        case 'f' :
+                            bytes[pos++] = ( byte ) ( ( ( byte ) ( array[i] - 'a' + 10 ) << 4 ) + toByte( array[i + 1] ) );
+                            i++;
+                            break;
+                            
+                        case 'A' :
+                        case 'B' :
+                        case 'C' :
+                        case 'D' :
+                        case 'E' :
+                        case 'F' :
+                            bytes[pos++] = ( byte ) ( ( ( byte ) ( array[i] - 'A' + 10 ) << 4 ) + toByte( array[i + 1] ) );
+                            i++;
+                            break;
+                            
+                        default :
+                            break;
+                    }
+                    
+                    escapeSeen = false;
+                }
+                else
+                {
+                    // We might have a UTF-8 char
+                    if ( ( c & 0x007F ) == c )
+                    {
+                        // Single byte char
+                        bytes[pos++] = ( byte ) c;
+                    }
+                    else if ( ( c & 0x07FF ) == c )
+                    {
+                        bytes[pos++] = ( byte ) ( 0x00C0 | ( c >> 6 ) );
+                        bytes[pos++] = ( byte ) ( 0x0080 | ( c & 0x003F ) );
+                    }
+                    else
+                    {
+                        bytes[pos++] = ( byte ) ( 0x00E0 | ( c >> 12 ) );
+                        bytes[pos++] = ( byte ) ( 0x0080 | ( ( c >> 6 ) & 0x3F ) );
+                        bytes[pos++] = ( byte ) ( 0x0080 | ( c & 0x003F ) );
+                    }
+                }
+            }
+        }
+        
+        // Deal with the special case where we have one single escape
+        if ( escapeSeen )
+        {
+            bytes[pos++] = '\\';
+        }
+        
+        String result = Strings.utf8ToString( bytes, pos );
+        
+        return result;
+    }
+    
+    
+    private static byte toByte( char c )
+    {
+        switch ( c )
+        {
+            case '0' :
+            case '1' :
+            case '2' :
+            case '3' :
+            case '4' :
+            case '5' :
+            case '6' :
+            case '7' :
+            case '8' :
+            case '9' :
+                return ( byte ) ( c - '0' );
+                
+            case 'a' :
+            case 'b' :
+            case 'c' :
+            case 'd' :
+            case 'e' :
+            case 'f' :
+                return ( byte ) ( c - 'a' + 10 );
+                
+            case 'A' :
+            case 'B' :
+            case 'C' :
+            case 'D' :
+            case 'E' :
+            case 'F' :
+                return ( byte ) ( c - 'A' + 10 );
+                
+            default :
+                break;
+        }
+        
+        return 0;
     }
 }

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/name/AvaSerializationTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/name/AvaSerializationTest.java?rev=1708486&r1=1708485&r2=1708486&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/name/AvaSerializationTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/name/AvaSerializationTest.java Tue Oct 13 18:56:51 2015
@@ -146,7 +146,7 @@ public class AvaSerializationTest
         catch ( IOException ioe )
         {
             String message = ioe.getMessage();
-            assertEquals( "Cannot serialize an wrong ATAV, the upValue should not be null", message );
+            assertEquals( "Cannot serialize a wrong ATAV, the value should not be null", message );
         }
     }
 
@@ -167,7 +167,7 @@ public class AvaSerializationTest
         catch ( IOException ioe )
         {
             String message = ioe.getMessage();
-            assertEquals( "Cannot serialize an wrong ATAV, the upValue should not be null", message );
+            assertEquals( "Cannot serialize a wrong ATAV, the value should not be null", message );
         }
     }
 
@@ -308,7 +308,7 @@ public class AvaSerializationTest
         catch ( IOException ioe )
         {
             String message = ioe.getMessage();
-            assertEquals( "Cannot serialize an wrong ATAV, the upValue should not be null", message );
+            assertEquals( "Cannot serialize a wrong ATAV, the value should not be null", message );
         }
     }
 

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/name/DnParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/name/DnParserTest.java?rev=1708486&r1=1708485&r2=1708486&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/name/DnParserTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/name/DnParserTest.java Tue Oct 13 18:56:51 2015
@@ -579,7 +579,7 @@ public class DnParserTest
     public void testAUmlautPlusBytes() throws Exception
     {
         String cn = new String( new byte[]
-            { 'c', 'n', '=', ( byte ) 0xC3, ( byte ) 0x84, 0x5C, 0x32, 0x42 }, "UTF-8" );
+            { 'c', 'n', '=', ( byte ) 0xC3, ( byte ) 0x84, '\\', '2', 'B' }, "UTF-8" );
 
         Dn dn = new Dn( cn );
 
@@ -664,7 +664,7 @@ public class DnParserTest
                 
                 Dn dn = new Dn( dnStr );
                 Rdn rdn = dn.getRdn();
-                assertEquals( value, rdn.getValue().getString() );
+                assertEquals( value, rdn.getValue() );
             }
             catch ( Exception e )
             {
@@ -679,7 +679,7 @@ public class DnParserTest
             
             Dn dn = new Dn( dnStr );
             Rdn rdn = dn.getRdn();
-            assertEquals( "2#", rdn.getValue().getString() );
+            assertEquals( "2#", rdn.getValue() );
         }
         catch ( Exception e )
         {

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/name/FastDnParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/name/FastDnParserTest.java?rev=1708486&r1=1708485&r2=1708486&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/name/FastDnParserTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/name/FastDnParserTest.java Tue Oct 13 18:56:51 2015
@@ -175,7 +175,7 @@ public class FastDnParserTest
         assertEquals( "a", dn.getRdn().getAva().getType() );
         assertEquals( "a", dn.getRdn().getAva().getNormType() );
         assertEquals( "b", dn.getRdn().getAva().getValue().getValue() );
-        assertEquals( "b", dn.getRdn().getAva().getNormValue().getValue() );
+        assertEquals( "b", dn.getRdn().getAva().getValue().getNormValue() );
     }
 
 

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/name/RdnTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/name/RdnTest.java?rev=1708486&r1=1708485&r2=1708486&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/name/RdnTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/name/RdnTest.java Tue Oct 13 18:56:51 2015
@@ -268,8 +268,10 @@ public class RdnTest
     @Test
     public void testRdnQuotedAttributeValue() throws LdapException
     {
-        assertEquals( "a=quoted \\\"value", new Rdn( "a = quoted \\\"value" ).getNormName() );
-        assertEquals( "quoted \"value", new Rdn( "a = quoted \\\"value" ).getValue( "a" ) );
+        Rdn rdn = new Rdn( "a = quoted \\\"value" );
+        assertEquals( "a=quoted \\\"value", rdn.getNormName() );
+        assertEquals( "quoted \\\"value", rdn.getValue( "a" ) );
+        assertEquals( "quoted \"value", rdn.getNormValue( "a" ) );
     }
 
 
@@ -605,7 +607,7 @@ public class RdnTest
     {
         Rdn rdn = new Rdn( " a = b + b = f + g = h + c = d " );
 
-        assertEquals( "b", rdn.getNormValue().getString() );
+        assertEquals( "b", rdn.getNormValue() );
     }
 
 
@@ -860,7 +862,7 @@ public class RdnTest
         assertEquals( "cn=a b c", rdn2.getNormName() );
         assertTrue( rdn1.equals( rdn2 ) );
 
-        Rdn rdn3 = new Rdn( "cn=\\ a b c\\ " );
+        Rdn rdn3 = new Rdn( "cn= \\ a b c\\  " );
         Rdn rdn4 = new Rdn( "cn=\\ a\\ b\\ c\\ " );
         assertEquals( "cn=\\ a b c\\ ", rdn3.getNormName() );
         assertEquals( "cn=\\ a b c\\ ", rdn4.getNormName() );
@@ -1154,7 +1156,7 @@ public class RdnTest
         assertTrue( Rdn.isValid( "a=\"b\\,c\"" ) );
         Rdn rdn = new Rdn( "a=\"b\\,c\"" );
         assertEquals( "a=\"b\\,c\"", rdn.getName() );
-        assertEquals( "a=b\\,c", rdn.getNormName() );
+        assertEquals( "a=b\\\\\\,c", rdn.getNormName() );
     }
 
 
@@ -1253,8 +1255,8 @@ public class RdnTest
         assertEquals( "CN=\u00E4+A=d", rdn.getName() );
         assertEquals( "cn=\u00E4+a=d", rdn.getNormName() );
         assertEquals( "\u00E4", rdn.getValue( "CN" ) );
-        assertEquals( "\u00E4", rdn.getValue().getValue() );
-        assertEquals( "\u00E4", rdn.getNormValue().getValue() );
+        assertEquals( "\u00E4", rdn.getValue() );
+        assertEquals( "\u00E4", rdn.getValue() );
         assertEquals( "CN", rdn.getType() );
         assertEquals( "cn", rdn.getNormType() );
     }

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/normalizers/DeepTrimNormalizerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/normalizers/DeepTrimNormalizerTest.java?rev=1708486&r1=1708485&r2=1708486&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/normalizers/DeepTrimNormalizerTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/normalizers/DeepTrimNormalizerTest.java Tue Oct 13 18:56:51 2015
@@ -113,7 +113,11 @@ public class DeepTrimNormalizerTest
             { ' ', 0x0310 };
         char[] expected = new char[]
             { ' ', 0x0310 };
-        assertEquals( new String( expected ), normalizer.normalize( new String( chars ) ) );
+        //assertEquals( new String( expected ), normalizer.normalize( new String( chars ) ) );
+        
+        String expectedStr = new String( expected );
+        String charsStr = new String( chars );
+        assertEquals( expectedStr, normalizer.normalize( charsStr ) );
     }
 
 
@@ -152,8 +156,10 @@ public class DeepTrimNormalizerTest
         char[] chars = new char[]
             { ' ', 0x0310, 'a', 'a', ' ', ' ', 0x0311, ' ', ' ', 'a', 0x0311, 0x0312 };
         char[] expected = new char[]
-            { ' ', 0x0310, 'a', 'a', ' ', ' ', 0x0311, ' ', 'a', 0x0311, 0x0312 };
-        assertEquals( new String( expected ), normalizer.normalize( new String( chars ) ) );
+            { ' ', 0x0310, 'a', 'a', ' ', 0x0311, ' ', 'a', 0x0311, 0x0312 };
+        String expectedStr = new String( expected );
+        String charsStr = new String( chars );
+        assertEquals( expectedStr, normalizer.normalize( charsStr ) );
     }
 
 

Modified: directory/shared/trunk/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolCodecFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolCodecFactory.java?rev=1708486&r1=1708485&r2=1708486&view=diff
==============================================================================
--- directory/shared/trunk/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolCodecFactory.java (original)
+++ directory/shared/trunk/ldap/net/mina/src/main/java/org/apache/directory/api/ldap/codec/protocol/mina/LdapProtocolCodecFactory.java Tue Oct 13 18:56:51 2015
@@ -44,17 +44,34 @@ public class LdapProtocolCodecFactory im
     /** The LdapEncoder key */
     public static final String LDAP_ENCODER = "LDAP_ENCODER";
 
-    private LdapApiService ldapApiService;
+    /** The statefull LDAP decoder */
+    private LdapProtocolDecoder ldapDecoder;
+
+    /** The statefull LDAP edcoder */
+    private LdapProtocolEncoder ldapEncoder;
+    
     
+    /**
+     * Creates a new instance of LdapProtocolCodecFactory.
+     */
     public LdapProtocolCodecFactory() 
     {
         this( LdapApiServiceFactory.getSingleton() );
     }
 
+    
+    /**
+     * 
+     * Creates a new instance of LdapProtocolCodecFactory.
+     *
+     * @param ldapApiService The associated LdapApiService instance
+     */
     public LdapProtocolCodecFactory( LdapApiService ldapApiService ) 
     {
-        this.ldapApiService = ldapApiService;
+        ldapDecoder = new LdapProtocolDecoder();
+        ldapEncoder = new LdapProtocolEncoder( ldapApiService );
     }
+    
 
     /**
      * Get the LDAP decoder.
@@ -64,7 +81,7 @@ public class LdapProtocolCodecFactory im
      */
     public ProtocolDecoder getDecoder( IoSession session )
     {
-        return new LdapProtocolDecoder();
+        return ldapDecoder;
     }
 
 
@@ -76,6 +93,6 @@ public class LdapProtocolCodecFactory im
      */
     public ProtocolEncoder getEncoder( IoSession session )
     {
-        return new LdapProtocolEncoder( ldapApiService );
+        return ldapEncoder;
     }
 }



Mime
View raw message