referralsHandlingMethod = ReferralHandlingMethod.MANAGE;
}
Control[] controls = null;
// get children,
ISearch search = new Search( null, parent.getBrowserConnection(), parent.getDn(), parent
.getChildrenFilter(), ISearch.NO_ATTRIBUTES, scope, parent.getBrowserConnection().getCountLimit(),
parent.getBrowserConnection().getTimeLimit(), aliasesDereferencingMethod, referralsHandlingMethod,
BrowserCorePlugin.getDefault().getPluginPreferences().getBoolean(
BrowserCoreConstants.PREFERENCE_CHECK_FOR_CHILDREN ), controls );
SearchRunnable.searchAndUpdateModel( parent.getBrowserConnection(), search, monitor );
ISearchResult[] srs = search.getSearchResults();
monitor.reportProgress( BrowserCoreMessages
.bind( BrowserCoreMessages.jobs__init_entries_progress_subcount,
new String[]
{ srs == null ? Integer.toString( 0 ) : Integer.toString( srs.length ),
parent.getDn().getUpName() } ) );
// fill children in search result
if ( srs != null && srs.length > 0 )
{
// clearing old children before filling new children is
// necessary to handle aliases and referrals.
IEntry[] connChildren = parent.getChildren();
for ( int i = 0; connChildren != null && i < connChildren.length; i++ )
{
if ( connChildren[i] != null )
{
parent.deleteChild( connChildren[i] );
}
}
parent.setChildrenInitialized( false );
for ( int i = 0; srs != null && i < srs.length; i++ )
{
if ( parent.isAlias() && !( srs[i].getEntry() instanceof AliasBaseEntry ) )
{
AliasBaseEntry aliasBaseEntry = new AliasBaseEntry( srs[i].getEntry().getBrowserConnection(),
srs[i].getEntry().getDn() );
parent.addChild( aliasBaseEntry );
}
else
{
parent.addChild( srs[i].getEntry() );
}
}
}
else
{
parent.setHasChildrenHint( false );
}
// get sub-entries
ISearch subSearch = new Search( null, parent.getBrowserConnection(), parent.getDn(), parent
.getChildrenFilter() != null ? parent.getChildrenFilter() : ISearch.FILTER_SUBENTRY,
ISearch.NO_ATTRIBUTES, scope, parent.getBrowserConnection().getCountLimit(), parent
.getBrowserConnection().getTimeLimit(), aliasesDereferencingMethod, referralsHandlingMethod,
BrowserCorePlugin.getDefault().getPluginPreferences().getBoolean(
BrowserCoreConstants.PREFERENCE_CHECK_FOR_CHILDREN ), new Control[]
{ Control.SUBENTRIES_CONTROL } );
if ( BrowserCorePlugin.getDefault().getPluginPreferences().getBoolean(
BrowserCoreConstants.PREFERENCE_FETCH_SUBENTRIES ) )
{
SearchRunnable.searchAndUpdateModel( parent.getBrowserConnection(), subSearch, monitor );
ISearchResult[] subSrs = subSearch.getSearchResults();
monitor.reportProgress( BrowserCoreMessages.bind(
BrowserCoreMessages.jobs__init_entries_progress_subcount, new String[]
{ subSrs == null ? Integer.toString( 0 ) : Integer.toString( subSrs.length ),
parent.getDn().getUpName() } ) );
// fill children in search result
if ( subSrs != null && subSrs.length > 0 )
{
for ( int i = 0; subSrs != null && i < subSrs.length; i++ )
{
parent.addChild( subSrs[i].getEntry() );
}
}
}
// check exceeded limits / canceled
parent.setHasMoreChildren( search.isCountLimitExceeded() || subSearch.isCountLimitExceeded()
|| monitor.isCanceled() );
// set initialized state
parent.setChildrenInitialized( true );
}