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 2007/04/03 07:47:44 UTC

svn commit: r525039 - in /directory/apacheds/trunk: bootstrap-extract/src/main/java/org/apache/directory/server/schema/bootstrap/partition/ core-unit/src/main/java/org/apache/directory/server/core/unit/ core-unit/src/test/java/org/apache/directory/serv...

Author: akarasulu
Date: Mon Apr  2 22:47:43 2007
New Revision: 525039

URL: http://svn.apache.org/viewvc?view=rev&rev=525039
Log:
Fix for DIRSERVER-893: schema changes should now persist across restarts

Added:
    directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaPersistenceITest.java
      - copied unchanged from r525035, directory/apacheds/branches/1.5-pre-release/core-unit/src/test/java/org/apache/directory/server/core/schema/SchemaPersistenceITest.java
Modified:
    directory/apacheds/trunk/bootstrap-extract/src/main/java/org/apache/directory/server/schema/bootstrap/partition/DbFileListing.java
    directory/apacheds/trunk/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractTestCase.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
    directory/apacheds/trunk/mitosis/   (props changed)

Modified: directory/apacheds/trunk/bootstrap-extract/src/main/java/org/apache/directory/server/schema/bootstrap/partition/DbFileListing.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/bootstrap-extract/src/main/java/org/apache/directory/server/schema/bootstrap/partition/DbFileListing.java?view=diff&rev=525039&r1=525038&r2=525039
==============================================================================
--- directory/apacheds/trunk/bootstrap-extract/src/main/java/org/apache/directory/server/schema/bootstrap/partition/DbFileListing.java (original)
+++ directory/apacheds/trunk/bootstrap-extract/src/main/java/org/apache/directory/server/schema/bootstrap/partition/DbFileListing.java Mon Apr  2 22:47:43 2007
@@ -42,7 +42,8 @@
 public class DbFileListing
 {
     Map<String, DbFileType> name2type = new HashMap<String, DbFileType>();
-    private static final String BASE_PATH = DbFileListing.class.getName().substring( 0, DbFileListing.class.getName().lastIndexOf( "." ) + 1 ).replace( '.', '/' );
+    private static final String BASE_PATH = DbFileListing.class.getName()
+        .substring( 0, DbFileListing.class.getName().lastIndexOf( "." ) + 1 ).replace( '.', '/' );
 
 
     public DbFileListing() throws IOException

Modified: directory/apacheds/trunk/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractTestCase.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractTestCase.java?view=diff&rev=525039&r1=525038&r2=525039
==============================================================================
--- directory/apacheds/trunk/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractTestCase.java (original)
+++ directory/apacheds/trunk/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractTestCase.java Mon Apr  2 22:47:43 2007
@@ -43,6 +43,7 @@
 import org.apache.directory.server.core.configuration.Configuration;
 import org.apache.directory.server.core.configuration.MutableStartupConfiguration;
 import org.apache.directory.server.core.configuration.ShutdownConfiguration;
+import org.apache.directory.server.core.configuration.SyncConfiguration;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.ldif.Entry;
 import org.apache.directory.shared.ldap.ldif.LdifReader;
@@ -217,6 +218,17 @@
         registries = DirectoryService.getInstance().getConfiguration().getRegistries();
     }
 
+    
+    /**
+     * Restarts the server without loading data when it has been shutdown.
+     */
+    protected void restart() throws NamingException
+    {
+        configuration = new MutableStartupConfiguration();
+        configuration.setShutdownHookEnabled( false );
+        setContextRoots( username, password, configuration );
+    }
+    
 
     /**
      * Deletes the Eve working directory.
@@ -310,14 +322,10 @@
 
 
     /**
-     * Sets the system context root to null.
-     *
-     * @see junit.framework.TestCase#tearDown()
+     * Issues a shutdown request to the server.
      */
-    protected void tearDown() throws Exception
+    protected void shutdown()
     {
-        super.tearDown();
-
         Hashtable<String,Object> env = new Hashtable<String,Object>();
 
         env.put( Context.PROVIDER_URL, "ou=system" );
@@ -333,9 +341,45 @@
         }
         catch ( Exception e )
         {
-        }
+        } 
         sysRoot = null;
         Runtime.getRuntime().gc();
