*
*/
public void modify( NextInterceptor next, ModifyOperationContext opContext ) throws Exception
{
ServerEntry serverEntry = null;
Modification modification = ServerEntryUtils.getModificationItem( opContext.getModItems(), entryDeleted );
boolean isDelete = ( modification != null );
if ( ! isDelete && ( changeLog.isEnabled() && opContext.isFirstOperation() ) )
{
// @todo make sure we're not putting in operational attributes that cannot be user modified
serverEntry = getAttributes( opContext );
}
// Duplicate modifications so that the reverse does not contain the operational attributes
List<Modification> clonedMods = new ArrayList<Modification>();
for ( Modification mod : opContext.getModItems() )
{
clonedMods.add( mod.clone() );
}
// Call the next interceptor
next.modify( opContext );
// @TODO: needs big consideration!!!
// NOTE: perhaps we need to log this as a system operation that cannot and should not be reapplied?
if (
isDelete ||
! changeLog.isEnabled() ||
! opContext.isFirstOperation() ||
// if there are no modifications due to stripping out bogus non-
// existing attributes then we will have no modification items and
// should ignore not this without registering it with the changelog
opContext.getModItems().size() == 0 )
{
if ( isDelete )
{
LOG.debug( "Bypassing changelog on modify of entryDeleted attribute." );
}
return;
}
LdifEntry forward = new LdifEntry();
forward.setChangeType( ChangeType.Modify );
forward.setDn( opContext.getDn() );
List<Modification> mods = new ArrayList<Modification>( clonedMods.size() );
for ( Modification modItem : clonedMods )
{
Modification mod = ((ServerModification)modItem).toClientModification();
// TODO: handle correctly http://issues.apache.org/jira/browse/DIRSERVER-1198
mod.getAttribute().setId( modItem.getAttribute().getId() );
mods.add( mod );
forward.addModificationItem( mod );
}