/**
* {@inheritDoc}
*/
public void action( LdapMessageContainer<ModifyDnRequestDecorator> container ) throws DecoderException
{
ModifyDnRequest modifyDnRequest = container.getMessage();
// Get the Value and store it in the modifyDNRequest
TLV tlv = container.getCurrentTLV();
// We have to handle the special case of a 0 length matched
// Dn
Dn newSuperior = Dn.EMPTY_DN;
if ( tlv.getLength() == 0 )
{
if ( modifyDnRequest.getDeleteOldRdn() )
{
// This will generate a PROTOCOL_ERROR
throw new DecoderException( I18n.err( I18n.ERR_04092 ) );
}
else
{
LOG.warn( "The new superior is null, so we will change the entry" );
}
modifyDnRequest.setNewSuperior( newSuperior );
}
else
{
byte[] dnBytes = tlv.getValue().getData();
String dnStr = Strings.utf8ToString( dnBytes );
try
{
newSuperior = new Dn( dnStr );
}
catch ( LdapInvalidDnException ine )
{
String msg = "Invalid new superior Dn given : " + dnStr + " ("
+ Strings.dumpBytes( dnBytes ) + ") is invalid";
LOG.error( "{} : {}", msg, ine.getMessage() );
ModifyDnResponseImpl response = new ModifyDnResponseImpl( modifyDnRequest.getMessageId() );
throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
modifyDnRequest.getName(), ine );
}
modifyDnRequest.setNewSuperior( newSuperior );
}
// We can have an END transition
container.setGrammarEndAllowed( true );