directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r612324 [1/2] - in /directory/apacheds/branches/bigbang: core-entry/src/main/java/org/apache/directory/server/core/entry/ core-entry/src/test/java/org/apache/directory/server/core/entry/ core/src/main/java/org/apache/directory/server/core/ ...
Date Wed, 16 Jan 2008 00:32:20 GMT
Author: elecharny
Date: Tue Jan 15 16:32:18 2008
New Revision: 612324

URL: http://svn.apache.org/viewvc?rev=612324&view=rev
Log:
Modified the Add request to ma,ipulate ServerEntry instead of Attributes

Modified:
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/AbstractServerAttribute.java
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ObjectClassAttribute.java
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerAttribute.java
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStreamedValue.java
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerValue.java
    directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java
    directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/AddOperationContext.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java
    directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddEntryOperation.java
    directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationCodec.java
    directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationFactory.java
    directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/support/EntryUtil.java
    directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationInterceptor.java
    directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationClientContextHandler.java
    directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/AbstractReplicationServiceTestCase.java
    directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/DIRSERVER1013ITest.java
    directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java
    directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/AbstractMessageCodecTest.java
    directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageCodecTest.java
    directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java
    directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/StoredProcedureExecutionITest.java

Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/AbstractServerAttribute.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/AbstractServerAttribute.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/AbstractServerAttribute.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/AbstractServerAttribute.java Tue Jan 15 16:32:18 2008
@@ -41,7 +41,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public abstract class AbstractServerAttribute implements ServerAttribute, Cloneable
+public abstract class AbstractServerAttribute implements ServerAttribute
 {
     /** logger for reporting errors that might not be handled properly upstream */
     private static final Logger LOG = LoggerFactory.getLogger( AbstractServerAttribute.class );
@@ -50,7 +50,7 @@
     protected List<ServerValue<?>> values = new ArrayList<ServerValue<?>>();
     
     /** The associated AttributeType */
-    protected AttributeType attributeType;
+    protected transient AttributeType attributeType;
     
     /** The User provided ID */
     protected String upId;

Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java Tue Jan 15 16:32:18 2008
@@ -19,6 +19,7 @@
 package org.apache.directory.server.core.entry;
 
 
+import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.entry.AbstractBinaryValue;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.AbstractStringValue;
@@ -30,6 +31,11 @@
 import javax.naming.NamingException;
 import javax.naming.directory.InvalidAttributeValueException;
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
 import java.util.Iterator;
 
 
@@ -39,8 +45,11 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public final class DefaultServerAttribute extends AbstractServerAttribute
+public final class DefaultServerAttribute extends AbstractServerAttribute implements Externalizable
 {
+    /** Used for serialization */
+    public static final long serialVersionUID = 2L;
+    
     /** logger for reporting errors that might not be handled properly upstream */
     private static final Logger LOG = LoggerFactory.getLogger( DefaultServerAttribute.class );
     
@@ -701,4 +710,117 @@
         return sb.toString();
     }
 
+    
+    /**
+     * @see Externalizable#writeExternal(ObjectOutput)
+     * 
+     * We have to store the UPid, and all the values, if any.
+     */
+    public void writeExternal( ObjectOutput out ) throws IOException
+    {
+        // Store the attribute's HR : true means H/R, false is for binary
+        try
+        {
+            out.writeBoolean( attributeType.getSyntax().isHumanReadable() );
+        }
+        catch ( NamingException ne )
+        {
+            out.writeBoolean( false );
+        }
+        
+        // Store the UP id
+        out.writeUTF( upId );
+        
+        // The number of values
+        if ( values == null ) 
+        {
+            out.writeInt( -1 );
+        }
+        else if ( values.size() == 0 )
+        {
+            out.writeInt( 0 );
+        }
+        else
+        {
+            out.writeInt( values.size() );
+
+            for ( ServerValue<?> value:values )
+            {
+                out.writeObject( value );
+            }
+        }
+        
+        out.flush();
+    }
+
+    
+    /**
+     * @see Externalizable#readExternal(ObjectInput)
+     */
+    public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
+    {
+        if ( in.available() == 0 )
+        {
+            String message = "Cannot read an null Attribute";
+            LOG.error( message );
+            throw new IOException( message );
+        }
+        else
+        {
+            // Read the HR flag
+            boolean hr = in.readBoolean();
+            
+            // Read the UPid
+            upId = in.readUTF();
+
+            // Read the number of values
+            int nbValues = in.readInt();
+            
+            switch ( nbValues )
+            {
+                case -1 :
+                    values = null;
+                    break;
+                    
+                case 0 :
+                    values = new ArrayList<ServerValue<?>>();
+                    break;
+                    
+                default :
+                    values = new ArrayList<ServerValue<?>>();
+                
+                    for ( int i = 0; i < nbValues; i++ )
+                    {
+                        if ( hr )
+                        {
+                            ServerStringValue value = new ServerStringValue( attributeType );
+                        }
+                    }
+                    
+                    break;
+            }
+                    
+            if ( nbValues != 0 )
+            {
+                
+            }
+            else
+            {
+                
+            }
+
+            String wrapped = in.readUTF();
+            /**
+            set( wrapped );
+            
+            normalizedValue = in.readUTF();
+            
+            if ( ( normalizedValue.length() == 0 ) &&  ( wrapped.length() != 0 ) )
+            {
+                // In this case, the normalized value is equal to the UP value
+                normalizedValue = wrapped;
+            }
+            */
+        }
+    }
 }

Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java Tue Jan 15 16:32:18 2008
@@ -19,6 +19,10 @@
 package org.apache.directory.server.core.entry;
 
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -50,8 +54,11 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public final class DefaultServerEntry implements ServerEntry
+public final class DefaultServerEntry implements ServerEntry, Externalizable
 {
+    /** Used for serialization */
+    public static final long serialVersionUID = 2L;
+    
     /** The logger for this class */
     private static final Logger LOG = LoggerFactory.getLogger( DefaultServerEntry.class );
 
@@ -111,12 +118,12 @@
      * <p>
      * This entry <b>must</b> be initialized before being used !
      */
-    public DefaultServerEntry()
+    /*public DefaultServerEntry()
     {
         registries = null;
         
         initObjectClassAT( registries );
-    }
+    }*/
 
 
     /**
@@ -1548,7 +1555,116 @@
         }
     }
 
+    
+    /**
+     * @see Externalizable#writeExternal(ObjectOutput)<p>
+     * 
+     * This is the place where we serialize entries, and all theirs
+     * elements. the reason why we don't call the underlying methods
+     * (<code>ServerAttribute.write(), Value.write()</code>) is that we need
+     * access to the registries to read back the values.
+     * <p>
+     * The structure used to store the entry is the following :
+     * <li><b>[DN length]</b> : can be -1 if we don't have a DN, 0 if the 
+     * DN is empty, otherwise contains the DN's length.<p> 
+     * <b>NOTE :</b>This should be unnecessary, as the DN should always exists
+     * <p>
+     * </li>
+     * <li>
+     * <b>DN</b> : The entry's DN. Can be empty (rootDSE=<p>
+     * </li>
+     * We have to store the UPid, and all the values, if any.
+     */
+    public void writeExternal( ObjectOutput out ) throws IOException
+    {
+        if ( dn == null )
+        {
+            // We don't have a DN, so write a -1 instead of a real length
+            out.writeInt( -1 );
+        }
+        else
+        {
+            // Here, we should ask ourselves if it would not be better
+            // to serialize the current LdapDN instead of a String.
+            String dnString = dn.getUpName();
+            out.writeInt( dnString.length() );
+            out.writeUTF( dnString );
+            
+        }
+        
+        out.flush();
+    }
 
+    
+    /**
+     * @see Externalizable#readExternal(ObjectInput)
+     */
+    public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
+    {
+        if ( in.available() == 0 )
+        {
+            String message = "Cannot read an null Attribute";
+            LOG.error( message );
+            throw new IOException( message );
+        }
+        else
+        {
+            // Read the HR flag
+            boolean hr = in.readBoolean();
+        }
+        /*
+            // Read the UPid
+            upId = in.readUTF();
+
+            // Read the number of values
+            int nbValues = in.readInt();
+            
+            switch ( nbValues )
+            {
+                case -1 :
+                    values = null;
+                    break;
+                    
+                case 0 :
+                    values = new ArrayList<ServerValue<?>>();
+                    break;
+                    
+                default :
+                    values = new ArrayList<ServerValue<?>>();
+                
+                    for ( int i = 0; i < nbValues; i++ )
+                    {
+                        if ( hr )
+                        {
+                            ServerStringValue value = new ServerStringValue( attributeType ); 
+                    }
+                    
+                    break;
+            }
+            if ( nbValues != 0 )
+            {
+                
+            }
+            else
+            {
+                
+            }
+            //
+            String wrapped = in.readUTF();
+            
+            set( wrapped );
+            
+            normalizedValue = in.readUTF();
+            
+            if ( ( normalizedValue.length() == 0 ) &&  ( wrapped.length() != 0 ) )
+            {
+                // In this case, the normalized value is equal to the UP value
+                normalizedValue = wrapped;
+            }
+        }*/
+    }
+
+        
     /**
      * @see Object#toString()
      */

Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ObjectClassAttribute.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ObjectClassAttribute.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ObjectClassAttribute.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ObjectClassAttribute.java Tue Jan 15 16:32:18 2008
@@ -42,6 +42,9 @@
  */
 public class ObjectClassAttribute extends AbstractServerAttribute
 {
+    /** Used for serialization */
+    public static final long serialVersionUID = 2L;
+    
     /** logger for reporting errors that might not be handled properly upstream */
     private static final Logger LOG = LoggerFactory.getLogger( ObjectClassAttribute.class );
     
@@ -62,7 +65,7 @@
     private Set<AttributeType> mustList = new HashSet<AttributeType>();
     
     /** The global registries */
-    private Registries registries;
+    private transient Registries registries;
 
 
     /**

Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerAttribute.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerAttribute.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerAttribute.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerAttribute.java Tue Jan 15 16:32:18 2008
@@ -32,7 +32,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public interface ServerAttribute extends EntryAttribute<ServerValue<?>>, Iterable<ServerValue<?>>, Cloneable
+public interface ServerAttribute extends EntryAttribute<ServerValue<?>>
 {
     /**
      * Gets the attribute type associated with this ServerAttribute.

Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java Tue Jan 15 16:32:18 2008
@@ -24,10 +24,16 @@
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.naming.NamingException;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.util.Arrays;
 import java.util.Comparator;
 
@@ -41,8 +47,11 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class ServerBinaryValue extends AbstractBinaryValue implements ServerValue<byte[]>, Cloneable
+public class ServerBinaryValue extends AbstractBinaryValue implements ServerValue<byte[]>, Externalizable
 {
+    /** Used for serialization */
+    public static final long serialVersionUID = 2L;
+    
     /** logger for reporting errors that might not be handled properly upstream */
     private static final Logger LOG = LoggerFactory.getLogger( ServerBinaryValue.class );
 
@@ -131,10 +140,40 @@
 
 
     // -----------------------------------------------------------------------
-    // ServerValue<String> Methods
+    // ServerValue<byte[]> Methods
     // -----------------------------------------------------------------------
+    public void normalize() throws NamingException
+    {
+        if ( getReference() != null )
+        {
+            Normalizer normalizer = getNormalizer();
+    
+            if ( normalizer == null )
+            {
+                normalizedValue = getCopy();
+            }
+            else
+            {
+                normalizedValue = ( byte[] ) normalizer.normalize( getCopy() );
+            }
+            
+            if ( Arrays.equals( super.getReference(), normalizedValue ) )
+            {
+                same = true;
+            }
+            else
+            {
+                same = false;
+            }
+        }
+        else
+        {
+            normalizedValue = null;
+            same = true;
+        }
+    }
 
-
+    
     /**
      * Gets the normalized (cannonical) representation for the wrapped string.
      * If the wrapped String is null, null is returned, otherwise the normalized
@@ -155,25 +194,7 @@
 
         if ( normalizedValue == null )
         {
-            Normalizer normalizer = getNormalizer();
-
-            if ( normalizer == null )
-            {
-                normalizedValue = getCopy();
-            }
-            else
-            {
-                normalizedValue = ( byte[] ) normalizer.normalize( getCopy() );
-            }
-            
-            if ( Arrays.equals( super.getReference(), normalizedValue ) )
-            {
-                same = true;
-            }
-            else
-            {
-                same = false;
-            }
+            normalize();
         }
 
         return normalizedValue;
@@ -460,5 +481,108 @@
         }
         
         return clone;
+    }
+
+
+    /**
+     * @see Externalizable#writeExternal(ObjectOutput)
+     * 
+     * We will write the value and the normalized value, only
+     * if the normalized value is different.
+     * 
+     * The data will be stored following this structure :
+     * 
+     *  [UP value]
+     *  [Norm value] (will be null if normValue == upValue)
+     */
+    public void writeExternal( ObjectOutput out ) throws IOException
+    {
+        if ( getReference() != null )
+        {
+            out.writeInt( getReference().length );
+            out.write( getReference() );
+            
+            if ( same )
+            {
+                // If the normalized value is equal to the UP value,
+                // don't save it
+                out.writeInt( 0 );
+            }
+            else
+            {
+                out.writeInt( normalizedValue.length );
+                out.write( normalizedValue );
+            }
+        }
+        else
+        {
+            out.writeInt( -1 );
+        }
+        
+        out.flush();
+    }
+
+    
+    /**
+     * @see Externalizable#readExternal(ObjectInput)
+     */
+    public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
+    {
+        if ( in.available() == 0 )
+        {
+            set( null );
+            normalizedValue = null;
+        }
+        else
+        {
+            int wrappedLength = in.readInt();
+            byte[] wrapped = null;
+            
+            switch ( wrappedLength )
+            {
+                case -1 :
+                    // No value, no normalized value
+                    same = true;
+                    break;
+                    
+                case 0 :
+                    // Empty value, so is the normalized value
+                    wrapped = StringTools.EMPTY_BYTES;
+                    normalizedValue = wrapped;
+                    same = true;
+                    break;
+                    
+                default :
+                    wrapped = new byte[wrappedLength];
+                    in.readFully( wrapped );
+                    
+                    int normalizedLength = in.readInt();
+                    
+                    // The normalized length should be either 0 or N, 
+                    // but it can't be -1
+                    switch ( normalizedLength )
+                    {
+                        case -1 :
+                            String message = "The normalized value cannot be null when the User Provide value is not";
+                            LOG.error(  message  );
+                            throw new IOException( message );
+                            
+                        case 0 :
+                            normalizedValue = StringTools.EMPTY_BYTES;
+                            same = true;
+                            break;
+                            
+                        default :
+                            same = false;
+                            normalizedValue = new byte[normalizedLength];
+                            in.readFully( normalizedValue );
+                            break;
+                    }
+                    
+                    break;
+            }
+            
+            set( wrapped );
+        }
     }
 }

Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStreamedValue.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStreamedValue.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStreamedValue.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStreamedValue.java Tue Jan 15 16:32:18 2008
@@ -72,8 +72,11 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class ServerStreamedValue extends AbstractStreamedValue implements ServerValue<URI>, Cloneable
+public class ServerStreamedValue extends AbstractStreamedValue implements ServerValue<URI>
 {
+    /** Used for serialization */
+    public static final long serialVersionUID = 2L;
+    
     /** logger for reporting errors that might not be handled properly upstream */
     private static final Logger LOG = LoggerFactory.getLogger( ServerStreamedValue.class );
 
@@ -143,6 +146,10 @@
     // -----------------------------------------------------------------------
     // ServerValue<String> Methods
     // -----------------------------------------------------------------------
+    public void normalize() throws NamingException
+    {
+        
+    }
 
 
     /**

Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java Tue Jan 15 16:32:18 2008
@@ -28,6 +28,11 @@
 import org.slf4j.LoggerFactory;
 
 import javax.naming.NamingException;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.util.Comparator;
 
 
@@ -40,8 +45,11 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class ServerStringValue extends AbstractStringValue implements ServerValue<String>, Cloneable
+public class ServerStringValue extends AbstractStringValue implements ServerValue<String>, Externalizable
 {
+    /** Used for serialization */
+    public static final long serialVersionUID = 2L;
+    
     /** logger for reporting errors that might not be handled properly upstream */
     private static final Logger LOG = LoggerFactory.getLogger( ServerStringValue.class );
 
@@ -49,7 +57,7 @@
     private transient AttributeType attributeType;
 
     /** the canonical representation of the wrapped String value */
-    private transient String normalizedValue;
+    private String normalizedValue;
 
     /** cached results of the isValid() method call */
     private transient Boolean valid;
@@ -111,7 +119,7 @@
     {
         // Why should we invalidate the normalized value if it's we're setting the
         // wrapper to it's current value?
-        if ( wrapped.equals( get() ) )
+        if ( ( wrapped != null ) && wrapped.equals( get() ) )
         {
             return;
         }
@@ -125,10 +133,28 @@
     // -----------------------------------------------------------------------
     // ServerValue<String> Methods
     // -----------------------------------------------------------------------
+    /**
+     * Compute the normalized (canonical) representation for the wrapped string.
+     * If the wrapped String is null, the normalized form will be null too.  
+     *
+     * @throws NamingException if the value cannot be properly normalized
+     */
+    public void normalize() throws NamingException
+    {
+        Normalizer normalizer = getNormalizer();
 
+        if ( normalizer == null )
+        {
+            normalizedValue = get();
+        }
+        else
+        {
+            normalizedValue = ( String ) normalizer.normalize( get() );
+        }
+    }
 
     /**
-     * Gets the normalized (cannonical) representation for the wrapped string.
+     * Gets the normalized (canonical) representation for the wrapped string.
      * If the wrapped String is null, null is returned, otherwise the normalized
      * form is returned.  If no the normalizedValue is null, then this method
      * will attempt to generate it from the wrapped value: repeated calls to
@@ -147,16 +173,7 @@
 
         if ( normalizedValue == null )
         {
-            Normalizer normalizer = getNormalizer();
-
-            if ( normalizer == null )
-            {
-                normalizedValue = get();
-            }
-            else
-            {
-                normalizedValue = ( String ) normalizer.normalize( get() );
-            }
+            normalize();
         }
 
         return normalizedValue;
@@ -410,6 +427,66 @@
         catch ( CloneNotSupportedException cnse )
         {
             return null;
+        }
+    }
+    
+    
+    /**
+     * @see Externalizable#writeExternal(ObjectOutput)
+     * 
+     * We will write the value and the normalized value, only
+     * if the normalized value is different.
+     * 
+     * The data will be stored following this structure :
+     * 
+     *  [UP value]
+     *  [Norm value] (will be null if normValue == upValue)
+     */
+    public void writeExternal( ObjectOutput out ) throws IOException
+    {
+        if ( get() != null )
+        {
+            out.writeUTF( get() );
+            
+            if ( normalizedValue.equals( get() ) )
+            {
+                // If the normalized value is equal to the UP value,
+                // don't save it
+                out.writeUTF( "" );
+            }
+            else
+            {
+                out.writeUTF( normalizedValue );
+            }
+        }
+        
+        out.flush();
+    }
+
+    
+    /**
+     * @see Externalizable#readExternal(ObjectInput)
+     */
+    public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
+    {
+        if ( in.available() == 0 )
+        {
+            set( null );
+            normalizedValue = null;
+        }
+        else
+        {
+            String wrapped = in.readUTF();
+            
+            set( wrapped );
+            
+            normalizedValue = in.readUTF();
+            
+            if ( ( normalizedValue.length() == 0 ) &&  ( wrapped.length() != 0 ) )
+            {
+                // In this case, the normalized value is equal to the UP value
+                normalizedValue = wrapped;
+            }
         }
     }
 }

Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerValue.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerValue.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerValue.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerValue.java Tue Jan 15 16:32:18 2008
@@ -84,4 +84,13 @@
     boolean instanceOf( AttributeType attributeType ) throws NamingException;
     
     ServerValue<T> clone();
+    
+    
+    /**
+     * Compute the normalized value
+     *
+     * @throws NamingException If the normalized has not been created of if
+     * there is a problem during the normalization
+     */
+    void normalize() throws NamingException;
 }

Modified: directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java Tue Jan 15 16:32:18 2008
@@ -20,19 +20,32 @@
 package org.apache.directory.server.core.entry;
 
 
+import org.apache.directory.server.core.entry.ServerStringValueTest.AT;
+import org.apache.directory.server.core.entry.ServerStringValueTest.MR;
+import org.apache.directory.server.core.entry.ServerStringValueTest.S;
 import org.apache.directory.shared.ldap.schema.AbstractAttributeType;
 import org.apache.directory.shared.ldap.schema.AbstractMatchingRule;
 import org.apache.directory.shared.ldap.schema.AbstractSyntax;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.ByteArrayComparator;
+import org.apache.directory.shared.ldap.schema.DeepTrimToLowerNormalizer;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.schema.Syntax;
+import org.apache.directory.shared.ldap.schema.syntax.AcceptAllSyntaxChecker;
 import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.junit.Before;
 import org.junit.Test;
 
 import javax.naming.NamingException;
 import javax.naming.directory.InvalidAttributeValueException;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.util.Arrays;
 import java.util.Comparator;
 
@@ -58,6 +71,10 @@
  */
 public class ServerBinaryValueTest
 {
+    static private S s;
+    static private AT at;
+    static private MR mr;
+    
     /**
      * A local Syntax class for tests
      */
@@ -259,7 +276,7 @@
                 if ( value instanceof byte[] )
                 {
                     byte[] val = (byte[])value;
-                    // each byte will be changed to be > 0
+                    // each byte will be changed to be > 0, and spaces will be trimmed
                     byte[] newVal = new byte[ val.length ];
                     int i = 0;
                     
@@ -268,7 +285,7 @@
                         newVal[i++] = (byte)(b & 0x007F); 
                     }
                     
-                    return newVal;
+                    return StringTools.trim( newVal );
                 }
 
                 throw new IllegalStateException( "expected byte[] to normalize" );
@@ -282,6 +299,49 @@
 
     
     /**
+     * Initialize an AttributeType and the associated MatchingRule 
+     * and Syntax
+     */
+    @Before public void initAT()
+    {
+        s = new S( "1.1.1.1", false );
+        s.setSyntaxChecker( new AcceptAllSyntaxChecker( "1.1.1.1" ) );
+        mr = new MR( "1.1.2.1" );
+        mr.syntax = s;
+        mr.comparator = new ByteArrayComparator();
+        mr.normalizer = new Normalizer()
+        {
+            public static final long serialVersionUID = 1L;
+            
+            public Object normalize( Object value ) throws NamingException
+            {
+                if ( value instanceof byte[] )
+                {
+                    byte[] val = (byte[])value;
+                    // each byte will be changed to be > 0, and spaces will be trimmed
+                    byte[] newVal = new byte[ val.length ];
+                    int i = 0;
+                    
+                    for ( byte b:val )
+                    {
+                        newVal[i++] = (byte)(b & 0x007F); 
+                    }
+                    
+                    return StringTools.trim( newVal );
+                }
+
+                throw new IllegalStateException( "expected byte[] to normalize" );
+            }
+        };
+        at = new AT( "1.1.3.1" );
+        at.setEquality( mr );
+        at.setOrdering( mr );
+        at.setSubstr( mr );
+        at.setSyntax( s );
+    }
+    
+
+    /**
      * Test the constructor with bad AttributeType
      */
     @Test public void testBadConstructor()
@@ -413,4 +473,138 @@
         assertFalse( v3.equals( v2 ) );
         assertTrue( v3.isValid() );
     }
