in core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java [1108:1265]
public void modify( ModifyOperationContext modifyContext ) throws LdapException
{
if ( IS_DEBUG )
{
OPERATION_LOG.debug( ">> ModifyOperation : {}", modifyContext );
}
long opStart = 0L;
if ( IS_TIME )
{
opStart = System.nanoTime();
}
ensureStarted();
// Normalize the modifyContext Dn
Dn dn = modifyContext.getDn();
if ( !dn.isSchemaAware() )
{
dn = new Dn( directoryService.getSchemaManager(), dn );
modifyContext.setDn( dn );
}
ReferralManager referralManager = directoryService.getReferralManager();
// We have to deal with the referral first
referralManager.lockRead();
try
{
// 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
// We have found a parent referral for the current Dn
Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
throw buildReferralException( parentEntry, childDn );
}
}
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() )
{
// We have found a parent referral for the current Dn
Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
throw buildLdapPartialResultException( childDn );
}
else
{
// We have found a parent referral for the current Dn
Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
throw buildReferralException( parentEntry, childDn );
}
}
}
}
finally
{
// Unlock the ReferralManager
referralManager.unlock();
}
Partition partition = directoryService.getPartitionNexus().getPartition( dn );
modifyContext.setPartition( partition );
lockWrite();
// Start a Write transaction right away
PartitionTxn transaction = modifyContext.getSession().getTransaction( partition );
try
{
if ( transaction == null )
{
transaction = partition.beginWriteTransaction();
if ( modifyContext.getSession().hasSessionTransaction() )
{
modifyContext.getSession().addTransaction( partition, transaction );
}
}
modifyContext.setTransaction( transaction );
// populate the context with the old entry
eagerlyPopulateFields( modifyContext );
// Call the Modify method
Interceptor head = directoryService.getInterceptor( modifyContext.getNextInterceptor() );
head.modify( modifyContext );
if ( !modifyContext.getSession().hasSessionTransaction() )
{
transaction.commit();
}
}
catch ( LdapException le )
{
try
{
if ( transaction != null )
{
transaction.abort();
}
throw le;
}
catch ( IOException ioe )
{
throw new LdapOtherException( ioe.getMessage(), ioe );
}
}
catch ( IOException ioe )
{
try
{
transaction.abort();
throw new LdapOtherException( ioe.getMessage(), ioe );
}
catch ( IOException ioe2 )
{
throw new LdapOtherException( ioe2.getMessage(), ioe2 );
}
}
finally
{
unlockWrite();
}
if ( IS_DEBUG )
{
OPERATION_LOG.debug( "<< ModifyOperation successful" );
}
if ( IS_TIME )
{
OPERATION_TIME.debug( "Modify operation took {} ns", ( System.nanoTime() - opStart ) );
}
}