// Normalize the modifyContext Dn
Dn dn = modifyContext.getDn();
dn.apply( directoryService.getSchemaManager() );
ReferralManager referralManager = directoryService.getReferralManager();
// We have to deal with the referral first
referralManager.lockRead();
// Check if we have an ancestor for this Dn
Entry parentEntry = referralManager.getParentReferral( dn );
if ( parentEntry != null )
{
if ( referralManager.isReferral( dn ) )
{
// This is a referral. We can delete it if the ManageDsaIt flag is true
// Otherwise, we just throw a LdapReferralException
if ( !modifyContext.isReferralIgnored() )
{
// Throw a Referral Exception
// Unlock the referral manager
referralManager.unlock();
// We have found a parent referral for the current Dn
Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
LdapReferralException exception = buildReferralException( parentEntry, childDn );
throw exception;
}
}
else if ( referralManager.hasParentReferral( dn ) )
{
// We can't delete an entry which has an ancestor referral
// Depending on the Context.REFERRAL property value, we will throw
// a different exception.
if ( modifyContext.isReferralIgnored() )
{
referralManager.unlock();
// We have found a parent referral for the current Dn
Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
LdapPartialResultException exception = buildLdapPartialResultException( childDn );
throw exception;
}
else
{
// Unlock the referral manager
referralManager.unlock();
// We have found a parent referral for the current Dn
Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
LdapReferralException exception = buildReferralException( parentEntry, childDn );
throw exception;
}
}
}
// Unlock the ReferralManager
referralManager.unlock();
try
{
lockWrite();