directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r686082 [4/7] - in /directory: apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ apacheds/branches/bigbang/c...
Date Thu, 14 Aug 2008 23:12:13 GMT
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogEvent.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogEvent.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogEvent.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogEvent.java Thu Aug 14 16:12:09 2008
@@ -20,11 +20,13 @@
 package org.apache.directory.server.core.changelog;
 
 
-import java.io.Serializable;
-
-import javax.naming.directory.Attribute;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
 import org.apache.directory.server.core.authn.LdapPrincipal;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.ldif.LdifEntry;
 
 
@@ -34,14 +36,23 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class ChangeLogEvent implements Serializable
+public class ChangeLogEvent implements Externalizable
 {
     private static final long serialVersionUID = 1L;
-    private final String zuluTime;
-    private final long revision;
-    private final LdifEntry forwardLdif;
-    private final LdifEntry reverseLdif;
-    private final LdapPrincipal committer;
+    private String zuluTime;
+    private long revision;
+    private LdifEntry forwardLdif;
+    private LdifEntry reverseLdif;
+    private LdapPrincipal committer;
+
+
+    /**
+     * Creates a new instance of ChangeLogEvent, used during the deserialization
+     * process
+     */
+    public ChangeLogEvent()
+    {
+    }
 
 
     /**
@@ -110,12 +121,107 @@
     }
 
 
-    public Attribute get( String attributeName )
+    public EntryAttribute get( String attributeName )
     {
         return forwardLdif.get( attributeName );
     }
 
 
+    /**
+     * @see Externalizable#readExternal(ObjectInput)
+     * 
+     * @param in The stream from which the ChangeOlgEvent is read
+     * @throws IOException If the stream can't be read
+     * @throws ClassNotFoundException If the ChangeLogEvent can't be created 
+     */
+    public void readExternal( ObjectInput in ) throws IOException , ClassNotFoundException
+    {
+        // Read the committer
+        committer = (LdapPrincipal)in.readObject();
+        
+        // Read the revision
+        revision = in.readLong();
+        
+        // Read the time
+        boolean hasZuluTime = in.readBoolean();
+        
+        if ( hasZuluTime )
+        {
+            zuluTime = in.readUTF();
+        }
+        
+        // Read the forward LDIF
+        boolean hasForwardLdif = in.readBoolean();
+        
+        if ( hasForwardLdif )
+        {
+            forwardLdif = (LdifEntry)in.readObject();
+        }
+        
+        // Read the reverse LDIF
+        boolean hasReverseLdif = in.readBoolean();
+        
+        if ( hasReverseLdif )
+        {
+            reverseLdif = (LdifEntry)in.readObject();
+        }
+    }
+
+
+    /**
+     * @see Externalizable#readExternal(ObjectInput)<p>
+     *
+     *@param out The stream in which the ChangeLogEvent will be serialized. 
+     *
+     *@throws IOException If the serialization fail
+     */
+    public void writeExternal( ObjectOutput out ) throws IOException
+    {
+        // Write the committer
+        out.writeObject( committer );
+        
+        // write the revision
+        out.writeLong( revision );
+        
+        // write the time
+        
+        if ( zuluTime != null )
+        {
+            out.writeBoolean( true );
+            out.writeUTF( zuluTime );
+        }
+        else
+        {
+            out.writeBoolean( false );
+        }
+        
+        // write the forward LDIF
+        if ( forwardLdif != null )
+        {
+            out.writeBoolean( true );
+            out.writeObject( forwardLdif );
+        }
+        else
+        {
+            out.writeBoolean( false );
+        }
+        
+        // write the reverse LDIF
+        if ( reverseLdif != null )
+        {
+            out.writeBoolean( true );
+            out.writeObject( reverseLdif );
+        }
+        else
+        {
+            out.writeBoolean( false );
+        }
+        
+        // and flush the result
+        out.flush();
+    }
+
+
     @Override
     public String toString()
     {

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java Thu Aug 14 16:12:09 2008
@@ -19,13 +19,17 @@
 package org.apache.directory.server.core.changelog;
 
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Set;
 
 import org.apache.directory.server.constants.ApacheSchemaConstants;
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.entry.ClonedServerEntry;
+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.ServerModification;
 import org.apache.directory.server.core.interceptor.BaseInterceptor;
 import org.apache.directory.server.core.interceptor.NextInterceptor;
 import org.apache.directory.server.core.interceptor.context.AddOperationContext;
@@ -37,7 +41,10 @@
 import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
 import org.apache.directory.server.core.partition.ByPassConstants;
 import org.apache.directory.server.core.schema.SchemaService;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
 import org.apache.directory.shared.ldap.ldif.ChangeType;
 import org.apache.directory.shared.ldap.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.ldif.LdifUtils;
@@ -110,13 +117,13 @@
         
         LdifEntry forward = new LdifEntry();
         forward.setChangeType( ChangeType.Add );
-        forward.setDn( opContext.getDn().getUpName() );
+        forward.setDn( opContext.getDn() );
 
         Set<AttributeType> list = addEntry.getAttributeTypes();
         
         for ( AttributeType attributeType:list )
         {
-            forward.addAttribute( ServerEntryUtils.toAttributeImpl( addEntry.get( attributeType ) ) );
+            forward.addAttribute( ((ServerAttribute)addEntry.get( attributeType) ).toClientAttribute() );
         }
         
         LdifEntry reverse = LdifUtils.reverseAdd( opContext.getDn() );
@@ -154,8 +161,16 @@
 
         LdifEntry forward = new LdifEntry();
         forward.setChangeType( ChangeType.Delete );
-        forward.setDn( opContext.getDn().getUpName() );
-        LdifEntry reverse = LdifUtils.reverseDel( opContext.getDn(), ServerEntryUtils.toAttributesImpl( serverEntry ) );
+        forward.setDn( opContext.getDn() );
+        
+        Entry reverseEntry = new DefaultClientEntry( serverEntry.getDn() );
+        
+        for ( EntryAttribute attribute:serverEntry )
+        {
+            reverseEntry.add( ((ServerAttribute)attribute).toClientAttribute() );
+        }
+
+        LdifEntry reverse = LdifUtils.reverseDel( opContext.getDn(), reverseEntry );
         opContext.setChangeLogEvent( changeLog.log( getPrincipal(), forward, reverse ) );
     }
 
@@ -186,6 +201,9 @@
     }
 
 
+    /**
+     * 
+     */
     public void modify( NextInterceptor next, ModifyOperationContext opContext ) throws Exception
     {
         ServerEntry serverEntry = null;
@@ -217,23 +235,38 @@
             {
                 LOG.debug( "Bypassing changelog on modify of entryDeleted attribute." );
             }
+            
             return;
         }
 
         LdifEntry forward = new LdifEntry();
         forward.setChangeType( ChangeType.Modify );
-        forward.setDn( opContext.getDn().getUpName() );
+        forward.setDn( opContext.getDn() );
+        
+        List<Modification> mods = new ArrayList<Modification>( opContext.getModItems().size() );
         
         for ( Modification modItem : opContext.getModItems() )
         {
-            forward.addModificationItem( ServerEntryUtils.toModificationItemImpl( modItem ) );
+            Modification mod = ((ServerModification)modItem).toClientModification();
+            mods.add( mod );
+            
+            forward.addModificationItem( mod );
+        }
+        
+        Entry clientEntry = new DefaultClientEntry( serverEntry.getDn() );
+        
+        for ( EntryAttribute attribute:serverEntry )
+        {
+            clientEntry.add( ((ServerAttribute)attribute).toClientAttribute() );
         }
 
         LdifEntry reverse = LdifUtils.reverseModify( 
             opContext.getDn(), 
-            ServerEntryUtils.toModificationItemImpl( opContext.getModItems() ), 
-            ServerEntryUtils.toAttributesImpl( serverEntry ) );
+            mods, 
+            clientEntry );
         
