directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1075330 [3/3] - in /directory/shared/branches/akarasulu: ./ all/ dsml-parser/ dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/ dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/ dsml-parser/src/main/java/org...
Date Mon, 28 Feb 2011 13:57:12 GMT
Modified: directory/shared/branches/akarasulu/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java?rev=1075330&r1=1075329&r2=1075330&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
(original)
+++ directory/shared/branches/akarasulu/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
Mon Feb 28 13:57:08 2011
@@ -22,10 +22,10 @@ package org.apache.directory.shared.ldap
 
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.commons.collections.list.UnmodifiableList;
 import org.apache.directory.shared.i18n.I18n;
@@ -80,7 +80,7 @@ public final class Dn implements Iterabl
     public static final int EQUAL = 0;
 
     /** A flag used to tell if the Dn has been normalized */
-    private AtomicBoolean normalized;
+    private boolean normalized;
 
     /**
      *  The RDNs that are elements of the Dn
@@ -174,41 +174,7 @@ public final class Dn implements Iterabl
         this.schemaManager = schemaManager;
         upName = "";
         normName = "";
-        normalized = new AtomicBoolean( true );
-    }
-
-
-    /**
-     * Creates a new Schema aware DN from the given String
-     *
-     * @param schemaManager the schema manager (optional)
-     * @param upName The String that contains the Dn
-     * @throws LdapInvalidNameException if the String does not contain a valid Dn.
-     *
-    public Dn( SchemaManager schemaManager, String upName ) throws LdapInvalidDnException
-    {
-        if ( upName != null )
-        {
-            DnParser.parseInternal( upName, rdns );
-        }
-
-        normalized = new AtomicBoolean();
-
-        if ( schemaManager != null )
-        {
-            this.schemaManager = schemaManager;
-            normalize( schemaManager.getNormalizerMapping() );
-        }
-        else
-        {
-            normalized.set( false );
-
-            // Stores the representations of a Dn : internal (as a string and as a
-            // byte[]) and external.
-            normalizeInternal();
-        }
-
-        this.upName = upName;
+        normalized = true;
     }
 
 
@@ -306,8 +272,6 @@ public final class Dn implements Iterabl
             throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, I18n.err(
I18n.ERR_04202 ) );
         }
 
-        normalized = new AtomicBoolean();
-
         // Stores the representations of a Dn : internal (as a string and as a
         // byte[]) and external.
         upName = sb.toString();
@@ -320,7 +284,7 @@ public final class Dn implements Iterabl
         }
         else
         {
-            normalized.set( false );
+            normalized = false;
             normalizeInternal();
         }
     }
@@ -334,12 +298,14 @@ public final class Dn implements Iterabl
      * @param normName the normalized name
      * @param bytes the name as a byte[]
      */
-    Dn(String upName, String normName, byte[] bytes)
+    Dn( SchemaManager schemaManager, String upName, String normName, Rdn... rdns )
     {
-        normalized = new AtomicBoolean( true );
+        this.schemaManager = schemaManager;
+        normalized = schemaManager != null;
         this.upName = upName;
         this.normName = normName;
-        this.bytes = bytes;
+        bytes = Strings.getBytesUtf8( upName );
+        this.rdns = Arrays.asList( rdns );
     }
 
 
@@ -362,7 +328,7 @@ public final class Dn implements Iterabl
 
         normalizeInternal();
         toUpName();
-        normalized = new AtomicBoolean( false );
+        normalized = false;
     }
 
 
@@ -385,7 +351,6 @@ public final class Dn implements Iterabl
         
         rdns.add( rdn );
         
-        normalized = new AtomicBoolean();
         schemaManager = dn.schemaManager;
 
         if ( schemaManager != null )
@@ -394,7 +359,7 @@ public final class Dn implements Iterabl
         }
         else
         {
-            normalized.set( false );
+            normalized = false;
 
             // Stores the representations of a Dn : internal (as a string and as a
             // byte[]) and external.
@@ -422,7 +387,6 @@ public final class Dn implements Iterabl
             rdns.add( rdnParent );
         }
         
-        normalized = new AtomicBoolean();
         this.schemaManager = schemaManager;
 
         if ( schemaManager != null )
@@ -431,7 +395,7 @@ public final class Dn implements Iterabl
         }
         else
         {
-            normalized.set( false );
+            normalized = false;
 
             // Stores the representations of a Dn : internal (as a string and as a
             // byte[]) and external.
@@ -462,7 +426,7 @@ public final class Dn implements Iterabl
 
         try
         {
-            normalized = new AtomicBoolean( false );
+            normalized = false;
             
             if ( this.schemaManager != null )
             {
@@ -510,7 +474,7 @@ public final class Dn implements Iterabl
         }
 
         newDn.normalizeInternal();
-        newDn.normalized.set( true );
+        newDn.normalized = true;
 
         return newDn;
     }
@@ -1096,7 +1060,7 @@ public final class Dn implements Iterabl
 
         newDn.toUpName();
         newDn.toNormName();
-        newDn.normalized.set( normalized.get() );
+        newDn.normalized = normalized;
 
         return newDn;
     }
