Search in sources :

Example 6 with AbandonRequestImpl

use of org.apache.directory.api.ldap.model.message.AbandonRequestImpl in project directory-ldap-api by apache.

the class InitAbandonRequest method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<AbandonRequestDecorator> container) throws DecoderException {
    // Create the AbandonRequest LdapMessage instance and store it in the container
    AbandonRequest internalAbandonRequest = new AbandonRequestImpl();
    internalAbandonRequest.setMessageId(container.getMessageId());
    AbandonRequestDecorator abandonRequest = new AbandonRequestDecorator(container.getLdapCodecService(), internalAbandonRequest);
    container.setMessage(abandonRequest);
    // The current TLV should be a integer
    // We get it and store it in MessageId
    TLV tlv = container.getCurrentTLV();
    BerValue value = tlv.getValue();
    if ((value == null) || (value.getData() == null)) {
        String msg = I18n.err(I18n.ERR_04075);
        LOG.error(msg);
        // This will generate a PROTOCOL_ERROR
        throw new DecoderException(msg);
    }
    try {
        int abandonnedMessageId = IntegerDecoder.parse(value, 0, Integer.MAX_VALUE);
        abandonRequest.setAbandoned(abandonnedMessageId);
        if (IS_DEBUG) {
            LOG.debug("AbandonMessage Id has been decoded : {}", Integer.valueOf(abandonnedMessageId));
        }
        container.setGrammarEndAllowed(true);
        return;
    } catch (IntegerDecoderException ide) {
        LOG.error(I18n.err(I18n.ERR_04076, Strings.dumpBytes(value.getData()), ide.getMessage()));
        // This will generate a PROTOCOL_ERROR
        throw new DecoderException(ide.getMessage(), ide);
    }
}
Also used : IntegerDecoderException(org.apache.directory.api.asn1.ber.tlv.IntegerDecoderException) DecoderException(org.apache.directory.api.asn1.DecoderException) BerValue(org.apache.directory.api.asn1.ber.tlv.BerValue) IntegerDecoderException(org.apache.directory.api.asn1.ber.tlv.IntegerDecoderException) AbandonRequest(org.apache.directory.api.ldap.model.message.AbandonRequest) AbandonRequestImpl(org.apache.directory.api.ldap.model.message.AbandonRequestImpl) AbandonRequestDecorator(org.apache.directory.api.ldap.codec.decorators.AbandonRequestDecorator) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Aggregations

AbandonRequest (org.apache.directory.api.ldap.model.message.AbandonRequest)6 AbandonRequestImpl (org.apache.directory.api.ldap.model.message.AbandonRequestImpl)6 DecoderException (org.apache.directory.api.asn1.DecoderException)5 AbandonRequestDecorator (org.apache.directory.api.ldap.codec.decorators.AbandonRequestDecorator)5 ByteBuffer (java.nio.ByteBuffer)4 EncoderException (org.apache.directory.api.asn1.EncoderException)4 Asn1Decoder (org.apache.directory.api.asn1.ber.Asn1Decoder)4 LdapMessageContainer (org.apache.directory.api.ldap.codec.api.LdapMessageContainer)4 AbstractCodecServiceTest (org.apache.directory.api.ldap.codec.osgi.AbstractCodecServiceTest)4 Test (org.junit.Test)4 CodecControl (org.apache.directory.api.ldap.codec.api.CodecControl)3 Control (org.apache.directory.api.ldap.model.message.Control)3 BerValue (org.apache.directory.api.asn1.ber.tlv.BerValue)1 IntegerDecoderException (org.apache.directory.api.asn1.ber.tlv.IntegerDecoderException)1 TLV (org.apache.directory.api.asn1.ber.tlv.TLV)1