directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r471330 - in /directory/trunks/apacheds/mitosis/src: main/java/org/apache/directory/mitosis/configuration/ main/java/org/apache/directory/mitosis/operation/ main/java/org/apache/directory/mitosis/operation/support/ test/java/org/apache/dire...
Date Sun, 05 Nov 2006 02:18:08 GMT
Author: akarasulu
Date: Sat Nov  4 18:18:07 2006
New Revision: 471330

URL: http://svn.apache.org/viewvc?view=rev&rev=471330
Log:
changes ...

 o source formating 
 o removed use of default constructor new BasicAttributes() replacing it with
   new BasicAttributes( true )
 o fixed search that use non-normalized filter expression
 o removed the use of Name replacing it with LdapDN since LdapDN may not always 
   implement Name


Modified:
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicaIdPropertyEditor.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicaPropertyEditor.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicationConfiguration.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicationConfigurationException.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddAttributeOperation.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddEntryOperation.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AttributeOperation.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/CompositeOperation.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/DeleteAttributeOperation.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/Operation.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationCodec.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationFactory.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/ReplaceAttributeOperation.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/support/EntryUtil.java
    directory/trunks/apacheds/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageCodecTest.java
    directory/trunks/apacheds/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicaIdPropertyEditor.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicaIdPropertyEditor.java?view=diff&rev=471330&r1=471329&r2=471330
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicaIdPropertyEditor.java (original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicaIdPropertyEditor.java Sat Nov  4 18:18:07 2006
@@ -19,11 +19,13 @@
  */
 package org.apache.directory.mitosis.configuration;
 
+
 import java.beans.PropertyEditor;
 import java.beans.PropertyEditorSupport;
 
 import org.apache.directory.mitosis.common.ReplicaId;
 
+
 /**
  * A {@link PropertyEditor} that converts strings into {@link ReplicaId}s
  * and vice versa.
@@ -38,15 +40,17 @@
         super();
     }
 
+
     public ReplicaIdPropertyEditor( Object source )
     {
         super( source );
     }
 
+
     public String getAsText()
     {
         Object val = getValue();
-        if( val == null )
+        if ( val == null )
         {
             return "";
         }
@@ -56,10 +60,11 @@
         }
     }
 
+
     public void setAsText( String text ) throws IllegalArgumentException
     {
         text = text.trim();
-        if( text.length() == 0 )
+        if ( text.length() == 0 )
         {
             setValue( null );
         }

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicaPropertyEditor.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicaPropertyEditor.java?view=diff&rev=471330&r1=471329&r2=471330
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicaPropertyEditor.java (original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicaPropertyEditor.java Sat Nov  4 18:18:07 2006
@@ -19,11 +19,13 @@
  */
 package org.apache.directory.mitosis.configuration;
 
+
 import java.beans.PropertyEditor;
 import java.beans.PropertyEditorSupport;
 
 import org.apache.directory.mitosis.common.Replica;
 
+
 /**
  * A {@link PropertyEditor} that converts strings into {@link Replica}s
  * and vice versa.
@@ -38,26 +40,26 @@
         super();
     }
 
+
     public ReplicaPropertyEditor( Object source )
     {
         super( source );
     }
 
+
     public String getAsText()
     {
         Object value = getValue();
-        if( value == null )
+        if ( value == null )
         {
             return "";
         }
-        
+
         Replica replica = ( Replica ) value;
-        return replica.getId().toString() +
-                '@' +
-                replica.getAddress().getAddress().getHostAddress() +
-                ':' +
-                replica.getAddress().getPort();
+        return replica.getId().toString() + '@' + replica.getAddress().getAddress().getHostAddress() + ':'
+            + replica.getAddress().getPort();
     }
+
 
     public void setAsText( String text ) throws IllegalArgumentException
     {

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicationConfiguration.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicationConfiguration.java?view=diff&rev=471330&r1=471329&r2=471330
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicationConfiguration.java (original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicationConfiguration.java Sat Nov  4 18:18:07 2006
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.mitosis.configuration;
 
+
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.HashMap;
@@ -28,7 +29,6 @@
 import java.util.Set;
 import java.util.TreeSet;
 
-import org.apache.commons.collections.set.TypedSet;
 import org.apache.directory.mitosis.common.CSNFactory;
 import org.apache.directory.mitosis.common.Replica;
 import org.apache.directory.mitosis.common.ReplicaId;
@@ -38,9 +38,11 @@
 import org.apache.directory.mitosis.store.ReplicationStore;
 import org.apache.directory.mitosis.store.derby.DerbyReplicationStore;
 import org.apache.directory.shared.ldap.util.StringTools;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+
 public class ReplicationConfiguration
 {
     /** The logger */
@@ -49,82 +51,96 @@
     private ReplicaId replicaId;
     private int serverPort = 7846;
     private int responseTimeout = 60;
-    private final Set peerReplicas = TypedSet.decorate( new HashSet(), Replica.class );
+
+    private final Set<Replica> peerReplicas = new HashSet<Replica>();
+    
     private UUIDFactory uuidFactory = new SimpleUUIDFactory();
     private CSNFactory csnFactory = new SimpleCSNFactory();
     private ReplicationStore store = new DerbyReplicationStore();
     private int logMaxAge = 7; // a week (days)
 
+
     public ReplicationConfiguration()
     {
     }
-    
+
+
     public int getServerPort()
     {
         return serverPort;
     }
 
+
     public void setServerPort( int serverPort )
     {
         this.serverPort = serverPort;
     }
 
+
     public int getResponseTimeout()
     {
         return responseTimeout;
     }
 
+
     public void setResponseTimeout( int responseTimeout )
     {
         this.responseTimeout = responseTimeout;
     }
 
+
     public CSNFactory getCsnFactory()
     {
         return csnFactory;
     }
-    
+
+
     public void setCsnFactory( CSNFactory csnFactory )
     {
         this.csnFactory = csnFactory;
     }
-    
+
+
     public void addPeerReplica( Replica peer )
     {
         assert peer != null;
         peerReplicas.add( peer );
     }
-    
+
+
     public void removePeerReplica( Replica peer )
     {
         assert peer != null;
         peerReplicas.remove( peer );
     }
-    
+
+
     public void removeAllPeerReplicas()
     {
         peerReplicas.clear();
     }
-    
-    public Set getPeerReplicas()
+
+
+    public Set<Replica> getPeerReplicas()
     {
-        Set result = new HashSet();
+        Set<Replica> result = new HashSet<Replica>();
         result.addAll( peerReplicas );
         return result;
     }
-    
+
+
     public void setPeerReplicas( Set replicas )
     {
         assert replicas != null;
-        
-        Set normalizedReplicas = new HashSet();
+
+        Set<Replica> normalizedReplicas = new HashSet<Replica>();
         Iterator i = replicas.iterator();
-        while( i.hasNext() )
+        while ( i.hasNext() )
         {
             Object o = i.next();
-            if( o instanceof Replica )
+            if ( o instanceof Replica )
             {
-                normalizedReplicas.add( o );
+                normalizedReplicas.add( ( Replica ) o );
             }
             else
             {
@@ -134,53 +150,62 @@
         this.peerReplicas.clear();
         this.peerReplicas.addAll( normalizedReplicas );
     }
-    
+
+
     public ReplicaId getReplicaId()
     {
         return replicaId;
     }
-    
+
+
     public void setReplicaId( ReplicaId replicaId )
     {
         assert replicaId != null;
         this.replicaId = replicaId;
     }
-    
+
+
     public ReplicationStore getStore()
     {
         return store;
     }
-    
+
+
     public void setStore( ReplicationStore store )
     {
         this.store = store;
     }
-    
+
+
     public UUIDFactory getUuidFactory()
     {
         return uuidFactory;
     }
-    
+
+
     public void setUuidFactory( UUIDFactory uuidFactory )
     {
         this.uuidFactory = uuidFactory;
     }
-    
+
+
     public int getLogMaxAge()
     {
         return logMaxAge;
     }
-    
+
+
     public void setLogMaxAge( int logMaxAge )
     {
-        if( logMaxAge <= 0 )
+        if ( logMaxAge <= 0 )
         {
             throw new ReplicationConfigurationException( "logMaxAge: " + logMaxAge );
         }
-        
+
         this.logMaxAge = logMaxAge;
     }
-    
+
+
     /**
      * Validate Mitosis configuration.
      * 
@@ -204,92 +229,95 @@
             log.error( "The replicaId is missing" );
             throw new ReplicationConfigurationException( "Replica ID is not specified." );
         }
-        
+
         if ( serverPort < 0 || serverPort > 65535 )
         {
             log.error( "The replica port is not between 0 and 65535" );
             throw new ReplicationConfigurationException( "Server port is invalid: " + serverPort );
         }
-        
+
         if ( responseTimeout <= 0 )
         {
             log.error( "The replica responsetimeout is negative" );
             throw new ReplicationConfigurationException( "Invalid response timeout: " + responseTimeout );
         }
-        
-        if( uuidFactory == null )
+
+        if ( uuidFactory == null )
         {
             log.error( "The UUID factory has not been declared" );
             throw new ReplicationConfigurationException( "UUID factory is not specified." );
         }
-        
-        if( csnFactory == null )
+
+        if ( csnFactory == null )
         {
             log.error( "The CSN factory has not been declared" );
             throw new ReplicationConfigurationException( "CSN factory is not specified." );
         }
-        
-        if( store == null )
+
+        if ( store == null )
         {
             log.error( "The store has not been declared" );
             throw new ReplicationConfigurationException( "Replication store is not specified." );
         }
-        
-        if( peerReplicas.size() == 0 )
+
+        if ( peerReplicas.size() == 0 )
         {
             log.error( "The replicas peer list is empty" );
             throw new ReplicationConfigurationException( "No peer replicas" );
         }
-        
+
         // Check the peer replicas.
         // We should check that no replica has the same Id, and that we don't
         // have two replicas on the same server with the same port
-        Set ids = new TreeSet();
-        Map servers = new HashMap();  
-        
+        Set<String> ids = new TreeSet<String>();
+        Map<String, Integer> servers = new HashMap<String, Integer>();
+
         // Initialize the set with this server replicaId
         ids.add( replicaId.getId() );
-        
+
         // And store the local inetadress
         Integer localPort = new Integer( serverPort );
         servers.put( "localhost", localPort );
         servers.put( "127.0.0.1", localPort );
-        
+
         try
         {
-            servers.put( StringTools.lowerCase( InetAddress.getByName( "127.0.0.1" ).getHostName() ) , localPort );
+            servers.put( StringTools.lowerCase( InetAddress.getByName( "127.0.0.1" ).getHostName() ), localPort );
         }
         catch ( UnknownHostException uhe )
         {
             // Should never occurs with 127.0.0.1
             throw new ReplicationConfigurationException( "Unknown host name" );
         }
-        
-        for ( Iterator peer = peerReplicas.iterator(); peer.hasNext(); )
+
+        for ( Iterator<Replica> peer = peerReplicas.iterator(); peer.hasNext(); )
         {
-            Replica replica = ( Replica ) peer.next();
-            
-            if ( ids.contains( replica.getId().getId() ) ) 
+            Replica replica = peer.next();
+
+            if ( ids.contains( replica.getId().getId() ) )
             {
                 log.error( "Peer replica ID '{}' has already been declared.", replica.getId() );
-                throw new ReplicationConfigurationException( "Peer replica ID '" + replica.getId() + "' has already been declared." );
+                throw new ReplicationConfigurationException( "Peer replica ID '" + replica.getId()
+                    + "' has already been declared." );
             }
-            
+
             // Now check that we don't already have a replica on a server with the same port 
             String replicaServer = StringTools.lowerCase( replica.getAddress().getHostName() );
             Integer replicaPort = new Integer( replica.getAddress().getPort() );
-            
+
             if ( servers.containsKey( replicaServer ) )
             {
-                Integer peerPort = ((Integer)servers.get( replicaServer ) );
-                
+                Integer peerPort = ( servers.get( replicaServer ) );
+
                 if ( replicaPort == peerPort )
                 {
-                    log.error( "The replica in the peer list has already been declared on the server {} with the port {}", replicaServer, peerPort );
+                    log.error(
+                        "The replica in the peer list has already been declared on the server {} with the port {}",
+                        replicaServer, peerPort );
                     throw new ReplicationConfigurationException( "Replication store is not specified." );
                 }
             }
-            
+
             servers.put( replicaServer, replicaPort );
         }
     }

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicationConfigurationException.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicationConfigurationException.java?view=diff&rev=471330&r1=471329&r2=471330
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicationConfigurationException.java (original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/configuration/ReplicationConfigurationException.java Sat Nov  4 18:18:07 2006
@@ -19,8 +19,10 @@
  */
 package org.apache.directory.mitosis.configuration;
 
+
 import org.apache.directory.mitosis.common.ReplicationException;
 
+
 public class ReplicationConfigurationException extends ReplicationException
 {
     /**
@@ -32,20 +34,24 @@
      */
     private static final long serialVersionUID = 1L;
 
+
     public ReplicationConfigurationException()
     {
         super();
     }
 
+
     public ReplicationConfigurationException( String message, Throwable cause )
     {
         super( message, cause );
     }
 
+
     public ReplicationConfigurationException( String message )
     {
         super( message );
     }
+
 
     public ReplicationConfigurationException( Throwable cause )
     {

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddAttributeOperation.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddAttributeOperation.java?view=diff&rev=471330&r1=471329&r2=471330
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddAttributeOperation.java (original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddAttributeOperation.java Sat Nov  4 18:18:07 2006
@@ -19,7 +19,7 @@
  */
 package org.apache.directory.mitosis.operation;
 
-import javax.naming.Name;
+
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
@@ -30,6 +30,7 @@
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.mitosis.common.CSN;
 
+
 /**
  * An {@link Operation} that adds an attribute to an entry.
  *
@@ -39,25 +40,28 @@
 {
     private static final long serialVersionUID = 7373124294791982297L;
 
+
     /**
      * Creates a new operation that adds the specified attribute.
      * 
      * @param attribute an attribute to add
      */
-    public AddAttributeOperation( CSN csn, Name name, Attribute attribute )
+    public AddAttributeOperation( CSN csn, LdapDN name, Attribute attribute )
     {
         super( csn, name, attribute );
     }
-    
+
+
     public String toString()
     {
         return super.toString() + ".add( " + getAttribute() + " )";
     }
 
+
     protected void execute1( PartitionNexus nexus ) throws NamingException
     {
-        Attributes attrs = new BasicAttributes();
+        Attributes attrs = new BasicAttributes( true );
         attrs.put( getAttribute() );
-        nexus.modify( (LdapDN)getName(), DirContext.ADD_ATTRIBUTE, attrs );
+        nexus.modify( getName(), DirContext.ADD_ATTRIBUTE, attrs );
     }
 }

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddEntryOperation.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddEntryOperation.java?view=diff&rev=471330&r1=471329&r2=471330
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddEntryOperation.java (original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddEntryOperation.java Sat Nov  4 18:18:07 2006
@@ -19,7 +19,7 @@
  */
 package org.apache.directory.mitosis.operation;
 
-import javax.naming.Name;
+
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
@@ -33,6 +33,7 @@
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.NamespaceTools;
 
+
 /**
  * An {@link Operation} that adds a new entry.
  *
@@ -42,69 +43,71 @@
 {
     private static final long serialVersionUID = 2294492811671880570L;
 
-    private final Name normalizedName;
+    private final LdapDN normalizedName;
     private final Attributes entry;
 
+
     /**
      * Creates a new instance.
      * 
      * @param entry an entry
      */
-    public AddEntryOperation( CSN csn, Name normalizedName, Attributes entry )
+    public AddEntryOperation( CSN csn, LdapDN normalizedName, Attributes entry )
     {
         super( csn );
 
         assert normalizedName != null;
         assert entry != null;
-        
+
         this.normalizedName = normalizedName;
         this.entry = ( Attributes ) entry.clone();
     }
-    
+
+
     public String toString()
     {
         return super.toString() + ": [" + normalizedName + "].new( " + entry + " )";
     }
 
+
     protected void execute0( PartitionNexus nexus, ReplicationStore store ) throws NamingException
     {
-        if( !EntryUtil.isEntryUpdatable( nexus, normalizedName, getCSN() ) )
+        if ( !EntryUtil.isEntryUpdatable( nexus, normalizedName, getCSN() ) )
         {
             return;
         }
         EntryUtil.createGlueEntries( nexus, normalizedName, false );
-        
+
         // Replace the entry if an entry with the same name exists.
-        Attributes oldEntry = nexus.lookup( (LdapDN)normalizedName );
-        if( oldEntry != null )
+        Attributes oldEntry = nexus.lookup( normalizedName );
+        if ( oldEntry != null )
         {
             // Find the attributes that new entry doesn't have.
             Attributes attrsToRemove = ( Attributes ) oldEntry.clone();
             NamingEnumeration e = oldEntry.getAll();
-            while( e.hasMore() )
+            while ( e.hasMore() )
             {
                 Attribute attr = ( Attribute ) e.next();
                 String attrID = attr.getID();
-                if( entry.get( attrID ) != null )
+                if ( entry.get( attrID ) != null )
                 {
                     attrsToRemove.remove( attrID );
                 }
             }
-            
+
             // Don't let RN attribute be removed
-            String rnAttrID = NamespaceTools.getRdnAttribute(
-                    normalizedName.get( normalizedName.size() - 1 ) );
+            String rnAttrID = NamespaceTools.getRdnAttribute( normalizedName.get( normalizedName.size() - 1 ) );
             attrsToRemove.remove( rnAttrID );
-            
+
             // Delete the attributes.
-            nexus.modify( (LdapDN)normalizedName, DirContext.REMOVE_ATTRIBUTE, entry );
+            nexus.modify( normalizedName, DirContext.REMOVE_ATTRIBUTE, entry );
 
             // Remove RN attribute from new entry because it should be the same
             // with the old one.
             entry.remove( rnAttrID );
 
             // Now replace old entries with the new attributes
-            nexus.modify( (LdapDN)normalizedName, DirContext.REPLACE_ATTRIBUTE, entry );
+            nexus.modify( normalizedName, DirContext.REPLACE_ATTRIBUTE, entry );
         }
         else
         {
@@ -113,10 +116,8 @@
             // LockableAttributesImpl which doesn't replace old attributes
             // when we put a new one.
             entry.remove( NamespaceTools.getRdnAttribute( rdn ) );
-            entry.put(
-                    NamespaceTools.getRdnAttribute( rdn ),
-                    NamespaceTools.getRdnValue( rdn ) );
-            nexus.add( (LdapDN)normalizedName, entry );
+            entry.put( NamespaceTools.getRdnAttribute( rdn ), NamespaceTools.getRdnValue( rdn ) );
+            nexus.add( normalizedName, entry );
         }
     }
 }

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AttributeOperation.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AttributeOperation.java?view=diff&rev=471330&r1=471329&r2=471330
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AttributeOperation.java (original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AttributeOperation.java Sat Nov  4 18:18:07 2006
@@ -19,15 +19,17 @@
  */
 package org.apache.directory.mitosis.operation;
 
-import javax.naming.Name;
+
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 
 import org.apache.directory.server.core.partition.PartitionNexus;
+import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.mitosis.common.CSN;
 import org.apache.directory.mitosis.operation.support.EntryUtil;
 import org.apache.directory.mitosis.store.ReplicationStore;
 
+
 /**
  * An {@link Operation} that adds an attribute to an entry.
  *
@@ -35,16 +37,17 @@
  */
 public abstract class AttributeOperation extends Operation
 {
-    private final Name name;
+    private final LdapDN name;
     private final Attribute attribute;
 
+
     /**
      * Create a new operation that affects an entry with the specified name.
      * 
      * @param name the normalized name of an entry 
      * @param attribute an attribute to modify
      */
-    public AttributeOperation( CSN csn, Name name, Attribute attribute )
+    public AttributeOperation( CSN csn, LdapDN name, Attribute attribute )
     {
         super( csn );
 
@@ -54,7 +57,8 @@
         this.name = name;
         this.attribute = ( Attribute ) attribute.clone();
     }
-    
+
+
     /**
      * Returns the attribute to modify.
      */
@@ -63,24 +67,27 @@
         return ( Attribute ) attribute.clone();
     }
 
+
     /**
      * Returns the name of an entry this operation will affect.
      */
-    public Name getName()
+    public LdapDN getName()
     {
-        return ( Name ) name.clone();
+        return ( LdapDN ) name.clone();
     }
 
+
     protected final void execute0( PartitionNexus nexus, ReplicationStore store ) throws NamingException
     {
-        if( !EntryUtil.isEntryUpdatable( nexus, name, getCSN() ) )
+        if ( !EntryUtil.isEntryUpdatable( nexus, name, getCSN() ) )
         {
             return;
         }
         EntryUtil.createGlueEntries( nexus, name, true );
-        
+
         execute1( nexus );
     }
+
 
     protected abstract void execute1( PartitionNexus nexus ) throws NamingException;
 

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/CompositeOperation.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/CompositeOperation.java?view=diff&rev=471330&r1=471329&r2=471330
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/CompositeOperation.java (original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/CompositeOperation.java Sat Nov  4 18:18:07 2006
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.mitosis.operation;
 
+
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -37,6 +38,7 @@
 import org.apache.directory.mitosis.store.ReplicationLogIterator;
 import org.apache.directory.mitosis.store.ReplicationStore;
 
+
 /**
  * An {@link Operation} that contains other {@link Operation}s.
  *
@@ -45,96 +47,131 @@
 public class CompositeOperation extends Operation
 {
     private static final long serialVersionUID = 6252675003841951356L;
-    
-    private static final ReplicationStore DUMMY_STORE = new ReplicationStore() {
 
-        public void open( DirectoryServiceConfiguration serviceCfg, ReplicationConfiguration cfg) {
+    private static final ReplicationStore DUMMY_STORE = new ReplicationStore()
+    {
+
+        public void open( DirectoryServiceConfiguration serviceCfg, ReplicationConfiguration cfg )
+        {
         }
 
-        public void close() {
+
+        public void close()
+        {
         }
 
-        public ReplicaId getReplicaId() {
+
+        public ReplicaId getReplicaId()
+        {
             return null;
         }
 
-        public Set getKnownReplicaIds() {
+
+        public Set getKnownReplicaIds()
+        {
             return null;
         }
 
-        public Name getDN(UUID uuid) {
+
+        public Name getDN( UUID uuid )
+        {
             return null;
         }
 
-        public boolean putUUID(UUID uuid, Name dn) {
+
+        public boolean putUUID( UUID uuid, Name dn )
+        {
             return false;
         }
 
-        public boolean removeUUID(UUID uuid) {
+
+        public boolean removeUUID( UUID uuid )
+        {
             return false;
         }
 
-        public void putLog(Operation operation) {
+
+        public void putLog( Operation operation )
+        {
         }
 
-        public ReplicationLogIterator getLogs(CSN fromCSN, boolean inclusive) {
+
+        public ReplicationLogIterator getLogs( CSN fromCSN, boolean inclusive )
+        {
             return null;
         }
 
-        public ReplicationLogIterator getLogs(CSNVector updateVector, boolean inclusive) {
+
+        public ReplicationLogIterator getLogs( CSNVector updateVector, boolean inclusive )
+        {
             return null;
         }
 
-        public int removeLogs(CSN toCSN, boolean inclusive) {
+
+        public int removeLogs( CSN toCSN, boolean inclusive )
+        {
             return 0;
         }
 
-        public int getLogSize() {
+
+        public int getLogSize()
+        {
             return 0;
         }
 
-        public int getLogSize(ReplicaId replicaId) {
+
+        public int getLogSize( ReplicaId replicaId )
+        {
             return 0;
         }
 
-        public CSNVector getUpdateVector() {
+
+        public CSNVector getUpdateVector()
+        {
             return null;
         }
 
-        public CSNVector getPurgeVector() {
+
+        public CSNVector getPurgeVector()
+        {
             return null;
         }
     };
 
-    private final List children = new ArrayList();
+    private final List<Operation> children = new ArrayList<Operation>();
+
 
     public CompositeOperation( CSN csn )
     {
         super( csn );
     }
-    
+
+
     public void add( Operation op )
     {
         assert op != null;
         assert op.getCSN().equals( this.getCSN() );
         children.add( op );
     }
-    
+
+
     public void clear()
     {
         children.clear();
     }
-    
+
+
     protected void execute0( PartitionNexus nexus, ReplicationStore store ) throws NamingException
     {
-        Iterator i = children.iterator();
-        while( i.hasNext() )
+        Iterator<Operation> i = children.iterator();
+        while ( i.hasNext() )
         {
-            Operation op = ( Operation ) i.next();
+            Operation op = i.next();
             op.execute( nexus, DUMMY_STORE );
         }
     }
-    
+
+
     public String toString()
     {
         return children.toString();

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/DeleteAttributeOperation.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/DeleteAttributeOperation.java?view=diff&rev=471330&r1=471329&r2=471330
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/DeleteAttributeOperation.java (original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/DeleteAttributeOperation.java Sat Nov  4 18:18:07 2006
@@ -19,7 +19,7 @@
  */
 package org.apache.directory.mitosis.operation;
 
-import javax.naming.Name;
+
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
@@ -30,6 +30,7 @@
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.mitosis.common.CSN;
 
+
 /**
  * An {@link Operation} that deletes an attribute from an entry.
  *
@@ -39,25 +40,28 @@
 {
     private static final long serialVersionUID = -131557844165710365L;
 
+
     /**
      * Creates a new operation that deletes the specified attribute.
      * 
      * @param attribute an attribute to delete
      */
-    public DeleteAttributeOperation( CSN csn, Name name, Attribute attribute )
+    public DeleteAttributeOperation( CSN csn, LdapDN name, Attribute attribute )
     {
         super( csn, name, attribute );
     }
-    
+
+
     public String toString()
     {
         return super.toString() + ".delete( " + getAttribute() + " )";
     }
 
+
     protected void execute1( PartitionNexus nexus ) throws NamingException
     {
-        Attributes attrs = new BasicAttributes();
+        Attributes attrs = new BasicAttributes( true );
         attrs.put( getAttribute() );
-        nexus.modify( (LdapDN)getName(), DirContext.REMOVE_ATTRIBUTE, attrs );
+        nexus.modify( getName(), DirContext.REMOVE_ATTRIBUTE, attrs );
     }
 }

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/Operation.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/Operation.java?view=diff&rev=471330&r1=471329&r2=471330
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/Operation.java (original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/Operation.java Sat Nov  4 18:18:07 2006
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.mitosis.operation;
 
+
 import java.io.Serializable;
 
 import javax.naming.NamingException;
@@ -28,6 +29,7 @@
 import org.apache.directory.mitosis.common.CSN;
 import org.apache.directory.mitosis.store.ReplicationStore;
 
+
 /**
  * Represents a small operation on an entry in replicated {@link DirectoryPartition}.
  *
@@ -46,7 +48,8 @@
 
     /** The entry CSN */
     private CSN csn;
-    
+
+
     /**
      * Creates a new instance of Operation, for the entry which
      * csn is given as a parameter.
@@ -58,7 +61,8 @@
         assert csn != null;
         this.csn = csn;
     }
-    
+
+
     /**
      * @return Returns {@link CSN} for this operation.
      */
@@ -66,7 +70,8 @@
     {
         return csn;
     }
-    
+
+
     /**
      * @return the CSN for this operation
      */
@@ -74,19 +79,21 @@
     {
         return csn.toString();
     }
-    
+
+
     /**
      * Exeutes this operation on the specified nexus.
      */
     public final void execute( PartitionNexus nexus, ReplicationStore store ) throws NamingException
     {
-        synchronized( nexus )
+        synchronized ( nexus )
         {
             execute0( nexus, store );
             store.putLog( this );
         }
     }
-    
+
+
     protected void execute0( PartitionNexus nexus, ReplicationStore store ) throws NamingException
     {
         throw new OperationNotSupportedException( nexus.getSuffix().toString() );

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationCodec.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationCodec.java?view=diff&rev=471330&r1=471329&r2=471330
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationCodec.java (original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationCodec.java Sat Nov  4 18:18:07 2006
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.mitosis.operation;
 
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -26,6 +27,7 @@
 import java.io.ObjectOutputStream;
 import java.io.ObjectStreamConstants;
 
+
 /**
  * Encodes {@link Operation}s to <tt>byte[]</tt> and vice versa.
  * 
@@ -36,7 +38,8 @@
     public OperationCodec()
     {
     }
-    
+
+
     public byte[] encode( Operation op )
     {
         ByteArrayOutputStream bout = new ByteArrayOutputStream();
@@ -48,27 +51,27 @@
             out.flush();
             out.close();
         }
-        catch( IOException e )
+        catch ( IOException e )
         {
             throw ( InternalError ) new InternalError().initCause( e );
         }
         return bout.toByteArray();
     }
-    
+
+
     public Operation decode( byte[] data )
     {
         ObjectInputStream in;
         try
         {
-            in = new ObjectInputStream(
-                    new ByteArrayInputStream( data ) );
+            in = new ObjectInputStream( new ByteArrayInputStream( data ) );
             return ( Operation ) in.readObject();
         }
-        catch( IOException e )
+        catch ( IOException e )
         {
             throw ( InternalError ) new InternalError().initCause( e );
         }
-        catch( ClassNotFoundException e )
+        catch ( ClassNotFoundException e )
         {
             throw ( InternalError ) new InternalError().initCause( e );
         }

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationFactory.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationFactory.java?view=diff&rev=471330&r1=471329&r2=471330
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationFactory.java (original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/OperationFactory.java Sat Nov  4 18:18:07 2006
@@ -19,9 +19,9 @@
  */
 package org.apache.directory.mitosis.operation;
 
+
 import java.util.Map;
 
-import javax.naming.Name;
 import javax.naming.NameAlreadyBoundException;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
@@ -46,6 +46,7 @@
 import org.apache.directory.mitosis.common.UUIDFactory;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
 
+
 /**
  * Converts a complex JNDI operations into multiple simple operations. 
  *
@@ -58,7 +59,8 @@
     private final PartitionNexus nexus;
     private final UUIDFactory uuidFactory;
     private final CSNFactory csnFactory;
-    
+
+
     public OperationFactory( DirectoryServiceConfiguration serviceCfg, ReplicationConfiguration cfg )
     {
         this.replicaId = cfg.getReplicaId();
@@ -67,19 +69,21 @@
         this.uuidFactory = cfg.getUuidFactory();
         this.csnFactory = cfg.getCsnFactory();
     }
-    
-    public Operation newAdd( Name normalizedName, Attributes entry ) throws NamingException
+
+
+    public Operation newAdd( LdapDN normalizedName, Attributes entry ) throws NamingException
     {
         return newAdd( newCSN(), normalizedName, entry );
     }
 
-    private Operation newAdd( CSN csn, Name normalizedName, Attributes entry ) throws NamingException
+
+    private Operation newAdd( CSN csn, LdapDN normalizedName, Attributes entry ) throws NamingException
     {
         // Check an entry already exists.
         checkBeforeAdd( normalizedName );
 
         CompositeOperation result = new CompositeOperation( csn );
-        
+
         // Insert 'entryUUID' and 'entryDeleted'.
         entry = ( Attributes ) entry.clone();
         entry.remove( Constants.ENTRY_UUID );
@@ -96,191 +100,164 @@
         return result;
     }
 
-    public Operation newDelete( Name normalizedName )
+
+    public Operation newDelete( LdapDN normalizedName )
     {
         CSN csn = newCSN();
         CompositeOperation result = new CompositeOperation( csn );
-        
+
         // Transform into replace operation.
-        result.add(
-                new ReplaceAttributeOperation(
-                        csn,
-                        normalizedName,
-                        new BasicAttribute( Constants.ENTRY_DELETED, "true" ) ) );
+        result.add( new ReplaceAttributeOperation( csn, normalizedName, new BasicAttribute( Constants.ENTRY_DELETED,
+            "true" ) ) );
 
         return addDefaultOperations( result, csn, normalizedName );
     }
-    
-    public Operation newModify( Name normalizedName, int modOp, Attributes attributes )
+
+
+    public Operation newModify( LdapDN normalizedName, int modOp, Attributes attributes )
     {
         CSN csn = newCSN();
         CompositeOperation result = new CompositeOperation( csn );
         NamingEnumeration e = attributes.getAll();
         // Transform into multiple {@link AttributeOperation}s.
-        while( e.hasMoreElements() )
+        while ( e.hasMoreElements() )
         {
             Attribute attr = ( Attribute ) e.nextElement();
             result.add( newModify( csn, normalizedName, modOp, attr ) );
         }
 
         // Resurrect the entry in case it is deleted.
-        result.add(
-                new ReplaceAttributeOperation(
-                        csn,
-                        normalizedName,
-                        new BasicAttribute( Constants.ENTRY_DELETED, "false" ) ) );
+        result.add( new ReplaceAttributeOperation( csn, normalizedName, new BasicAttribute( Constants.ENTRY_DELETED,
+            "false" ) ) );
 
         return addDefaultOperations( result, null, normalizedName );
     }
-    
-    public Operation newModify( Name normalizedName, ModificationItem[] items )
+
+
+    public Operation newModify( LdapDN normalizedName, ModificationItem[] items )
     {
         CSN csn = newCSN();
         CompositeOperation result = new CompositeOperation( csn );
         final int length = items.length;
         // Transform into multiple {@link AttributeOperation}s.
-        for( int i = 0; i < length; i ++ )
+        for ( int i = 0; i < length; i++ )
         {
-            ModificationItem item = items[ i ];
-            result.add(
-                    newModify(
-                            csn,
-                            normalizedName,
-                            item.getModificationOp(),
-                            item.getAttribute() ) );
+            ModificationItem item = items[i];
+            result.add( newModify( csn, normalizedName, item.getModificationOp(), item.getAttribute() ) );
         }
 
         // Resurrect the entry in case it is deleted.
-        result.add(
-                new ReplaceAttributeOperation(
-                        csn,
-                        normalizedName,
-                        new BasicAttribute( Constants.ENTRY_DELETED, "false" ) ) );
+        result.add( new ReplaceAttributeOperation( csn, normalizedName, new BasicAttribute( Constants.ENTRY_DELETED,
+            "false" ) ) );
 
         return addDefaultOperations( result, csn, normalizedName );
     }
-    
-    private Operation newModify( CSN csn, Name normalizedName, int modOp, Attribute attribute )
+
+
+    private Operation newModify( CSN csn, LdapDN normalizedName, int modOp, Attribute attribute )
     {
-        switch( modOp )
+        switch ( modOp )
         {
-        case DirContext.ADD_ATTRIBUTE:
-            return new AddAttributeOperation(
-                    csn,
-                    normalizedName,
-                    attribute );
-        case DirContext.REPLACE_ATTRIBUTE:
-            return new ReplaceAttributeOperation(
-                    csn,
-                    normalizedName,
-                    attribute );
-        case DirContext.REMOVE_ATTRIBUTE:
-            return new DeleteAttributeOperation(
-                    csn,
-                    normalizedName,
-                    attribute );
-        default:
-            throw new IllegalArgumentException( "Unknown modOp: " + modOp );
+            case DirContext.ADD_ATTRIBUTE:
+                return new AddAttributeOperation( csn, normalizedName, attribute );
+            case DirContext.REPLACE_ATTRIBUTE:
+                return new ReplaceAttributeOperation( csn, normalizedName, attribute );
+            case DirContext.REMOVE_ATTRIBUTE:
+                return new DeleteAttributeOperation( csn, normalizedName, attribute );
+            default:
+                throw new IllegalArgumentException( "Unknown modOp: " + modOp );
         }
     }
-    
-    public Operation newModifyRn( Name oldName, String newRdn, boolean deleteOldRn ) throws NamingException
+
+
+    public Operation newModifyRn( LdapDN oldName, String newRdn, boolean deleteOldRn ) throws NamingException
     {
-        return newMove( oldName, oldName.getSuffix( 1 ), newRdn, deleteOldRn );
+        return newMove( oldName, ( LdapDN ) oldName.getSuffix( 1 ), newRdn, deleteOldRn );
     }
-    
-    public Operation newMove( Name oldName, Name newParentName ) throws NamingException
+
+
+    public Operation newMove( LdapDN oldName, LdapDN newParentName ) throws NamingException
     {
         return newMove( oldName, newParentName, oldName.get( oldName.size() - 1 ), true );
     }
-    
-    public Operation newMove( Name oldName, Name newParentName, String newRdn, boolean deleteOldRn ) throws NamingException
+
+
+    public Operation newMove( LdapDN oldName, LdapDN newParentName, String newRdn, boolean deleteOldRn )
+        throws NamingException
     {
-        if( !deleteOldRn )
+        if ( !deleteOldRn )
         {
             throw new OperationNotSupportedException( "deleteOldRn must be true." );
         }
-        
+
         // Prepare to create composite operations
         CSN csn = newCSN();
         CompositeOperation result = new CompositeOperation( csn );
 
         // Retrieve all subtree including the base entry
         SearchControls ctrl = new SearchControls();
-        ctrl.setSearchScope( SearchControls.SUBTREE_SCOPE ); 
-        NamingEnumeration e = nexus.search(
-            (LdapDN)oldName, environment, new PresenceNode( "objectClass" ), ctrl );
-        
-        while( e.hasMore() )
+        ctrl.setSearchScope( SearchControls.SUBTREE_SCOPE );
+        NamingEnumeration e = nexus.search( oldName, environment, new PresenceNode( Constants.OBJECT_CLASS_OID ), ctrl );
+
+        while ( e.hasMore() )
         {
             SearchResult sr = ( SearchResult ) e.next();
-            
+
             // Get the name of the old entry
-            Name oldEntryName = new LdapDN( sr.getName() );
-            
+            LdapDN oldEntryName = new LdapDN( sr.getName() );
+
             // Delete the old entry
-            result.add(
-                    new ReplaceAttributeOperation(
-                            csn,
-                            oldEntryName,
-                            new BasicAttribute( Constants.ENTRY_DELETED, "true" ) ) );
+            result.add( new ReplaceAttributeOperation( csn, oldEntryName, new BasicAttribute( Constants.ENTRY_DELETED,
+                "true" ) ) );
 
             // Get the old entry attributes and replace RDN if required
             Attributes entry = sr.getAttributes();
-            if( oldEntryName.size() == oldName.size() )
+            if ( oldEntryName.size() == oldName.size() )
             {
-                entry.remove(
-                        NamespaceTools.getRdnAttribute(
-                                oldName.get( oldName.size() - 1 ) ) ); 
-                entry.put(
-                        NamespaceTools.getRdnAttribute( newRdn ),
-                        NamespaceTools.getRdnValue( newRdn ) );
+                entry.remove( NamespaceTools.getRdnAttribute( oldName.get( oldName.size() - 1 ) ) );
+                entry.put( NamespaceTools.getRdnAttribute( newRdn ), NamespaceTools.getRdnValue( newRdn ) );
             }
-            
+
             // Calculate new name from newParentName, oldEntryName, and newRdn.
-            Name newEntryName = ( Name ) newParentName.clone();
+            LdapDN newEntryName = ( LdapDN ) newParentName.clone();
             newEntryName.add( newRdn );
-            for( int i = oldEntryName.size() - newEntryName.size(); i > 0; i-- )
+            for ( int i = oldEntryName.size() - newEntryName.size(); i > 0; i-- )
             {
                 newEntryName.add( oldEntryName.get( oldEntryName.size() - i ) );
             }
-            
+
             // Add the new entry
-            //// FIXME Get UPDN somehow
-            result.add( newAdd( csn, newEntryName, entry ) );
-            
+            result.add( newAdd( csn, new LdapDN( newEntryName.getUpName() ), entry ) );
+
             // Add default operations to the old entry.
             // Please note that newAdd() already added default operations
             // to the new entry. 
             addDefaultOperations( result, csn, oldEntryName );
         }
-        
+
         return result;
     }
 
-    private void checkBeforeAdd( Name newEntryName ) throws NamingException
+
+    private void checkBeforeAdd( LdapDN newEntryName ) throws NamingException
     {
-        if( nexus.hasEntry( (LdapDN)newEntryName ) )
+        if ( nexus.hasEntry( newEntryName ) )
         {
             throw new NameAlreadyBoundException( newEntryName.toString() + " already exists." );
         }
     }
 
-    private CompositeOperation addDefaultOperations( CompositeOperation result, CSN csn, Name normalizedName )
+
+    private CompositeOperation addDefaultOperations( CompositeOperation result, CSN csn, LdapDN normalizedName )
     {
-        result.add(
-                new ReplaceAttributeOperation(
-                        csn,
-                        normalizedName,
-                        new BasicAttribute(
-                                Constants.ENTRY_CSN,
-                                csn.toOctetString()) ) );
+        result.add( new ReplaceAttributeOperation( csn, normalizedName, new BasicAttribute( Constants.ENTRY_CSN, csn
+            .toOctetString() ) ) );
         return result;
     }
 
+
     private CSN newCSN()
     {
         return csnFactory.newInstance( replicaId );
     }
-
 }

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/ReplaceAttributeOperation.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/ReplaceAttributeOperation.java?view=diff&rev=471330&r1=471329&r2=471330
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/ReplaceAttributeOperation.java (original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/ReplaceAttributeOperation.java Sat Nov  4 18:18:07 2006
@@ -19,7 +19,7 @@
  */
 package org.apache.directory.mitosis.operation;
 
-import javax.naming.Name;
+
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
@@ -30,6 +30,7 @@
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.mitosis.common.CSN;
 
+
 /**
  * An {@link Operation} that replaces an attribute in an entry.
  *
@@ -39,25 +40,28 @@
 {
     private static final long serialVersionUID = -6573196586521610472L;
 
+
     /**
      * Creates a new operation that replaces the specified attribute.
      * 
      * @param attribute an attribute to replace
      */
-    public ReplaceAttributeOperation( CSN csn, Name name, Attribute attribute )
+    public ReplaceAttributeOperation( CSN csn, LdapDN name, Attribute attribute )
     {
         super( csn, name, attribute );
     }
 
+
     public String toString()
     {
         return super.toString() + ".replace( " + getAttribute() + " )";
     }
 
+
     protected void execute1( PartitionNexus nexus ) throws NamingException
     {
-        Attributes attrs = new BasicAttributes();
+        Attributes attrs = new BasicAttributes( true );
         attrs.put( getAttribute() );
-        nexus.modify( (LdapDN)getName(), DirContext.REPLACE_ATTRIBUTE, attrs );
+        nexus.modify( getName(), DirContext.REPLACE_ATTRIBUTE, attrs );
     }
 }

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/support/EntryUtil.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/support/EntryUtil.java?view=diff&rev=471330&r1=471329&r2=471330
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/support/EntryUtil.java (original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/support/EntryUtil.java Sat Nov  4 18:18:07 2006
@@ -19,7 +19,7 @@
  */
 package org.apache.directory.mitosis.operation.support;
 
-import javax.naming.Name;
+
 import javax.naming.NameNotFoundException;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
@@ -34,86 +34,94 @@
 import org.apache.directory.mitosis.common.Constants;
 import org.apache.directory.mitosis.common.SimpleCSN;
 
+
 public class EntryUtil
 {
-    public static boolean isEntryUpdatable( PartitionNexus nexus, Name name, CSN newCSN ) throws NamingException
+    @SuppressWarnings("unchecked")
+    public static boolean isEntryUpdatable( PartitionNexus nexus, LdapDN name, CSN newCSN ) throws NamingException
     {
-        Attributes entry = nexus.lookup( (LdapDN)name );
-        
-        if( entry == null )
+        Attributes entry = nexus.lookup( name );
+
+        if ( entry == null )
         {
             return true;
         }
-        
+
         Attribute entryCSNAttr = entry.get( Constants.ENTRY_CSN );
-        
-        if( entryCSNAttr == null )
+
+        if ( entryCSNAttr == null )
         {
             return true;
         }
         else
         {
             CSN oldCSN = null;
-            
+
             try
             {
                 oldCSN = new SimpleCSN( String.valueOf( entryCSNAttr.get() ) );
             }
-            catch( IllegalArgumentException e )
+            catch ( IllegalArgumentException e )
             {
                 return true;
             }
-            
+
             return oldCSN.compareTo( newCSN ) < 0;
         }
     }
 
-    public static void createGlueEntries( PartitionNexus nexus, Name name, boolean includeLeaf ) throws NamingException
+
+    public static void createGlueEntries( PartitionNexus nexus, LdapDN name, boolean includeLeaf )
+        throws NamingException
     {
         assert name.size() > 0;
 
-        for( int i = name.size() - 1; i > 0; i -- )
+        for ( int i = name.size() - 1; i > 0; i-- )
         {
-            createGlueEntry( nexus, name.getSuffix( i ) );
+            createGlueEntry( nexus, ( LdapDN ) name.getSuffix( i ) );
         }
-        
-        if( includeLeaf )
+
+        if ( includeLeaf )
         {
             createGlueEntry( nexus, name );
         }
     }
-    
-    private static void createGlueEntry( PartitionNexus nexus, Name name ) throws NamingException
+
+
+    private static void createGlueEntry( PartitionNexus nexus, LdapDN name ) throws NamingException
     {
         try
         {
-            if( nexus.hasEntry( (LdapDN)name ) )
+            if ( nexus.hasEntry( name ) )
             {
                 return;
             }
         }
-        catch( NameNotFoundException e )
+        catch ( NameNotFoundException e )
         {
             // Skip if there's no backend associated with the name.
             return;
         }
-        
+
         // Create a glue entry.
-        Attributes entry = new BasicAttributes();
+        Attributes entry = new BasicAttributes( true );
+        
         //// Add RDN attribute. 
         String rdn = name.get( name.size() - 1 );
         String rdnAttribute = NamespaceTools.getRdnAttribute( rdn );
         String rdnValue = NamespaceTools.getRdnValue( rdn );
         entry.put( rdnAttribute, rdnValue );
+        
         //// Add objectClass attribute. 
         Attribute objectClassAttr = new BasicAttribute( "objectClass" );
         objectClassAttr.add( "top" );
         objectClassAttr.add( "extensibleObject" );
         entry.put( objectClassAttr );
-        
+
         // And add it to the nexus.
-        nexus.add( (LdapDN)name, entry );
+        nexus.add( name, entry );
     }
+
 
     private EntryUtil()
     {

Modified: directory/trunks/apacheds/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageCodecTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageCodecTest.java?view=diff&rev=471330&r1=471329&r2=471330
==============================================================================
--- directory/trunks/apacheds/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageCodecTest.java (original)
+++ directory/trunks/apacheds/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/LogEntryMessageCodecTest.java Sat Nov  4 18:18:07 2006
@@ -19,9 +19,9 @@
  */
 package org.apache.directory.mitosis.service.protocol.codec;
 
+
 import javax.naming.InvalidNameException;
 import javax.naming.directory.BasicAttribute;
-import javax.naming.ldap.LdapName;
 
 import org.apache.directory.mitosis.common.ReplicaId;
 import org.apache.directory.mitosis.common.SimpleCSN;
@@ -30,28 +30,31 @@
 import org.apache.directory.mitosis.service.protocol.codec.LogEntryMessageEncoder;
 import org.apache.directory.mitosis.service.protocol.message.BaseMessage;
 import org.apache.directory.mitosis.service.protocol.message.LogEntryMessage;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
 
-public class LogEntryMessageCodecTest extends AbstractMessageCodecTest {
+public class LogEntryMessageCodecTest extends AbstractMessageCodecTest
+{
 
-    public LogEntryMessageCodecTest() throws InvalidNameException {
+    public LogEntryMessageCodecTest() throws InvalidNameException
+    {
         super( new LogEntryMessage( 1234,
-                                    new AddAttributeOperation(
-                                            new SimpleCSN( System.currentTimeMillis(), new ReplicaId( "testReplica0" ), 1234 ),
-                                            new LdapName( "ou=system" ),
-                                            new BasicAttribute( "Hello", "Test" ) ) ),
-               new LogEntryMessageEncoder(),
-               new LogEntryMessageDecoder() );
+            new AddAttributeOperation(
+                new SimpleCSN( System.currentTimeMillis(), new ReplicaId( "testReplica0" ), 1234 ), new LdapDN(
+                    "ou=system" ), new BasicAttribute( "Hello", "Test" ) ) ), new LogEntryMessageEncoder(),
+            new LogEntryMessageDecoder() );
     }
 
-    protected boolean compare( BaseMessage expected0, BaseMessage actual0 ) {
+
+    protected boolean compare( BaseMessage expected0, BaseMessage actual0 )
+    {
         LogEntryMessage expected = ( LogEntryMessage ) expected0;
         LogEntryMessage actual = ( LogEntryMessage ) actual0;
-        
+
         // We don't compare operation here because it is {@link OperationCodec}'s
         // duty to serialize and deserialize Invocations.
-        return expected.getType() == actual.getType() &&
-               expected.getSequence() == actual.getSequence() &&
-               expected.getOperation().getCSN().equals( actual.getOperation().getCSN() ) &&
-               expected.getOperation().getClass() == actual.getOperation().getClass();
+        return expected.getType() == actual.getType() && expected.getSequence() == actual.getSequence()
+            && expected.getOperation().getCSN().equals( actual.getOperation().getCSN() )
+            && expected.getOperation().getClass() == actual.getOperation().getClass();
     }
 }

Modified: directory/trunks/apacheds/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java?view=diff&rev=471330&r1=471329&r2=471330
==============================================================================
--- directory/trunks/apacheds/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java (original)
+++ directory/trunks/apacheds/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java Sat Nov  4 18:18:07 2006
@@ -45,6 +45,7 @@
 import org.apache.directory.server.core.interceptor.InterceptorChain;
 import org.apache.directory.server.core.partition.PartitionNexus;
 import org.apache.directory.server.core.schema.global.GlobalRegistries;
+import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.mitosis.common.CSN;
 import org.apache.directory.mitosis.common.CSNFactory;
 import org.apache.directory.mitosis.common.CSNVector;
@@ -177,20 +178,20 @@
     {
         CSN csn = csnFactory.newInstance( REPLICA_ID );
         CompositeOperation op1 = new CompositeOperation( csn );
-        op1.add( new AddEntryOperation( csn, new LdapName( "ou=a" ), new BasicAttributes() ) );
-        op1.add( new AddAttributeOperation( csn, new LdapName( "ou=a" ), new BasicAttribute( "id", "valie" ) ) );
-        op1.add( new ReplaceAttributeOperation( csn, new LdapName( "ou=a" ), new BasicAttribute( "id", "valie" ) ) );
-        op1.add( new DeleteAttributeOperation( csn, new LdapName( "ou=a" ), new BasicAttribute( "id", "valie" ) ) );
+        op1.add( new AddEntryOperation( csn, new LdapDN( "ou=a" ), new BasicAttributes( true ) ) );
+        op1.add( new AddAttributeOperation( csn, new LdapDN( "ou=a" ), new BasicAttribute( "id", "valie" ) ) );
+        op1.add( new ReplaceAttributeOperation( csn, new LdapDN( "ou=a" ), new BasicAttribute( "id", "valie" ) ) );
+        op1.add( new DeleteAttributeOperation( csn, new LdapDN( "ou=a" ), new BasicAttribute( "id", "valie" ) ) );
         
         store.putLog( op1 );
         testGetLogs( csn, op1 );
 
         csn = csnFactory.newInstance( OTHER_REPLICA_ID );
         CompositeOperation op2 = new CompositeOperation( csn );
-        op2.add( new AddEntryOperation( csn, new LdapName( "ou=a" ), new BasicAttributes() ) );
-        op2.add( new AddAttributeOperation( csn, new LdapName( "ou=a" ), new BasicAttribute( "id", "valie" ) ) );
-        op2.add( new ReplaceAttributeOperation( csn, new LdapName( "ou=a" ), new BasicAttribute( "id", "valie" ) ) );
-        op2.add( new DeleteAttributeOperation( csn, new LdapName( "ou=a" ), new BasicAttribute( "id", "valie" ) ) );
+        op2.add( new AddEntryOperation( csn, new LdapDN( "ou=a" ), new BasicAttributes( true ) ) );
+        op2.add( new AddAttributeOperation( csn, new LdapDN( "ou=a" ), new BasicAttribute( "id", "valie" ) ) );
+        op2.add( new ReplaceAttributeOperation( csn, new LdapDN( "ou=a" ), new BasicAttribute( "id", "valie" ) ) );
+        op2.add( new DeleteAttributeOperation( csn, new LdapDN( "ou=a" ), new BasicAttribute( "id", "valie" ) ) );
         
         store.putLog( op2 );
         testGetLogs( csn, op2 );
@@ -200,7 +201,7 @@
         Assert.assertEquals( 1, store.getLogSize( OTHER_REPLICA_ID ) );
         
         // Test getLogs(CSNVector, true)
-        List expected = new ArrayList();
+        List<Operation> expected = new ArrayList<Operation>();
         expected.add( op1 );
         expected.add( op2 );
         CSNVector updateVector = new CSNVector();
@@ -217,22 +218,22 @@
         testGetLogs( updateVector, true, expected );
 
         // Test getLogs(CSNVector, false)
-        expected = new ArrayList();
+        expected = new ArrayList<Operation>();
         expected.add( op1 );
         expected.add( op2 );
         updateVector = new CSNVector();
         testGetLogs( updateVector, false, expected );
-        expected = new ArrayList();
+        expected = new ArrayList<Operation>();
         expected.add( op2 );
         updateVector = new CSNVector();
         updateVector.setCSN( op1.getCSN() );
         testGetLogs( updateVector, false, expected );
-        expected = new ArrayList();
+        expected = new ArrayList<Operation>();
         expected.add( op1 );
         updateVector = new CSNVector();
         updateVector.setCSN( op2.getCSN() );
         testGetLogs( updateVector, false, expected );
-        expected = new ArrayList();
+        expected = new ArrayList<Operation>();
         updateVector = new CSNVector();
         updateVector.setCSN( op1.getCSN() );
         updateVector.setCSN( op2.getCSN() );
@@ -276,7 +277,7 @@
         store.putLog( new Operation( csnC ) );
         store.putLog( new Operation( csnD ) );
         
-        Set expectedKnownReplicaIds = new HashSet();
+        Set<ReplicaId> expectedKnownReplicaIds = new HashSet<ReplicaId>();
         expectedKnownReplicaIds.add( REPLICA_ID );
         expectedKnownReplicaIds.add( OTHER_REPLICA_ID );
         expectedKnownReplicaIds.add( OTHER_REPLICA_ID_2 );
@@ -298,7 +299,7 @@
     
     private void testGetLogs( CSN csn, Operation operation )
     {
-        List operations = new ArrayList();
+        List<Operation> operations = new ArrayList<Operation>();
         operations.add( operation );
         testGetLogs( csn, operations );
     }



Mime
View raw message