@@ -1178,7 +1142,7 @@ public final class Dn implements Iterabl
 
         newDn.toUpName();
         newDn.toNormName();
-        newDn.normalized.set( normalized.get() );
+        newDn.normalized = normalized;
 
         return newDn;
     }
@@ -1317,7 +1281,7 @@ public final class Dn implements Iterabl
             else
             {
                 clonedDn.normalizeInternal();
-                clonedDn.normalized.set( false );
+                clonedDn.normalized = false;
             }
 
             clonedDn.toUpName();
@@ -1351,7 +1315,7 @@ public final class Dn implements Iterabl
         else
         {
             clonedDn.normalizeInternal();
-            clonedDn.normalized.set( false );
+            clonedDn.normalized = false;
         }
 
         clonedDn.toUpName();
@@ -1372,7 +1336,7 @@ public final class Dn implements Iterabl
         Dn clonedDn = copy();
 
         clonedDn.rdns.add( 0, newRdn.clone() );
-        clonedDn.normalized.getAndSet( false );
+        clonedDn.normalized = false;
 
         // FIXME this try-catch block shouldn't be here
         // instead this method should throw the LdapInvalidDnException
@@ -1391,7 +1355,7 @@ public final class Dn implements Iterabl
                 else
                 {
                     clonedDn.normalizeInternal();
-                    clonedDn.normalized.set( false );
+                    clonedDn.normalized = false;
                 }
             }
         }
@@ -1461,7 +1425,7 @@ public final class Dn implements Iterabl
 
         newDn.normName = newDn.toNormName();
         newDn.upName = getUpNamePrefix( posn );
-        newDn.normalized.set( normalized.get() );
+        newDn.normalized = normalized;
 
         return newDn;
     }
@@ -1474,7 +1438,7 @@ public final class Dn implements Iterabl
     private Dn copy()
     {
         Dn dn = new Dn( schemaManager );
-        dn.normalized = new AtomicBoolean( normalized.get() );
+        dn.normalized = normalized;
         dn.rdns = new ArrayList<Rdn>();
 
         for ( Rdn rdn : rdns )
@@ -1596,7 +1560,7 @@ public final class Dn implements Iterabl
         for ( Ava val : rdnCopy )
         {
             Ava newAtav = atavOidToName( val, oidsMap );
-            rdn.addAVA( newAtav );
+            rdn.addAVA( null, newAtav );
         }
     }
 
@@ -1619,7 +1583,7 @@ public final class Dn implements Iterabl
 
         if ( this.schemaManager != null )
         {
-            if ( normalized.get() )
+            if ( normalized )
             {
                 return this;
             }
@@ -1628,7 +1592,7 @@ public final class Dn implements Iterabl
             {
                 if ( size() == 0 )
                 {
-                    normalized.set( true );
+                    normalized = true;
                     return this;
                 }
 
@@ -1639,7 +1603,7 @@ public final class Dn implements Iterabl
 
                 normalizeInternal();
 
-                normalized.set( true );
+                normalized = true;
 
                 return this;
             }
@@ -1671,7 +1635,7 @@ public final class Dn implements Iterabl
      */
     public boolean isNormalized()
     {
-        return normalized.get();
+        return normalized;
     }
 
 

Modified: directory/shared/branches/akarasulu/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/DnSerializer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/DnSerializer.java?rev=1075330&r1=1075329&r2=1075330&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/DnSerializer.java
(original)
+++ directory/shared/branches/akarasulu/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/DnSerializer.java
Mon Feb 28 13:57:08 2011
@@ -27,8 +27,8 @@ import java.io.ObjectInputStream;
 import java.io.ObjectOutput;
 import java.io.ObjectOutputStream;
 
-import org.apache.directory.shared.i18n.I18n;
-import org.apache.directory.shared.util.Strings;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.util.Unicode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -112,22 +112,13 @@ public final class DnSerializer
         Unicode.writeUTF(out, dn.getName());
 
         // Write the NormName if different
-        if ( dn.isNormalized() )
+        if ( dn.getName().equals( dn.getNormName() ) )
         {
-            if ( dn.getName().equals( dn.getNormName() ) )
-            {
-                Unicode.writeUTF(out, "");
-            }
-            else
-            {
-                Unicode.writeUTF(out, dn.getNormName());
-            }
+            Unicode.writeUTF(out, "");
         }
         else
         {
-            String message = I18n.err( I18n.ERR_04212, dn );
-            LOG.error( message );
-            throw new IOException( message );
+            Unicode.writeUTF(out, dn.getNormName());
         }
 
         // Should we store the byte[] ???
@@ -155,12 +146,13 @@ public final class DnSerializer
      * @return a deserialized Dn
      * @throws IOException If the stream can't be read
      */
-    public static Dn deserialize( byte[] bytes ) throws IOException
+    public static Dn deserialize( SchemaManager schemaManager, byte[] bytes ) 
+        throws IOException, LdapInvalidDnException
     {
         ByteArrayInputStream bais = new ByteArrayInputStream( bytes );
         ObjectInputStream in = new ObjectInputStream( bais );
     
-        return deserialize( in );
+        return deserialize( schemaManager, in );
     }
     
 
@@ -171,11 +163,13 @@ public final class DnSerializer
      * read is exposed in the {@link DnSerializer#serialize(Dn, ObjectOutput)}
      * method<p>
      *
+     * @param schemaManager The SchemaManager (can be null)
      * @param in The input stream from which the Dn is read
      * @return a deserialized Dn
      * @throws IOException If the stream can't be read
      */
-    public static Dn deserialize( ObjectInput in ) throws IOException
+    public static Dn deserialize( SchemaManager schemaManager, ObjectInput in ) 
+        throws IOException, LdapInvalidDnException
     {
         // Read the UPName
         String upName = Unicode.readUTF(in);
@@ -191,19 +185,19 @@ public final class DnSerializer
             normName = upName;
         }
 
-        // Should we read the byte[] ???
-        byte[] bytes = Strings.getBytesUtf8(upName);
-
         // Read the RDNs. Is it's null, the number will be -1.
         int nbRdns = in.readInt();
-        Dn dn = new Dn( upName, normName, bytes );
-
+        
+        Rdn[] rdns = new Rdn[nbRdns];
+        
         for ( int i = 0; i < nbRdns; i++ )
         {
-            Rdn rdn = RdnSerializer.deserialize( in );
-            dn = dn.addInternal( 0, rdn );
+            Rdn rdn = RdnSerializer.deserialize( schemaManager, in );
+            rdns[i] = rdn;
         }
 
+        Dn dn = new Dn( schemaManager, upName, normName, rdns );
+        
         return dn;
     }
 }