+        //System.out.println( "forward : " + forward );
+        //System.out.println( "reverse : " + reverse );
         opContext.setChangeLogEvent( changeLog.log( getPrincipal(), forward, reverse ) );
     }
 
@@ -262,7 +295,7 @@
 
         LdifEntry forward = new LdifEntry();
         forward.setChangeType( ChangeType.ModRdn );
-        forward.setDn( renameContext.getDn().getUpName() );
+        forward.setDn( renameContext.getDn() );
         forward.setDeleteOldRdn( renameContext.getDelOldDn() );
 
         LdifEntry reverse = LdifUtils.reverseModifyRdn( ServerEntryUtils.toAttributesImpl( serverEntry ), 
@@ -292,7 +325,7 @@
 
         LdifEntry forward = new LdifEntry();
         forward.setChangeType( ChangeType.ModDn );
-        forward.setDn( opCtx.getDn().getUpName() );
+        forward.setDn( opCtx.getDn() );
         forward.setDeleteOldRdn( opCtx.getDelOldDn() );
         forward.setNewRdn( opCtx.getNewRdn().getUpName() );
         forward.setNewSuperior( opCtx.getParent().getUpName() );
@@ -314,7 +347,7 @@
 
         LdifEntry forward = new LdifEntry();
         forward.setChangeType( ChangeType.ModDn );
-        forward.setDn( opCtx.getDn().getUpName() );
+        forward.setDn( opCtx.getDn() );
         forward.setNewSuperior( opCtx.getParent().getUpName() );
 
         LdifEntry reverse = LdifUtils.reverseModifyDn( opCtx.getParent(), opCtx.getDn() );

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/DefaultChangeLog.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/DefaultChangeLog.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/DefaultChangeLog.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/DefaultChangeLog.java Thu Aug 14 16:12:09 2008
@@ -264,4 +264,17 @@
         this.tagContainerName = tagContainerName;
     }
 
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+        
+        sb.append( "ChangeLog tag[" ).append( latest ).append( "]\n" );
+        sb.append( "    store : \n" ).append( store );
+        
+        return sb.toString();
+    }
 }

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/MemoryChangeLogStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/MemoryChangeLogStore.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/MemoryChangeLogStore.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/MemoryChangeLogStore.java Thu Aug 14 16:12:09 2008
@@ -19,7 +19,6 @@
 package org.apache.directory.server.core.changelog;
 
 import java.io.BufferedReader;