+
+
+
+    /**
+     * Test serialization of a BinaryValue which has a normalized value
+     */
+    @Test public void testNormalizedBinaryValueSerialization() throws NamingException, IOException, ClassNotFoundException
+    {
+        byte[] v1 = StringTools.getBytesUtf8( "  Test   Test  " );
+        byte[] v1Norm = StringTools.getBytesUtf8( "Test   Test" );
+        
+        // First check with a value which will be normalized
+        ServerBinaryValue sv = new ServerBinaryValue( at, v1 );
+        
+        sv.normalize();
+        byte[] normalized = sv.getNormalizedReference();
+        
+        assertTrue( Arrays.equals( v1Norm, normalized ) );
+        assertTrue( Arrays.equals( v1, sv.getReference() ) );
+        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+        
+        sv.writeExternal( out );
+        
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+        
+        ServerBinaryValue sv2 = new ServerBinaryValue( at );
+        sv2.readExternal( in );
+        
+        assertEquals( sv, sv2 );
+    }
+
+
+    /**
+     * Test serialization of a BinaryValue which does not have a normalized value
+     */
+    @Test public void testNoNormalizedBinaryValueSerialization() throws NamingException, IOException, ClassNotFoundException
+    {
+        byte[] v1 = StringTools.getBytesUtf8( "test" );
+        byte[] v1Norm = StringTools.getBytesUtf8( "test" );
+
+        // First check with a value which will be normalized
+        ServerBinaryValue sv = new ServerBinaryValue( at, v1 );
+        
+        sv.normalize();
+        byte[] normalized = sv.getNormalizedReference();
+        
+        assertTrue( Arrays.equals( v1Norm, normalized ) );
+        assertTrue( Arrays.equals( v1, sv.get() ) );
+        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+        
+        sv.writeExternal( out );
+        
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+        
+        ServerBinaryValue sv2 = new ServerBinaryValue( at );
+        sv2.readExternal( in );
+        
+        assertEquals( sv, sv2 );
+   }
+
+
+    /**
+     * Test serialization of a null BinaryValue
+     */
+    @Test public void testNullBinaryValueSerialization() throws NamingException, IOException, ClassNotFoundException
+    {
+        // First check with a value which will be normalized
+        ServerBinaryValue sv = new ServerBinaryValue( at );
+        
+        sv.normalize();
+        byte[] normalized = sv.getNormalizedReference();
+        
+        assertEquals( null, normalized );
+        assertEquals( null, sv.get() );
+        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+        
+        sv.writeExternal( out );
+        
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+        
+        ServerBinaryValue sv2 = new ServerBinaryValue( at );
+        sv2.readExternal( in );
+        
+        assertEquals( sv, sv2 );
+   }
+
+
+    /**
+     * Test serialization of an empty BinaryValue
+     */
+    @Test public void testEmptyBinaryValueSerialization() throws NamingException, IOException, ClassNotFoundException
+    {
+        // First check with a value which will be normalized
+        ServerBinaryValue sv = new ServerBinaryValue( at, StringTools.EMPTY_BYTES );
+        
+        sv.normalize();
+        byte[] normalized = sv.getNormalizedReference();
+        
+        assertTrue( Arrays.equals( StringTools.EMPTY_BYTES, normalized ) );
+        assertTrue( Arrays.equals( StringTools.EMPTY_BYTES, sv.get() ) );
+        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+        
+        sv.writeExternal( out );
+        
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+        
+        ServerBinaryValue sv2 = new ServerBinaryValue( at );
+        sv2.readExternal( in );
+        
+        assertEquals( sv, sv2 );
+   }
 }

