/* instanciate fitler */
String _filter = (String) env.get("filter");
boolean relative = true;
if (_filter == null && filter != null) {
if (input == null)
throw new MapperException(getName()
+ ": The input object cannot be null if used as filter");
input = filter.map(input, env);
_filter = (String) env.get("filter");
}
if (_filter == null) {
if (log.isInfoEnabled()) {
log
.info("["
+ getName()
+ "] no filter defined. Will try lookup using only root "
+ _root);
}
relative = false;
}
/* instanciate controls */
instanciateControls(env);
/* run query */
try {
if (log.isDebugEnabled())
log.debug("[" + getName() + "] searching " + _root + " for "
+ _filter + " with controls " + controls);
List ret = new ArrayList();
if (_filter != null) {
NamingEnumeration enumeration = null;
enumeration = directory.search(_root, _filter, controls);
/* create list of search results */
while (enumeration.hasMore()) {
SearchResult res = (SearchResult) enumeration.next();
ret.add(res);
}
} else {
Attributes attrs = directory.getAttributes(_root, controls
.getReturningAttributes());
SearchResult sr = new SearchResult(_root.toString(),null,attrs);
sr.setRelative(relative);
ret.add(sr);
}
if (log.isDebugEnabled())
log.debug("[" + getName() + "] done");
/* output list of objects */
return output.map(ret, env);
} catch (NamingException e) {
throw new MapperException("Exception in JNDI mapping "
+ e.getLocalizedMessage(), e);
}
}