int num = 0;
StudioProgressMonitor dummyMonitor = new StudioProgressMonitor( monitor );
for ( Iterator<IEntry> iterator = entriesToDelete.iterator(); !monitor.isCanceled()
&& !monitor.errorsReported() && iterator.hasNext(); )
{
IEntry entryToDelete = iterator.next();
IBrowserConnection browserConnection = entryToDelete.getBrowserConnection();
// delete from directory
int errorStatusSize1 = monitor.getErrorStatus( "" ).getChildren().length; //$NON-NLS-1$
num = optimisticDeleteEntryRecursive( browserConnection, entryToDelete.getDn(), entryToDelete.isReferral(),
useTreeDeleteControl, num, dummyMonitor, monitor );
int errorStatusSize2 = monitor.getErrorStatus( "" ).getChildren().length; //$NON-NLS-1$
if ( !monitor.isCanceled() )
{
if ( errorStatusSize1 == errorStatusSize2 )
{
// delete
deletedEntriesSet.add( entryToDelete );
//entryToDelete.setChildrenInitialized( false );
// delete from parent entry
entryToDelete.getParententry().setChildrenInitialized( false );
entryToDelete.getParententry().deleteChild( entryToDelete );
// delete from searches
List<ISearch> searches = browserConnection.getSearchManager().getSearches();
for ( ISearch search : searches )
{
if ( search.getSearchResults() != null )
{
ISearchResult[] searchResults = search.getSearchResults();
List<ISearchResult> searchResultList = new ArrayList<ISearchResult>();
searchResultList.addAll( Arrays.asList( searchResults ) );
for ( Iterator<ISearchResult> it = searchResultList.iterator(); it.hasNext(); )
{
ISearchResult result = it.next();
if ( entryToDelete.equals( result.getEntry() ) )
{
it.remove();
searchesToUpdateSet.add( search );
}
}
if ( searchesToUpdateSet.contains( search ) )
{
search.setSearchResults( searchResultList.toArray( new ISearchResult[searchResultList
.size()] ) );
}
}
}
// delete from cache
browserConnection.uncacheEntryRecursive( entryToDelete );
}
}
else
{
entryToDelete.setChildrenInitialized( false );
}
monitor.worked( 1 );
}
}