Search in sources :

Example 1 with LongDecoderException

use of org.apache.directory.api.asn1.ber.tlv.LongDecoderException in project directory-ldap-api by apache.

the class StoreSearchRequestSizeLimit method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
    SearchRequest searchRequest = container.getMessage().getDecorated();
    TLV tlv = container.getCurrentTLV();
    // The current TLV should be a integer
    // We get it and store it in sizeLimit
    BerValue value = tlv.getValue();
    long sizeLimit = 0;
    try {
        sizeLimit = LongDecoder.parse(value, 0, Integer.MAX_VALUE);
    } catch (LongDecoderException lde) {
        String msg = I18n.err(I18n.ERR_04103, value.toString());
        LOG.error(msg);
        throw new DecoderException(msg, lde);
    }
    searchRequest.setSizeLimit(sizeLimit);
    if (IS_DEBUG) {
        LOG.debug("The sizeLimit value is set to {} objects", Long.valueOf(sizeLimit));
    }
}
Also used : SearchRequest(org.apache.directory.api.ldap.model.message.SearchRequest) LongDecoderException(org.apache.directory.api.asn1.ber.tlv.LongDecoderException) DecoderException(org.apache.directory.api.asn1.DecoderException) BerValue(org.apache.directory.api.asn1.ber.tlv.BerValue) LongDecoderException(org.apache.directory.api.asn1.ber.tlv.LongDecoderException) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Aggregations

DecoderException (org.apache.directory.api.asn1.DecoderException)1 BerValue (org.apache.directory.api.asn1.ber.tlv.BerValue)1 LongDecoderException (org.apache.directory.api.asn1.ber.tlv.LongDecoderException)1 TLV (org.apache.directory.api.asn1.ber.tlv.TLV)1 SearchRequest (org.apache.directory.api.ldap.model.message.SearchRequest)1