You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2008/08/27 09:26:51 UTC

svn commit: r689396 [2/2] - in /directory/apacheds/trunk: bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/ btree-base/src/main/java/org/apache/directory/server/xdbm/ core-integ/src/test/java/org/apache/directory/server/...

Modified: directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java?rev=689396&r1=689395&r2=689396&view=diff
==============================================================================
--- directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java (original)
+++ directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java Wed Aug 27 00:26:48 2008
@@ -44,7 +44,6 @@
 import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.cursor.Cursor;
-import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmMasterTable;
@@ -66,12 +65,10 @@
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.Tuple;
 import org.apache.directory.shared.ldap.MultiException;
-import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.exception.LdapConfigurationException;
 import org.apache.directory.shared.ldap.exception.LdapNamingException;
 import org.apache.directory.shared.ldap.ldif.LdifUtils;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.UsageEnum;
 import org.apache.directory.shared.ldap.util.Base64;
@@ -169,12 +166,6 @@
         schemaPartition.setIndexedAttributes( indexedAttributes );
         schemaPartition.setSuffix( ServerDNConstants.OU_SCHEMA_DN );
 
-        ServerEntry systemEntry = new DefaultServerEntry( registries, new LdapDN( "ou=schema" ) );
-        systemEntry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC,
-            SchemaConstants.ORGANIZATIONAL_UNIT_OC );
-        systemEntry.put( SchemaConstants.OU_AT, "schema" );
-        schemaPartition.setContextEntry( systemEntry );
-
         DirectoryService directoryService = new DefaultDirectoryService();
         schemaPartition.init( directoryService );
 

Modified: directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/IndexCommand.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/IndexCommand.java?rev=689396&r1=689395&r2=689396&view=diff
==============================================================================
--- directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/IndexCommand.java (original)
+++ directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/IndexCommand.java Wed Aug 27 00:26:48 2008
@@ -40,7 +40,6 @@
 import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.cursor.Cursor;
-import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmMasterTable;
@@ -61,11 +60,9 @@
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.Tuple;
 import org.apache.directory.shared.ldap.MultiException;
-import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.exception.LdapConfigurationException;
 import org.apache.directory.shared.ldap.exception.LdapNamingException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
 
@@ -88,6 +85,7 @@
     }
 
 
+    @SuppressWarnings("unchecked")
     private Registries loadRegistries() throws Exception
     {
         // --------------------------------------------------------------------
@@ -160,12 +158,6 @@
         schemaPartition.setIndexedAttributes( indexedAttributes );
         schemaPartition.setSuffix( ServerDNConstants.OU_SCHEMA_DN );
 
-        ServerEntry systemEntry = new DefaultServerEntry( registries, new LdapDN( "ou=schema" ) );
-        systemEntry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC,
-            SchemaConstants.ORGANIZATIONAL_UNIT_OC );
-        systemEntry.put( SchemaConstants.OU_AT, "schema" );
-        schemaPartition.setContextEntry( systemEntry );
-
         DirectoryService directoryService = new DefaultDirectoryService();
         schemaPartition.init( directoryService );
 
@@ -197,6 +189,7 @@
     }
 
 