Modified: directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java Tue Jan 15 16:32:18 2008
@@ -25,16 +25,24 @@
 import org.apache.directory.shared.ldap.schema.AbstractSyntax;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.ByteArrayComparator;
+import org.apache.directory.shared.ldap.schema.DeepTrimToLowerNormalizer;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.NoOpNormalizer;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.schema.Syntax;
 import org.apache.directory.shared.ldap.schema.syntax.AcceptAllSyntaxChecker;
 import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
+import org.junit.Before;
 import org.junit.Test;
 
 import javax.naming.NamingException;
 import javax.naming.directory.InvalidAttributeValueException;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
@@ -62,6 +70,10 @@
  */
 public class ServerStringValueTest
 {
+    static private S s;
+    static private AT at;
+    static private MR mr;
+    
     /**
      * A local Syntax class for tests
      */
@@ -364,6 +376,26 @@
 
     
     /**
+     * Initialize an AttributeType and the associated MatchingRule 
+     * and Syntax
+     */
+    @Before public void initAT()
+    {
+        s = new S( "1.1.1.1", false );
+        s.setSyntaxChecker( new AcceptAllSyntaxChecker( "1.1.1.1" ) );
+        mr = new MR( "1.1.2.1" );
+        mr.syntax = s;
+        mr.comparator = new ByteArrayComparator();
+        mr.normalizer = new DeepTrimToLowerNormalizer();
+        at = new AT( "1.1.3.1" );
+        at.setEquality( mr );
+        at.setOrdering( mr );
+        at.setSubstr( mr );
+        at.setSyntax( s );
+    }
+    
+
+    /**
      * Test the constructor with bad AttributeType
      */
     @Test public void testBadConstructor()
@@ -657,18 +689,6 @@
      */
     @Test public void testAcceptAllNoNormalization() throws Exception
     {
-        S s = new S( "1.1.1.1", false );
-        s.setSyntaxChecker( new AcceptAllSyntaxChecker( "1.1.1.1" ) );
-        final MR mr = new MR( "1.1.2.1" );
-        mr.syntax = s;
-        mr.comparator = new ByteArrayComparator();
-        mr.normalizer = new NoOpNormalizer();
-        AT at = new AT( "1.1.3.1" );
-        at.setEquality( mr );
-        at.setOrdering( mr );
-        at.setSubstr( mr );
-        at.setSyntax( s );
-
         // check that normalization and syntax checks work as expected
         ServerStringValue value = new ServerStringValue( at, "hello" );
         assertEquals( value.get(), value.get() );
@@ -772,4 +792,129 @@
     }
 
     
+    /**
+     * Test serialization of a StringValue which has a normalized value
+     */
+    @Test public void testNormalizedStringValueSerialization() throws NamingException, IOException, ClassNotFoundException
+    {
+        // First check with a value which will be normalized
+        ServerStringValue sv = new ServerStringValue( at, "  Test   Test  " );
+        
+        sv.normalize();
+        String normalized = sv.getNormalized();
+        
+        assertEquals( "test test", normalized );
+        assertEquals( "  Test   Test  ", sv.get() );
+        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+        
+        sv.writeExternal( out );
+        
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+        
+        ServerStringValue sv2 = new ServerStringValue( at );
+        sv2.readExternal( in );
+        
+        assertEquals( sv, sv2 );
+   }
+
+
+    /**
+     * Test serialization of a StringValue which does not have a normalized value
+     */
+    @Test public void testNoNormalizedStringValueSerialization() throws NamingException, IOException, ClassNotFoundException
+    {
+        // First check with a value which will be normalized
+        ServerStringValue sv = new ServerStringValue( at, "test" );
+        
+        sv.normalize();
+        String normalized = sv.getNormalized();
+        
+        assertEquals( "test", normalized );
+        assertEquals( "test", sv.get() );
+        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+        
+        sv.writeExternal( out );
+        
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+        
+        ServerStringValue sv2 = new ServerStringValue( at );
+        sv2.readExternal( in );
+        
+        assertEquals( sv, sv2 );
+   }
+
+
+    /**
+     * Test serialization of a null StringValue
+     */
+    @Test public void testNullStringValueSerialization() throws NamingException, IOException, ClassNotFoundException
+    {
+        // First check with a value which will be normalized
+        ServerStringValue sv = new ServerStringValue( at );
+        
+        sv.normalize();
+        String normalized = sv.getNormalized();
+        
+        assertEquals( null, normalized );
+        assertEquals( null, sv.get() );
+        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+        
+        sv.writeExternal( out );
+        
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+        
+        ServerStringValue sv2 = new ServerStringValue( at );
+        sv2.readExternal( in );
+        
+        assertEquals( sv, sv2 );
+   }
+
+
+    /**
+     * Test serialization of an empty StringValue
+     */
+    @Test public void testEmptyStringValueSerialization() throws NamingException, IOException, ClassNotFoundException
+    {
+        // First check with a value which will be normalized
+        ServerStringValue sv = new ServerStringValue( at, "" );
+        
+        sv.normalize();
+        String normalized = sv.getNormalized();
+        
+        assertEquals( "", normalized );
+        assertEquals( "", sv.get() );
+        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+        
+        sv.writeExternal( out );
+        
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+        
+        ServerStringValue sv2 = new ServerStringValue( at );
+        sv2.readExternal( in );
+        
+        assertEquals( sv, sv2 );
+   }
 }

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java Tue Jan 15 16:32:18 2008
@@ -700,7 +700,7 @@
                 switch( reverse.getChangeType().getChangeType() )
                 {
                     case( ChangeType.ADD_ORDINAL ):
-                        System.out.println( "Reverted attributes : --> " + reverse.getAttributes() );
+                        //System.out.println( "Reverted attributes : --> " + reverse.getAttributes() );
                         ctx.createSubcontext( reverse.getDn(), reverse.getAttributes() );
                         break;
                     case( ChangeType.DELETE_ORDINAL ):

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/AddOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/AddOperationContext.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/AddOperationContext.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/AddOperationContext.java Tue Jan 15 16:32:18 2008
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.server.core.interceptor.context;
 
+
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.name.LdapDN;

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java Tue Jan 15 16:32:18 2008
@@ -33,6 +33,7 @@
 import org.apache.directory.server.core.authz.DefaultAuthorizationInterceptor;
 import org.apache.directory.server.core.entry.ServerAttribute;
 import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ServerEntryUtils;
 import org.apache.directory.server.core.entry.ServerStringValue;
 import org.apache.directory.server.core.entry.ServerValue;
 import org.apache.directory.server.core.enumeration.ReferralHandlingEnumeration;
@@ -79,7 +80,6 @@
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
-import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -297,14 +297,15 @@
     }
 
 