-import java.io.EOFException;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -294,6 +293,7 @@
     private void loadChangeLog() throws Exception
     {
         File file = new File( workingDirectory, CHANGELOG_FILE );
+        
         if ( file.exists() )
         {
             ObjectInputStream in = null;
@@ -301,19 +301,14 @@
             try
             {
                 in = new ObjectInputStream( new FileInputStream( file ) );
-                ArrayList<ChangeLogEvent> changeLogEvents = new ArrayList<ChangeLogEvent>();
+                int size = in.readInt();
+                
+                ArrayList<ChangeLogEvent> changeLogEvents = new ArrayList<ChangeLogEvent>( size );
 
-                while ( true )
+                for ( int i = 0; i < size; i++ )
                 {
-                    try
-                    {
-                        ChangeLogEvent event = ( ChangeLogEvent ) in.readObject();
-                        changeLogEvents.add( event );
-                    }
-                    catch ( EOFException eofe )
-                    {
-                        break;
-                    }
+                    ChangeLogEvent event = ( ChangeLogEvent ) in.readObject();
+                    changeLogEvents.add( event );
                 }
 
                 // @todo man o man we need some synchronization later after getting this to work
@@ -365,6 +360,8 @@
         {
             out = new ObjectOutputStream( new FileOutputStream( file ) );
 
+            out.writeInt( events.size() );
+            
             for ( ChangeLogEvent event : events )
             {
                 out.writeObject( event );
@@ -495,4 +492,33 @@
         return latest;
     }
     
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+        
+        sb.append( "MemoryChangeLog\n" );
+        sb.append( "latest tag : " ).append( latest ).append( '\n' );
+        
+        if ( events != null )
+        {
+            sb.append( "Nb of events : " ).append( events.size() ).append( '\n' );
+            
+            int i = 0;
+            
+            for ( ChangeLogEvent event:events )
+            {
+                sb.append( "event[" ).append( i++ ).append( "] : " );
+                sb.append( "\n---------------------------------------\n" );
+                sb.append( event );
+                sb.append( "\n---------------------------------------\n" );
+            }
+        }
+        
+        
+        return sb.toString();
+    }
 }

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributesSchemaChecker.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributesSchemaChecker.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributesSchemaChecker.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributesSchemaChecker.java Thu Aug 14 16:12:09 2008
@@ -27,8 +27,6 @@
 
 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.LookupOperationContext;
 import org.apache.directory.server.core.interceptor.context.OperationContext;
 import org.apache.directory.server.core.partition.ByPassConstants;
 import org.apache.directory.server.core.partition.PartitionNexus;
@@ -83,10 +81,7 @@
     public void checkModify( OperationContext opContext, LdapDN normName, List<Modification> mods ) throws Exception
     {
         ServerEntry originalEntry = opContext.lookup( normName, ByPassConstants.LOOKUP_BYPASS );
-        ServerEntry targetEntry = ServerEntryUtils.toServerEntry( 
-            SchemaUtils.getTargetEntry( ServerEntryUtils.toModificationItemImpl( mods ), ServerEntryUtils.toAttributesImpl( originalEntry ) ),
-            normName,
-            opContext.getSession().getDirectoryService().getRegistries() );
+        ServerEntry targetEntry = (ServerEntry)SchemaUtils.getTargetEntry( mods, originalEntry );
         
         EntryAttribute targetObjectClasses = targetEntry.get( SchemaConstants.OBJECT_CLASS_AT );
         

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java Thu Aug 14 16:12:09 2008
@@ -1154,6 +1154,7 @@
                     }
                     catch ( Exception ne )
                     {
+                        ne.printStackTrace();
                         throw ne;
                     }
                     catch ( Throwable e )

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/ModifyOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/ModifyOperationContext.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/ModifyOperationContext.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/ModifyOperationContext.java Thu Aug 14 16:12:09 2008
@@ -75,6 +75,7 @@
     public ModifyOperationContext( CoreSession session, LdapDN dn, List<Modification> modItems )
     {
         super( session, dn );
+
         this.modItems = modItems;
     }
 

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java Thu Aug 14 16:12:09 2008
@@ -59,8 +59,8 @@
 import javax.swing.tree.TreeNode;
 import javax.swing.tree.TreePath;
 
+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.partition.impl.btree.BTreePartition;
 import org.apache.directory.server.xdbm.Index;
@@ -465,11 +465,11 @@
 
             for ( LdifEntry entry:new LdifReader( in ) )
             {
-                String updn = entry.getDn();
+                String updn = entry.getDn().getUpName();
                 
                 LdapDN ndn = new LdapDN( StringTools.deepTrimToLower( updn ) );
 
-                ServerEntry attrs = ServerEntryUtils.toServerEntry( entry.getAttributes(), ndn, null );
+                ServerEntry attrs = new DefaultServerEntry( registries, entry.getEntry() );
 
                 if ( null == partition.getEntryId( ndn.toString() ) )
                 {

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java Thu Aug 14 16:12:09 2008
@@ -449,7 +449,7 @@
     
     public final void add( AddOperationContext addContext ) throws Exception
     {
-        store.add( addContext.getDn(), ((ClonedServerEntry)addContext.getEntry()).getClonedEntry() );
+        store.add( addContext.getDn(), (ServerEntry)((ClonedServerEntry)addContext.getEntry()).getClonedEntry() );
     }
 
 

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java Thu Aug 14 16:12:09 2008
@@ -43,7 +43,6 @@
 import org.apache.directory.server.core.entry.ServerAttribute;
 import org.apache.directory.server.core.entry.ServerBinaryValue;
 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.filtering.BaseEntryFilteringCursor;
 import org.apache.directory.server.core.filtering.EntryFilter;
@@ -1208,8 +1207,7 @@
         }
 
         // First, we get the entry from the backend. If it does not exist, then we throw an exception
-        ServerEntry targetEntry = ServerEntryUtils.toServerEntry( SchemaUtils.getTargetEntry( ServerEntryUtils
-            .toModificationItemImpl( mods ), ServerEntryUtils.toAttributesImpl( entry ) ), name, registries );
+        ServerEntry targetEntry = (ServerEntry)SchemaUtils.getTargetEntry( mods , entry );
 
         if ( entry == null )
         {

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/sp/StoredProcExecutionManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/sp/StoredProcExecutionManager.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/sp/StoredProcExecutionManager.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/sp/StoredProcExecutionManager.java Thu Aug 14 16:12:09 2008
@@ -22,6 +22,7 @@
 
 import org.apache.directory.server.core.CoreSession;
 import org.apache.directory.server.core.entry.ClonedServerEntry;
+import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.entry.ServerStringValue;
 import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
@@ -138,7 +139,7 @@
                     throw ne;
                 }
                 
-                engine.setSPUnitEntry( spUnitEntry.getOriginalEntry() );
+                engine.setSPUnitEntry( (ServerEntry)spUnitEntry.getOriginalEntry() );
                 return engine;
             }
 

Added: directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authn/LdapPrincipalTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authn/LdapPrincipalTest.java?rev=686082&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authn/LdapPrincipalTest.java (added)
+++ directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authn/LdapPrincipalTest.java Thu Aug 14 16:12:09 2008
@@ -0,0 +1,61 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.authn;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.junit.Test;
+
+
+/**
+ * 
+ * Test the LdapPrincipal class
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LdapPrincipalTest
+{
+    /**
+     * Test the serialization of an empty LdapPrincipal
+     */
+    @Test
+    public void testStaticSerializeEmptyLdapPrincipal() throws Exception
+    {
+        LdapPrincipal principal = new LdapPrincipal();
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+
+        out.writeObject( principal );
+
+        byte[] data = baos.toByteArray();
+        ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+        LdapPrincipal readPrincipal = (LdapPrincipal)in.readObject();
+        assertEquals( principal.getAuthenticationLevel(), readPrincipal.getAuthenticationLevel() );
+        assertEquals( principal.getName(), readPrincipal.getName() );
+    }
+}

Modified: directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/changelog/MemoryChangeLogStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/changelog/MemoryChangeLogStoreTest.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/changelog/MemoryChangeLogStoreTest.java (original)
+++ directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/changelog/MemoryChangeLogStoreTest.java Thu Aug 14 16:12:09 2008
@@ -19,12 +19,32 @@
 package org.apache.directory.server.core.changelog;
 
 
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.naming.NamingException;
+
 import junit.framework.TestCase;
 import org.apache.directory.server.core.authn.LdapPrincipal;
+import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.ldif.ChangeType;
 import org.apache.directory.shared.ldap.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.ldif.LdifUtils;
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.NoOpNormalizer;
+import org.apache.directory.shared.ldap.schema.OidNormalizer;
+import org.apache.directory.shared.ldap.util.DateUtils;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 
 /**
@@ -37,14 +57,26 @@
 {
     MemoryChangeLogStore store;
 
-
+    Map<String, OidNormalizer> oidsMap = new HashMap<String, OidNormalizer>();
+    
+    
+    @Before
     public void setUp() throws Exception
     {
         super.setUp();
         store = new MemoryChangeLogStore();
+
+        oidsMap.put( SchemaConstants.UID_AT, new OidNormalizer( SchemaConstants.UID_AT_OID, new NoOpNormalizer() ) );
+        oidsMap.put( SchemaConstants.USER_ID_AT, new OidNormalizer( SchemaConstants.UID_AT_OID, new NoOpNormalizer() ) );
+        oidsMap.put( SchemaConstants.UID_AT_OID, new OidNormalizer( SchemaConstants.UID_AT_OID, new NoOpNormalizer() ) );
+        
+        oidsMap.put( SchemaConstants.OU_AT, new OidNormalizer( SchemaConstants.OU_AT_OID, new NoOpNormalizer()  ) );
+        oidsMap.put( SchemaConstants.ORGANIZATIONAL_UNIT_NAME_AT, new OidNormalizer( SchemaConstants.OU_AT_OID, new NoOpNormalizer()  ) );
+        oidsMap.put( SchemaConstants.OU_AT_OID, new OidNormalizer( SchemaConstants.OU_AT_OID, new NoOpNormalizer()  ) );
     }
 
 
+    @After
     public void tearDown() throws Exception
     {
         super.tearDown();
@@ -52,6 +84,7 @@
     }
 
 
+    @Test
     public void testLogCheckRevision() throws Exception
     {
         assertEquals( "first revision is always 0", 0, store.getCurrentRevision() );
@@ -66,4 +99,58 @@
         assertEquals( 1, store.log( new LdapPrincipal(), forward, reverse ).getRevision() );
         assertEquals( 1, store.getCurrentRevision() );
     }
+    
+    
+    @Test
+    public void testChangeLogSerialization() throws NamingException, IOException, ClassNotFoundException
+    {
+        LdapDN systemDn = new LdapDN( "ou=system" );
+        systemDn.normalize( oidsMap );
+        
+        LdapDN adminDn = new LdapDN( "uid=admin, ou=system" );
+        adminDn.normalize( oidsMap );
+
+        LdifEntry forward = new LdifEntry();
+        forward.setDn( systemDn );
+        forward.setChangeType( ChangeType.Add );
+        forward.putAttribute( "objectClass", "organizationalUnit" );
+        forward.putAttribute( "ou", "system" );
+        
+        LdapDN reverseDn = new LdapDN( forward.getDn() );
+        reverseDn.normalize( oidsMap );
+
+        LdifEntry reverse = LdifUtils.reverseAdd( reverseDn );
+
+        String zuluTime = DateUtils.getGeneralizedTime();
+        long revision = 1L;
+        
+        LdapPrincipal principal = new LdapPrincipal( adminDn, AuthenticationLevel.SIMPLE, StringTools.getBytesUtf8( "secret"  ) );
+        ChangeLogEvent event = new ChangeLogEvent( revision, zuluTime, principal, forward, reverse );
+        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+
+        out.writeObject( event );
+        
+        byte[] data = baos.toByteArray();
+        ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+        
+        ChangeLogEvent read = (ChangeLogEvent)in.readObject(); 
+        
+        // The read event should not be equal to the written event, as
+        // the principal's password has not been stored
+        assertNotSame( event, read );
+        
+        LdapPrincipal readPrincipal = read.getCommitterPrincipal();
+        
+        assertEquals( principal.getAuthenticationLevel(), readPrincipal.getAuthenticationLevel() );
+        assertEquals( principal.getName(), readPrincipal.getName() );
+        assertEquals( principal.getJndiName(), readPrincipal.getJndiName() );
+        assertNull( readPrincipal.getUserPassword() );
+        
+        assertEquals( zuluTime, read.getZuluTime() );
+        assertEquals( revision, read.getRevision() );
+        assertEquals( forward, read.getForwardLdif() );
+        assertEquals( reverse, read.getReverseLdif() );
+    }
 }

Modified: directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/store/LdifFileLoader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/store/LdifFileLoader.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/store/LdifFileLoader.java (original)
+++ directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/store/LdifFileLoader.java Thu Aug 14 16:12:09 2008
@@ -28,18 +28,16 @@
 import java.io.InputStreamReader;
 import java.util.Collections;
 import java.util.List;
-import java.util.Properties;
 
-import javax.naming.CompoundName;
-import javax.naming.Name;
 import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.ModificationItem;
 
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.ldif.LdifReader;
-import org.apache.directory.shared.ldap.message.ModificationItemImpl;
+import org.apache.directory.shared.ldap.name.LdapDN;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -58,9 +56,9 @@
     private static final Logger log = LoggerFactory.getLogger( LdifFileLoader.class );
 
     /**
-     * a handle on the top initial context: get new context from this
+     * a handle on the top core session
      */
-    protected DirContext ctx;
+    protected CoreSession coreSession;
     /**
      * the LDIF file or directory containing LDIFs to load
      */
@@ -85,9 +83,9 @@
      * @param ctx  the context to load the entries into.
      * @param ldif the file of LDIF entries to load.
      */
-    public LdifFileLoader( DirContext ctx, String ldif )
+    public LdifFileLoader( CoreSession coreSession, String ldif )
     {
-        this( ctx, new File( ldif ), null );
+        this( coreSession, new File( ldif ), null );
     }
 
 
@@ -98,9 +96,9 @@
      * @param ldif
      * @param filters
      */
-    public LdifFileLoader( DirContext ctx, File ldif, List<? extends LdifLoadFilter> filters )
+    public LdifFileLoader( CoreSession coreSession, File ldif, List<? extends LdifLoadFilter> filters )
     {
-        this( ctx, ldif, filters, null );
+        this( coreSession, ldif, filters, null );
     }
 
 
@@ -112,9 +110,9 @@
      * @param filters
      * @param loader
      */
-    public LdifFileLoader( DirContext ctx, File ldif, List<? extends LdifLoadFilter> filters, ClassLoader loader )
+    public LdifFileLoader( CoreSession coreSession, File ldif, List<? extends LdifLoadFilter> filters, ClassLoader loader )
     {
-        this.ctx = ctx;
+        this.coreSession = coreSession;
         this.ldif = ldif;
         this.loader = loader;
 
@@ -135,7 +133,7 @@
      * @param entry the attributes of the entry
      * @return true if all filters passed the entry, false otherwise
      */
-    private boolean applyFilters( String dn, Attributes entry )
+    private boolean applyFilters( LdapDN dn, Entry entry )
     {
         boolean accept = true;
         final int limit = filters.size();
@@ -149,7 +147,7 @@
         {
             try
             {
-                accept &= ( filters.get( ii ) ).filter( ldif, dn, entry, ctx );
+                accept &= ( filters.get( ii ) ).filter( ldif, dn, entry, coreSession );
             }
             catch ( NamingException e )
             {
@@ -173,7 +171,7 @@
      */
     public int execute()
     {
-        Name rdn = null;
+        LdapDN rdn = null;
         InputStream in = null;
 
         try
@@ -182,44 +180,46 @@
 
             for ( LdifEntry ldifEntry:new LdifReader( new BufferedReader( new InputStreamReader( in ) ) ) )
             {
-                String dn = ldifEntry.getDn();
+                LdapDN dn = ldifEntry.getDn();
 
                 if ( ldifEntry.isEntry() )
                 {
-                    Attributes attributes = ldifEntry.getAttributes();
-                    boolean filterAccepted = applyFilters( dn, attributes );
+                    Entry entry = ldifEntry.getEntry();
+                    boolean filterAccepted = applyFilters( dn, entry );
 
                     if ( !filterAccepted )
                     {
                         continue;
                     }
 
-                    rdn = getRelativeName( ctx, dn );
-
                     try
                     {
-                        ctx.lookup( rdn );
+                        coreSession.lookup( dn );
                         log.info( "Found {}, will not create.", rdn );
                     }
                     catch ( Exception e )
                     {
                         try
                         {
-                            ctx.createSubcontext( rdn, attributes );
-                            count++;
+                            coreSession.add( 
+                                new DefaultServerEntry( 
+                                    coreSession.getDirectoryService().getRegistries(), entry ) ); 
+                           count++;
                             log.info( "Created {}.", rdn );
-                        } catch ( NamingException e1 )
+                        } 
+                        catch ( NamingException e1 )
                         {
-                            log.info( "Could not create: " + dn + " with attributes: " + attributes, e1 );
+                            log.info( "Could not create entry " + entry, e1 );
                         }
                     }
                 } else
                 {
                     //modify
-                    List<ModificationItemImpl> items = ldifEntry.getModificationItems();
+                    List<Modification> items = ldifEntry.getModificationItems();
+                    
                     try
                     {
-                        ctx.modifyAttributes( dn, items.toArray( new ModificationItem[items.size()] ) );
+                        coreSession.modify( dn, items );
                         log.info( "Modified: " + dn + " with modificationItems: " + items );
                     }
                     catch ( NamingException e )
@@ -256,40 +256,6 @@
     }
 
 
-    private Name getRelativeName( DirContext ctx, String baseDn ) throws NamingException
-    {
-        Properties props = new Properties();
-        props.setProperty( "jndi.syntax.direction", "right_to_left" );
-        props.setProperty( "jndi.syntax.separator", "," );
-        props.setProperty( "jndi.syntax.ignorecase", "true" );
-        props.setProperty( "jndi.syntax.trimblanks", "true" );
-
-        Name searchBaseDn;
-
-        try
-        {
-            Name ctxRoot = new CompoundName( ctx.getNameInNamespace(), props );
-            searchBaseDn = new CompoundName( baseDn, props );
-
-            if ( !searchBaseDn.startsWith( ctxRoot ) )
-            {
-                throw new NamingException( "Invalid search base " + baseDn );
-            }
-
-            for ( int ii = 0; ii < ctxRoot.size(); ii++ )
-            {
-                searchBaseDn.remove( 0 );
-            }
-        }
-        catch ( NamingException e )
-        {
-            throw new NamingException( "Failed to initialize search base " + baseDn );
-        }
-
-        return searchBaseDn;
-    }
-
-
     /**
      * Tries to find an LDIF file either on the file system or packaged within a jar.
      *

Modified: directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/store/LdifLoadFilter.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/store/LdifLoadFilter.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/store/LdifLoadFilter.java (original)
+++ directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/store/LdifLoadFilter.java Thu Aug 14 16:12:09 2008
@@ -20,9 +20,12 @@
 package org.apache.directory.server.protocol.shared.store;
 
 
-import javax.naming.directory.Attributes;
-import javax.naming.directory.DirContext;
 import javax.naming.NamingException;
+
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
 import java.io.File;
 
 
@@ -40,9 +43,9 @@
      * @param file the file being loaded
      * @param dn the distinguished name of the entry being loaded
      * @param entry the entry attributes within the LDIF file
-     * @param ctx context to be used for loading the entry into the DIT
+     * @param coreSession session to be used for loading the entry into the DIT
      * @return true if the entry will be created in the DIT, false if it is to be skipped
      * @throws NamingException
      */
-    boolean filter( File file, String dn, Attributes entry, DirContext ctx ) throws NamingException;
+    boolean filter( File file, LdapDN dn, Entry entry, CoreSession coreSession ) throws NamingException;
 }

Modified: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java (original)
+++ directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java Thu Aug 14 16:12:09 2008
@@ -25,10 +25,9 @@
 import java.util.List;
 
 import javax.naming.NamingException;
-import javax.naming.ldap.LdapContext;
 
 import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.integ.IntegrationUtils;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.server.integ.InheritableServerSettings;
 import org.apache.directory.shared.ldap.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.ldif.LdifReader;
@@ -183,7 +182,6 @@
         
         if ( ldifs.size() != 0 )
         {
-            LdapContext root = IntegrationUtils.getRootContext( service );
             for ( String ldif:ldifs )
             {
                 StringReader in = new StringReader( ldif );
@@ -191,7 +189,8 @@
                 
                 for ( LdifEntry entry : ldifReader )
                 {
-                    root.createSubcontext( entry.getDn(), entry.getAttributes() );
+                    service.getAdminSession().add( 
+                        new DefaultServerEntry( service.getRegistries(), entry.getEntry() ) ); 
                     LOG.debug( "Successfully injected LDIF enry for test {}: {}", settings.getDescription(), entry );
                 }
             }

Modified: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java (original)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java Thu Aug 14 16:12:09 2008
@@ -47,7 +47,7 @@
  * @version $Rev$, $Date$
  */
 @RunWith ( SiRunner.class ) 
-@CleanupLevel ( Level.SUITE )
+@CleanupLevel ( Level.CLASS )
 @ApplyLdifs( {
     // Entry # 1
     "dn: uid=akarasulu,ou=users,ou=system\n" +

Modified: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java (original)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java Thu Aug 14 16:12:09 2008
@@ -55,7 +55,7 @@
  * @version $Rev$, $Date$
  */
 @RunWith ( SiRunner.class ) 
-@CleanupLevel ( Level.SUITE )
+@CleanupLevel ( Level.CLASS )
 @ApplyLdifs( {
     // Entry # 1
     "dn: uid=hnelson,ou=users,ou=system\n" +

Modified: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyRdnIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyRdnIT.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyRdnIT.java (original)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyRdnIT.java Thu Aug 14 16:12:09 2008
@@ -936,7 +936,6 @@
      * @throws NamingException
      */
     @Test
-    @Ignore ( "Until this is fixed: https://issues.apache.org/jira/browse/DIRSERVER-1216" )
     public void testModifyRdnOperationalAttribute() throws Exception
     {
         DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );

Modified: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchIT.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchIT.java (original)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchIT.java Thu Aug 14 16:12:09 2008
@@ -31,6 +31,7 @@
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
 
+import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.server.core.integ.annotations.ApplyLdifs;
 import org.apache.directory.server.integ.SiRunner;
 
@@ -65,6 +66,7 @@
     "objectClass: top\n" +
     "objectClass: referral\n" +
     "objectClass: extensibleObject\n" +
+    "ou: RemoteUsers\n" +
     "ref: ldap://fermi:10389/ou=users,ou=system\n" +
     "ref: ldap://hertz:10389/ou=users,dc=example,dc=com\n" +
     "ref: ldap://maxwell:10389/ou=users,ou=system\n\n" +
@@ -89,7 +91,7 @@
     "objectClass: locality\n" +
     "l: Jacksonville\n\n" +
     
-    "dn: cn=emmanuel lecharney,l=paris,c=france,ou=system\n" +
+    "dn: cn=emmanuel lecharny,l=paris,c=france,ou=system\n" +
     "objectClass: top\n" +
     "objectClass: person\n" +
     "objectClass: residentialPerson\n" +
@@ -138,8 +140,8 @@
         while ( reader.hasNext() )
         {
             LdifEntry entry = reader.next();
-            DirContext ctx = getWiredContext( ldapServer );
-            ctx.createSubcontext( entry.getDn(), entry.getAttributes() );
+            ldapServer.getDirectoryService().getAdminSession().add( 
+                new DefaultServerEntry( ldapServer.getDirectoryService().getRegistries(), entry.getEntry() ) ); 
         }
     }
     

Modified: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java (original)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java Thu Aug 14 16:12:09 2008
@@ -36,7 +36,9 @@
 import javax.naming.ldap.Control;
 import javax.naming.ldap.LdapContext;
 
+import org.apache.directory.server.core.integ.Level;
 import org.apache.directory.server.core.integ.annotations.ApplyLdifs;
+import org.apache.directory.server.core.integ.annotations.CleanupLevel;
 import org.apache.directory.server.core.subtree.SubentryInterceptor;
 import org.apache.directory.server.integ.SiRunner;
 import org.apache.directory.server.newldap.LdapServer;
@@ -66,6 +68,7 @@
  * @version $Rev: 682556 $
  */
 @RunWith ( SiRunner.class ) 
+@CleanupLevel ( Level.CLASS )
 @ApplyLdifs( {
     
     // Entry # 0

Modified: directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java (original)
+++ directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java Thu Aug 14 16:12:09 2008
@@ -27,7 +27,6 @@
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.jndi.ServerLdapContext;
 import org.apache.directory.server.newldap.LdapServer;
 import org.apache.directory.server.protocol.shared.store.LdifFileLoader;
 import org.apache.directory.server.protocol.shared.store.LdifLoadFilter;
@@ -40,7 +39,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.naming.directory.DirContext;
 
 import java.io.File;
 import java.io.FileFilter;
@@ -361,9 +359,7 @@
         }
         else
         {
-            DirContext root = new ServerLdapContext( directoryService, 
-                directoryService.getAdminSession(), new LdapDN() );
-            LdifFileLoader loader = new LdifFileLoader( root, ldifFile, ldifFilters );
+            LdifFileLoader loader = new LdifFileLoader( directoryService.getAdminSession(), ldifFile, ldifFilters );
             int count = loader.execute();
             LOG.info( "Loaded " + count + " entries from LDIF file '" + getCanonical( ldifFile ) + "'" );
             addFileEntry( ldifFile );

Modified: directory/apacheds/branches/bigbang/server-jndi/src/test/java/org/apache/directory/server/configuration/ApacheDSTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-jndi/src/test/java/org/apache/directory/server/configuration/ApacheDSTest.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-jndi/src/test/java/org/apache/directory/server/configuration/ApacheDSTest.java (original)
+++ directory/apacheds/branches/bigbang/server-jndi/src/test/java/org/apache/directory/server/configuration/ApacheDSTest.java Thu Aug 14 16:12:09 2008
@@ -22,12 +22,10 @@
 
 import java.io.File;
 
-import org.apache.directory.server.configuration.ApacheDS;
 import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
 import org.apache.directory.server.newldap.LdapServer;
 import org.apache.directory.server.protocol.shared.SocketAcceptor;

Modified: directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java (original)
+++ directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java Thu Aug 14 16:12:09 2008
@@ -32,8 +32,6 @@
 import javax.naming.InvalidNameException;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
 import javax.naming.directory.DirContext;
 
 import org.apache.commons.cli.CommandLine;
@@ -60,6 +58,9 @@
 import org.apache.directory.shared.ldap.codec.modify.ModifyRequest;
 import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNRequest;
 import org.apache.directory.shared.ldap.codec.unbind.UnBindRequest;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.ldif.ChangeType;
 import org.apache.directory.shared.ldap.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.ldif.LdifReader;
@@ -212,39 +213,36 @@
      * Send the entry to the encoder, then wait for a
      * reponse from the LDAP server on the results of the operation.
      * 
-     * @param entry
+     * @param ldifEntry
      *            The entry to add
      * @param msgId
      *            message id number
      */
-    private int addEntry( LdifEntry entry, int messageId ) throws IOException, DecoderException, InvalidNameException,
+    private int addEntry( LdifEntry ldifEntry, int messageId ) throws IOException, DecoderException, InvalidNameException,
         NamingException, EncoderException
     {
         AddRequest addRequest = new AddRequest();
 
-        String dn = entry.getDn();
+        String dn = ldifEntry.getDn().getUpName();
 
         if ( isDebugEnabled() )
         {
             System.out.println( "Adding entry " + dn );
         }
 
-        Attributes attributes = entry.getAttributes();
+        Entry entry = ldifEntry.getEntry();
 
         addRequest.setEntry( new LdapDN( dn ) );
 
         // Copy the attributes
         addRequest.initAttributes();
 
-        for ( NamingEnumeration attrs = attributes.getAll(); attrs.hasMoreElements(); )
+        for ( EntryAttribute attribute:entry )
         {
-            Attribute attribute = ( Attribute ) attrs.nextElement();
-
-            addRequest.addAttributeType( attribute.getID() );
+            addRequest.addAttributeType( attribute.getId() );
 
-            for ( NamingEnumeration values = attribute.getAll(); values.hasMoreElements(); )
+            for ( Value<?> value: attribute )
             {
-                Object value = values.nextElement();
                 addRequest.addAttributeValue( value );
             }
         }
@@ -300,7 +298,7 @@
     {
         DelRequest delRequest = new DelRequest();
 
-        String dn = entry.getDn();
+        String dn = entry.getDn().getUpName();
 
         if ( isDebugEnabled() )
         {
@@ -359,7 +357,7 @@
     {
         ModifyDNRequest modifyDNRequest = new ModifyDNRequest();
 
-        String dn = entry.getDn();
+        String dn = entry.getDn().getUpName();
 
         if ( isDebugEnabled() )
         {
@@ -425,7 +423,7 @@
     {
         ModifyRequest modifyRequest = new ModifyRequest();
 
-        String dn = entry.getDn();
+        String dn = entry.getDn().getUpName();
 
         if ( isDebugEnabled() )
         {

Modified: directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java (original)
+++ directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java Thu Aug 14 16:12:09 2008
@@ -31,10 +31,7 @@
 import java.util.Map;
 
 import javax.naming.Context;
-import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
 import javax.naming.ldap.InitialLdapContext;
 import javax.naming.ldap.LdapContext;
 
@@ -43,8 +40,10 @@
 
 import org.apache.commons.io.FileUtils;
 import org.apache.directory.server.constants.ServerDNConstants;
+import org.apache.directory.server.core.CoreSession;
 import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.server.core.jndi.CoreContextFactory;
 import org.apache.directory.server.newldap.LdapServer;
 import org.apache.directory.server.newldap.handlers.bind.MechanismHandler;
@@ -57,10 +56,12 @@
 import org.apache.directory.server.newldap.handlers.extended.StoredProcedureExtendedOperationHandler;
 import org.apache.directory.server.protocol.shared.SocketAcceptor;
 import org.apache.directory.shared.ldap.constants.SupportedSaslMechanisms;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.exception.LdapConfigurationException;
 import org.apache.directory.shared.ldap.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.ldif.LdifReader;
-import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.mina.util.AvailablePortFinder;
 
 import org.slf4j.Logger;
@@ -83,7 +84,7 @@
     protected LdapContext sysRoot;
 
     /** the context root for the rootDSE */
-    protected LdapContext rootDSE;
+    protected CoreSession rootDSE;
 
     /** the context root for the schema */
     protected LdapContext schemaRoot;
@@ -143,7 +144,8 @@
 
         for ( LdifEntry entry:ldifReader )
         {
-            rootDSE.createSubcontext( entry.getDn(), entry.getAttributes() );
+            rootDSE.add( 
+                new DefaultServerEntry( directoryService.getRegistries(), entry.getEntry() ) ); 
             
             if ( verifyEntries )
             {
@@ -171,17 +173,16 @@
      */
     protected void verify( LdifEntry entry ) throws Exception
     {
-        Attributes readAttributes = rootDSE.getAttributes( entry.getDn() );
-        NamingEnumeration<String> readIds = entry.getAttributes().getIDs();
-        while ( readIds.hasMore() )
-        {
-            String id = readIds.next();
-            Attribute readAttribute = readAttributes.get( id );
-            Attribute origAttribute = entry.getAttributes().get( id );
+        Entry readEntry = rootDSE.lookup( entry.getDn() );
+        
+        for ( EntryAttribute readAttribute:readEntry )
+        {
+            String id = readAttribute.getId();
+            EntryAttribute origAttribute = entry.getEntry().get( id );
             
-            for ( int ii = 0; ii < origAttribute.size(); ii++ )
+            for ( Value<?> value:origAttribute )
             {
-                if ( ! readAttribute.contains( origAttribute.get( ii ) ) )
+                if ( ! readAttribute.contains( value ) )
                 {
                     LOG.error( "Failed to verify entry addition of {}. {} attribute in original " +
                             "entry missing from read entry.", entry.getDn(), id );
@@ -370,7 +371,7 @@
         sysRoot = new InitialLdapContext( envFinal, null );
 
         envFinal.put( Context.PROVIDER_URL, "" );
-        rootDSE = new InitialLdapContext( envFinal, null );
+        rootDSE = directoryService.getAdminSession();
 
         envFinal.put( Context.PROVIDER_URL, ServerDNConstants.OU_SCHEMA_DN );
         schemaRoot = new InitialLdapContext( envFinal, null );
@@ -420,8 +421,9 @@
         {
             for ( LdifEntry ldifEntry:new LdifReader( in ) )
             {
-                LdapDN dn = new LdapDN( ldifEntry.getDn() );
-                rootDSE.createSubcontext( dn, ldifEntry.getAttributes() );
+                rootDSE.add( 
+                    new DefaultServerEntry( 
+                        rootDSE.getDirectoryService().getRegistries(), ldifEntry.getEntry() ) ); 
             }
         }
         catch ( Exception e )
@@ -447,7 +449,9 @@
 
         for ( LdifEntry entry : entries )
         {
-            rootDSE.createSubcontext( new LdapDN( entry.getDn() ), entry.getAttributes() );
+            rootDSE.add( 
+                new DefaultServerEntry( 
+                    rootDSE.getDirectoryService().getRegistries(), entry.getEntry() ) ); 
         }
     }
 }

Modified: directory/shared/branches/bigbang/convert/src/main/java/org/apache/directory/shared/converter/schema/AttributeTypeHolder.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/convert/src/main/java/org/apache/directory/shared/converter/schema/AttributeTypeHolder.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/shared/branches/bigbang/convert/src/main/java/org/apache/directory/shared/converter/schema/AttributeTypeHolder.java (original)
+++ directory/shared/branches/bigbang/convert/src/main/java/org/apache/directory/shared/converter/schema/AttributeTypeHolder.java Thu Aug 14 16:12:09 2008
@@ -21,12 +21,12 @@
 
 
 import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
 
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
 import org.apache.directory.shared.ldap.ldif.LdifUtils;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.schema.UsageEnum;
 
@@ -423,11 +423,11 @@
         String dn = "m-oid=" + oid + ", ou=attributeTypes" + ", cn=" + Rdn.escapeValue( schemaName ) + ", ou=schema";
 
         // First dump the DN only
-        Attributes attributes = new AttributesImpl();
-        Attribute attribute = new AttributeImpl( "dn", dn );
+        Entry entry = new DefaultClientEntry();
+        EntryAttribute attribute = new DefaultClientAttribute( "dn", dn );
 
-        attributes.put( attribute );
-        sb.append( LdifUtils.convertToLdif( attributes ) );
+        entry.put( attribute );
+        sb.append( LdifUtils.convertToLdif( entry ) );
 
         return sb.toString();
     }

Modified: directory/shared/branches/bigbang/convert/src/main/java/org/apache/directory/shared/converter/schema/ObjectClassHolder.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/convert/src/main/java/org/apache/directory/shared/converter/schema/ObjectClassHolder.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/shared/branches/bigbang/convert/src/main/java/org/apache/directory/shared/converter/schema/ObjectClassHolder.java (original)
+++ directory/shared/branches/bigbang/convert/src/main/java/org/apache/directory/shared/converter/schema/ObjectClassHolder.java Thu Aug 14 16:12:09 2008
@@ -24,12 +24,12 @@
 import java.util.List;
 
 import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
 
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
 import org.apache.directory.shared.ldap.ldif.LdifUtils;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
 
@@ -216,11 +216,11 @@
         String dn = "m-oid=" + oid + ", ou=objectClasses" + ", cn=" + Rdn.escapeValue( schemaName ) + ", ou=schema";
 
         // First dump the DN only
-        Attributes attributes = new AttributesImpl();
-        Attribute attribute = new AttributeImpl( "dn", dn );
+        Entry entry = new DefaultClientEntry();
+        EntryAttribute attribute = new DefaultClientAttribute( "dn", dn );
 
-        attributes.put( attribute );
-        sb.append( LdifUtils.convertToLdif( attributes ) );
+        entry.put( attribute );
+        sb.append( LdifUtils.convertToLdif( entry ) );
 
         return sb.toString();
     }

Modified: directory/shared/branches/bigbang/convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaElementImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaElementImpl.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/shared/branches/bigbang/convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaElementImpl.java (original)
+++ directory/shared/branches/bigbang/convert/src/main/java/org/apache/directory/shared/converter/schema/SchemaElementImpl.java Thu Aug 14 16:12:09 2008
@@ -23,12 +23,12 @@
 import java.util.List;
 
 import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
 
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
 import org.apache.directory.shared.ldap.ldif.LdifUtils;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.util.StringTools;
 
 /**
@@ -147,17 +147,17 @@
         }
         else
         {
-            Attributes attributes = new AttributesImpl();
-            Attribute attribute = new AttributeImpl( "m-name" );
+            Entry entry = new DefaultClientEntry();
+            EntryAttribute attribute = new DefaultClientAttribute( "m-name" );
             
             for ( String name:names )
             {
                 attribute.add( name );
             }
             
-            attributes.put( attribute );
+            entry.put( attribute );
             
-            return LdifUtils.convertToLdif( attributes );
+            return LdifUtils.convertToLdif( entry );
         }
     }
     
@@ -172,11 +172,12 @@
         }
         else
         {
-            Attributes attributes = new AttributesImpl();
-            Attribute attribute = new AttributeImpl( "m-description", description );
-            attributes.put( attribute );
+            Entry entry = new DefaultClientEntry();
+            EntryAttribute attribute = new DefaultClientAttribute( "m-description", description );
+
+            entry.put( attribute );
             
-            return LdifUtils.convertToLdif( attributes );
+            return LdifUtils.convertToLdif( entry );
         }
     }
     
@@ -197,15 +198,15 @@
     {
         StringBuilder sb = new StringBuilder();
         
-        Attributes attributes = new AttributesImpl();
-        Attribute attribute = new AttributeImpl( ID ); 
+        Entry entry = new DefaultClientEntry();
+        EntryAttribute attribute = new DefaultClientAttribute( ID ); 
 
         for ( String extension:extensions )
         {
             attribute.add( extension );
         }
 
-        sb.append( LdifUtils.convertToLdif( attributes ) );
+        sb.append( LdifUtils.convertToLdif( entry ) );
         
         return sb.toString();
     }

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java Thu Aug 14 16:12:09 2008
@@ -19,6 +19,7 @@
 package org.apache.directory.shared.ldap.entry;
 
 
+import java.io.Externalizable;
 import java.util.Iterator;
 import java.util.List;
 
@@ -42,7 +43,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public interface Entry extends Cloneable, Iterable<EntryAttribute>
+public interface Entry extends Cloneable, Iterable<EntryAttribute>, Externalizable
 {
     /**
      * Remove all the attributes for this entry. The DN is not reset

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java Thu Aug 14 16:12:09 2008
@@ -18,6 +18,7 @@
  */
 package org.apache.directory.shared.ldap.entry;
 
+import java.io.Externalizable;
 import java.util.Iterator;
 import java.util.List;
 
@@ -30,7 +31,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public interface EntryAttribute extends Iterable<Value<?>>, Cloneable
+public interface EntryAttribute extends Iterable<Value<?>>, Cloneable, Externalizable
 {
     /**
      * Adds some values to this attribute. If the new values are already present in

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Modification.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Modification.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Modification.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Modification.java Thu Aug 14 16:12:09 2008
@@ -19,6 +19,8 @@
  */
 package org.apache.directory.shared.ldap.entry;
 
+import java.io.Externalizable;
+
 /**
  * An internal interface for a ModificationItem. The name has been
  * chosen so that it does not conflict with @see ModificationItem
@@ -26,7 +28,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public interface Modification extends Cloneable
+public interface Modification extends Cloneable, Externalizable
 {
     /**
      *  @return the operation
@@ -66,9 +68,8 @@
     
     /**
      * The clone operation
-     * TODO clone.
      *
-     * @return
+     * @return a clone of the current modification
      */
     Modification clone();
 }
\ No newline at end of file

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ModificationOperation.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ModificationOperation.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ModificationOperation.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ModificationOperation.java Thu Aug 14 16:12:09 2008
@@ -56,6 +56,35 @@
     }
     
     
+    /**
+     * Get the ModificationOperation from an int value
+     *
+     * @param value the ModificationOperation int value
+     * @return the associated ModifciationOperation instance
+     */
+    public static ModificationOperation getOperation( int value )
+    {
+        if ( value == ADD_ATTRIBUTE.value )
+        {
+            return ADD_ATTRIBUTE;
+        }
+        else if ( value == REMOVE_ATTRIBUTE.value )
+        {
+            return REMOVE_ATTRIBUTE;
+        }
+        else if ( value == REPLACE_ATTRIBUTE.value )
+        {
+            return REPLACE_ATTRIBUTE;
+        }
+        else
+        {
+            return null;
+        }
+    }
+    
+    /**
+     * @see Object#toString()
+     */
     public String toString()
     {
         switch ( this )

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValue.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValue.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValue.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValue.java Thu Aug 14 16:12:09 2008
@@ -355,8 +355,36 @@
      */
     public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
     {
-        // TODO implement this method
-        return;
+        // Read the wrapped value, if it's not null
+        int wrappedLength = in.readInt();
+        
+        if ( wrappedLength >= 0 )
+        {
+            wrapped = new byte[wrappedLength];
+            
+            if ( wrappedLength > 0 )
+            {
+                in.read( wrapped );
+            }
+        }
+        
+        // Read the isNormalized flag
+        normalized = in.readBoolean();
+        
+        if ( normalized )
+        {
+            int normalizedLength = in.readInt();
+            
+            if ( normalizedLength >= 0 )
+            {
+                normalizedValue = new byte[normalizedLength];
+                
+                if ( normalizedLength > 0 )
+                {
+                    in.read( normalizedValue );
+                }
+            }
+        }
     }
 
     
@@ -365,7 +393,45 @@
      */
     public void writeExternal( ObjectOutput out ) throws IOException
     {
-        // TODO Implement this method
+        // Write the wrapped value, if it's not null
+        if ( wrapped != null )
+        {
+            out.writeInt( wrapped.length );
+            
+            if ( wrapped.length > 0 )
+            {
+                out.write( wrapped, 0, wrapped.length );
+            }
+        }
+        else
+        {
+            out.writeInt( -1 );
+        }
+        
+        // Write the isNormalized flag
+        if ( normalized )
+        {
+            out.writeBoolean( true );
+            
+            // Write the normalized value, if not null
+            if ( normalizedValue != null )
+            {
+                out.writeInt( normalizedValue.length );
+                
+                if ( normalizedValue.length > 0 )
+                {
+                    out.write( normalizedValue, 0, normalizedValue.length );
+                }
+            }
+            else
+            {
+                out.writeInt( -1 );
+            }
+        }
+        else
+        {
+            out.writeBoolean( false );
+        }
     }
     
     

Added: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientModification.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientModification.java?rev=686082&view=auto
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientModification.java (added)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientModification.java Thu Aug 14 16:12:09 2008
@@ -0,0 +1,271 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.entry.client;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import javax.naming.directory.DirContext;
+
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
+
+/**
+ * An internal implementation for a ModificationItem. The name has been
+ * chosen so that it does not conflict with @see ModificationItem
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ClientModification implements Modification
+{
+    /** The modification operation */
+    private ModificationOperation operation;
+    
+    /** The attribute which contains the modification */
+    private EntryAttribute attribute;
+ 
+    
+    /**
+     * 
+     * Creates a new instance of ClientModification.
+     *
+     * @param operation The modification operation
+     * @param attribute The asociated attribute 
+     */
+    public ClientModification( ModificationOperation operation, EntryAttribute attribute )
+    {
+        this.operation = operation;
+        this.attribute = attribute;
+    }
+    
+    
+    /**
+     * 
+     * Creates a new instance of ClientModification.
+     */
+    public ClientModification()
+    {
+    }
+    
+    
+    /**
+     * 
+     * Creates a new instance of ClientModification.
+     *
+     * @param operation The modification operation
+     * @param attribute The asociated attribute 
+     */
+    public ClientModification( int operation, EntryAttribute attribute )
+    {
+        setOperation( operation );
+        this.attribute = attribute;
+    }
+    
+    
+    /**
+     *  @return the operation
+     */
+    public ModificationOperation getOperation()
+    {
+        return operation;
+    }
+    
+    
+    /**
+     * Store the modification operation
+     *
+     * @param operation The DirContext value to assign
+     */
+    public void setOperation( int operation )
+    {
+        switch ( operation )
+        {
+            case DirContext.ADD_ATTRIBUTE :
+                this.operation = ModificationOperation.ADD_ATTRIBUTE;
+                break;
+
+            case DirContext.REPLACE_ATTRIBUTE :
+                this.operation = ModificationOperation.REPLACE_ATTRIBUTE;
+                break;
+            
+            case DirContext.REMOVE_ATTRIBUTE :
+                this.operation = ModificationOperation.REMOVE_ATTRIBUTE;
+                break;
+        }
+    }
+
+    
+    /**
+     * Store the modification operation
+     *
+     * @param operation The DirContext value to assign
+     */
+    public void setOperation( ModificationOperation operation )
+    {
+        this.operation = operation;
+    }
+        
+    
+    /**
+     * @return the attribute containing the modifications
+     */
+    public EntryAttribute getAttribute()
+    {
+        return attribute;
+    }
+    
+    
+    /**
+     * Set the attribute's modification
+     *
+     * @param attribute The modified attribute 
+     */
+    public void setAttribute( EntryAttribute attribute )
+    {
+        this.attribute = (ClientAttribute)attribute;
+    }
+    
+    
+    /**
+     * @see Object#equals(Object)
+     * @return <code>true</code> if both values are equal
+     */
+    public boolean equals( Object o )
+    {
+        // Basic equals checks
+        if ( this == o )
+        {
+            return true;
+        }
+        
+        if ( o == null )
+        {
+           return false;
+        }
+        
+        if ( ! (o instanceof ClientModification ) )
+        {
+            return false;
+        }
+        
+        Modification otherModification = (ClientModification)o;
+        
+        // Check the operation
+        if ( !operation.equals( otherModification.getOperation() ) )
+        {
+            return false;
+        }
+
+        
+        // Check the attribute
+        if ( attribute == null )
+        {
+            return otherModification.getAttribute() == null;
+        }
+        
+        return attribute.equals( otherModification.getAttribute() );
+    }
+    
+    
+    /**
+     * Compute the modification @see Object#hashCode
+     * @return the instance's hash code 
+     */
+    public int hashCode()
+    {
+        int h = 37;
+        
+        h += h*17 + operation.getValue();
+        h += h*17 + attribute.hashCode();
+        
+        return h;
+    }
+    
+
+    /**
+     * @see java.io.Externalizable#readExternal(ObjectInput)
+     */
+    public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
+    {
+        // Read the operation
+        int op = in.readInt();
+        
+        operation = ModificationOperation.getOperation( op );
+        
+        // Read the attribute
+        attribute = (ClientAttribute)in.readObject();
+    }
+    
+    
+    /**
+     * @see java.io.Externalizable#writeExternal(ObjectOutput)
+     */
+    public void writeExternal( ObjectOutput out ) throws IOException
+    {
+        // Write the operation
+        out.writeInt( operation.getValue() );
+        
+        // Write the attribute
+        out.writeObject( attribute );
+        
+        out.flush();
+    }
+    
+    
+    /**
+     * Clone a modification
+     * 
+     * @return  a copied instance of the current modification
+     */
+    public ClientModification clone()
+    {
+        try
+        {
+            ClientModification clone = (ClientModification)super.clone();
+            
+            clone.attribute = (ClientAttribute)this.attribute.clone();
+            return clone;
+        }
+        catch ( CloneNotSupportedException cnse )
+        {
+            return null;
+        }
+    }
+    
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+        
+        sb.append( "Modification: " ).
+            append( operation ).
+            append( "\n" ).
+            append( ", attribute : " ).
+            append( attribute );
+        
+        return sb.toString();
+    }
+}



Mime
View raw message