+    @SuppressWarnings("unchecked")
     private void buildIndex( File partitionDirectory, AttributeType attributeType ) throws Exception
     {
         if ( !partitionDirectory.exists() )

Modified: directory/apacheds/trunk/server-xml/src/main/resources/server.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-xml/src/main/resources/server.xml?rev=689396&r1=689395&r2=689396&view=diff
==============================================================================
--- directory/apacheds/trunk/server-xml/src/main/resources/server.xml (original)
+++ directory/apacheds/trunk/server-xml/src/main/resources/server.xml Wed Aug 27 00:26:48 2008
@@ -45,15 +45,6 @@
           <jdbmIndex attributeId="uid" cacheSize="100"/>
           <jdbmIndex attributeId="objectClass" cacheSize="100"/>
         </indexedAttributes>
-        <contextEntry>#systemContextEntry</contextEntry>
-        <!-- contextEntry>
-          <s:value>
-            objectClass: top
-            objectClass: organizationalUnit
-            objectClass: extensibleObject
-            ou: system
-          </s:value>
-        </contextEntry -->
       </jdbmPartition>
     </systemPartition>
 
@@ -77,15 +68,6 @@
           <jdbmIndex attributeId="uid" cacheSize="100"/>
           <jdbmIndex attributeId="objectClass" cacheSize="100"/>
         </indexedAttributes>
-        <contextEntry>#exampleContextEntry</contextEntry>
-        <!-- contextEntry>
-          <s:value>
-            objectClass: top
-            objectClass: domain
-            objectClass: extensibleObject
-            dc: example
-          </s:value>
-        </contextEntry -->
       </jdbmPartition>
     </partitions>
 
@@ -216,40 +198,6 @@
     <ldapsServer>#ldapsServer</ldapsServer>
   </apacheDS>
 
-  <spring:bean id="systemContextEntry" 
-	class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
-    <spring:property name="targetObject"><spring:ref local='directoryService'/></spring:property>
-    <spring:property name="targetMethod"><spring:value>newEntry</spring:value></spring:property>
-    <spring:property name="arguments">
-      <spring:list>
-        <spring:value xmlns="http://www.springframework.org/schema/beans">
-          objectClass: top
-          objectClass: organizationalUnit
-          objectClass: extensibleObject
-          ou: system
-        </spring:value>
-        <spring:value>ou=system</spring:value>
-      </spring:list>
-    </spring:property>
-  </spring:bean>
-  
-  <spring:bean id="exampleContextEntry" 
-	class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
-    <spring:property name="targetObject"><spring:ref local='directoryService'/></spring:property>
-    <spring:property name="targetMethod"><spring:value>newEntry</spring:value></spring:property>
-    <spring:property name="arguments">
-      <spring:list>
-        <spring:value xmlns="http://www.springframework.org/schema/beans">
-          objectClass: top
-          objectClass: domain
-          objectClass: extensibleObject
-          dc: example
-        </spring:value>
-        <spring:value>dc=example,dc=com</spring:value>
-      </spring:list>
-    </spring:property>
-  </spring:bean>
-
   <!-- another bean I didn't convert -->
   <spring:bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
     <spring:property name="customEditors">

Modified: directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java?rev=689396&r1=689395&r2=689396&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java (original)
+++ directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java Wed Aug 27 00:26:48 2008
@@ -53,7 +53,7 @@
 {
     /** the database this optimizer operates on */
     private final Store<E> db;
-    private final Long contextEntryId;
+    private Long contextEntryId;
     
 
     /**
@@ -61,12 +61,34 @@
      *
      * @param db the database this optimizer works for.
      */
-    public DefaultOptimizer( Store<E> db )
+    public DefaultOptimizer( Store<E> db ) throws Exception
     {
         this.db = db;
-        this.contextEntryId = db.getContextEntryId();
     }
 
+    
+    private Long getContextEntryId()
+    {
+        if ( contextEntryId == null )
+        {
+            try
+            {
+                this.contextEntryId = db.getEntryId( db.getSuffix().getNormName() );
+            }
+            catch ( Exception e )
+            {
+                // might not have been created
+            }
+        }
+        
+        if ( contextEntryId == null )
+        {
+            return 1L;
+        }
+        
+        return contextEntryId;
+    }
+    
 
     /**
      * Annotates the expression tree to determine optimal evaluation order based
@@ -76,6 +98,7 @@
      *
      * @see org.apache.directory.server.xdbm.search.Optimizer#annotate(ExprNode)
      */
+    @SuppressWarnings("unchecked")
     public Long annotate( ExprNode node ) throws Exception
     {
         // Start off with the worst case unless scan count says otherwise.
@@ -246,11 +269,11 @@
      * @return the worst case
      * @throws Exception if there is an error accessing an index
      */
+    @SuppressWarnings("unchecked")
     private<V> long getEqualityScan( SimpleNode<V> node ) throws Exception
     {
         if ( db.hasUserIndexOn( node.getAttribute() ) )
         {
-            //noinspection unchecked
             Index<V,E> idx = ( Index<V, E> ) db.getUserIndex( node.getAttribute() );
             return idx.count( node.getValue().get() );
         }
@@ -269,11 +292,11 @@
      * @return the scan count of all nodes satisfying the AVA
      * @throws Exception if there is an error accessing an index
      */
+    @SuppressWarnings("unchecked")
     private<V> long getGreaterLessScan( SimpleNode<V> node, boolean isGreaterThan ) throws Exception
     {
         if ( db.hasUserIndexOn( node.getAttribute() ) )
         {
-            //noinspection unchecked
             Index<V, E> idx = ( Index<V, E> ) db.getUserIndex( node.getAttribute() );
             if ( isGreaterThan )
             {
@@ -299,6 +322,7 @@
      * @return the worst case full scan count
      * @throws Exception if there is an error access database indices
      */
+    @SuppressWarnings("unchecked")
     private long getFullScan( LeafNode node ) throws Exception
     {
         if ( db.hasUserIndexOn( node.getAttribute() ) )
@@ -350,7 +374,7 @@
                 return db.getChildCount( id );
                 
             case SUBTREE:
-                if ( id.longValue() == contextEntryId.longValue() )
+                if ( id == getContextEntryId() )
                 {
                     return db.count();
                 }

Modified: directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java?rev=689396&r1=689395&r2=689396&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java (original)
+++ directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java Wed Aug 27 00:26:48 2008
@@ -147,6 +147,11 @@
             entry = db.lookup( indexEntry.getId() );
             indexEntry.setObject( entry );
         }
+        
+        if ( null == entry )
+        {
+            return false;
+        }
 
         // get the attribute
         ServerAttribute attr = ( ServerAttribute ) entry.get( type );

Modified: directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java?rev=689396&r1=689395&r2=689396&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java (original)
+++ directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java Wed Aug 27 00:26:48 2008
@@ -58,7 +58,9 @@
     /** Whether or not this Cursor is positioned so an entry is available */
     private boolean available = false;
 
+    private Long contextEntryId;
 
+    
     /**
      * Creates a Cursor over entries satisfying subtree level scope criteria.
      *
@@ -71,7 +73,7 @@
         this.db = db;
         this.evaluator = evaluator;
         
-        if ( evaluator.getBaseId().longValue() == db.getContextEntryId().longValue() )
+        if ( evaluator.getBaseId() == getContextEntryId() )
         {
             scopeCursor = new AllEntriesCursor( db );
         }
@@ -91,6 +93,30 @@
     }
 
 
+    private Long getContextEntryId()
+    {
+        if ( contextEntryId == null )
+        {
+            try
+            {
+                this.contextEntryId = db.getEntryId( db.getSuffix().getNormName() );
+            }
+            catch ( Exception e )
+            {
+                // might not have been created
+                // might not have been created
+            }
+        }
+        
+        if ( contextEntryId == null )
+        {
+            return 1L;
+        }
+        
+        return contextEntryId;
+    }
+
+    
     public boolean available()
     {
         return available;

Modified: directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java?rev=689396&r1=689395&r2=689396&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java (original)
+++ directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java Wed Aug 27 00:26:48 2008
@@ -79,12 +79,39 @@
         }
 
         baseId = db.getEntryId( node.getBaseDn() );
-        baseIsContextEntry = db.getContextEntryId().longValue() == baseId.longValue();
+        baseIsContextEntry = getContextEntryId() == baseId;
         dereferencing = node.getDerefAliases().isDerefInSearching() ||
             node.getDerefAliases().isDerefAlways();
     }
 
     
+    private Long contextEntryId;
+
+
+    private Long getContextEntryId()
+    {
+        if ( contextEntryId == null )
+        {
+            try
+            {
+                this.contextEntryId = db.getEntryId( db.getSuffix().getNormName() );
+            }
+            catch ( Exception e )
+            {
+                // might not have been created
+                // might not have been created
+            }
+        }
+        
+        if ( contextEntryId == null )
+        {
+            return 1L;
+        }
+        
+        return contextEntryId;
+    }
+
+    
     /**
      * Asserts whether or not a candidate has one level scope while taking
      * alias dereferencing into account.

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=689396&r1=689395&r2=689396&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 Aug 27 00:26:48 2008
@@ -47,6 +47,7 @@
 import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.ForwardIndexEntry;
 import org.apache.directory.server.core.cursor.Cursor;
+import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.directory.shared.ldap.NotImplementedException;
 
@@ -222,6 +223,7 @@
         scanBut.setText( "Scan" );
         scanBut.addActionListener( new ActionListener()
         {
+            @SuppressWarnings("unchecked")
             public void actionPerformed( ActionEvent e )
             {
                 //noinspection unchecked
@@ -402,10 +404,10 @@
     }
     
     
-    public static void show( Index index )
+    @SuppressWarnings("unchecked")
+    public static void show( Index<?,ServerEntry> index )
     {
-        //noinspection unchecked
-        IndexDialog dialog = new IndexDialog( index );
+        IndexDialog<?,ServerEntry> 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=689396&r1=689395&r2=689396&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 Aug 27 00:26:48 2008
@@ -21,7 +21,8 @@
 
 
 import org.apache.directory.server.xdbm.Index;
-import org.apache.directory.server.core.cursor.Cursor;
+import org.apache.directory.server.xdbm.IndexCursor;
+import org.apache.directory.server.core.entry.ServerEntry;
 
 import java.io.OutputStream;
 import java.io.PrintStream;
@@ -35,13 +36,13 @@
  */
 public class IndexUtils
 {
-    public static void printContents( Index idx ) throws Exception
+    public static void printContents( Index<?, ServerEntry> idx ) throws Exception
     {
         printContents( idx, System.out );    
     }
 
 
-    public static void printContents( Index idx, OutputStream outputStream ) throws Exception
+    public static void printContents( Index<?, ServerEntry> idx, OutputStream outputStream ) throws Exception
     {
         PrintStream out;
 
@@ -58,7 +59,7 @@
             out = new PrintStream( outputStream );
         }
 
-        Cursor cursor = idx.forwardCursor();
+        IndexCursor<?, ServerEntry> 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=689396&r1=689395&r2=689396&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 Aug 27 00:26:48 2008
@@ -27,6 +27,7 @@
 
 import org.apache.directory.server.core.cursor.Cursor;
 import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.server.xdbm.ForwardIndexEntry;
@@ -59,28 +60,30 @@
      * @param registries oid registries
      * @throws Exception on access exceptions
      */
-    public static void loadExampleData( Store store, Registries registries ) throws Exception
+    public static void loadExampleData( Store<ServerEntry> store, Registries registries ) throws Exception
     {
         store.setSuffixDn( "o=Good Times Co." );
 
         LdapDN suffixDn = new LdapDN( "o=Good Times Co." );
         suffixDn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
         
-        DefaultServerEntry contextEntry = new DefaultServerEntry( registries, suffixDn );
-        contextEntry.add( "objectClass", "organization" );
-        contextEntry.add( "o", "Good Times Co." );
-        contextEntry.add( "postalCode", "1" );
-        contextEntry.add( "postOfficeBox", "1" );
-        store.setContextEntry( contextEntry );
-        
         AttributeTypeRegistry attributeRegistry = registries.getAttributeTypeRegistry();
 
         store.init( registries );
 
+        // Entry #1
+        DefaultServerEntry entry = new DefaultServerEntry( registries, suffixDn );
+        entry.add( "objectClass", "organization" );
+        entry.add( "o", "Good Times Co." );
+        entry.add( "postalCode", "1" );
+        entry.add( "postOfficeBox", "1" );
+        store.add( suffixDn, entry );
+
+        
         // Entry #2
         LdapDN dn = new LdapDN( "ou=Sales,o=Good Times Co." );
         dn.normalize( attributeRegistry.getNormalizerMapping() );
-        DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+        entry = new DefaultServerEntry( registries, dn );
         entry.add( "objectClass", "top", "organizationalUnit" );
         entry.add( "ou", "Sales" );
         entry.add( "postalCode", "1" );