public PartitionSearchResult computeResult( SchemaManager schemaManager, SearchOperationContext searchContext )
throws Exception
{
SearchScope scope = searchContext.getScope();
Dn baseDn = searchContext.getDn();
AliasDerefMode aliasDerefMode = searchContext.getAliasDerefMode();
ExprNode filter = searchContext.getFilter();
// Compute the UUID of the baseDN entry
String baseId = db.getEntryId( baseDn );
// Prepare the instance containing the search result
PartitionSearchResult searchResult = new PartitionSearchResult( schemaManager );
Set<IndexEntry<String, String>> resultSet = new HashSet<IndexEntry<String, String>>();
// Check that we have an entry, otherwise we can immediately get out
if ( baseId == null )
{
if ( ( ( Partition ) db ).getSuffixDn().equals( baseDn ) )
{
// The context entry is not created yet, return an empty result
searchResult.setResultSet( resultSet );
return searchResult;
}
else
{
// The search base doesn't exist
throw new LdapNoSuchObjectException( I18n.err( I18n.ERR_648, baseDn ) );
}
}
// --------------------------------------------------------------------
// Determine the effective base with aliases
// --------------------------------------------------------------------
Dn aliasedBase = null;
if ( db.getAliasCache() != null )
{
Element aliasBaseElement = db.getAliasCache().get( baseId );
if ( aliasBaseElement != null )
{
aliasedBase = (Dn)(aliasBaseElement).getObjectValue();
}
}
else
{
aliasedBase = db.getAliasIndex().reverseLookup( baseId );
}
Dn effectiveBase = baseDn;
String effectiveBaseId = baseId;
if ( ( aliasedBase != null ) && aliasDerefMode.isDerefFindingBase() )
{
/*
* If the base is an alias and alias dereferencing does occur on
* finding the base, or always then we set the effective base to the alias target
* got from the alias index.