{
// add returning attributes for children and alias detection
SearchParameter searchParameter = getSearchParameter( search );
ArrayList<ISearchResult> searchResultList = new ArrayList<ISearchResult>();
StudioNamingEnumeration enumeration = null;
// search
try
{
enumeration = search( browserConnection, searchParameter, monitor );
// iterate through the search result
while ( !monitor.isCanceled() && enumeration != null && enumeration.hasMore() )
{
StudioSearchResult sr = enumeration.next();
LdapDN dn = JNDIUtils.getDn( sr );
boolean isReferral = sr.isReferral();
Connection resultConnection = sr.getConnection();
IBrowserConnection resultBrowserConnection = BrowserCorePlugin.getDefault()
.getConnectionManager().getBrowserConnection( resultConnection );
if ( resultBrowserConnection == null )
{
resultBrowserConnection = browserConnection;
}
// get entry from cache or create it
IEntry entry = resultBrowserConnection.getEntryFromCache( dn );
if ( entry == null )
{
entry = createAndCacheEntry( resultBrowserConnection, dn, monitor );
}
// initialize special flags
initFlags( entry, sr, searchParameter );
// fill the attributes
fillAttributes( entry, sr, search.getSearchParameter() );
if ( isReferral )
{
entry = new ReferralBaseEntry( resultBrowserConnection, dn );
}
searchResultList.add( new org.apache.directory.studio.ldapbrowser.core.model.impl.SearchResult(
entry, search ) );
monitor
.reportProgress( searchResultList.size() == 1 ? BrowserCoreMessages.model__retrieved_1_entry
: BrowserCoreMessages.bind( BrowserCoreMessages.model__retrieved_n_entries,
new String[]
{ Integer.toString( searchResultList.size() ) } ) );
}
}
catch ( Exception e )
{
ConnectionException ce = JNDIUtils.createConnectionException( searchParameter, e );
if ( ce.getLdapStatusCode() == 3 || ce.getLdapStatusCode() == 4 || ce.getLdapStatusCode() == 11 )
{
search.setCountLimitExceeded( true );
}
else
{
monitor.reportError( ce );
}
}
// check for response controls
try
{
if ( enumeration != null )
{
Control[] jndiControls = enumeration.getResponseControls();
if ( jndiControls != null )
{
for ( Control jndiControl : jndiControls )
{
if ( jndiControl instanceof PagedResultsResponseControl )