/**
* {@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
// newDN
Rdn newRdn = null;
if ( tlv.getLength() == 0 )
{
String msg = I18n.err( I18n.ERR_04090 );
LOG.error( msg );
ModifyDnResponseImpl response = new ModifyDnResponseImpl( modifyDnRequest.getMessageId() );
throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
modifyDnRequest.getName(), null );
}
else
{
byte[] dnBytes = tlv.getValue().getData();
String dnStr = Strings.utf8ToString(dnBytes);
try
{
Dn dn = new Dn( dnStr );
newRdn = dn.getRdn( dn.size() - 1 );
}
catch ( LdapInvalidDnException ine )
{
String msg = "Invalid new Rdn 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.setNewRdn( newRdn );
}
if ( IS_DEBUG )
{
LOG.debug( "Modifying with new Rdn {}", newRdn );