Modified: directory/shared/branches/akarasulu/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/FastDnParser.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/FastDnParser.java?rev=1075330&r1=1075329&r2=1075330&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/FastDnParser.java
(original)
+++ directory/shared/branches/akarasulu/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/FastDnParser.java
Mon Feb 28 13:57:08 2011
@@ -179,7 +179,7 @@ public enum FastDnParser
 
         Ava ava = new Ava( type, type, new StringValue( upValue ),
             new StringValue( value ), upName );
-        rdn.addAVA( ava );
+        rdn.addAVA( null, ava );
 
         rdn.setUpName( upName );
         rdn.normalize();

Modified: directory/shared/branches/akarasulu/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java?rev=1075330&r1=1075329&r2=1075330&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java
(original)
+++ directory/shared/branches/akarasulu/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java
Mon Feb 28 13:57:08 2011
@@ -25,6 +25,7 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
@@ -284,7 +285,7 @@ public final class Rdn implements Clonea
     {
         this.schemaManager = schemaManager;
 
-        addAVA( upType, normType, new StringValue( upValue ), new StringValue( normValue
) );
+        addAVA( schemaManager, upType, normType, new StringValue( upValue ), new StringValue(
normValue ) );
 
         upName = upType + '=' + upValue;
 
@@ -332,7 +333,7 @@ public final class Rdn implements Clonea
      */
     public Rdn( SchemaManager schemaManager, String upType, String upValue ) throws LdapInvalidDnException
     {
-        addAVA( upType, upType, new StringValue( upValue ), new StringValue( upValue ) );
+        addAVA( schemaManager, upType, upType, new StringValue( upValue ), new StringValue(
upValue ) );
 
         upName = upType + '=' + upValue;
 
@@ -368,28 +369,12 @@ public final class Rdn implements Clonea
 
 
     /**
-     * A constructor that constructs a Rdn from a type, a position and a length.
-     *
-     * @param start the starting point for this Rdn in the user provided Dn
-     * @param length the Rdn's length
-     * @param upName the user provided name
-     * @param normName the normalized name
-     */
-    Rdn(int start, int length, String upName, String normName)
-    {
-        this.upName = upName;
-        this.normName = normName;
-        normalized = true;
-    }
-
-
-    /**
      * Constructs an Rdn from the given rdn. The contents of the rdn are simply
      * copied into the newly created
      *
      * @param rdn The non-null Rdn to be copied.
      */
-    public Rdn(Rdn rdn)
+    public Rdn( Rdn rdn )
     {
         nbAtavs = rdn.getNbAtavs();
         this.normName = rdn.normName;
@@ -505,6 +490,43 @@ public final class Rdn implements Clonea
             return this;
         }
     }
+    
+    
+    /* no qualifier */ Rdn( SchemaManager schemaManager, String upName, String normName,
Ava... atavs )
+    {
+        this.upName = upName;
+        this.normName = normName;
+        this.schemaManager = schemaManager;
+        this.normalized = (schemaManager != null );
+        
+        if ( atavs != null )
+        {
+            nbAtavs = atavs.length;
+            
+            switch ( nbAtavs )
+            {
+                case 0 :
+                    break;
+                    
+                case 1 :
+                    atav = atavs[ 0 ];
+                    atavTypes.put( atav.getUpType(), atav );
+                    atavTypes.put( atav.getNormType(), atav );
+                    break;
+                    
+                default :
+                    this.atavs = Arrays.asList( atavs );
+                    
+                    for ( Ava ava : atavs )
+                    {
+                        atavTypes.put( ava.getUpType(), ava );
+                        atavTypes.put( ava.getNormType(), ava );
+                    }
+                    
+                    break;
+            }
+        }
+    }
 
 
     /**
@@ -517,20 +539,19 @@ public final class Rdn implements Clonea
      * @throws LdapInvalidDnException
      *             If the Rdn is 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 */void addAVA( String upType, String type, Value<?> upValue,
+    private void addAVA( SchemaManager schemaManager, String upType, String type, Value<?>
upValue,
         Value<?> value ) throws LdapInvalidDnException
     {
         // First, let's normalize the type
         Value<?> normalizedValue = value;
         String normalizedType = Strings.lowerCaseAscii(type);
+        this.schemaManager = schemaManager;
 
-        if( schemaManager != null )
+        if ( schemaManager != null )
         {
             OidNormalizer oidNormalizer = schemaManager.getNormalizerMapping().get( normalizedType
);
             normalizedType = oidNormalizer.getAttributeTypeOid();
+            
             try
             {
                 normalizedValue = oidNormalizer.getNormalizer().normalize( value );
@@ -545,7 +566,7 @@ public final class Rdn implements Clonea
         {
             case 0:
                 // This is the first AttributeTypeAndValue. Just stores it.
-                atav = new Ava( upType, normalizedType, upValue, normalizedValue );
+                atav = new Ava( schemaManager, upType, normalizedType, upValue, normalizedValue
);
                 nbAtavs = 1;
                 atavType = normalizedType;
                 return;
@@ -568,7 +589,7 @@ public final class Rdn implements Clonea
 
             default:
                 // add a new AttributeTypeAndValue
-                Ava newAtav = new Ava( upType, normalizedType, upValue, normalizedValue );
+                Ava newAtav = new Ava( schemaManager, upType, normalizedType, upValue, normalizedValue
);
                 atavs.add( newAtav );
                 atavTypes.put( normalizedType, newAtav );
 
@@ -587,8 +608,9 @@ public final class Rdn implements Clonea
     // 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 */void addAVA( Ava value )
+    /* Unspecified protection */void addAVA( SchemaManager schemaManager, Ava value )
     {
+        this.schemaManager = schemaManager;
         String normalizedType = value.getNormType();
 
         switch ( nbAtavs )
@@ -623,7 +645,6 @@ public final class Rdn implements Clonea
 
                 nbAtavs++;
                 break;
-
         }
     }
 
@@ -1551,6 +1572,17 @@ public final class Rdn implements Clonea
                 break;
         }
     }
+    
+    
+    /**
+     * Get the associated SchemaManager if any.
+     * 
+     * @return The SchemaManager
+     */
+    public SchemaManager getSchemaManager()
+    {
+        return schemaManager;
+    }
 
 
     /**
@@ -1560,5 +1592,4 @@ public final class Rdn implements Clonea
     {
         return upName == null ? "" : upName;
     }
-
 }

Modified: directory/shared/branches/akarasulu/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/RdnSerializer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/RdnSerializer.java?rev=1075330&r1=1075329&r2=1075330&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/RdnSerializer.java
(original)
+++ directory/shared/branches/akarasulu/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/RdnSerializer.java
Mon Feb 28 13:57:08 2011
@@ -23,6 +23,8 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.util.Strings;
 import org.apache.directory.shared.util.Unicode;
 import org.slf4j.Logger;
@@ -54,17 +56,15 @@ public final class RdnSerializer
      * We should write all those ATAVs sequencially, following the 
      * structure :
      * 
-     * <li>nbAtavs</li> The number of ATAVs to write. Can't be 0.
-     * <li>upName</li> The User provided Rdn
-     * <li>normName</li> The normalized Rdn. It can be empty if the normalized
-     * name equals the upName.
+     * <li>nbAtavs : The number of ATAVs to write. Can't be 0.</li>
+     * <li>upName< : The User provided Rdn</li>
+     * <li>normName : The normalized Rdn. It can be empty if the normalized
+     * name equals the upName.</li>
      * <li>atavs</li>
      * <p>
      * For each ATAV :<p>
-     * <li>start</li> The position of this ATAV in the upName string
-     * <li>length</li> The ATAV user provided length
-     * <li>Call the ATAV write method</li> The ATAV itself
-     *  
+     * <li>Call the ATAV write method :The ATAV itself</li>
+     * <br/>
      * @param rdn The Rdn to serialize
      * @param out the stream in which the Rdn will be serialized
      * @throws IOException If we can't write in this stream
@@ -94,15 +94,17 @@ public final class RdnSerializer
     /**
      * Deserialize a Rdn instance
      * 
-     * We read back the data to create a new RDB. The structure 
+     * We read back the data to create a new Rdn. The structure 
      * read is exposed in the {@link Rdn#writeExternal(ObjectOutput)}
      * method<p>
      * 
+     * @param schemaManager The SchemaManager (can be null)
      * @param in The input stream from which the Rdn is read
      * @return a deserialized Rdn
      * @throws IOException If the stream can't be read
      */
-    public static Rdn deserialize( ObjectInput in ) throws IOException
+    public static Rdn deserialize( SchemaManager schemaManager, ObjectInput in )
+        throws IOException, LdapInvalidDnException
     {
         // Read the ATAV number
         int nbAtavs = in.readInt();
@@ -118,30 +120,33 @@ public final class RdnSerializer
             normName = upName;
         }
         
-        // Now creates the Rdn
-        Rdn rdn = new Rdn( 0, 0, upName, normName );
+        Rdn rdn = null;
 
         // Read through the Atavs
         switch ( nbAtavs )
         {
             case 0 :
-                return rdn;
+                rdn = new Rdn( schemaManager, upName, normName, (Ava[])null );
+                break;
                 
             case 1 :
-                Ava atav = AvaSerializer.deserialize(in);
+                Ava ava = AvaSerializer.deserialize( schemaManager, in );
                 
-                rdn.addAVA( atav );
-
-                return rdn;
+                rdn = new Rdn( schemaManager, upName, normName, ava );
+                break;
                 
             default :
+                Ava[] avas = new Ava[nbAtavs];
+                
                 for ( int i = 0; i < nbAtavs; i++  )
                 {
-                    atav = AvaSerializer.deserialize(in);
-                    rdn.addAVA( atav );
+                    ava = AvaSerializer.deserialize( schemaManager, in );
+                    avas[i] = ava;
                 }
-            
-                return rdn;
+
+                rdn = new Rdn( schemaManager, upName, normName, avas );
         }
+
+        return rdn;
     }
 }

Modified: directory/shared/branches/akarasulu/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java?rev=1075330&r1=1075329&r2=1075330&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java
(original)
+++ directory/shared/branches/akarasulu/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java
Mon Feb 28 13:57:08 2011
@@ -32,6 +32,8 @@ import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
 import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.util.Strings;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -49,8 +51,9 @@ import com.mycila.junit.concurrent.Concu
 @Concurrency()
 public class AvaTest
 {
-    // ~ Methods
-    // ------------------------------------------------------------------------------------
+    /** A null schemaManager used in tests */
+    SchemaManager schemaManager = null;
+    
     /**
      * Test a null AttributeTypeAndValue
      */
@@ -71,7 +74,7 @@ public class AvaTest
     {
         try
         {
-            new Ava( null, null, (String)null, (String)null );
+            new Ava( schemaManager, null, (String)null );
             fail();
         }
         catch ( LdapException ine )
@@ -89,7 +92,7 @@ public class AvaTest
     {
         try
         {
-            new Ava( "  ", " ", (String)null, (String)null );
+            new Ava( schemaManager, "  ", (String)null );
             fail();
         }
         catch ( LdapException ine )
@@ -105,26 +108,25 @@ public class AvaTest
     @Test
     public void testAttributeTypeAndValueValidType() throws LdapException
     {
-        Ava atav = new Ava( "A", "a", (String)null, (String)null );
+        Ava atav = new Ava( schemaManager, "A", (String)null );
         assertEquals( "A=", atav.toString() );
         assertEquals( "a=", atav.getNormName() );
         assertEquals( "A=", atav.getUpName() );
         
-        atav = new Ava( "  A  ", "a", (String)null, (String)null );
+        atav = new Ava( schemaManager, "  A  ", (String)null );
         assertEquals( "a=", atav.getNormName() );
         assertEquals( "  A  =", atav.toString() );
         assertEquals( "  A  =", atav.getUpName() );
         
-        atav = new Ava( "  A  ", null, (String)null, (String)null );
-        assertEquals( "a=", atav.getNormName() );
-        assertEquals( "  A  =", atav.toString() );
-        assertEquals( "  A  =", atav.getUpName() );
-        
-        atav = new Ava( null, "a", (String)null, (String)null );
-        assertEquals( "a=", atav.getNormName() );
-        assertEquals( "a=", atav.toString() );
-        assertEquals( "a=", atav.getUpName() );
-        
+        try
+        {
+            atav = new Ava( schemaManager, null, (String)null );
+            fail();
+        }
+        catch ( LdapInvalidDnException lide )
+        {
+            assertTrue( true );
+        }
     }
 
     /**
@@ -135,7 +137,7 @@ public class AvaTest
     {
         try
         {
-            new Ava( "", "", "", "" );
+            new Ava( schemaManager, "", "" );
             fail( "Should not occurs ... " );
         }
         catch ( LdapException ine )
@@ -151,7 +153,7 @@ public class AvaTest
     @Test
     public void testLdapRDNSimple() throws LdapException
     {
-        Ava atav = new Ava( "a", "a", "b", "b" );
+        Ava atav = new Ava( schemaManager, "a", "b" );
         assertEquals( "a=b", atav.toString() );
         assertEquals( "a=b", atav.getUpName() );
     }
@@ -163,8 +165,8 @@ public class AvaTest
     @Test
     public void testCompareToEquals() throws LdapException
     {
-        Ava atav1 = new Ava( "a", "a","b", "b" );
-        Ava atav2 = new Ava( "a", "a","b", "b" );
+        Ava atav1 = new Ava( schemaManager, "a", "b" );
+        Ava atav2 = new Ava( schemaManager, "a", "b" );
 
         assertTrue( atav1.equals( atav2 ) );
     }
@@ -176,8 +178,8 @@ public class AvaTest
     @Test
     public void testCompareToEqualsCase() throws LdapException
     {
-        Ava atav1 = new Ava( "a", "a", "b", "b" );
-        Ava atav2 = new Ava( "A", "A", "b", "b" );
+        Ava atav1 = new Ava( schemaManager, "a", "b" );
+        Ava atav2 = new Ava( schemaManager, "A", "b" );
 
         assertTrue( atav1.equals( atav2 ) );
     }
@@ -190,9 +192,9 @@ public class AvaTest
     @Test
     public void testCompareAtav1TypeSuperior() throws LdapException
     {
-        Ava atav1 = new Ava( "b", "b", "b", "b" );
+        Ava atav1 = new Ava( schemaManager, "b", "b" );
             
-        Ava atav2 = new Ava( "a", "a", "b", "b" );
+        Ava atav2 = new Ava( schemaManager, "a", "b" );
 
         assertFalse( atav1.equals( atav2 ) );
     }
@@ -205,8 +207,8 @@ public class AvaTest
     @Test
     public void testCompareAtav2TypeSuperior() throws LdapException
     {
-        Ava atav1 = new Ava( "a", "a", "b", "b" );
-        Ava atav2 = new Ava( "b", "b", "b", "b" );
+        Ava atav1 = new Ava( schemaManager, "a", "b" );
+        Ava atav2 = new Ava( schemaManager, "b", "b" );
 
         assertFalse( atav1.equals( atav2 ) );
     }
@@ -219,8 +221,8 @@ public class AvaTest
     @Test
     public void testCompareAtav1ValueSuperior() throws LdapException
     {
-        Ava atav1 = new Ava( "a", "a", "b", "b" );
-        Ava atav2 = new Ava( "a", "a", "a", "a" );
+        Ava atav1 = new Ava( schemaManager, "a", "b" );
+        Ava atav2 = new Ava( schemaManager, "a", "a" );
 
         assertFalse( atav1.equals( atav2 ) );
     }
@@ -233,8 +235,8 @@ public class AvaTest
     @Test
     public void testCompareAtav2ValueSuperior() throws LdapException
     {
-        Ava atav1 = new Ava( "a", "a", "a", "a" );
-        Ava atav2 = new Ava( "a", "a", "b", "b" );
+        Ava atav1 = new Ava( schemaManager, "a", "a" );
+        Ava atav2 = new Ava( schemaManager, "a", "b" );
 
         assertFalse( atav1.equals( atav2 ) );
     }
@@ -243,7 +245,7 @@ public class AvaTest
     @Test
     public void testNormalize() throws LdapException
     {
-        Ava atav = new Ava( " A ", " A ", "a", "a" );
+        Ava atav = new Ava( schemaManager, " A ", "a" );
 
         assertEquals( "a=a", atav.normalize() );
 
@@ -258,7 +260,7 @@ public class AvaTest
     @Test
     public void testStringAtavSerialization() throws LdapException, IOException, ClassNotFoundException
     {
-        Ava atav = new Ava( "cn", "CN", "test", "Test" );
+        Ava atav = new Ava( schemaManager, "CN", "Test" );
 
         atav.normalize();
 
@@ -282,9 +284,8 @@ public class AvaTest
     public void testBinaryAtavSerialization() throws LdapException, IOException, ClassNotFoundException
     {
         byte[] upValue = Strings.getBytesUtf8("  Test  ");
-        byte[] normValue = Strings.getBytesUtf8("Test");
 
-        Ava atav = new Ava( "cn", "CN", upValue, normValue );
+        Ava atav = new Ava( schemaManager, "CN", upValue );
 
         atav.normalize();
 
@@ -330,7 +331,7 @@ public class AvaTest
     @Test
     public void testNullNormValueSerialization() throws LdapException, IOException, ClassNotFoundException
     {
-        Ava atav = new Ava( "CN", "cn", "test", (String)null );
+        Ava atav = new Ava( schemaManager, "CN", (String)null );
 
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
@@ -343,7 +344,7 @@ public class AvaTest
         catch ( IOException ioe )
         {
             String message = ioe.getMessage();
-            assertEquals( "Cannot serialize an wrong ATAV, the value should not be null",
message );
+            assertEquals( "Cannot serialize an wrong ATAV, the upValue should not be null",
message );
         }
     }
 
@@ -351,7 +352,7 @@ public class AvaTest
     @Test
     public void testNullUpValueSerialization() throws LdapException, IOException, ClassNotFoundException
     {
-        Ava atav = new Ava( "CN", "cn", null, "test" );
+        Ava atav = new Ava( schemaManager, "CN", (String)null );
 
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
@@ -372,7 +373,7 @@ public class AvaTest
     @Test
     public void testEmptyNormValueSerialization() throws LdapException, IOException, ClassNotFoundException
     {
-        Ava atav = new Ava( "CN", "cn", "test", "" );
+        Ava atav = new Ava( schemaManager, "CN", "test" );
 
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
@@ -393,7 +394,7 @@ public class AvaTest
     @Test
     public void testEmptyUpValueSerialization() throws LdapException, IOException, ClassNotFoundException
     {
-        Ava atav = new Ava( "CN", "cn", "", "test" );
+        Ava atav = new Ava( schemaManager, "CN", "" );
 
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
@@ -417,7 +418,7 @@ public class AvaTest
     @Test
     public void testStringAtavStaticSerialization() throws LdapException, IOException, ClassNotFoundException
     {
-        Ava atav = new Ava( "cn", "CN", "test", "Test" );
+        Ava atav = new Ava( schemaManager, "CN", "Test" );
 
         atav.normalize();
 
@@ -432,7 +433,7 @@ public class AvaTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Ava atav2 = AvaSerializer.deserialize(in);
+        Ava atav2 = AvaSerializer.deserialize( schemaManager, in );
 
         assertEquals( atav, atav2 );
     }
@@ -442,9 +443,8 @@ public class AvaTest
     public void testBinaryAtavStaticSerialization() throws LdapException, IOException, ClassNotFoundException
     {
         byte[] upValue = Strings.getBytesUtf8("  Test  ");
-        byte[] normValue = Strings.getBytesUtf8("Test");
 
-        Ava atav = new Ava( "cn", "CN", upValue, normValue );
+        Ava atav = new Ava( schemaManager, "CN", upValue );
 
         atav.normalize();
 
@@ -459,7 +459,7 @@ public class AvaTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Ava atav2 = AvaSerializer.deserialize(in);
+        Ava atav2 = AvaSerializer.deserialize( schemaManager, in );
 
         assertEquals( atav, atav2 );
     }
@@ -489,30 +489,9 @@ public class AvaTest
 
 
     @Test
-    public void testNullNormValueStaticSerialization() throws LdapException, IOException,
ClassNotFoundException
-    {
-        Ava atav = new Ava( "CN", "cn", "test", (String)null );
-
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        ObjectOutputStream out = new ObjectOutputStream( baos );
-
-        try
-        {
-            AvaSerializer.serialize(atav, out);
-            fail();
-        }
-        catch ( IOException ioe )
-        {
-            String message = ioe.getMessage();
-            assertEquals( "Cannot serialize an wrong ATAV, the value should not be null",
message );
-        }
-    }
-
-
-    @Test
     public void testNullUpValueStaticSerialization() throws LdapException, IOException, ClassNotFoundException
     {
-        Ava atav = new Ava( "CN", "cn", null, "test" );
+        Ava atav = new Ava( schemaManager, "CN", (String)null );
 
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
@@ -533,7 +512,7 @@ public class AvaTest
     @Test
     public void testEmptyNormValueStaticSerialization() throws LdapException, IOException,
ClassNotFoundException
     {
-        Ava atav = new Ava( "CN", "cn", "test", "" );
+        Ava atav = new Ava( schemaManager, "CN", "" );
 
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
@@ -546,7 +525,7 @@ public class AvaTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Ava atav2 = AvaSerializer.deserialize(in);
+        Ava atav2 = AvaSerializer.deserialize( schemaManager, in );
 
         assertEquals( atav, atav2 );
     }
@@ -555,7 +534,7 @@ public class AvaTest
     @Test
     public void testEmptyUpValueStaticSerialization() throws LdapException, IOException,
ClassNotFoundException
     {
-        Ava atav = new Ava( "CN", "cn", "", "test" );
+        Ava atav = new Ava( schemaManager, "CN", "" );
 
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
@@ -568,7 +547,7 @@ public class AvaTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Ava atav2 = AvaSerializer.deserialize(in);
+        Ava atav2 = AvaSerializer.deserialize( schemaManager, in );
 
         assertEquals( atav, atav2 );
     }

Modified: directory/shared/branches/akarasulu/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnTest.java?rev=1075330&r1=1075329&r2=1075330&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnTest.java
(original)
+++ directory/shared/branches/akarasulu/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnTest.java
Mon Feb 28 13:57:08 2011
@@ -34,6 +34,8 @@ import java.io.ObjectOutputStream;
 import java.util.Iterator;
 
 import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.util.Strings;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -51,8 +53,9 @@ import com.mycila.junit.concurrent.Concu
 @Concurrency()
 public class RdnTest
 {
-    // ~ Methods
-    // ------------------------------------------------------------------------------------
+    /** A null schemaManager used in tests */
+    SchemaManager schemaManager = null;
+    
     /**
      * Test a null Rdn
      */
@@ -1149,14 +1152,14 @@ public class RdnTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Rdn rdn2 = RdnSerializer.deserialize( in );
+        Rdn rdn2 = RdnSerializer.deserialize( schemaManager, in );
 
         assertEquals( rdn, rdn2 );
     }
 
 
     @Test
-    public void testNullRdnStaticSerialization() throws IOException, ClassNotFoundException
+    public void testNullRdnStaticSerialization() throws IOException, ClassNotFoundException,
LdapInvalidDnException
     {
         Rdn rdn = new Rdn();
 
@@ -1173,7 +1176,7 @@ public class RdnTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Rdn rdn2 = RdnSerializer.deserialize( in );
+        Rdn rdn2 = RdnSerializer.deserialize( schemaManager, in );
 
         assertEquals( rdn, rdn2 );
     }
@@ -1199,7 +1202,7 @@ public class RdnTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Rdn rdn2 = RdnSerializer.deserialize( in );
+        Rdn rdn2 = RdnSerializer.deserialize( schemaManager, in );
 
         assertEquals( rdn, rdn2 );
     }
@@ -1225,7 +1228,7 @@ public class RdnTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Rdn rdn2 = RdnSerializer.deserialize( in );
+        Rdn rdn2 = RdnSerializer.deserialize( schemaManager, in );
 
         assertEquals( rdn, rdn2 );
     }
@@ -1251,7 +1254,7 @@ public class RdnTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Rdn rdn2 = RdnSerializer.deserialize( in );
+        Rdn rdn2 = RdnSerializer.deserialize( schemaManager, in );
 
         assertEquals( rdn, rdn2 );
     }