-    public void doReferralException( LdapDN farthest, LdapDN targetUpdn, Attribute refs ) throws NamingException
+    public void doReferralException( LdapDN farthest, LdapDN targetUpdn, ServerAttribute refs ) throws NamingException
     {
         // handle referral here
         List<String> list = new ArrayList<String>( refs.size() );
         
-        for ( int ii = 0; ii < refs.size(); ii++ )
+        Iterator<ServerValue<?>> refUrls = refs.getAll();
+        while ( refUrls.hasNext() )
         {
-            String val = ( String ) refs.get( ii );
+            String val = (String)(refUrls.next().get());
 
             // need to add non-ldap URLs as-is
             if ( !val.startsWith( "ldap" ) )
@@ -411,9 +412,14 @@
                 return;
             }
 
-            Attributes referral = invocation.getProxy().lookup( new LookupOperationContext( registries, farthest ), PartitionNexusProxy.LOOKUP_BYPASS );
+            ServerEntry referral = ServerEntryUtils.toServerEntry( 
+                invocation.getProxy().lookup( 
+                    new LookupOperationContext( registries, farthest ), 
+                    PartitionNexusProxy.LOOKUP_BYPASS ),
+                farthest, registries );
+            
             AttributeType refsType = atRegistry.lookup( oidRegistry.getOid( SchemaConstants.REF_AT ) );
-            Attribute refs = AttributeUtils.getAttribute( referral, refsType );
+            ServerAttribute refs = referral.get( refsType );
             doReferralException( farthest, new LdapDN( name.getUpName() ), refs );
         }
         else if ( refval.equals( FOLLOW ) )
