Search in sources :

Example 6 with SubstringFilter

use of org.apache.directory.api.ldap.codec.search.SubstringFilter in project directory-ldap-api by apache.

the class InitSubstringsFilter method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
    SearchRequestDecorator searchRequestDecorator = container.getMessage();
    TLV tlv = container.getCurrentTLV();
    int expectedLength = tlv.getLength();
    if (expectedLength == 0) {
        String msg = I18n.err(I18n.ERR_04012);
        LOG.error(msg);
        throw new DecoderException(msg);
    }
    // We can allocate the SearchRequest
    Filter substringFilter = new SubstringFilter(container.getTlvId());
    searchRequestDecorator.addCurrentFilter(substringFilter);
    searchRequestDecorator.setTerminalFilter(substringFilter);
    if (IS_DEBUG) {
        LOG.debug("Initialize Substrings filter");
    }
}
Also used : DecoderException(org.apache.directory.api.asn1.DecoderException) SubstringFilter(org.apache.directory.api.ldap.codec.search.SubstringFilter) Filter(org.apache.directory.api.ldap.codec.search.Filter) 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)

Example 7 with SubstringFilter

use of org.apache.directory.api.ldap.codec.search.SubstringFilter in project directory-ldap-api by apache.

the class StoreAny method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
    SearchRequestDecorator decorator = container.getMessage();
    TLV tlv = container.getCurrentTLV();
    // Store the value.
    SubstringFilter substringFilter = (SubstringFilter) decorator.getTerminalFilter();
    if (tlv.getLength() == 0) {
        String msg = I18n.err(I18n.ERR_04019);
        LOG.error(msg);
        throw new DecoderException(msg);
    }
    String any = Strings.utf8ToString(tlv.getValue().getData());
    substringFilter.addAnySubstrings(any);
    // We now have to get back to the nearest filter which is
    // not terminal.
    decorator.unstackFilters(container);
    if (IS_DEBUG) {
        LOG.debug("Stored a any substring : {}", any);
    }
}
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)

Example 8 with SubstringFilter

use of org.apache.directory.api.ldap.codec.search.SubstringFilter in project directory-ldap-api by apache.

the class StoreFinal method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
    SearchRequestDecorator searchRequest = container.getMessage();
    TLV tlv = container.getCurrentTLV();
    // Store the value.
    SubstringFilter substringFilter = (SubstringFilter) searchRequest.getTerminalFilter();
    if (tlv.getLength() == 0) {
        String msg = I18n.err(I18n.ERR_04020);
        LOG.error(msg);
        throw new DecoderException(msg);
    }
    String finalValue = Strings.utf8ToString(tlv.getValue().getData());
    substringFilter.setFinalSubstrings(finalValue);
    // We now have to get back to the nearest filter which is
    // not terminal.
    searchRequest.unstackFilters(container);
    if (IS_DEBUG) {
        LOG.debug("Stored a any substring : {}", finalValue);
    }
}
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

SubstringFilter (org.apache.directory.api.ldap.codec.search.SubstringFilter)8 DecoderException (org.apache.directory.api.asn1.DecoderException)6 SearchRequestDecorator (org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator)6 TLV (org.apache.directory.api.asn1.ber.tlv.TLV)5 AndFilter (org.apache.directory.api.ldap.codec.search.AndFilter)3 Filter (org.apache.directory.api.ldap.codec.search.Filter)3 BerValue (org.apache.directory.api.asn1.ber.tlv.BerValue)2 AttributeValueAssertion (org.apache.directory.api.ldap.codec.AttributeValueAssertion)2 AttributeValueAssertionFilter (org.apache.directory.api.ldap.codec.search.AttributeValueAssertionFilter)2 ConnectorFilter (org.apache.directory.api.ldap.codec.search.ConnectorFilter)2 ExtensibleMatchFilter (org.apache.directory.api.ldap.codec.search.ExtensibleMatchFilter)2 NotFilter (org.apache.directory.api.ldap.codec.search.NotFilter)2 OrFilter (org.apache.directory.api.ldap.codec.search.OrFilter)2 PresentFilter (org.apache.directory.api.ldap.codec.search.PresentFilter)2 Value (org.apache.directory.api.ldap.model.entry.Value)2 AndNode (org.apache.directory.api.ldap.model.filter.AndNode)2 ApproximateNode (org.apache.directory.api.ldap.model.filter.ApproximateNode)2 BranchNode (org.apache.directory.api.ldap.model.filter.BranchNode)2 EqualityNode (org.apache.directory.api.ldap.model.filter.EqualityNode)2 ExtensibleNode (org.apache.directory.api.ldap.model.filter.ExtensibleNode)2