partition.setSchemaManager( service.getSchemaManager() );
// Inject the partition into the DirectoryService
service.addPartition( partition );
SchemaManager schemaManager = service.getSchemaManager();
// process the schemas
for ( LoadSchema loadedSchema : dsBuilder.loadedSchemas() )
{
String schemaName = loadedSchema.name();
Boolean enabled = loadedSchema.enabled();
// Check if the schema is loaded or not
boolean isLoaded = schemaManager.isSchemaLoaded( schemaName );
if ( !isLoaded )
{
// We have to load the schema, if it exists
try
{
isLoaded = schemaManager.load( schemaName );
}
catch ( LdapUnwillingToPerformException lutpe )
{
// Cannot load the schema, it does not exists
LOG.error( lutpe.getMessage() );
continue;
}
}
if ( isLoaded )
{
if ( enabled )
{
schemaManager.enable( schemaName );
if ( schemaManager.isDisabled( schemaName ) )
{
LOG.error( "Cannot enable " + schemaName );
}
}
else
{
schemaManager.disable( schemaName );
if ( schemaManager.isEnabled( schemaName ) )
{
LOG.error( "Cannot disable " + schemaName );
}
}
}