@@ -451,8 +457,12 @@
                 return next.compare( opContext );
             }
 
-            Attributes referral = invocation.getProxy().lookup( new LookupOperationContext( registries, farthest ), PartitionNexusProxy.LOOKUP_BYPASS );
-            Attribute refs = referral.get( SchemaConstants.REF_AT );
+            ServerEntry referral = ServerEntryUtils.toServerEntry( 
+                invocation.getProxy().lookup( 
+                    new LookupOperationContext( registries, farthest ), 
+                    PartitionNexusProxy.LOOKUP_BYPASS ),
+                farthest, registries );
+            ServerAttribute refs = referral.get( SchemaConstants.REF_AT );
             doReferralException( farthest, new LdapDN( name.getUpName() ), refs );
 
             // we really can't get here since doReferralException will throw an exception
@@ -506,9 +516,14 @@
                 return;
             }
 
-            Attributes referral = invocation.getProxy().lookup( new LookupOperationContext( registries, farthest ), PartitionNexusProxy.LOOKUP_BYPASS );
-            Attribute refs = referral.get( SchemaConstants.REF_AT );
+            ServerEntry referral = ServerEntryUtils.toServerEntry( 
+                invocation.getProxy().lookup( 
+                    new LookupOperationContext( registries, farthest ), 
+                    PartitionNexusProxy.LOOKUP_BYPASS ),
+                farthest, registries );
+            ServerAttribute refs = referral.get( SchemaConstants.REF_AT );
             doReferralException( farthest, new LdapDN( name.getUpName() ), refs );
