* @return the created entry
*/
private static IEntry createAndCacheEntry( IBrowserConnection browserConnection, LdapDN dn,
StudioProgressMonitor monitor )
{
StudioProgressMonitor dummyMonitor = new StudioProgressMonitor( monitor );
IEntry entry = null;
// build tree to parent
LinkedList<LdapDN> parentDnList = new LinkedList<LdapDN>();
LdapDN parentDN = dn;
while ( parentDN != null && browserConnection.getEntryFromCache( parentDN ) == null )
{
parentDnList.addFirst( parentDN );
parentDN = DnUtils.getParent( parentDN );
}
for ( LdapDN aDN : parentDnList )
{
parentDN = DnUtils.getParent( aDN );
if ( parentDN == null )
{
// only the root DSE has a null parent
entry = browserConnection.getRootDSE();
}
else if ( !parentDN.isEmpty() && browserConnection.getEntryFromCache( parentDN ) != null )
{
// a normal entry has a parent but the parent isn't the rootDSE
IEntry parentEntry = browserConnection.getEntryFromCache( parentDN );
entry = new Entry( parentEntry, aDN.getRdn() );
entry.setDirectoryEntry( true );
parentEntry.addChild( entry );
parentEntry.setChildrenInitialized( true );
parentEntry.setHasMoreChildren( true );
parentEntry.setHasChildrenHint( true );
browserConnection.cacheEntry( entry );
}
else
{
// we have a base DN, check if the entry really exists in LDAP
// this is to avoid that a node "dc=com" is created for "dc=example,dc=com" context entry
SearchParameter searchParameter = new SearchParameter();
searchParameter.setSearchBase( aDN );
searchParameter.setFilter( null );
searchParameter.setReturningAttributes( ISearch.NO_ATTRIBUTES );
searchParameter.setScope( SearchScope.OBJECT );
searchParameter.setCountLimit( 1 );
searchParameter.setTimeLimit( 0 );
searchParameter.setAliasesDereferencingMethod( browserConnection.getAliasesDereferencingMethod() );
searchParameter.setReferralsHandlingMethod( browserConnection.getReferralsHandlingMethod() );
searchParameter.setInitHasChildrenFlag( true );
dummyMonitor.reset();
StudioNamingEnumeration enumeration = search( browserConnection, searchParameter, dummyMonitor );
try
{
if ( enumeration != null && enumeration.hasMore() )
{