UniversalTag.ENUMERATED.getValue(),
new GrammarAction<EntryChangeContainer>( "Set EntryChangeControl changeType" )
{
public void action( EntryChangeContainer container ) throws DecoderException
{
BerValue value = container.getCurrentTLV().getValue();
try
{
int change = IntegerDecoder.parse( value, 1, 8 );
switch ( ChangeType.getChangeType( change ) )
{
case ADD:
case DELETE:
case MODDN:
case MODIFY:
ChangeType changeType = ChangeType.getChangeType( change );
if ( IS_DEBUG )
{
LOG.debug( "changeType = " + changeType );
}
container.getEntryChangeDecorator().setChangeType( changeType );
break;
default:
String msg = I18n.err( I18n.ERR_04044 );
LOG.error( msg );
throw new DecoderException( msg );
}
// We can have an END transition
container.setGrammarEndAllowed( true );
}
catch ( IntegerDecoderException e )
{
String msg = I18n.err( I18n.ERR_04044 );
LOG.error( msg, e );
throw new DecoderException( msg );
}
catch ( IllegalArgumentException e )
{
throw new DecoderException( e.getLocalizedMessage() );
}
}
} );
// ============================================================================================
// Transition from Change Type to Previous Dn
// ============================================================================================
// EntryChangeNotification ::= SEQUENCE {
// ...
// previousDN LDAPDN OPTIONAL,
// ...
//
// Set the previousDN into the structure. We first check that it's a
// valid Dn
super.transitions[EntryChangeStates.CHANGE_TYPE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
new GrammarTransition<EntryChangeContainer>( EntryChangeStates.CHANGE_TYPE_STATE,
EntryChangeStates.PREVIOUS_DN_STATE,
UniversalTag.OCTET_STRING.getValue(),
new GrammarAction<EntryChangeContainer>( "Set EntryChangeControl previousDN" )
{
public void action( EntryChangeContainer container ) throws DecoderException
{
ChangeType changeType = container.getEntryChangeDecorator().getChangeType();
if ( changeType != ChangeType.MODDN )
{
LOG.error( I18n.err( I18n.ERR_04045 ) );
throw new DecoderException( I18n.err( I18n.ERR_04046 ) );
}
else
{
BerValue value = container.getCurrentTLV().getValue();
Dn previousDn;
try
{
previousDn = new Dn( Strings.utf8ToString( value.getData() ) );
}
catch ( LdapInvalidDnException ine )
{
LOG.error( I18n.err( I18n.ERR_04047, Strings.dumpBytes( value.getData() ) ) );
throw new DecoderException( I18n.err( I18n.ERR_04048 ) );
}
if ( IS_DEBUG )
{
LOG.debug( "previousDN = " + previousDn );
}
container.getEntryChangeDecorator().setPreviousDn( previousDn );
// We can have an END transition
container.setGrammarEndAllowed( true );
}
}
} );
// Change Number action
GrammarAction<EntryChangeContainer> setChangeNumberAction = new GrammarAction<EntryChangeContainer>(
"Set EntryChangeControl changeNumber" )
{
public void action( EntryChangeContainer container ) throws DecoderException
{
BerValue value = container.getCurrentTLV().getValue();
try
{
long changeNumber = LongDecoder.parse( value );