directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r938820 [10/10] - in /directory: apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/ apacheds/trunk/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/ apacheds/trunk/core-annot...
Date Wed, 28 Apr 2010 08:44:47 GMT
Modified: directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/EntryNode.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/EntryNode.java?rev=938820&r1=938819&r2=938820&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/EntryNode.java
(original)
+++ directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/EntryNode.java
Wed Apr 28 08:44:42 2010
@@ -35,7 +35,7 @@ import org.apache.directory.server.xdbm.
 import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.search.Evaluator;
 import org.apache.directory.server.xdbm.search.SearchEngine;
-import org.apache.directory.shared.ldap.entry.ServerEntry;
+import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.name.DN;
 
@@ -50,18 +50,18 @@ public class EntryNode implements TreeNo
 {
     private final BTreePartition partition;
     private final EntryNode parent;
-    private final ServerEntry entry;
+    private final Entry entry;
     private final ArrayList<TreeNode> children;
     private final Long id;
 
 
-    public EntryNode( Long id, EntryNode parent, BTreePartition partition, ServerEntry entry,
Map<Long, EntryNode> map )
+    public EntryNode( Long id, EntryNode parent, BTreePartition partition, Entry entry, Map<Long,
EntryNode> map )
     {
         this( id, parent, partition, entry, map, null, null );
     }
 
 
-    public EntryNode( Long id, EntryNode parent, BTreePartition db, ServerEntry entry, Map<Long,
EntryNode> map,
+    public EntryNode( Long id, EntryNode parent, BTreePartition db, Entry entry, Map<Long,
EntryNode> map,
         ExprNode exprNode, SearchEngine engine )
     {
         this.partition = db;
@@ -81,7 +81,7 @@ public class EntryNode implements TreeNo
         try
         {
             List<ForwardIndexEntry> recordForwards = new ArrayList<ForwardIndexEntry>();
-            IndexCursor<Long, ServerEntry, Long> childList = db.list( id );
+            IndexCursor<Long, Entry, Long> childList = db.list( id );
 
             while ( childList.next() )
             {
@@ -106,7 +106,7 @@ public class EntryNode implements TreeNo
                         Evaluator evaluator = engine.evaluator( exprNode );
                         if ( evaluator.evaluateId( rec.getId() ) )
                         {
-                            ServerEntry newEntry = db.lookup( rec.getId() );
+                            Entry newEntry = db.lookup( rec.getId() );
                             EntryNode child = new EntryNode( ( Long ) rec.getId(), this,
db, newEntry, map, exprNode,
                                 engine );
                             children.add( child );
@@ -118,7 +118,7 @@ public class EntryNode implements TreeNo
                     }
                     else
                     {
-                        ServerEntry newEntry = db.lookup( rec.getId() );
+                        Entry newEntry = db.lookup( rec.getId() );
                         EntryNode child = new EntryNode( ( Long ) rec.getId(), this, db,
newEntry, map, exprNode,
                             engine );
                         children.add( child );
@@ -126,7 +126,7 @@ public class EntryNode implements TreeNo
                 }
                 else
                 {
-                    ServerEntry newEntry = db.lookup( ( Long ) rec.getId() );
+                    Entry newEntry = db.lookup( ( Long ) rec.getId() );
                     EntryNode child = new EntryNode( ( Long ) rec.getId(), this, db, newEntry,
map );
                     children.add( child );
                 }
@@ -213,7 +213,7 @@ public class EntryNode implements TreeNo
     }
 
 
-    public ServerEntry getLdapEntry()
+    public Entry getLdapEntry()
     {
         return entry;
     }

Modified: directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java?rev=938820&r1=938819&r2=938820&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java
(original)
+++ directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java
Wed Apr 28 08:44:42 2010
@@ -65,8 +65,8 @@ import org.apache.directory.server.i18n.
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.IndexEntry;
-import org.apache.directory.shared.ldap.entry.DefaultServerEntry;
-import org.apache.directory.shared.ldap.entry.ServerEntry;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.filter.FilterParser;
 import org.apache.directory.shared.ldap.ldif.LdifEntry;
@@ -468,7 +468,7 @@ public class PartitionFrame extends JFra
 
                 DN ndn = new DN( StringTools.deepTrimToLower( updn ) );
 
-                ServerEntry attrs = new DefaultServerEntry( schemaManager, entry.getEntry()
);
+                Entry attrs = new DefaultClientEntry( schemaManager, entry.getEntry() );
 
                 if ( null == partition.getEntryId( ndn ) )
                 {
@@ -662,7 +662,7 @@ public class PartitionFrame extends JFra
             limitMax = Integer.parseInt( limit );
         }
 
-        IndexCursor<Long, ServerEntry, Long> cursor = partition.getSearchEngine().cursor(
new DN( base ),
+        IndexCursor<Long, Entry, Long> cursor = partition.getSearchEngine().cursor(
new DN( base ),
             AliasDerefMode.DEREF_ALWAYS, root, ctls );
         String[] cols = new String[2];
         cols[0] = "id";
@@ -866,7 +866,7 @@ public class PartitionFrame extends JFra
     }
 
 
-    void displayEntry( Long id, ServerEntry entry ) throws Exception
+    void displayEntry( Long id, Entry entry ) throws Exception
     {
         String dn = partition.getEntryUpdn( id );
         AttributesTableModel model = new AttributesTableModel( entry, id, dn, false );
@@ -885,7 +885,7 @@ public class PartitionFrame extends JFra
         // boolean doFiltered = false;
         nodes = new HashMap<Long, EntryNode>();
 
-        ServerEntry suffix = partition.lookup( partition.getEntryId( partition.getSuffixDn()
) );
+        Entry suffix = partition.lookup( partition.getEntryId( partition.getSuffixDn() )
);
         Long id = partition.getEntryId( partition.getSuffixDn() );
         root = new EntryNode( id, null, partition, suffix, nodes );
 

Modified: directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/IndexDialog.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/IndexDialog.java?rev=938820&r1=938819&r2=938820&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/IndexDialog.java
(original)
+++ directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/IndexDialog.java
Wed Apr 28 08:44:42 2010
@@ -49,7 +49,7 @@ import org.apache.directory.server.xdbm.
 import org.apache.directory.server.xdbm.ForwardIndexEntry;
 import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.shared.ldap.cursor.Cursor;
-import org.apache.directory.shared.ldap.entry.ServerEntry;
+import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.directory.shared.ldap.NotImplementedException;
 
@@ -406,9 +406,9 @@ public class IndexDialog<K, O, ID> exten
 
 
     @SuppressWarnings("unchecked")
-    public static void show( Index<?, ServerEntry, Long> index )
+    public static void show( Index<?, Entry, Long> index )
     {
-        IndexDialog<?, ServerEntry, Long> dialog = new IndexDialog( index );
+        IndexDialog<?, Entry, Long> dialog = new IndexDialog( index );
         dialog.setVisible( true );
     }
 }

Modified: directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/IndexUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/IndexUtils.java?rev=938820&r1=938819&r2=938820&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/IndexUtils.java
(original)
+++ directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/IndexUtils.java
Wed Apr 28 08:44:42 2010
@@ -22,7 +22,7 @@ package org.apache.directory.server.xdbm
 
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.IndexCursor;
-import org.apache.directory.shared.ldap.entry.ServerEntry;
+import org.apache.directory.shared.ldap.entry.Entry;
 
 import java.io.OutputStream;
 import java.io.PrintStream;
@@ -36,13 +36,13 @@ import java.io.PrintStream;
  */
 public class IndexUtils
 {
-    public static void printContents( Index<?, ServerEntry, Long> idx ) throws Exception
+    public static void printContents( Index<?, Entry, Long> idx ) throws Exception
     {
         printContents( idx, System.out );
     }
 
 
-    public static void printContents( Index<?, ServerEntry, Long> idx, OutputStream
outputStream ) throws Exception
+    public static void printContents( Index<?, Entry, Long> idx, OutputStream outputStream
) throws Exception
     {
         PrintStream out;
 
@@ -59,7 +59,7 @@ public class IndexUtils
             out = new PrintStream( outputStream );
         }
 
-        IndexCursor<?, ServerEntry, Long> cursor = idx.forwardCursor();
+        IndexCursor<?, Entry, Long> cursor = idx.forwardCursor();
         cursor.first();
         for ( Object entry : cursor )
         {

Modified: directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java?rev=938820&r1=938819&r2=938820&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java
(original)
+++ directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java
Wed Apr 28 08:44:42 2010
@@ -31,10 +31,8 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.csn.CsnFactory;
 import org.apache.directory.shared.ldap.cursor.Cursor;
 import org.apache.directory.shared.ldap.entry.DefaultEntryAttribute;
-import org.apache.directory.shared.ldap.entry.DefaultServerEntry;
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
-import org.apache.directory.shared.ldap.entry.ServerEntry;
 import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.schema.SchemaManager;
@@ -64,7 +62,7 @@ public class StoreUtils
      * @param registries oid registries
      * @throws Exception on access exceptions
      */
-    public static void loadExampleData( Store<ServerEntry, Long> store, SchemaManager
schemaManager ) throws Exception
+    public static void loadExampleData( Store<Entry, Long> store, SchemaManager schemaManager
) throws Exception
     {
         DN suffixDn = new DN( "o=Good Times Co." );
         suffixDn.normalize( schemaManager.getNormalizerMapping() );
@@ -73,7 +71,7 @@ public class StoreUtils
         store.init( schemaManager );
 
         // Entry #1
-        DefaultServerEntry entry = new DefaultServerEntry( schemaManager, suffixDn );
+        DefaultClientEntry entry = new DefaultClientEntry( schemaManager, suffixDn );
         entry.add( "objectClass", "organization" );
         entry.add( "o", "Good Times Co." );
         entry.add( "postalCode", "1" );
@@ -83,7 +81,7 @@ public class StoreUtils
         // Entry #2
         DN dn = new DN( "ou=Sales,o=Good Times Co." );
         dn.normalize( schemaManager.getNormalizerMapping() );
-        entry = new DefaultServerEntry( schemaManager, dn );
+        entry = new DefaultClientEntry( schemaManager, dn );
         entry.add( "objectClass", "top", "organizationalUnit" );
         entry.add( "ou", "Sales" );
         entry.add( "postalCode", "1" );
@@ -93,7 +91,7 @@ public class StoreUtils
         // Entry #3
         dn = new DN( "ou=Board of Directors,o=Good Times Co." );
         dn.normalize( schemaManager.getNormalizerMapping() );
-        entry = new DefaultServerEntry( schemaManager, dn );
+        entry = new DefaultClientEntry( schemaManager, dn );
         entry.add( "objectClass", "top", "organizationalUnit" );
         entry.add( "ou", "Board of Directors" );
         entry.add( "postalCode", "1" );
@@ -103,7 +101,7 @@ public class StoreUtils
         // Entry #4
         dn = new DN( "ou=Engineering,o=Good Times Co." );
         dn.normalize( schemaManager.getNormalizerMapping() );
-        entry = new DefaultServerEntry( schemaManager, dn );
+        entry = new DefaultClientEntry( schemaManager, dn );
         entry.add( "objectClass", "top", "organizationalUnit" );
         entry.add( "ou", "Engineering" );
         entry.add( "postalCode", "2" );
@@ -113,7 +111,7 @@ public class StoreUtils
         // Entry #5
         dn = new DN( "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );
         dn.normalize( schemaManager.getNormalizerMapping() );
-        entry = new DefaultServerEntry( schemaManager, dn );
+        entry = new DefaultClientEntry( schemaManager, dn );
         entry.add( "objectClass", "top", "person", "organizationalPerson" );
         entry.add( "ou", "Sales" );
         entry.add( "cn", "JOhnny WAlkeR" );
@@ -125,7 +123,7 @@ public class StoreUtils
         // Entry #6
         dn = new DN( "cn=JIM BEAN,ou=Sales,o=Good Times Co." );
         dn.normalize( schemaManager.getNormalizerMapping() );
-        entry = new DefaultServerEntry( schemaManager, dn );
+        entry = new DefaultClientEntry( schemaManager, dn );
         entry.add( "objectClass", "top", "person", "organizationalPerson" );
         entry.add( "ou", "Sales" );
         entry.add( "cn", "JIM BEAN" );
@@ -137,7 +135,7 @@ public class StoreUtils
         // Entry #7
         dn = new DN( "ou=Apache,ou=Board of Directors,o=Good Times Co." );
         dn.normalize( schemaManager.getNormalizerMapping() );
-        entry = new DefaultServerEntry( schemaManager, dn );
+        entry = new DefaultClientEntry( schemaManager, dn );
         entry.add( "objectClass", "top", "organizationalUnit" );
         entry.add( "ou", "Apache" );
         entry.add( "postalCode", "5" );
@@ -147,7 +145,7 @@ public class StoreUtils
         // Entry #8
         dn = new DN( "cn=Jack Daniels,ou=Engineering,o=Good Times Co." );
         dn.normalize( schemaManager.getNormalizerMapping() );
-        entry = new DefaultServerEntry( schemaManager, dn );
+        entry = new DefaultClientEntry( schemaManager, dn );
         entry.add( "objectClass", "top", "person", "organizationalPerson" );
         entry.add( "ou", "Engineering" );
         entry.add( "cn", "Jack Daniels" );
@@ -161,7 +159,7 @@ public class StoreUtils
         // Entry #9
         dn = new DN( "commonName=Jim Bean,ou=Apache,ou=Board of Directors,o=Good Times Co."
);
         dn.normalize( schemaManager.getNormalizerMapping() );
-        entry = new DefaultServerEntry( schemaManager, dn );
+        entry = new DefaultClientEntry( schemaManager, dn );
         entry.add( "objectClass", "top", "alias", "extensibleObject" );
         entry.add( "ou", "Apache" );
         entry.add( "commonName", "Jim Bean" );
@@ -171,7 +169,7 @@ public class StoreUtils
         // Entry #10
         dn = new DN( "commonName=Jim Bean,ou=Board of Directors,o=Good Times Co." );
         dn.normalize( schemaManager.getNormalizerMapping() );
-        entry = new DefaultServerEntry( schemaManager, dn );
+        entry = new DefaultClientEntry( schemaManager, dn );
         entry.add( "objectClass", "top", "alias", "extensibleObject" );
         entry.add( "commonName", "Jim Bean" );
         entry.add( "aliasedObjectName", "cn=Jim Bean,ou=Sales,o=Good Times Co." );
@@ -180,7 +178,7 @@ public class StoreUtils
         // Entry #11
         dn = new DN( "2.5.4.3=Johnny Walker,ou=Engineering,o=Good Times Co." );
         dn.normalize( schemaManager.getNormalizerMapping() );
-        entry = new DefaultServerEntry( schemaManager, dn );
+        entry = new DefaultClientEntry( schemaManager, dn );
         entry.add( "objectClass", "top", "alias", "extensibleObject" );
         entry.add( "ou", "Engineering" );
         entry.add( "2.5.4.3", "Johnny Walker" );
@@ -291,7 +289,7 @@ public class StoreUtils
      * @param entry the server entry
      * @throws Exception in case of any problems in adding the entry to the store
      */
-    public static void injectEntryInStore( Store<ServerEntry, Long> store, ServerEntry
entry ) throws Exception
+    public static void injectEntryInStore( Store<Entry, Long> store, Entry entry )
throws Exception
     {
         entry.add( SchemaConstants.ENTRY_CSN_AT, CSN_FACTORY.newInstance().toString() );
         entry.add( SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString() );

Modified: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java?rev=938820&r1=938819&r2=938820&view=diff
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
(original)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
Wed Apr 28 08:44:42 2010
@@ -115,11 +115,11 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.unbind.UnBindRequestCodec;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.cursor.Cursor;
-import org.apache.directory.shared.ldap.entry.DefaultServerEntry;
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
 import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.filter.FilterParser;
@@ -434,7 +434,7 @@ public class LdapNetworkConnection exten
         searchResultEntry.setMessageId( searchEntryResultCodec.getMessageId() );
         if( schemaManager != null )
         {
-            searchResultEntry.setEntry( new DefaultServerEntry( schemaManager, searchEntryResultCodec.getEntry()
) );
+            searchResultEntry.setEntry( new DefaultClientEntry( schemaManager, searchEntryResultCodec.getEntry()
) );
         }
         else
         {

Modified: directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java?rev=938820&r1=938819&r2=938820&view=diff
==============================================================================
--- directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
(original)
+++ directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
Wed Apr 28 08:44:42 2010
@@ -98,7 +98,7 @@ public class LdifEntry implements Clonea
         changeType = ChangeType.Add; // Default LDIF content
         modificationList = new LinkedList<Modification>();
         modificationItems = new HashMap<String, Modification>();
-        entry = new DefaultClientEntry( null );
+        entry = new DefaultClientEntry( (DN)null );
         control = null;
     }
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java?rev=938820&r1=938819&r2=938820&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java
Wed Apr 28 08:44:42 2010
@@ -20,6 +20,9 @@ package org.apache.directory.shared.ldap
 
 
 import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntry.java?rev=938820&r1=938819&r2=938820&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntry.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntry.java
Wed Apr 28 08:44:42 2010
@@ -18,7 +18,6 @@
  */
 package org.apache.directory.shared.ldap.entry.client;
 
-
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
@@ -32,6 +31,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.directory.shared.ldap.NotImplementedException;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.exception.LdapException;
 
 import org.apache.directory.shared.i18n.I18n;
@@ -81,6 +81,9 @@ public class DefaultClientEntry implemen
     /** The computed hashcode. We don't want to compute it each time the hashcode() method
is called */
     private volatile int h;
 
+    /** A mutex to manage synchronization*/
+    private static transient Object MUTEX = new Object();
+
     
     //-------------------------------------------------------------------------
     // Constructors
@@ -92,12 +95,33 @@ public class DefaultClientEntry implemen
      */
     public DefaultClientEntry()
     {
+        schemaManager = null;
         dn = DN.EMPTY_DN;
     }
 
 
     /**
-     * Creates a new instance of DefaultServerEntry, with a 
+     * <p>
+     * Creates a new instance of DefaultClientEntry, schema aware. 
+     * </p>
+     * <p>
+     * No attributes will be created.
+     * </p> 
+     * 
+     * @param schemaManager The reference to the schemaManager
+     */
+    public DefaultClientEntry( SchemaManager schemaManager )
+    {
+        this.schemaManager = schemaManager;
+        dn = DN.EMPTY_DN;
+
+        // Initialize the ObjectClass object
+        initObjectClassAT( schemaManager );
+    }
+
+
+    /**
+     * Creates a new instance of DefaultClientEntry, with a 
      * DN. 
      * 
      * @param dn The DN for this serverEntry. Can be null.
@@ -109,7 +133,36 @@ public class DefaultClientEntry implemen
 
 
     /**
-     * Creates a new instance of DefaultServerEntry, with a 
+     * <p>
+     * Creates a new instance of DefaultClientEntry, schema aware. 
+     * </p>
+     * <p>
+     * No attributes will be created.
+     * </p> 
+     * 
+     * @param schemaManager The reference to the schemaManager
+     * @param dn The DN for this serverEntry. Can be null.
+     */
+    public DefaultClientEntry( SchemaManager schemaManager, DN dn )
+    {
+        if ( dn == null )
+        {
+            dn = DN.EMPTY_DN;
+        }
+        else
+        {
+            this.dn = dn;
+        }
+        
+        this.schemaManager = schemaManager;
+
+        // Initialize the ObjectClass object
+        initObjectClassAT( schemaManager );
+    }
+
+
+    /**
+     * Creates a new instance of DefaultClientEntry, with a 
      * DN and a list of IDs. 
      * 
      * @param dn The DN for this serverEntry. Can be null.
@@ -129,6 +182,111 @@ public class DefaultClientEntry implemen
     
     /**
      * <p>
+     * Creates a new instance of DefaultClientEntry, copying 
+     * another entry. 
+     * </p>
+     * <p>
+     * No attributes will be created.
+     * </p> 
+     * 
+     * @param schemaManager The reference to the schemaManager
+     * @param entry the entry to copy
+     */
+    public DefaultClientEntry( SchemaManager schemaManager, Entry entry )
+    {
+        this.schemaManager = schemaManager;
+
+        // Initialize the ObjectClass object
+        initObjectClassAT( schemaManager );
+
+        // We will clone the existing entry, because it may be normalized
+        if ( entry.getDn() != null )
+        {
+            dn = (DN)entry.getDn().clone();
+        }
+        else
+        {
+            dn = DN.EMPTY_DN;
+        }
+        
+        if ( !dn.isNormalized( ) )
+        {
+            try
+            {
+                // The dn must be normalized
+                dn.normalize( schemaManager.getNormalizerMapping() );
+            }
+            catch ( LdapException ne )
+            {
+                LOG.warn( "The DN '" + entry.getDn() + "' cannot be normalized" );
+            }
+        }
+        
+        // Init the attributes map
+        attributes = new HashMap<String, EntryAttribute>( entry.size() );
+        
+        // and copy all the attributes
+        for ( EntryAttribute attribute:entry )
+        {
+            try
+            {
+                // First get the AttributeType
+                AttributeType attributeType = attribute.getAttributeType();
+
+                if ( attributeType == null )
+                {
+                    attributeType = schemaManager.lookupAttributeTypeRegistry( attribute.getId()
);
+                }
+                
+                // Create a new ServerAttribute.
+                EntryAttribute serverAttribute = new DefaultEntryAttribute( attributeType,
attribute );
+                
+                // And store it
+                add( serverAttribute );
+            }
+            catch ( LdapException ne )
+            {
+                // Just log a warning
+                LOG.warn( "The attribute '" + attribute.getId() + "' cannot be stored" );
+            }
+        }
+    }
+
+
+    /**
+     * Creates a new instance of DefaultClientEntry, with a 
+     * DN, a list of ID and schema aware. 
+     * <p>
+     * No attributes will be created except the ObjectClass attribute,
+     * which will contains "top". 
+     * <p>
+     * If any of the AttributeType does not exist, they are simply discarded.
+     * 
+     * @param schemaManager The reference to the schemaManager
+     * @param dn The DN for this serverEntry. Can be null.
+     * @param upIds The list of attributes to create.
+     */
+    public DefaultClientEntry( SchemaManager schemaManager, DN dn, String... upIds )
+    {
+        if ( dn == null )
+        {
+            dn = DN.EMPTY_DN;
+        }
+        else
+        {
+            this.dn = dn;
+        }
+        
+        this.schemaManager = schemaManager;
+
+        initObjectClassAT( schemaManager );
+
+        set( upIds );
+    }
+
+    
+    /**
+     * <p>
      * Creates a new instance of DefaultClientEntry, with a 
      * DN and a list of EntryAttributes.
      * </p> 
@@ -153,9 +311,167 @@ public class DefaultClientEntry implemen
     }
 
     
+    /**
+     * Creates a new instance of DefaultClientEntry, with a 
+     * DN, a list of ServerAttributes and schema aware. 
+     * <p>
+     * No attributes will be created except the ObjectClass attribute,
+     * which will contains "top". 
+     * <p>
+     * If any of the AttributeType does not exist, they are simply discarded.
+     * 
+     * @param schemaManager The reference to the schemaManager
+     * @param dn The DN for this serverEntry. Can be null
+     * @param attributes The list of attributes to create
+     */
+    public DefaultClientEntry( SchemaManager schemaManager, DN dn, EntryAttribute... attributes
)
+    {
+        if ( dn == null )
+        {
+            dn = DN.EMPTY_DN;
+        }
+        else
+        {
+            this.dn = dn;
+        }
+        
+        this.schemaManager = schemaManager;
+
+        initObjectClassAT( schemaManager );
+
+        for ( EntryAttribute attribute:attributes )
+        {
+            // Store a new ServerAttribute
+            try
+            {
+                put( attribute );
+            }
+            catch ( LdapException ne )
+            {
+                LOG.warn( "The ServerAttribute '{}' does not exist. It has been discarded",
attribute );
+            }
+        }
+    }
+    /**
+     * <p>
+     * Creates a new instance of DefaultClientEntry, with a 
+     * DN, a list of attributeTypes and schema aware. 
+     * </p>
+     * <p>
+     * The newly created entry is fed with the list of attributeTypes. No
+     * values are associated with those attributeTypes.
+     * </p>
+     * <p>
+     * If any of the AttributeType does not exist, they it's simply discarded.
+     * </p>
+     * 
+     * @param schemaManager The reference to the schemaManager
+     * @param dn The DN for this serverEntry. Can be null.
+     * @param attributeTypes The list of attributes to create, without value.
+     */
+    public DefaultClientEntry( SchemaManager schemaManager, DN dn, AttributeType... attributeTypes
)
+    {
+        if ( dn == null )
+        {
+            dn = DN.EMPTY_DN;
+        }
+        else
+        {
+            this.dn = dn;
+        }
+
+        this.schemaManager = schemaManager;
+
+        // Initialize the ObjectClass object
+        initObjectClassAT( schemaManager );
+
+        // Add the attributeTypes
+        set( attributeTypes );
+    }
+
+    
+    /**
+     * <p>
+     * Creates a new instance of DefaultClientEntry, with a 
+     * DN, an attributeType with the user provided ID, and schema aware. 
+     * </p>
+     * <p>
+     * The newly created entry is fed with the given attributeType. No
+     * values are associated with this attributeType.
+     * </p>
+     * <p>
+     * If the AttributeType does not exist, they it's simply discarded.
+     * </p>
+     * <p>
+     * We also check that the normalized upID equals the AttributeType ID
+     * </p>
+     * 
+     * @param schemaManager The reference to the schemaManager
+     * @param dn The DN for this serverEntry. Can be null.
+     * @param attributeType The attribute to create, without value.
+     * @param upId The User Provided ID fro this AttributeType
+     */
+    public DefaultClientEntry( SchemaManager schemaManager, DN dn, AttributeType attributeType,
String upId )
+    {
+        if ( dn == null )
+        {
+            dn = DN.EMPTY_DN;
+        }
+        else
+        {
+            this.dn = dn;
+        }
+        
+        this.schemaManager = schemaManager;
+
+        // Initialize the ObjectClass object
+        initObjectClassAT( schemaManager );
+
+        try
+        {
+            put( upId, attributeType, (String)null );
+        }
+        catch ( LdapException ne )
+        {
+            // Just discard the AttributeType
+            LOG.error( I18n.err( I18n.ERR_04459, upId, ne.getLocalizedMessage() ) );
+        }
+    }
+
+    
     //-------------------------------------------------------------------------
     // Helper methods
     //-------------------------------------------------------------------------
+    /**
+     * This method is used to initialize the OBJECT_CLASS_AT attributeType.
+     * 
+     * We want to do it only once, so it's a synchronized method. Note that
+     * the alternative would be to call the lookup() every time, but this won't
+     * be very efficient, as it will get the AT from a map, which is also
+     * synchronized, so here, we have a very minimal cost.
+     * 
+     * We can't do it once as a static part in the body of this class, because
+     * the access to the registries is mandatory to get back the AttributeType.
+     */
+    private void initObjectClassAT( SchemaManager schemaManager )
+    {
+        try
+        {
+            if ( OBJECT_CLASS_AT == null )
+            {
+                synchronized ( MUTEX )
+                {
+                    OBJECT_CLASS_AT = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT
);
+                }
+            }
+        }
+        catch ( LdapException ne )
+        {
+            // do nothing...
+        }
+    }
+
+    
     private String getId( String upId ) throws IllegalArgumentException
     {
         String id = StringTools.trim( StringTools.toLowerCase( upId ) );
@@ -661,7 +977,7 @@ public class DefaultClientEntry implemen
             // First, clone the DN, if not null.
             if ( dn != null )
             {
-                clone.setDn( (DN)dn.clone() );
+                clone.dn = (DN)dn.clone();
             }
             
             // then clone the ClientAttribute Map.
@@ -670,9 +986,21 @@ public class DefaultClientEntry implemen
             // now clone all the attributes
             clone.attributes.clear();
             
-            for ( EntryAttribute attribute:attributes.values() )
+            if ( schemaManager != null )
             {
-                clone.attributes.put( attribute.getId(), attribute.clone() );
+                for ( EntryAttribute attribute:attributes.values() )
+                {
+                    String oid = attribute.getAttributeType().getOid();
+                    clone.attributes.put( oid, attribute.clone() );
+                }
+            }
+            else
+            {
+                for ( EntryAttribute attribute:attributes.values() )
+                {
+                    clone.attributes.put( attribute.getId(), attribute.clone() );
+                }
+                
             }
             
             // We are done !
@@ -2270,8 +2598,6 @@ public class DefaultClientEntry implemen
     }
     
     
-    
-
     /**
      * Serialize an Entry.
      * 
@@ -2341,7 +2667,7 @@ public class DefaultClientEntry implemen
             }
         }
     }
-
+    
     
     /**
      * Deserialize an entry. 
@@ -2616,7 +2942,7 @@ public class DefaultClientEntry implemen
                 {
                     sb.append( attribute );
                 }
-                else if ( !attribute.getId().equals( "objectclass" ) )
+                else if ( !attribute.getId().equalsIgnoreCase( "objectclass" ) )
                 {
                     sb.append( attribute );
                 }



Mime
View raw message