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");
}
}
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);
}
}
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);
}
}
Aggregations