Author: akarasulu
Date: Thu Oct 28 12:02:22 2004
New Revision: 55884
Added:
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/SearchResultFilter.java
- copied, changed from rev 55787,
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/ResultFilter.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/ibs/LookupFilter.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/ibs/ResultFilteringService.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/ibs/ResultFilteringServiceImpl.java
Removed:
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/ResultFilter.java
Modified:
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/ResultFilteringEnumeration.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/EveContextFactory.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/ibs/OperationalAttributeService.java
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/ibs/SchemaService.java
incubator/directory/eve/trunk/backend/core/src/test/org/apache/eve/jndi/AbstractJndiTest.java
Log:
Changes ...
o abstract test case now cleans up eve working directory on setup as opposed
to
tearDown
o added a new search and lookup filtering service which other services will
depend upon instead of adding their own decorating wrappers around search
enumerations; this is an optimization which prevents us from needlessly
cloning Attributes or having too many wrappers around a search result enum
o properly used a service interface - other services should follow this proper
model by also defining a POJI.
o added new lookup filter interface to differentiate between times when values
are filtered via a lookup as opposed to when results are filtered in a
search;
plus accept verses the filter methods connotate different kinds of filtering
where on can actually reject entire entries from being returned in a search
and the other cannot unless they through a NameNotFound exception
o renamed and modified the search result filter to accept search parameters
to better make decisions about how to filter - other parameters like LDAP
controls may also make their way into this method as arguments; this new
added argument specific to search further justifies the LookupFilter to
SearchResultFilter separation: its very natural
o refurbished the OperationalAttributeService to now use the FilterService
instead of yet again wrapping the returned enumeration.
o made the necessary changes to the initialization code in the
EveContextFactory
Todos ...
o I need to rename ResultFilterService to just FilterService because the
Result part makes it sound like its only for SearchResults and this does
both for search and for lookup operations.
Modified:
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/ResultFilteringEnumeration.java
==============================================================================
---
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/ResultFilteringEnumeration.java
(original)
+++
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/ResultFilteringEnumeration.java
Thu Oct 28 12:02:22 2004
@@ -23,13 +23,14 @@
import javax.naming.NamingException;
import javax.naming.NamingEnumeration;
+import javax.naming.directory.SearchControls;
/**
* A enumeration decorator which filters database search results as they are
* being enumerated back to the client caller.
*
- * @see ResultFilter
+ * @see SearchResultFilter
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
@@ -44,6 +45,8 @@
private DbSearchResult prefetched;
/** flag storing closed state of this naming enumeration */
private boolean isClosed = false;
+ /** the controls associated with the search operation */
+ private final SearchControls searchControls;
// ------------------------------------------------------------------------
@@ -56,10 +59,13 @@
* underlying enumeration.
*
* @param decorated the underlying decorated enumeration
+ * @param searchControls
*/
- public ResultFilteringEnumeration( NamingEnumeration decorated )
+ public ResultFilteringEnumeration( NamingEnumeration decorated,
+ SearchControls searchControls )
throws NamingException
{
+ this.searchControls = searchControls;
this.filters = new ArrayList();
this.decorated = decorated;
@@ -74,7 +80,7 @@
// ------------------------------------------------------------------------
- // New ResultFilter management methods
+ // New SearchResultFilter management methods
// ------------------------------------------------------------------------
@@ -86,7 +92,7 @@
* @param filter a filter to apply to the results
* @return the result of [EMAIL PROTECTED] List#add(Object)}
*/
- public boolean addResultFilter( ResultFilter filter )
+ public boolean addResultFilter( SearchResultFilter filter )
{
return filters.add( filter );
}
@@ -99,7 +105,7 @@
* @param filter a filter to remove from the filter list
* @return the result of [EMAIL PROTECTED] List#remove(Object)}
*/
- public boolean removeResultFilter( ResultFilter filter )
+ public boolean removeResultFilter( SearchResultFilter filter )
{
return filters.remove( filter );
}
@@ -202,7 +208,8 @@
}
else if ( filters.size() == 1 )
{
- accepted = ( ( ResultFilter ) filters.get( 0 ) ).accept( tmp );
+ accepted = ( ( SearchResultFilter ) filters.get( 0 ) )
+ .accept( tmp, searchControls );
this.prefetched = tmp;
return;
}
@@ -210,8 +217,8 @@
// apply all filters shorting their application on result denials
for ( int ii = 0; ii < filters.size(); ii ++ )
{
- ResultFilter filter = ( ResultFilter ) filters.get( ii );
- accepted &= filter.accept( tmp );
+ SearchResultFilter filter = ( SearchResultFilter )
filters.get( ii );
+ accepted &= filter.accept( tmp, searchControls );
if ( ! accepted )
{
Copied:
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/SearchResultFilter.java
(from rev 55787,
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/ResultFilter.java)
==============================================================================
---
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/ResultFilter.java
(original)
+++
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/db/SearchResultFilter.java
Thu Oct 28 12:02:22 2004
@@ -18,6 +18,7 @@
import javax.naming.NamingException;
+import javax.naming.directory.SearchControls;
/**
@@ -29,15 +30,17 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
* @version $Rev$
*/
-public interface ResultFilter
+public interface SearchResultFilter
{
/**
* Filters the contents of search results on the way out the door to client
* callers. These filters can and do produce side-effects on the results
if
* if need be the attributes or names within the result should be cloned.
*
+ * @param result the database search result to return
+ * @param controls search controls associated with the invocation
* @return true if the result is to be returned, false if it is to be
* discarded from the result set
*/
- boolean accept( DbSearchResult result ) throws NamingException;
+ boolean accept( DbSearchResult result, SearchControls controls ) throws
NamingException;
}
Modified:
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/EveContextFactory.java
==============================================================================
---
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/EveContextFactory.java
(original)
+++
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/EveContextFactory.java
Thu Oct 28 12:02:22 2004
@@ -14,9 +14,7 @@
import org.apache.eve.RootNexus;
import org.apache.eve.SystemPartition;
-import org.apache.eve.jndi.ibs.EveExceptionService;
-import org.apache.eve.jndi.ibs.OperationalAttributeService;
-import org.apache.eve.jndi.ibs.SchemaService;
+import org.apache.eve.jndi.ibs.*;
import org.apache.eve.db.*;
import org.apache.eve.db.jdbm.JdbmDatabase;
import org.apache.eve.schema.bootstrap.BootstrapRegistries;
@@ -217,10 +215,23 @@
* before and onError interceptor chains.
*/
InvocationStateEnum[] state = new InvocationStateEnum[]{
+ InvocationStateEnum.POSTINVOCATION
+ };
+ Interceptor interceptor;
+ ResultFilteringService resultFilteringService =
+ new ResultFilteringServiceImpl();
+ interceptor = ( Interceptor ) resultFilteringService;
+ provider.addInterceptor( interceptor, state );
+
+ /*
+ * Create and add the Eve Exception service interceptor to both the
+ * before and onError interceptor chains.
+ */
+ state = new InvocationStateEnum[]{
InvocationStateEnum.PREINVOCATION,
InvocationStateEnum.FAILUREHANDLING
};
- Interceptor interceptor = new EveExceptionService( root );
+ interceptor = new EveExceptionService( root );
provider.addInterceptor( interceptor, state );
/*
@@ -242,7 +253,8 @@
InvocationStateEnum.PREINVOCATION,
InvocationStateEnum.POSTINVOCATION
};
- interceptor = new OperationalAttributeService( root );
+ interceptor = new OperationalAttributeService( root, globalRegistries,
+ resultFilteringService );
provider.addInterceptor( interceptor, state );
}
Added:
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/ibs/LookupFilter.java
==============================================================================
--- (empty file)
+++
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/ibs/LookupFilter.java
Thu Oct 28 12:02:22 2004
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.eve.jndi.ibs;
+
+
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+
+
+/**
+ * A simple filter for modifying Attributes as they are returned to the caller
+ * following a lookup operation. For filtering search results see
+ * [EMAIL PROTECTED] org.apache.eve.db.SearchResultFilter}s. These filters
unlike ResultFilters
+ * cannot stop an entry from being returned unless they throw exceptions like
+ * [EMAIL PROTECTED] javax.naming.NameNotFoundException}. That is why the
method is named
+ * <code>filter()</code> instead of <code>accept()</code>. This is also why
+ * <code>filter()</code> returns void instead of a boolean like <code>accept()
+ * </code>.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface LookupFilter
+{
+ /**
+ * Filters attributes to be returned from
+ * [EMAIL PROTECTED] org.apache.eve.BackingStore#lookup(Name)} operations.
+ *
+ * @param dn the distinguished name of the entry looked up
+ * @param entry the attributes of the entry that were looked up
+ * @throws NamingException if there are any errors while trying to apply
+ * the filter
+ */
+ void filter( Name dn, Attributes entry ) throws NamingException;
+
+ /**
+ * Filters attributes to be returned from
+ * [EMAIL PROTECTED] org.apache.eve.BackingStore#lookup(Name,String[])}
operations.
+ *
+ * @param dn the distinguished name of the entry looked up
+ * @param entry the attributes of the entry that were looked up
+ * @param ids
+ * @throws NamingException if there are any errors while trying to apply
+ * the filter
+ */
+ void filter( Name dn, Attributes entry, String[] ids ) throws
NamingException;
+}
Modified:
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/ibs/OperationalAttributeService.java
==============================================================================
---
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/ibs/OperationalAttributeService.java
(original)
+++
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/ibs/OperationalAttributeService.java
Thu Oct 28 12:02:22 2004
@@ -17,23 +17,20 @@
package org.apache.eve.jndi.ibs;
-import java.util.Map;
import javax.naming.Name;
-import javax.naming.NamingException;
import javax.naming.Context;
+import javax.naming.NamingException;
import javax.naming.directory.*;
import org.apache.eve.RootNexus;
-import org.apache.eve.db.SearchResultEnumeration;
import org.apache.eve.db.DbSearchResult;
-import org.apache.eve.db.ResultFilteringEnumeration;
-import org.apache.eve.db.ResultFilter;
+import org.apache.eve.db.SearchResultFilter;
import org.apache.eve.jndi.Invocation;
import org.apache.eve.jndi.BaseInterceptor;
import org.apache.eve.jndi.InvocationStateEnum;
+import org.apache.eve.schema.GlobalRegistries;
import org.apache.ldap.common.util.DateUtils;
-import org.apache.ldap.common.filter.ExprNode;
/**
@@ -47,18 +44,73 @@
{
/** the default user principal or DN */
private final String DEFAULT_PRINCIPAL = "cn=admin,ou=system";
+ /** the database search result filter to register with filter service */
+ private final SearchResultFilter SEARCH_FILTER = new SearchResultFilter()
+ {
+ public boolean accept( DbSearchResult result, SearchControls controls )
+ {
+ if ( controls.getReturningAttributes() == null )
+ {
+ return filter( result.getAttributes() );
+ }
+
+ return true;
+ }
+ };
+ /** the lookup filter to register with filter service */
+ private final LookupFilter LOOKUP_FILTER = new LookupFilter()
+ {
+ public void filter( Name dn, Attributes entry )
+ {
+ OperationalAttributeService.this.filter( entry );
+ }
+
+ public void filter( Name dn, Attributes entry, String[] ids )
+ {
+ // do nothing since this explicity specifies which attributes
+ // to include - backends will automatically populate with right
+ // set of attributes
+ }
+ };
+
/** the root nexus of the system */
private final RootNexus nexus;
+ /** a service used to filter search and lookup operations */
+ private ResultFilteringService filteringService;
+ /** the global schema object registries */
+ private final GlobalRegistries globalRegistries;
/**
* Creates the operational attribute management service interceptor.
*
* @param nexus the root nexus of the system
+ * @param globalRegistries the global schema object registries
*/
- public OperationalAttributeService( RootNexus nexus )
+ public OperationalAttributeService( RootNexus nexus,
+ GlobalRegistries globalRegistries,
+ ResultFilteringService
filteringService )
{
this.nexus = nexus;
+ if ( this.nexus == null )
+ {
+ throw new NullPointerException( "the nexus cannot be null" );
+ }
+
+ this.globalRegistries = globalRegistries;
+ if ( this.globalRegistries == null )
+ {
+ throw new NullPointerException( "the global registries cannot be
null" );
+ }
+
+ this.filteringService = filteringService;
+ if ( this.filteringService == null )
+ {
+ throw new NullPointerException( "the filter service cannot be
null" );
+ }
+
+ this.filteringService.addLookupFilter( LOOKUP_FILTER );
+ this.filteringService.addSearchResultFilter( SEARCH_FILTER );
}
@@ -191,48 +243,6 @@
attributes.put( attribute );
nexus.modify( newParentName, DirContext.REPLACE_ATTRIBUTE,
attributes );
- }
- }
-
-
- protected void lookup( Name dn ) throws NamingException
- {
- Invocation invocation = getInvocation();
-
- if ( invocation.getState() == InvocationStateEnum.POSTINVOCATION )
- {
- Attributes attributes = ( Attributes ) invocation.getReturnValue();
- Attributes retval = ( Attributes ) attributes.clone();
- filter( retval );
- invocation.setReturnValue( retval );
- }
- }
-
-
- protected void search( Name base, Map env, ExprNode filter,
- SearchControls searchControls )
- throws NamingException
- {
- Invocation invocation = getInvocation();
-
- if ( invocation.getState() == InvocationStateEnum.POSTINVOCATION )
- {
- if ( searchControls.getReturningAttributes() != null )
- {
- return;
- }
-
- SearchResultEnumeration enum ;
- ResultFilteringEnumeration retval;
- enum = ( SearchResultEnumeration ) invocation.getReturnValue();
- retval = new ResultFilteringEnumeration( enum );
- retval.addResultFilter( new ResultFilter() {
- public boolean accept( DbSearchResult result )
- {
- return filter( result.getAttributes() );
- }
- } );
- invocation.setReturnValue( retval );
}
}
Added:
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/ibs/ResultFilteringService.java
==============================================================================
--- (empty file)
+++
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/ibs/ResultFilteringService.java
Thu Oct 28 12:02:22 2004
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.eve.jndi.ibs;
+
+
+import org.apache.eve.db.SearchResultFilter;
+
+
+/**
+ * A service which applies a linear combination of filters to attributes before
+ * they are returned from calls to the following operations:
+ * <ul>
+ * <li><code>[EMAIL PROTECTED]
org.apache.eve.BackingStore#lookup(javax.naming.Name)}</code></li>
+ * <li><code>[EMAIL PROTECTED]
org.apache.eve.BackingStore#lookup(javax.naming.Name,String[])}</code></li>
+ * <li><code>[EMAIL PROTECTED]
org.apache.eve.BackingStore#search(javax.naming.Name,
+ * java.util.Map, org.apache.ldap.common.filter.ExprNode,
+ * javax.naming.directory.SearchControls)}</code></li>
+ * </ul>
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface ResultFilteringService
+{
+ /**
+ * Adds a new lookup filter to the end of the list of filters be applied to
+ * attributes being returned to Eve JNDI Contexts from calls made to
+ * [EMAIL PROTECTED]
org.apache.eve.BackingStore#lookup(javax.naming.Name)} and
+ * [EMAIL PROTECTED]
org.apache.eve.BackingStore#lookup(javax.naming.Name,String[])}
+ *
+ * @param filter the filter to be added
+ * @return the return value from [EMAIL PROTECTED]
java.util.List#add(Object)}
+ */
+ boolean addLookupFilter( LookupFilter filter );
+
+
+ /**
+ * Adds a new database search result filter to the end of the list of
+ * filters be applied to attributes being returned via NamingEnumerations
+ * created via calls made to [EMAIL PROTECTED]
org.apache.eve.BackingStore#search(
+ * javax.naming.Name, java.util.Map,
org.apache.ldap.common.filter.ExprNode,
+ * javax.naming.directory.SearchControls)}
+ *
+ * @param filter the filter to be added
+ * @return the return value from [EMAIL PROTECTED]
java.util.List#add(Object)}
+ */
+ boolean addSearchResultFilter( SearchResultFilter filter );
+}
Added:
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/ibs/ResultFilteringServiceImpl.java
==============================================================================
--- (empty file)
+++
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/ibs/ResultFilteringServiceImpl.java
Thu Oct 28 12:02:22 2004
@@ -0,0 +1,235 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.eve.jndi.ibs;
+
+
+import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
+
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.directory.*;
+
+import org.apache.eve.db.SearchResultFilter;
+import org.apache.eve.db.DbSearchResult;
+import org.apache.eve.db.SearchResultEnumeration;
+import org.apache.eve.db.ResultFilteringEnumeration;
+import org.apache.eve.jndi.Invocation;
+import org.apache.eve.jndi.BaseInterceptor;
+import org.apache.eve.jndi.InvocationStateEnum;
+
+import org.apache.ldap.common.filter.ExprNode;
+
+
+/**
+ * An interceptor based service which manages the filtering of result responses
+ * back to callers. This service is strictly post invocation based and
+ * operates upon Attributes and SearchResults obtained through
+ * [EMAIL PROTECTED] org.apache.eve.BackingStore#lookup(Name)},
+ * [EMAIL PROTECTED] org.apache.eve.BackingStore#lookup(Name,String[])} and
+ * [EMAIL PROTECTED] org.apache.eve.BackingStore#search(Name, Map, ExprNode,
SearchControls)}
+ * operations.
+ * <p>
+ * We try to limit the amount of filtering decorators used on search results
and
+ * lookup values to prevent inefficiencies such as the unecessary cloning of
+ * Attributes. Several other services may depend upon this service to modify
+ * search and lookup results as callers access them.
+ * </p><p>
+ * This service should be registered last within after chain of the interceptor
+ * framework.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ResultFilteringServiceImpl extends BaseInterceptor
+ implements ResultFilteringService
+{
+ /** the set of registered result filters for search */
+ private final List resultFilters = new ArrayList();
+ /** the set of registered entry filters for lookup operations */
+ private final List lookupFilters = new ArrayList();
+
+
+ // ------------------------------------------------------------------------
+ // BaseInterceptor Overrides
+ // ------------------------------------------------------------------------
+
+
+ /**
+ * @see ResultFilteringService#addLookupFilter(LookupFilter)
+ */
+ public boolean addLookupFilter( LookupFilter filter )
+ {
+ return lookupFilters.add( filter );
+ }
+
+
+ /**
+ * @see ResultFilteringService#addSearchResultFilter(SearchResultFilter)
+ */
+ public boolean addSearchResultFilter( SearchResultFilter filter )
+ {
+ return resultFilters.add( filter );
+ }
+
+
+ // ------------------------------------------------------------------------
+ // BaseInterceptor Overrides
+ // ------------------------------------------------------------------------
+
+
+ /**
+ * @see BaseInterceptor#lookup(javax.naming.Name)
+ */
+ protected void lookup( Name dn ) throws NamingException
+ {
+ Invocation invocation = getInvocation();
+
+ if ( invocation.getState() == InvocationStateEnum.POSTINVOCATION )
+ {
+ Attributes attributes = ( Attributes ) invocation.getReturnValue();
+ Attributes retval = ( Attributes ) attributes.clone();
+ filter( dn, retval );
+ invocation.setReturnValue( retval );
+ }
+ }
+
+
+ /**
+ * @see BaseInterceptor#lookup(javax.naming.Name, String[])
+ */
+ protected void lookup( Name dn, String[] ids ) throws NamingException
+ {
+ Invocation invocation = getInvocation();
+
+ if ( invocation.getState() == InvocationStateEnum.POSTINVOCATION )
+ {
+ Attributes attributes = ( Attributes ) invocation.getReturnValue();
+ Attributes retval = ( Attributes ) attributes.clone();
+ filter( dn, retval, ids );
+ invocation.setReturnValue( retval );
+ }
+ }
+
+
+ /**
+ * @see BaseInterceptor#search(Name, Map, ExprNode, SearchControls)
+ */
+ protected void search( Name base, Map env, ExprNode filter,
+ SearchControls searchControls )
+ throws NamingException
+ {
+ Invocation invocation = getInvocation();
+
+ if ( invocation.getState() == InvocationStateEnum.POSTINVOCATION )
+ {
+ if ( searchControls.getReturningAttributes() != null )
+ {
+ return;
+ }
+
+ SearchResultEnumeration enum ;
+ ResultFilteringEnumeration retval;
+ enum = ( SearchResultEnumeration ) invocation.getReturnValue();
+ retval = new ResultFilteringEnumeration( enum, searchControls );
+ retval.addResultFilter( new SearchResultFilter()
+ {
+ public boolean accept( DbSearchResult result, SearchControls
controls )
+ throws NamingException
+ {
+ return ResultFilteringServiceImpl.this.accept( result,
controls );
+ }
+ } );
+ invocation.setReturnValue( retval );
+ }
+ }
+
+
+ // ------------------------------------------------------------------------
+ // Private methods used to apply filters
+ // ------------------------------------------------------------------------
+
+
+ /**
+ * Applies the linear stack of result filters to the search result to be
+ * returned to the user.
+ *
+ * @param result the copy of the database search result to accep, modify,
+ * or reject before being returned
+ * @param controls the search controls associated with the invocation
+ * @return true if this result should not be returned to the callers of a
+ * search result enumeration
+ * @throws NamingException if there are errors while applying the linear
+ * composition of filters
+ */
+ private boolean accept( DbSearchResult result, SearchControls controls )
+ throws NamingException
+ {
+ boolean isAccepted = true;
+
+ for ( int ii = 0; ii < resultFilters.size(); ii++ )
+ {
+ SearchResultFilter filter = ( SearchResultFilter )
resultFilters.get( ii );
+
+ if ( ! ( isAccepted &= filter.accept( result, controls ) ) )
+ {
+ break;
+ }
+ }
+
+ return isAccepted;
+ }
+
+
+ /**
+ * Applies the linear stack of entry filters to the entry looked up and
+ * eventually returned a caller of the lookup methods.
+ *
+ * @param dn the distinguished name of the lookup entry being filtered
+ * @param entry the attributes of the entry being filtered
+ * @throws NamingException if there are errors while applying the linear
+ * composition of filters
+ */
+ private void filter( Name dn, Attributes entry ) throws NamingException
+ {
+ for ( int ii = 0; ii < lookupFilters.size(); ii++ )
+ {
+ ( ( LookupFilter ) lookupFilters.get( ii ) ).filter( dn, entry );
+ }
+ }
+
+
+ /**
+ * Applies the linear stack of entry filters to the entry looked up and
+ * eventually returned a caller of the lookup methods.
+ *
+ * @param dn the distinguished name of the lookup entry being filtered
+ * @param entry the attributes of the entry being filtered
+ * @param ids the attributes of the the lookup operation is supposed to
+ * return
+ * @throws NamingException if there are errors while applying the linear
+ * composition of filters
+ */
+ private void filter( Name dn, Attributes entry, String[] ids ) throws
NamingException
+ {
+ for ( int ii = 0; ii < lookupFilters.size(); ii++ )
+ {
+ ( ( LookupFilter ) lookupFilters.get( ii ) ).filter( dn, entry,
ids );
+ }
+ }
+}
Modified:
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/ibs/SchemaService.java
==============================================================================
---
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/ibs/SchemaService.java
(original)
+++
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/ibs/SchemaService.java
Thu Oct 28 12:02:22 2004
@@ -36,7 +36,6 @@
private final GlobalRegistries globalRegistries;
-
/**
* Creates a schema service interceptor.
*
@@ -46,6 +45,15 @@
public SchemaService( RootNexus nexus, GlobalRegistries globalRegistries )
{
this.nexus = nexus;
+ if ( this.nexus == null )
+ {
+ throw new NullPointerException( "the nexus cannot be null" );
+ }
+
this.globalRegistries = globalRegistries;
+ if ( this.globalRegistries == null )
+ {
+ throw new NullPointerException( "the global registries cannot be
null" );
+ }
}
}
Modified:
incubator/directory/eve/trunk/backend/core/src/test/org/apache/eve/jndi/AbstractJndiTest.java
==============================================================================
---
incubator/directory/eve/trunk/backend/core/src/test/org/apache/eve/jndi/AbstractJndiTest.java
(original)
+++
incubator/directory/eve/trunk/backend/core/src/test/org/apache/eve/jndi/AbstractJndiTest.java
Thu Oct 28 12:02:22 2004
@@ -52,6 +52,16 @@
{
super.setUp();
+ if ( doDelete == true )
+ {
+ File file = new File( "target/eve" );
+
+ if ( file.exists() )
+ {
+ FileUtils.deleteDirectory( file );
+ }
+ }
+
Hashtable env = new Hashtable();
env.put( Context.PROVIDER_URL, "ou=system" );
env.put( Context.INITIAL_CONTEXT_FACTORY,
"org.apache.eve.jndi.EveContextFactory" );
@@ -84,11 +94,5 @@
}
sysRoot = null;
-
- if ( doDelete == true )
- {
- File file = new File( "target/eve" );
- FileUtils.deleteDirectory( file );
- }
}
}