@@ -1277,7 +1280,7 @@ public class RdnTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Rdn rdn2 = RdnSerializer.deserialize( in );
+        Rdn rdn2 = RdnSerializer.deserialize( schemaManager, in );
 
         assertEquals( rdn, rdn2 );
     }
@@ -1304,7 +1307,7 @@ public class RdnTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Rdn rdn2 = RdnSerializer.deserialize( in );
+        Rdn rdn2 = RdnSerializer.deserialize( schemaManager, in );
 
         assertEquals( rdn, rdn2 );
     }
@@ -1331,7 +1334,7 @@ public class RdnTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Rdn rdn2 = RdnSerializer.deserialize( in );
+        Rdn rdn2 = RdnSerializer.deserialize( schemaManager, in );
 
         assertEquals( rdn, rdn2 );
     }

Propchange: directory/shared/branches/akarasulu/ldap-protocol-codec/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Feb 28 13:57:08 2011
@@ -6,3 +6,4 @@
 /directory/shared/branches-dnfactory-experiment/ldap:980350-980351
 /directory/shared/trunk/ldap:1066124-1067784
 /directory/shared/trunk/ldap-codec:1067785-1067995,1068025-1072732,1072797-1074636
+/directory/shared/trunk/ldap-protocol-codec:1074637-1075328