+            
         }
         else if ( refval.equals( FOLLOW ) )
         {
@@ -578,9 +593,12 @@
             }
             else if ( farthestSrc != null )
             {
-                Attributes referral = invocation.getProxy().lookup( new LookupOperationContext( registries, farthestSrc ),
-                    PartitionNexusProxy.LOOKUP_BYPASS );
-                Attribute refs = referral.get( SchemaConstants.REF_AT );
+                ServerEntry referral = ServerEntryUtils.toServerEntry( 
+                    invocation.getProxy().lookup( 
+                        new LookupOperationContext( registries, farthestSrc ), 
+                        PartitionNexusProxy.LOOKUP_BYPASS ),
+                    farthestSrc, registries );
+                ServerAttribute refs = referral.get( SchemaConstants.REF_AT );
                 doReferralException( farthestSrc, new LdapDN( oldName.getUpName() ), refs );
             }
             else if ( farthestDst != null )
@@ -650,10 +668,14 @@
             }
             else if ( farthestSrc != null )
             {
-                Attributes referral = invocation.getProxy().lookup( new LookupOperationContext( registries, farthestSrc ),
-                    PartitionNexusProxy.LOOKUP_BYPASS );
-                Attribute refs = referral.get( SchemaConstants.REF_AT );
+                ServerEntry referral = ServerEntryUtils.toServerEntry( 
+                    invocation.getProxy().lookup( 
+                        new LookupOperationContext( registries, farthestSrc ), 
+                        PartitionNexusProxy.LOOKUP_BYPASS ),
+                    farthestSrc, registries );
+                ServerAttribute refs = referral.get( SchemaConstants.REF_AT );
                 doReferralException( farthestSrc, new LdapDN( oldName.getUpName() ), refs );
+                
             }
             else if ( farthestDst != null )
             {
@@ -727,10 +749,14 @@
             
             if ( farthestSrc != null )
             {
-                Attributes referral = invocation.getProxy().lookup( new LookupOperationContext( registries, farthestSrc ),
-                    PartitionNexusProxy.LOOKUP_BYPASS );
-                Attribute refs = referral.get( SchemaConstants.REF_AT );
+                ServerEntry referral = ServerEntryUtils.toServerEntry( 
+                    invocation.getProxy().lookup( 
+                        new LookupOperationContext( registries, farthestSrc ), 
+                        PartitionNexusProxy.LOOKUP_BYPASS ),
+                    farthestSrc, registries );
+                ServerAttribute refs = referral.get( SchemaConstants.REF_AT );
                 doReferralException( farthestSrc, new LdapDN( oldName.getUpName() ), refs );
+                
             }
             else if ( farthestDst != null )
             {
@@ -856,8 +882,12 @@
                 return;
             }
 
-            Attributes referral = invocation.getProxy().lookup( new LookupOperationContext( registries, farthest ), PartitionNexusProxy.LOOKUP_BYPASS );
-            Attribute refs = referral.get( SchemaConstants.REF_AT );
+            ServerEntry referral = ServerEntryUtils.toServerEntry( 
+                invocation.getProxy().lookup( 
+                    new LookupOperationContext( registries, farthest ), 
+                    PartitionNexusProxy.LOOKUP_BYPASS ),
+                    farthest, registries );
+            ServerAttribute refs = referral.get( SchemaConstants.REF_AT );
             doReferralException( farthest, new LdapDN( name.getUpName() ), refs );
         }
         else if ( refval.equals( FOLLOW ) )

Modified: directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddEntryOperation.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddEntryOperation.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddEntryOperation.java (original)
+++ directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddEntryOperation.java Tue Jan 15 16:32:18 2008
@@ -28,6 +28,7 @@
 import org.apache.directory.mitosis.common.CSN;
 import org.apache.directory.mitosis.operation.support.EntryUtil;
 import org.apache.directory.mitosis.store.ReplicationStore;
+import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.entry.ServerEntryUtils;
 import org.apache.directory.server.core.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.interceptor.context.DeleteOperationContext;
@@ -56,7 +57,7 @@
      * 
      * @param entry an entry
      */
-    public AddEntryOperation( CSN csn, LdapDN normalizedName, Attributes entry )
+    public AddEntryOperation( CSN csn, LdapDN normalizedName, ServerEntry entry )
     {
         super( csn );
 
@@ -64,7 +65,7 @@
         assert entry != null;
 
         this.normalizedName = normalizedName;
-        this.entry = ( Attributes ) entry.clone();
+        this.entry = ServerEntryUtils.toAttributesImpl( entry );
     }
 
 
@@ -85,9 +86,7 @@
         EntryUtil.createGlueEntries( registries, nexus, normalizedName, false );
 
         // Replace the entry if an entry with the same name exists.
-        Attributes oldEntry = nexus.lookup( new LookupOperationContext( registries, normalizedName ) );
-        
-        if ( oldEntry != null )
+        if ( nexus.lookup( new LookupOperationContext( registries, normalizedName ) ) != null )
         {
             recursiveDelete( nexus, normalizedName, registries );
         }
