directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lécharny <>
Subject Re: Queston on Interceptor
Date Mon, 26 Sep 2016 20:09:45 GMT
Le 22/09/16 à 21:52, Sathyanarayan, Harish a écrit :
> Thanks, will look at it and get back to you what I find.  Meanwhile, wanted to check
how the EntryFilteringCursor for search works?. 

This interface is used to add a Filter on Entries being processed by a
Cursor. The Cursor is used to navigate backward and forward (if te
implementation allows it), and teh EntryCursor navigates across a set of
Entries. The EntryFilter is used to filter an entry : make it a valid
candidate or not. It can also be used to apply some modifications on the

Basically, an EntryFilter contains an accept() methods that retursn true
or false if the entry should be accpetd or discarded. Here is an example :

     * the search result filter to use for the addition of mandatory
operational attributes
    private class OperationalAttributeSearchFilter implements EntryFilter
         * {@inheritDoc}
        public boolean accept( SearchOperationContext operation, Entry
entry ) throws LdapException
            if ( operation.getReturningAttributesString() == null )
                return true;

            // Add the SubschemaSubentry AttributeType if it's requested
            SchemaManager schemaManager =
            if ( operation.isAllOperationalAttributes()
                || operation.getReturningAttributes().contains(
                    new AttributeTypeOptions(
schemaManager.getAttributeType( SchemaConstants.SUBSCHEMA_SUBENTRY_AT )
) ) )
                AttributeType subschemaSubentryAt =
schemaManager.getAttributeType( SchemaConstants.SUBSCHEMA_SUBENTRY_AT );
                entry.add( new DefaultAttribute( subschemaSubentryAt,
subschemaSubentryAt ) ) );

            return true;

Don't be scared by this piece of code, the meat is just doing some
controls on the content of the entry, and depending on teh result, make
it acceptable or not.

It is used this way :

    /** The filter that add the mandatory operational attributes */
    private final EntryFilter operationalAttributeSearchFilter = new
    /** The filter that add the subordinates operational attributes */
    private final EntryFilter subordinatesSearchFilter = new

    public EntryFilteringCursor search( SearchOperationContext
searchContext ) throws LdapException
        EntryFilteringCursor cursor = next( searchContext );

        if ( searchContext.isAllOperationalAttributes()
            || ( ( searchContext.getReturningAttributes() != null ) &&
!searchContext.getReturningAttributes().isEmpty() ) )
            if ( directoryService.isDenormalizeOpAttrsEnabled() )
                cursor.addEntryFilter( denormalizingSearchFilter );

            cursor.addEntryFilter( operationalAttributeSearchFilter );
            cursor.addEntryFilter( subordinatesSearchFilter );
            return cursor;

        return cursor;

As you can see, we update the cursor we got back from thebackend search
by adding some new filters, that will get executed when the cursor will
be navigated later on. This is automatic.

> I cannot return it back(Entry result from search operation) from the interceptor to the

The interceptor wil always return a cursor for the search operation,
your client will be able to use it.

View raw message