Propchange: directory/shared/branches/akarasulu/ldap-schema/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Feb 28 13:57:08 2011
@@ -9,4 +9,4 @@
 /directory/shared/branches/shared-subtree/ldap-schema:965208-965686
 /directory/shared/branches/xdbm-refactoring/ldap-schema:945830-946347
 /directory/shared/branches-dnfactory-experiment/ldap-schema:980350-980351
-/directory/shared/trunk/ldap-schema:1066124-1067995,1068025-1072732,1072797-1074636
+/directory/shared/trunk/ldap-schema:1066124-1067995,1068025-1072732,1072797-1075328

Propchange: directory/shared/branches/akarasulu/ldap-schema/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Feb 28 13:57:08 2011
@@ -8,5 +8,5 @@
 /directory/shared/branches/shared-subtree/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl:965208-965686
 /directory/shared/branches/xdbm-refactoring/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl:945830-946347
 /directory/shared/branches-dnfactory-experiment/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl:980350-980351
-/directory/shared/trunk/ldap-schema/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl:1066124-1067995,1068025-1072732,1072797-1074636
+/directory/shared/trunk/ldap-schema/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl:1066124-1067995,1068025-1072732,1072797-1075328
 /directory/shared/trunk/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl:806622-894844*

Propchange: directory/shared/branches/akarasulu/ldap-schema/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Feb 28 13:57:08 2011
@@ -8,5 +8,5 @@
 /directory/shared/branches/shared-subtree/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl/DefaultSchemaManager.java:965208-965686
 /directory/shared/branches/xdbm-refactoring/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl/DefaultSchemaManager.java:945830-946347
 /directory/shared/branches-dnfactory-experiment/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl/DefaultSchemaManager.java:980350-980351
-/directory/shared/trunk/ldap-schema/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java:1066124-1067995,1068025-1072732,1072797-1074636
+/directory/shared/trunk/ldap-schema/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java:1066124-1067995,1068025-1072732,1072797-1075328
 /directory/shared/trunk/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl/DefaultSchemaManager.java:806622-894844



Mime
View raw message