{
// Get the Partition name. It's a Dn.
String key = partitionDn.getNormName();
// Retrieve this partition from the aprtition's table
Partition partition = partitions.get( key );
if ( partition == null )
{
String msg = I18n.err( I18n.ERR_34, key );
LOG.error( msg );
throw new LdapNoSuchObjectException( msg );
}
String partitionSuffix = partition.getSuffixDn().getName();
// Retrieve the namingContexts from the RootDSE : the partition
// suffix must be present in those namingContexts
Attribute namingContexts = rootDse.get( SchemaConstants.NAMING_CONTEXTS_AT );
if ( namingContexts != null )
{
if ( namingContexts.contains( partitionSuffix ) )
{
namingContexts.remove( partitionSuffix );
}
else
{
String msg = I18n.err( I18n.ERR_35, key );
LOG.error( msg );
throw new LdapNoSuchObjectException( msg );
}
}
// Update the partition tree
synchronized ( partitionLookupTree )
{
partitionLookupTree.remove( partition.getSuffixDn() );
}
partitions.remove( key );
try
{
partition.destroy();
}
catch ( Exception e )
{
throw new LdapOperationErrorException( e.getMessage(), e );
}