@@ -101,6 +100,7 @@
         throws NamingException
     {
         NamingEnumeration<SearchResult> ne = nexus.list( new ListOperationContext( registries, normalizedName ) );
+        
         if ( !ne.hasMore() )
         {
             nexus.delete( new DeleteOperationContext( registries, normalizedName ) );

Modified: directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationCodec.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationCodec.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationCodec.java (original)
+++ directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationCodec.java Tue Jan 15 16:32:18 2008
@@ -69,6 +69,7 @@
     public Operation decode( byte[] data )
     {
         ObjectInputStream in;
+        
         try
         {
             in = new ObjectInputStream( new ByteArrayInputStream( data ) );
@@ -76,6 +77,7 @@
         }
         catch ( IOException e )
         {
+            e.printStackTrace();
             throw ( InternalError ) new InternalError().initCause( e );
         }
         catch ( ClassNotFoundException e )

Modified: directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationFactory.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationFactory.java (original)
+++ directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationFactory.java Tue Jan 15 16:32:18 2008
@@ -26,6 +26,9 @@
 import org.apache.directory.mitosis.common.UUIDFactory;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
 import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.entry.ServerAttribute;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ServerEntryUtils;
 import org.apache.directory.server.core.interceptor.context.EntryOperationContext;
 import org.apache.directory.server.core.interceptor.context.LookupOperationContext;
 import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
@@ -107,7 +110,7 @@
      * Creates a new {@link Operation} that performs LDAP "add" operation
      * with a newly generated {@link CSN}.
      */
-    public Operation newAdd( LdapDN normalizedName, Attributes entry ) throws NamingException
+    public Operation newAdd( LdapDN normalizedName, ServerEntry entry ) throws NamingException
     {
         return newAdd( newCSN(), normalizedName, entry );
     }
@@ -119,24 +122,24 @@
      * additional attributes; {@link Constants#ENTRY_CSN} ({@link CSN}),
      * {@link Constants#ENTRY_UUID}, and {@link Constants#ENTRY_DELETED}.
      */
-    private Operation newAdd( CSN csn, LdapDN normalizedName, Attributes entry ) throws NamingException
+    private Operation newAdd( CSN csn, LdapDN normalizedName, ServerEntry entry ) throws NamingException
     {
         // Check an entry already exists.
         checkBeforeAdd( normalizedName );
 
         // Insert 'entryUUID' and 'entryDeleted'.
-        entry = ( Attributes ) entry.clone();
-        entry.remove( Constants.ENTRY_UUID );
-        entry.remove( Constants.ENTRY_DELETED );
-        entry.put( Constants.ENTRY_UUID, uuidFactory.newInstance().toOctetString() );
-        entry.put( Constants.ENTRY_DELETED, "FALSE" );
+        ServerEntry cloneEntry = ( ServerEntry ) entry.clone();
+        cloneEntry.remove( Constants.ENTRY_UUID );
+        cloneEntry.remove( Constants.ENTRY_DELETED );
+        cloneEntry.put( Constants.ENTRY_UUID, uuidFactory.newInstance().toOctetString() );
+        cloneEntry.put( Constants.ENTRY_DELETED, "FALSE" );
 
         // NOTE: We inlined addDefaultOperations() because ApacheDS currently
         // creates an index entry only for ADD operation (and not for
         // MODIFY operation)
-        entry.put( Constants.ENTRY_CSN, csn.toOctetString() );
+        cloneEntry.put( Constants.ENTRY_CSN, csn.toOctetString() );
 
-        return new AddEntryOperation( csn, normalizedName, entry );
+        return new AddEntryOperation( csn, normalizedName, cloneEntry );
     }
 
 
@@ -253,6 +256,7 @@
         // Retrieve all subtree including the base entry
         SearchControls ctrl = new SearchControls();
         ctrl.setSearchScope( SearchControls.SUBTREE_SCOPE );
+        
         NamingEnumeration<SearchResult> e = nexus.search( 
             new SearchOperationContext( registries, oldName, AliasDerefMode.DEREF_ALWAYS,
                     new PresenceNode( SchemaConstants.OBJECT_CLASS_AT_OID ), ctrl ) );
@@ -270,17 +274,21 @@
                 "TRUE" ) ) );
 
             // Get the old entry attributes and replace RDN if required
-            Attributes entry = sr.getAttributes();
+            LdapDN entryName = new LdapDN( sr.getName() ); 
+            ServerEntry entry = ServerEntryUtils.toServerEntry( sr.getAttributes(), entryName, registries );
+            
             if ( oldEntryName.size() == oldName.size() )
             {
                 if ( deleteOldRn )
                 {
                     // Delete the old RDN attribute value
                     String oldRDNAttributeID = oldName.getRdn().getUpType();
-                    Attribute oldRDNAttribute = entry.get( oldRDNAttributeID );
+                    ServerAttribute oldRDNAttribute = entry.get( oldRDNAttributeID );
+                    
                     if ( oldRDNAttribute != null )
                     {
-                        boolean removed = oldRDNAttribute.remove( oldName.getRdn().getUpValue() );
+                        boolean removed = oldRDNAttribute.remove( (String)oldName.getRdn().getUpValue() );
+                        
                         if ( removed && oldRDNAttribute.size() == 0 )
                         {
                             // Now an empty attribute, remove it.
@@ -288,10 +296,12 @@
                         }
                     }
                 }
+                
                 // Add the new RDN attribute value.
                 String newRDNAttributeID = newRdn.getUpType();
                 String newRDNAttributeValue = ( String ) newRdn.getUpValue();
-                Attribute newRDNAttribute = entry.get( newRDNAttributeID );
+                ServerAttribute newRDNAttribute = entry.get( newRDNAttributeID );
+                
                 if ( newRDNAttribute != null )
                 {
                     newRDNAttribute.add( newRDNAttributeValue );
@@ -305,10 +315,12 @@
             // Calculate new name from newParentName, oldEntryName, and newRdn.
             LdapDN newEntryName = ( LdapDN ) newParentName.clone();
             newEntryName.add( newRdn );
+            
             for ( int i = oldEntryName.size() - newEntryName.size(); i > 0; i-- )
             {
                 newEntryName.add( oldEntryName.get( oldEntryName.size() - i ) );
             }
+            
             newEntryName.normalize( attributeRegistry.getNormalizerMapping() );
 
             // Add the new entry

Modified: directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/support/EntryUtil.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/support/EntryUtil.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/support/EntryUtil.java (original)
+++ directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/support/EntryUtil.java Tue Jan 15 16:32:18 2008
@@ -25,6 +25,8 @@
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.entry.ServerEntryUtils;
 import org.apache.directory.server.core.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.interceptor.context.EntryOperationContext;
@@ -32,8 +34,6 @@
 import org.apache.directory.server.core.partition.PartitionNexus;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.NamespaceTools;
 import org.apache.directory.shared.ldap.util.StringTools;
@@ -120,7 +120,7 @@
         }
 
         // Create a glue entry.
-        Attributes entry = new AttributesImpl( true );
+        ServerEntry entry = new DefaultServerEntry( registries, name );
         
         //// Add RDN attribute. 
         String rdn = name.get( name.size() - 1 );
@@ -129,13 +129,10 @@
         entry.put( rdnAttribute, rdnValue );
         
         //// Add objectClass attribute. 
-        Attribute objectClassAttr = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT );
-        objectClassAttr.add( SchemaConstants.TOP_OC );
-        objectClassAttr.add( SchemaConstants.EXTENSIBLE_OBJECT_OC );
-        entry.put( objectClassAttr );
+        entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, SchemaConstants.EXTENSIBLE_OBJECT_OC );
 
         // And add it to the nexus.
-        nexus.add( new AddOperationContext( registries, name, ServerEntryUtils.toServerEntry( entry, name, registries ) ) );
+        nexus.add( new AddOperationContext( registries, name, entry ) );
     }
 
 

Modified: directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationInterceptor.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationInterceptor.java (original)
+++ directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationInterceptor.java Tue Jan 15 16:32:18 2008
@@ -397,7 +397,8 @@
 
     public void add( NextInterceptor nextInterceptor, AddOperationContext addContext ) throws NamingException
     {
-        Operation op = operationFactory.newAdd( addContext.getDn(), ServerEntryUtils.toAttributesImpl( addContext.getEntry() ) );
+        Operation op = operationFactory.newAdd( 
+            addContext.getDn(), addContext.getEntry() );
         op.execute( nexus, store, registries );
     }
 

Modified: directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationClientContextHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationClientContextHandler.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationClientContextHandler.java (original)
+++ directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationClientContextHandler.java Tue Jan 15 16:32:18 2008
@@ -44,6 +44,7 @@
 import org.apache.directory.mitosis.store.ReplicationStore;
 import org.apache.directory.server.core.entry.ServerAttribute;
 import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ServerEntryUtils;
 import org.apache.directory.server.core.entry.ServerValue;
 import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
@@ -58,8 +59,6 @@
 
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
 import java.net.InetSocketAddress;
