Search in sources :

Example 51 with SearchRequestDecorator

use of org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator in project directory-ldap-api by apache.

the class InitLessOrEqualFilter method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
    SearchRequestDecorator searchRequestDecorator = container.getMessage();
    // We can allocate the Attribute Value Assertion
    Filter filter = new AttributeValueAssertionFilter(container.getTlvId(), LdapCodecConstants.LESS_OR_EQUAL_FILTER);
    searchRequestDecorator.addCurrentFilter(filter);
    // Store the filter structure that still has to be
    // fulfilled
    searchRequestDecorator.setTerminalFilter(filter);
    if (IS_DEBUG) {
        LOG.debug("Initialize Less Or Equal filter");
    }
}
Also used : AttributeValueAssertionFilter(org.apache.directory.api.ldap.codec.search.AttributeValueAssertionFilter) Filter(org.apache.directory.api.ldap.codec.search.Filter) AttributeValueAssertionFilter(org.apache.directory.api.ldap.codec.search.AttributeValueAssertionFilter) SearchRequestDecorator(org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator)

Example 52 with SearchRequestDecorator

use of org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator in project directory-ldap-api by apache.

the class InitNotFilter method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
    TLV tlv = container.getCurrentTLV();
    if (tlv.getLength() == 0) {
        String msg = I18n.err(I18n.ERR_04009);
        LOG.error(msg);
        throw new DecoderException(msg);
    }
    SearchRequestDecorator searchRequestDecorator = container.getMessage();
    // We can allocate the SearchRequest
    Filter notFilter = new NotFilter(container.getTlvId());
    // Set the filter
    searchRequestDecorator.addCurrentFilter(notFilter);
    if (IS_DEBUG) {
        LOG.debug("Initialize NOT filter");
    }
}
Also used : DecoderException(org.apache.directory.api.asn1.DecoderException) NotFilter(org.apache.directory.api.ldap.codec.search.NotFilter) Filter(org.apache.directory.api.ldap.codec.search.Filter) NotFilter(org.apache.directory.api.ldap.codec.search.NotFilter) SearchRequestDecorator(org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Example 53 with SearchRequestDecorator

use of org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator in project directory-ldap-api by apache.

the class InitOrFilter method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
    TLV tlv = container.getCurrentTLV();
    if (tlv.getLength() == 0) {
        String msg = I18n.err(I18n.ERR_04010);
        LOG.error(msg);
        throw new DecoderException(msg);
    }
    SearchRequestDecorator searchRequestDecorator = container.getMessage();
    // We can allocate the SearchRequest
    Filter orFilter = new OrFilter(container.getTlvId());
    // Set the filter
    searchRequestDecorator.addCurrentFilter(orFilter);
    if (IS_DEBUG) {
        LOG.debug("Initialize OR filter");
    }
}
Also used : DecoderException(org.apache.directory.api.asn1.DecoderException) Filter(org.apache.directory.api.ldap.codec.search.Filter) OrFilter(org.apache.directory.api.ldap.codec.search.OrFilter) OrFilter(org.apache.directory.api.ldap.codec.search.OrFilter) SearchRequestDecorator(org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Example 54 with SearchRequestDecorator

use of org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator in project directory-ldap-api by apache.

the class InitPresentFilter method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
    SearchRequestDecorator searchRequestDecorator = container.getMessage();
    TLV tlv = container.getCurrentTLV();
    // We can allocate the Attribute Value Assertion
    PresentFilter presentFilter = new PresentFilter(container.getTlvId());
    // add the filter to the request filter
    searchRequestDecorator.addCurrentFilter(presentFilter);
    searchRequestDecorator.setTerminalFilter(presentFilter);
    String value = Strings.utf8ToString(tlv.getValue().getData());
    if (Strings.isEmpty(value)) {
        presentFilter.setAttributeDescription("");
    } else {
        // Store the value.
        String type = Strings.utf8ToString(tlv.getValue().getData());
        presentFilter.setAttributeDescription(type);
    }
    // We now have to get back to the nearest filter which is
    // not terminal.
    searchRequestDecorator.unstackFilters(container);
    if (IS_DEBUG) {
        LOG.debug("Initialize Present filter");
    }
}
Also used : PresentFilter(org.apache.directory.api.ldap.codec.search.PresentFilter) SearchRequestDecorator(org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Example 55 with SearchRequestDecorator

use of org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator in project directory-ldap-api by apache.

the class StoreInitial method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
    SearchRequestDecorator searchRequestDecorator = container.getMessage();
    TLV tlv = container.getCurrentTLV();
    // Store the value.
    SubstringFilter substringFilter = (SubstringFilter) searchRequestDecorator.getTerminalFilter();
    if (tlv.getLength() == 0) {
        String msg = I18n.err(I18n.ERR_04108);
        LOG.error(msg);
        throw new DecoderException(msg);
    }
    substringFilter.setInitialSubstrings(Strings.utf8ToString(tlv.getValue().getData()));
    // We now have to get back to the nearest filter which is
    // not terminal.
    searchRequestDecorator.unstackFilters(container);
}
Also used : DecoderException(org.apache.directory.api.asn1.DecoderException) SubstringFilter(org.apache.directory.api.ldap.codec.search.SubstringFilter) SearchRequestDecorator(org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator) TLV(org.apache.directory.api.asn1.ber.tlv.TLV)

Aggregations

SearchRequestDecorator (org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator)110 DecoderException (org.apache.directory.api.asn1.DecoderException)97 ByteBuffer (java.nio.ByteBuffer)85 Asn1Decoder (org.apache.directory.api.asn1.ber.Asn1Decoder)85 LdapMessageContainer (org.apache.directory.api.ldap.codec.api.LdapMessageContainer)85 AbstractCodecServiceTest (org.apache.directory.api.ldap.codec.osgi.AbstractCodecServiceTest)85 Test (org.junit.Test)85 SearchRequest (org.apache.directory.api.ldap.model.message.SearchRequest)48 ExprNode (org.apache.directory.api.ldap.model.filter.ExprNode)37 EncoderException (org.apache.directory.api.asn1.EncoderException)33 AndNode (org.apache.directory.api.ldap.model.filter.AndNode)19 EqualityNode (org.apache.directory.api.ldap.model.filter.EqualityNode)18 TLV (org.apache.directory.api.asn1.ber.tlv.TLV)17 SubstringNode (org.apache.directory.api.ldap.model.filter.SubstringNode)12 OrNode (org.apache.directory.api.ldap.model.filter.OrNode)10 Filter (org.apache.directory.api.ldap.codec.search.Filter)9 PresenceNode (org.apache.directory.api.ldap.model.filter.PresenceNode)9 SubstringFilter (org.apache.directory.api.ldap.codec.search.SubstringFilter)6 GreaterEqNode (org.apache.directory.api.ldap.model.filter.GreaterEqNode)6 NotNode (org.apache.directory.api.ldap.model.filter.NotNode)6