NamingEnumeration<SearchResult> results = null;
PagedResultsDirContextProcessor processor = null;
boolean noExceptions = false;
try
{
PagedResultsCookie cookie = null;
int index = 0;
boolean doNext = true;
if (handler.getMaxCount() > 0 && controls.getCountLimit() <= 0 || handler.getMaxCount()+1 < controls.getCountLimit())
{
controls.setCountLimit(handler.getMaxCount()+1);
}
int pageSize = handler.getSearchPageSize() < 0 ? this.pageSize : handler.getSearchPageSize();
if (pageSize > 0)
{
do
{
processor = new PagedResultsDirContextProcessor(pageSize, cookie);
processor.preProcess(ctx);
results = base != null ? ctx.search(base, filter, controls) : ctx.search(baseName, filter, controls);
int pageIndex = 0;
while (doNext && results.hasMore())
{
doNext = handler.handleSearchResult(results.next(), pageSize, pageIndex++, index++);
}
processor.postProcess(ctx);
cookie = processor.getCookie();
}
while (doNext && cookie != null && cookie.getCookie() != null && cookie.getCookie().length != 0);
}
else
{
results = base != null ? ctx.search(base, filter, controls) : ctx.search(baseName, filter, controls);
int pageIndex = 0;