use of org.apache.directory.api.ldap.model.message.AliasDerefMode in project directory-ldap-api by apache.
the class SearchRequestDsml method toDsml.
/**
* {@inheritDoc}
*/
@Override
public Element toDsml(Element root) {
Element element = super.toDsml(root);
SearchRequest request = getDecorated();
// Dn
if (request.getBase() != null) {
element.addAttribute("dn", request.getBase().getName());
}
// Scope
SearchScope scope = request.getScope();
if (scope != null) {
if (scope == SearchScope.OBJECT) {
element.addAttribute("scope", "baseObject");
} else if (scope == SearchScope.ONELEVEL) {
element.addAttribute("scope", "singleLevel");
} else if (scope == SearchScope.SUBTREE) {
element.addAttribute("scope", "wholeSubtree");
}
}
// DerefAliases
AliasDerefMode derefAliases = request.getDerefAliases();
switch(derefAliases) {
case NEVER_DEREF_ALIASES:
element.addAttribute(DEREF_ALIASES, "neverDerefAliases");
break;
case DEREF_ALWAYS:
element.addAttribute(DEREF_ALIASES, "derefAlways");
break;
case DEREF_FINDING_BASE_OBJ:
element.addAttribute(DEREF_ALIASES, "derefFindingBaseObj");
break;
case DEREF_IN_SEARCHING:
element.addAttribute(DEREF_ALIASES, "derefInSearching");
break;
default:
throw new IllegalStateException("Unexpected deref alias mode " + derefAliases);
}
// SizeLimit
if (request.getSizeLimit() != 0L) {
element.addAttribute("sizeLimit", Long.toString(request.getSizeLimit()));
}
// TimeLimit
if (request.getTimeLimit() != 0) {
element.addAttribute("timeLimit", Integer.toString(request.getTimeLimit()));
}
// TypesOnly
if (request.getTypesOnly()) {
element.addAttribute("typesOnly", "true");
}
// Filter
Element filterElement = element.addElement("filter");
toDsml(filterElement, request.getFilter());
// Attributes
List<String> attributes = request.getAttributes();
if (!attributes.isEmpty()) {
Element attributesElement = element.addElement("attributes");
for (String entryAttribute : attributes) {
attributesElement.addElement("attribute").addAttribute(NAME, entryAttribute);
}
}
return element;
}
Aggregations