@@ -399,10 +398,14 @@
             while ( e.hasMore() )
             {
                 SearchResult sr = e.next();
-                Attributes attrs = sr.getAttributes();
+                ServerEntry attrs = ServerEntryUtils.toServerEntry( 
+                    sr.getAttributes(), 
+                    new LdapDN( sr.getName() ), 
+                    ctx.getDirectoryService().getRegistries() ) ;
 
                 // Skip entries without entryCSN attribute.
-                Attribute entryCSNAttr = attrs.get( org.apache.directory.mitosis.common.Constants.ENTRY_CSN );
+                ServerAttribute entryCSNAttr = attrs.get( org.apache.directory.mitosis.common.Constants.ENTRY_CSN );
+                
                 if ( entryCSNAttr == null )
                 {
                     continue;
@@ -410,6 +413,7 @@
 
                 // Get entryCSN of the entry.  Skip if entryCSN value is invalid. 
                 CSN csn;
+                
                 try
                 {
                     Object val = entryCSNAttr.get();

Modified: directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/AbstractReplicationServiceTestCase.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/AbstractReplicationServiceTestCase.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/AbstractReplicationServiceTestCase.java (original)
+++ directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/AbstractReplicationServiceTestCase.java Tue Jan 15 16:32:18 2008
@@ -31,6 +31,8 @@
 import org.apache.directory.server.core.interceptor.Interceptor;
 import org.apache.directory.server.core.jndi.CoreContextFactory;
 import org.apache.mina.util.AvailablePortFinder;
+import org.junit.After;
+import org.junit.Before;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -53,7 +55,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public abstract class AbstractReplicationServiceTestCase extends TestCase
+public abstract class AbstractReplicationServiceTestCase
 {
     private static final Logger LOG = LoggerFactory.getLogger( AbstractReplicationServiceTestCase.class );
     protected Map<String, LdapContext> contexts = new HashMap<String, LdapContext>();
@@ -61,13 +63,13 @@
     protected Map<String, ReplicationInterceptor> replicationServices = new HashMap<String, ReplicationInterceptor>();
 
 
-    protected void setUp() throws Exception
+    @Before public void setUp() throws Exception
     {
         createReplicas( new String[] { "A", "B", "C" } );
     }
 
 
-    protected void tearDown() throws Exception
+    @After public void tearDown() throws Exception
     {
         destroyAllReplicas();
     }
@@ -78,6 +80,7 @@
         int lastAvailablePort = 1024;
 
         Replica[] replicas = new Replica[ names.length ];
+        
         for( int i = 0; i < names.length; i++ )
         {
             int replicationPort = AvailablePortFinder.getNextAvailable( lastAvailablePort );

Modified: directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/DIRSERVER1013ITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/DIRSERVER1013ITest.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/DIRSERVER1013ITest.java (original)
+++ directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/DIRSERVER1013ITest.java Tue Jan 15 16:32:18 2008
@@ -24,6 +24,10 @@
 
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNull;
 
 
 /**
@@ -39,14 +43,14 @@
  */
 public class DIRSERVER1013ITest extends AbstractReplicationServiceTestCase
 {
-    protected void setUp() throws Exception
+    @Before public void setUp() throws Exception
     {
         // Create two replicas as we currently can't have the
         // replication service enabled without more than one.
         createReplicas( new String[] { "A", "B" } );
     }
     
-    public void testNoRDNOID () throws Exception
+    @Test public void testNoRDNOID () throws Exception
     {
         LdapContext ctxA = getReplicaContext( "A" );
         

Modified: directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java (original)
+++ directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java Tue Jan 15 16:32:18 2008
@@ -19,6 +19,9 @@
  */
 package org.apache.directory.mitosis.service;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
@@ -34,6 +37,11 @@
 import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.message.ModificationItemImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.DeepTrimToLowerNormalizer;
+import org.apache.directory.shared.ldap.schema.OidNormalizer;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
 
 /**
  * A test case for {@link ReplicationServiceITest}
@@ -43,12 +51,26 @@
  */
 public class ReplicationServiceITest extends AbstractReplicationServiceTestCase
 {
-    protected void setUp() throws Exception
+    private Map<String, OidNormalizer> oids;
+    
+    @Before public void setUp() throws Exception
     {
         createReplicas( new String[] { "A", "B", "C" } );
+
+        
+        // Initialize OIDs maps for normalization
+        oids = new HashMap<String, OidNormalizer>();
+
+        oids.put( "ou", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
+        oids.put( "organizationalUnitName", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
+        oids.put( "2.5.4.11", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
+        oids.put( "cn", new OidNormalizer( "cn", new DeepTrimToLowerNormalizer() ) );
+        oids.put( "commonName", new OidNormalizer( "cn", new DeepTrimToLowerNormalizer() ) );
+        oids.put( "2.5.4.3", new OidNormalizer( "cn", new DeepTrimToLowerNormalizer() ) );
     }
 
-    public void testOneWay() throws Exception
+    @Ignore
+    @Test public void testOneWay() throws Exception
     {
         String dn1 = "cn=test,ou=system";
         String dn2 = "cn=test2,ou=system";

Modified: directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/AbstractMessageCodecTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/AbstractMessageCodecTest.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/AbstractMessageCodecTest.java (original)
+++ directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/AbstractMessageCodecTest.java Tue Jan 15 16:32:18 2008
@@ -30,11 +30,12 @@
 import org.apache.mina.filter.codec.demux.MessageDecoder;
 import org.apache.mina.filter.codec.demux.MessageEncoder;
 import org.apache.mina.filter.codec.support.SimpleProtocolEncoderOutput;
+import org.junit.Test;
 
 import sun.misc.Queue;
 
 
-public abstract class AbstractMessageCodecTest extends TestCase
+public abstract class AbstractMessageCodecTest
 {
     private final BaseMessage message;
     private final MessageEncoder encoder;
@@ -62,7 +63,7 @@
     }
 
 
-    public void testMessageCodec() throws Exception
+    @Test public void testMessageCodec() throws Exception
     {
         SimpleProtocolEncoderOutput encoderOut = new SimpleProtocolEncoderOutput()
         {

Modified: directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageCodecTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageCodecTest.java?rev=612324&r1=612323&r2=612324&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageCodecTest.java (original)
+++ directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageCodecTest.java Tue Jan 15 16:32:18 2008
@@ -20,7 +20,11 @@
 package org.apache.directory.mitosis.service.protocol.codec;
 
 
+import java.util.HashMap;
+import java.util.Map;
+
 import javax.naming.InvalidNameException;
+import javax.naming.NamingException;
 
 import org.apache.directory.mitosis.common.ReplicaId;
 import org.apache.directory.mitosis.common.DefaultCSN;
@@ -31,17 +35,42 @@
 import org.apache.directory.mitosis.service.protocol.message.LogEntryMessage;
 import org.apache.directory.shared.ldap.message.AttributeImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.DeepTrimToLowerNormalizer;
+import org.apache.directory.shared.ldap.schema.OidNormalizer;
 
 
 public class LogEntryMessageCodecTest extends AbstractMessageCodecTest
 {
+    private static Map<String, OidNormalizer> oids = new HashMap<String, OidNormalizer>();
+
+    static 
+    {
+        oids.put( "ou", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
+        oids.put( "organizationalUnitName", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
+        oids.put( "2.5.4.11", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
+    }
+    
 
-    public LogEntryMessageCodecTest() throws InvalidNameException
+    public LogEntryMessageCodecTest() throws InvalidNameException, NamingException
     {
+        // Initialize OIDs maps for normalization
+        /*Map<String, OidNormalizer> oids = new HashMap<String, OidNormalizer>();
+
+        oids.put( "ou", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
+        oids.put( "organizationalUnitName", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
+        oids.put( "2.5.4.11", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
+         */
+        
         super(
-            new LogEntryMessage( 1234, new AddAttributeOperation( new DefaultCSN( System.currentTimeMillis(),
-                new ReplicaId( "testReplica0" ), 1234 ), new LdapDN( "ou=system" ),
-                new AttributeImpl( "Hello", "Test" ) ) ), new LogEntryMessageEncoder(), new LogEntryMessageDecoder() );
+            new LogEntryMessage( 
+                1234, 
+                new AddAttributeOperation( 
+                    new DefaultCSN( System.currentTimeMillis(),
+                        new ReplicaId( "testReplica0" ), 1234 ), 
+                    new LdapDN( "ou=system" ).normalize( oids ),
+                    new AttributeImpl( "Hello", "Test" ) ) ), 
+            new LogEntryMessageEncoder(), 
+            new LogEntryMessageDecoder() );
     }
 
 



Mime
View raw message