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 2006/12/15 23:47:57 UTC
svn commit: r487702 - in /directory/branches/trunks/schema/apacheds:
bootstrap-partition/src/main/java/org/ bootstrap-partition/src/test/java/org/
bootstrap-partition/src/test/resources/
bootstrap-plugin/src/main/java/org/apache/directory/server/core/b...
Author: akarasulu
Date: Fri Dec 15 14:47:56 2006
New Revision: 487702
URL: http://svn.apache.org/viewvc?view=rev&rev=487702
Log:
making the bootstrap plugin generate a db file listing ... also removed code
for zip file extractor which is not the right way to go
Removed:
directory/branches/trunks/schema/apacheds/bootstrap-partition/src/main/java/org/
directory/branches/trunks/schema/apacheds/bootstrap-partition/src/test/java/org/
directory/branches/trunks/schema/apacheds/bootstrap-partition/src/test/resources/
directory/branches/trunks/schema/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/core/
Modified:
directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java
directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
directory/branches/trunks/schema/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java
Modified: directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java?view=diff&rev=487702&r1=487701&r2=487702
==============================================================================
--- directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java (original)
+++ directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java Fri Dec 15 14:47:56 2006
@@ -19,8 +19,11 @@
*/
package org.apache.directory.server.core.bootstrap.plugin;
+
import java.io.File;
+import java.io.FileWriter;
import java.io.IOException;
+import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.HashSet;
import java.util.Iterator;
@@ -32,6 +35,8 @@
import javax.naming.directory.DirContext;
import javax.naming.directory.ModificationItem;
+import org.apache.directory.server.core.partition.impl.btree.Index;
+import org.apache.directory.server.core.partition.impl.btree.IndexNotFoundException;
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStoreConfiguration;
import org.apache.directory.server.schema.bootstrap.ApacheSchema;
@@ -78,7 +83,22 @@
private static final String M_DISABLED_AT = "m-disabled";
/**
- * The target directory into which the plugin generates schema partion files.
+ * The package to put the db file entry listing info as well as the partition.
+ *
+ * @parameter expression="org.apache.directory.server.schema.bootstrap.partition"
+ */
+ private String outputPackage;
+
+ /**
+ * The file name to use for the package listing.
+ *
+ * @parameter expression="DBFILES"
+ */
+ private String listingFileName;
+
+ /**
+ * The target directory into which the plugin generates schema partion files
+ * within the specified outputPackage.
*
* @parameter expression="target/classes"
*/
@@ -123,8 +143,14 @@
*/
public void execute() throws MojoExecutionException, MojoFailureException
{
+ File packageDirectory = new File( outputDirectory, outputPackage.replace( '.', File.separatorChar ) );
+ if ( ! packageDirectory.exists() )
+ {
+ packageDirectory.mkdirs();
+ }
+
// delete output directory if it exists
- File schemaDirectory = new File( outputDirectory, "schema" );
+ File schemaDirectory = new File( packageDirectory, "schema" );
if ( schemaDirectory.exists() )
{
try
@@ -139,7 +165,7 @@
}
initializeSchemas();
- initializePartition();
+ initializePartition( schemaDirectory );
try
{
@@ -195,6 +221,36 @@
{
e.printStackTrace();
}
+
+ // ------------------------------------------------------------------
+ // Create db file listing and place it into the right package on disk
+ // ------------------------------------------------------------------
+
+
+ File listingFile = new File( packageDirectory, listingFileName );
+ PrintWriter out = null;
+ try
+ {
+ out = new PrintWriter( new FileWriter( listingFile ) );
+ out.print( getDbFileListing().toString() );
+ out.flush();
+ }
+ catch ( IOException e )
+ {
+ throw new MojoFailureException( "Failed to write file: " + e.getMessage() );
+ }
+ catch ( IndexNotFoundException e )
+ {
+ // never really thrown
+ e.printStackTrace();
+ }
+ finally
+ {
+ if ( out != null )
+ {
+ out.close();
+ }
+ }
}
@@ -393,7 +449,7 @@
*
* @throws MojoFailureException
*/
- private void initializePartition() throws MojoFailureException
+ private void initializePartition( File workingDirectory ) throws MojoFailureException
{
JdbmStoreConfiguration storeConfig = new JdbmStoreConfiguration();
storeConfig.setAttributeTypeRegistry( registries.getAttributeTypeRegistry() );
@@ -403,8 +459,6 @@
storeConfig.setOidRegistry( registries.getOidRegistry() );
storeConfig.setSuffixDn( "ou=schema" );
storeConfig.setSyncOnWrite( false );
-
- File workingDirectory = new File( outputDirectory, "schema" );
storeConfig.setWorkingDirectory( workingDirectory );
// add the indices
@@ -563,5 +617,31 @@
return false;
}
return true;
+ }
+
+
+ private final StringBuffer getDbFileListing() throws IndexNotFoundException
+ {
+ StringBuffer buf = new StringBuffer();
+ buf.append( "schema/master.db\n" );
+
+ Iterator systemIndices = store.getSystemIndices();
+ while( systemIndices.hasNext() )
+ {
+ Index index = store.getSystemIndex( ( String ) systemIndices.next() );
+ buf.append( "schema/" );
+ buf.append( index.getAttribute().getName() );
+ buf.append( ".db\n" );
+ }
+
+ buf.append( "[USER INDICES]\n" );
+ for ( String userIndex: indexedAttributes )
+ {
+ buf.append( "schema/" );
+ buf.append( userIndex );
+ buf.append( ".db\n" );
+ }
+
+ return buf;
}
}
Modified: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?view=diff&rev=487702&r1=487701&r2=487702
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java (original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java Fri Dec 15 14:47:56 2006
@@ -20,6 +20,7 @@
package org.apache.directory.server.core;
+import java.io.File;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
@@ -42,7 +43,14 @@
import org.apache.directory.server.core.jndi.ServerLdapContext;
import org.apache.directory.server.core.partition.DefaultPartitionNexus;
import org.apache.directory.server.core.partition.PartitionNexus;
+import org.apache.directory.server.schema.bootstrap.ApacheSchema;
+import org.apache.directory.server.schema.bootstrap.ApachemetaSchema;
+import org.apache.directory.server.schema.bootstrap.BootstrapSchema;
+import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
+import org.apache.directory.server.schema.bootstrap.CoreSchema;
+import org.apache.directory.server.schema.bootstrap.SystemSchema;
import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
+import org.apache.directory.server.schema.registries.DefaultRegistries;
import org.apache.directory.server.schema.registries.Registries;
import org.apache.directory.shared.ldap.exception.LdapAuthenticationNotSupportedException;
import org.apache.directory.shared.ldap.exception.LdapConfigurationException;
@@ -734,30 +742,42 @@
}
// --------------------------------------------------------------------
- // Load the schema here and check that it is ok!
+ // Load the bootstrap schemas to start up the schema partition
// --------------------------------------------------------------------
+
+ // setup temporary loader and temp registry
+ Registries bootstrapRegistries = new DefaultRegistries();
+ BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
+
+ // load essential bootstrap schemas
+ Set<BootstrapSchema> bootstrapSchemas = new HashSet<BootstrapSchema>();
+ bootstrapSchemas.add( new ApachemetaSchema() );
+ bootstrapSchemas.add( new ApacheSchema() );
+ bootstrapSchemas.add( new CoreSchema() );
+ bootstrapSchemas.add( new SystemSchema() );
+ loader.load( bootstrapSchemas, bootstrapRegistries );
+
+ // run referential integrity tests
+ java.util.List errors = bootstrapRegistries.checkRefInteg();
+ if ( !errors.isEmpty() )
+ {
+ NamingException e = new NamingException();
+ e.setRootCause( ( Throwable ) errors.get( 0 ) );
+ throw e;
+ }
- // @TODO need to seriously rewrite this section here
+ // --------------------------------------------------------------------
+ // If not present extract schema partition from jar
+ // --------------------------------------------------------------------
+
- if ( true )
- {
- throw new RuntimeException( "rewrite this schema initialization code" );
- }
-// BootstrapRegistries bootstrapRegistries = new BootstrapRegistries();
-// BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
-// loader.load( startupConfiguration.getBootstrapSchemas(), bootstrapRegistries );
-//
-// java.util.List errors = bootstrapRegistries.checkRefInteg();
-// if ( !errors.isEmpty() )
-// {
-// NamingException e = new NamingException();
-//
-// e.setRootCause( ( Throwable ) errors.get( 0 ) );
-//
-// throw e;
-// }
-//
-// globalRegistries = new GlobalRegistries( bootstrapRegistries );
+
+
+
+ // --------------------------------------------------------------------
+ //
+ // --------------------------------------------------------------------
+
Set<String> binaries = new HashSet<String>();
if ( this.environment.containsKey( BINARY_KEY ) )
{
Modified: directory/branches/trunks/schema/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java?view=diff&rev=487702&r1=487701&r2=487702
==============================================================================
--- directory/branches/trunks/schema/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java (original)
+++ directory/branches/trunks/schema/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java Fri Dec 15 14:47:56 2006
@@ -101,7 +101,7 @@
* @param registries the registries to fill with producer created objects
* @throws NamingException if there are any failures during this process
*/
- public final void load( Collection<BootstrapSchema> bootstrapSchemas, DefaultRegistries registries ) throws NamingException
+ public final void load( Collection<BootstrapSchema> bootstrapSchemas, Registries registries ) throws NamingException
{
BootstrapSchema[] schemas = new BootstrapSchema[bootstrapSchemas.size()];
schemas = ( BootstrapSchema[] ) bootstrapSchemas.toArray( schemas );
@@ -145,7 +145,7 @@
* failure results while loading, producing and or registering schema objects
*/
public final void loadDepsFirst( Stack<String> beenthere, HashMap notLoaded, BootstrapSchema schema,
- DefaultRegistries registries ) throws NamingException
+ Registries registries ) throws NamingException
{
beenthere.push( schema.getSchemaName() );
String[] deps = schema.getDependencies();
@@ -197,7 +197,7 @@
* @param registries the registries to fill with producer created objects
* @throws NamingException if there are any failures during this process
*/
- public final void load( BootstrapSchema schema, DefaultRegistries registries ) throws NamingException
+ public final void load( BootstrapSchema schema, Registries registries ) throws NamingException
{
this.registries.set( registries );
this.schemas.set( schema );