+    }
+
+
+    /**
+     * Issues a sync request to the server.
+     */
+    protected void sync()
+    {
+        Hashtable<String,Object> env = new Hashtable<String,Object>();
+
+        env.put( Context.PROVIDER_URL, "ou=system" );
+        env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.directory.server.core.jndi.CoreContextFactory" );
+        env.putAll( new SyncConfiguration().toJndiEnvironment() );
+        env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
+        env.put( Context.SECURITY_CREDENTIALS, "secret" );
+        env.put( Context.SECURITY_AUTHENTICATION, "simple" );
+
+        try
+        {
+            new InitialContext( env );
+        }
+        catch ( Exception e )
+        {
+        } 
+    }
+
+    
+    /**
+     * Sets the system context root to null.
+     *
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+        shutdown();
         testEntries.clear();
         ldifPath = null;
         loadClass = null;

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?view=diff&rev=525039&r1=525038&r2=525039
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java Mon Apr  2 22:47:43 2007
@@ -20,6 +20,7 @@
 package org.apache.directory.server.core;
 
 
+import java.io.File;
 import java.io.IOException;
 import java.util.Hashtable;
 import java.util.Iterator;
@@ -57,6 +58,7 @@
 import org.apache.directory.server.schema.bootstrap.CoreSchema;
 import org.apache.directory.server.schema.bootstrap.Schema;
 import org.apache.directory.server.schema.bootstrap.SystemSchema;
+import org.apache.directory.server.schema.bootstrap.partition.DbFileListing;
 import org.apache.directory.server.schema.bootstrap.partition.SchemaPartitionExtractor;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.DefaultOidRegistry;
@@ -66,6 +68,7 @@
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.exception.LdapAuthenticationNotSupportedException;
 import org.apache.directory.shared.ldap.exception.LdapConfigurationException;
+import org.apache.directory.shared.ldap.exception.LdapNamingException;
 import org.apache.directory.shared.ldap.exception.LdapNoPermissionException;
 import org.apache.directory.shared.ldap.ldif.Entry;
 import org.apache.directory.shared.ldap.message.AttributeImpl;
@@ -806,17 +809,21 @@
         // If not present extract schema partition from jar
         // --------------------------------------------------------------------
 
-        SchemaPartitionExtractor extractor = null; 
-        try
-        {
-            extractor = new SchemaPartitionExtractor( startupConfiguration.getWorkingDirectory() );
-            extractor.extract();
-        }
-        catch ( IOException e )
+        File schemaDirectory = new File( startupConfiguration.getWorkingDirectory(), "schema" );
+        SchemaPartitionExtractor extractor = null;
+        if ( ! schemaDirectory.exists() )
         {
-            NamingException ne = new NamingException( "Failed to extract pre-loaded schema partition." );
-            ne.setRootCause( e );
-            throw ne;
+            try
+            {
+                extractor = new SchemaPartitionExtractor( startupConfiguration.getWorkingDirectory() );
+                extractor.extract();
+            }
+            catch ( IOException e )
+            {
+                NamingException ne = new NamingException( "Failed to extract pre-loaded schema partition." );
+                ne.setRootCause( e );
+                throw ne;
+            }
         }
         
         // --------------------------------------------------------------------
@@ -826,7 +833,19 @@
         MutablePartitionConfiguration schemaPartitionConfig = new MutablePartitionConfiguration();
         schemaPartitionConfig.setName( "schema" );
         schemaPartitionConfig.setCacheSize( 1000 );
-        schemaPartitionConfig.setIndexedAttributes( extractor.getDbFileListing().getIndexedAttributes() );
+        
+        DbFileListing listing = null;
+        try 
+        {
+            listing = new DbFileListing();
+        }
+        catch( IOException e )
+        {
+            throw new LdapNamingException( "Got IOException while trying to read DBFileListing: " + e.getMessage(), 
+                ResultCodeEnum.OTHER );
+        }
+        
+        schemaPartitionConfig.setIndexedAttributes( listing.getIndexedAttributes() );
         schemaPartitionConfig.setOptimizerEnabled( true );
         schemaPartitionConfig.setSuffix( "ou=schema" );
         

Propchange: directory/apacheds/trunk/mitosis/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Apr  2 22:47:43 2007
@@ -1,4 +1,5 @@
 *.iml
+*.log
 target
 .classpath
 .project