use of org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator 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.decorators.SearchRequestDecorator 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.decorators.SearchRequestDecorator 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);
}
}
use of org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator in project directory-ldap-api by apache.
the class StoreMatchingRuleDnAttributes method action.
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
SearchRequestDecorator searchRequest = container.getMessage();
TLV tlv = container.getCurrentTLV();
// Store the value.
ExtensibleMatchFilter extensibleMatchFilter = (ExtensibleMatchFilter) searchRequest.getTerminalFilter();
// We get the value. If it's a 0, it's a FALSE. If it's
// a FF, it's a TRUE. Any other value should be an error,
// but we could relax this constraint. So if we have
// something
// which is not 0, it will be interpreted as TRUE, but we
// will generate a warning.
BerValue value = tlv.getValue();
try {
extensibleMatchFilter.setDnAttributes(BooleanDecoder.parse(value));
} catch (BooleanDecoderException bde) {
LOG.error(I18n.err(I18n.ERR_04110, Strings.dumpBytes(value.getData()), bde.getMessage()));
throw new DecoderException(bde.getMessage(), bde);
}
if (IS_DEBUG) {
LOG.debug("Dn Attributes : {}", Boolean.valueOf(extensibleMatchFilter.isDnAttributes()));
}
// unstack the filters if needed
searchRequest.unstackFilters(container);
}
use of org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator in project directory-ldap-api by apache.
the class StoreTypeMatchingRule method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<SearchRequestDecorator> container) throws DecoderException {
SearchRequestDecorator searchRequest = container.getMessage();
TLV tlv = container.getCurrentTLV();
if (tlv.getLength() == 0) {
String msg = I18n.err(I18n.ERR_04022);
LOG.error(msg);
throw new DecoderException(msg);
} else {
// Store the value.
ExtensibleMatchFilter extensibleMatchFilter = (ExtensibleMatchFilter) searchRequest.getTerminalFilter();
String type = Strings.utf8ToString(tlv.getValue().getData());
extensibleMatchFilter.setType(type);
if (IS_DEBUG) {
LOG.debug("Stored a type matching rule : {}", type);
}
}
}
Aggregations