directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 56273 - in incubator/directory/eve/trunk/jndi-provider/src: java/org/apache/eve java/org/apache/eve/db java/org/apache/eve/jndi/ibs test/org/apache/eve/jndi
Date Mon, 01 Nov 2004 19:36:32 GMT
Author: akarasulu
Date: Mon Nov  1 11:36:30 2004
New Revision: 56273

Added:
   incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/ListTest.java
Modified:
   incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/AbstractContextPartition.java
   incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/BackingStore.java
   incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/db/SearchResultEnumeration.java
   incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/ibs/FilterServiceImpl.java
Log:
Changes ...

 o added list functionality
   - list now returns NameClassPairs which really are DbSearchResults
 o part of the list functionality where list operations have their 
   NameClassPairs populated with contexts rests under the FilterInterceptor 
 o added some skeletal tests - will add more to this



Modified: incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/AbstractContextPartition.java
==============================================================================
--- incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/AbstractContextPartition.java
(original)
+++ incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/AbstractContextPartition.java
Mon Nov  1 11:36:30 2004
@@ -33,6 +33,7 @@
 import org.apache.ldap.common.filter.ExprNode;
 import org.apache.ldap.common.schema.AttributeType;
 import org.apache.ldap.common.message.LockableAttributesImpl;
+import org.apache.ldap.common.util.ArrayUtils;
 
 import org.apache.eve.db.Database;
 import org.apache.eve.db.SearchEngine;
@@ -274,7 +275,10 @@
      */
     public NamingEnumeration list( Name base ) throws NamingException
     {
-        return db.list( db.getEntryId( base.toString() ) );
+        SearchResultEnumeration list;
+        list = new SearchResultEnumeration( ArrayUtils.EMPTY_STRING_ARRAY,
+                db.list( db.getEntryId( base.toString() ) ), db );
+        return list;
     }
     
     

Modified: incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/BackingStore.java
==============================================================================
--- incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/BackingStore.java
(original)
+++ incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/BackingStore.java
Mon Nov  1 11:36:30 2004
@@ -98,7 +98,8 @@
      * retrieval.
      *
      * @param base the base distinguished/absolute name for the search/listing
-     * @return a NamingEnumeration containing objects of type {@link Index}
+     * @return a NamingEnumeration containing objects of type
+     * {@link org.apache.eve.db.DbSearchResult}
      * @throws NamingException if there are any problems
      */
     NamingEnumeration list( Name base ) throws NamingException;

Modified: incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/db/SearchResultEnumeration.java
==============================================================================
--- incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/db/SearchResultEnumeration.java
(original)
+++ incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/db/SearchResultEnumeration.java
Mon Nov  1 11:36:30 2004
@@ -46,7 +46,7 @@
     /** underlying enumeration over IndexRecords */
     private final NamingEnumeration underlying;
 
-    
+
     /**
      * Creates an enumeration that returns entries packaged within SearchResults
      * using the search parameters supplied to a search call.

Modified: incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/ibs/FilterServiceImpl.java
==============================================================================
--- incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/ibs/FilterServiceImpl.java
(original)
+++ incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/ibs/FilterServiceImpl.java
Mon Nov  1 11:36:30 2004
@@ -35,6 +35,7 @@
 import org.apache.eve.jndi.InvocationStateEnum;
 
 import org.apache.ldap.common.filter.ExprNode;
+import org.apache.ldap.common.name.LdapName;
 
 
 /**
@@ -64,6 +65,7 @@
     private final List resultFilters = new ArrayList();
     /** the set of registered entry filters for lookup operations */
     private final List lookupFilters = new ArrayList();
+    private final static SearchControls LIST_CONTROLS = new SearchControls();
 
 
     // ------------------------------------------------------------------------
@@ -92,6 +94,35 @@
     // ------------------------------------------------------------------------
     // BaseInterceptor Overrides
     // ------------------------------------------------------------------------
+
+
+    protected void list( final Name base ) throws NamingException
+    {
+        Invocation invocation = getInvocation();
+
+        if ( invocation.getState() == InvocationStateEnum.POSTINVOCATION )
+        {
+            SearchResultEnumeration enum ;
+            ResultFilteringEnumeration retval;
+            LdapContext ctx = ( LdapContext ) invocation.getContextStack().peek();
+            enum = ( SearchResultEnumeration ) invocation.getReturnValue();
+            retval = new ResultFilteringEnumeration( enum, LIST_CONTROLS, ctx,
+                new SearchResultFilter()
+                {
+                    public boolean accept( LdapContext ctx, DbSearchResult result,
+                                           SearchControls controls )
+                            throws NamingException
+                    {
+                        String rdn = new LdapName( result.getName() ).getRdn();
+                        result.setName( rdn );
+                        result.setObject( ctx.lookup( rdn ) );
+                        result.setRelative( true );
+                        return FilterServiceImpl.this.accept( ctx, result, controls );
+                    }
+                } );
+            invocation.setReturnValue( retval );
+        }
+    }
 
 
     /**

Added: incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/ListTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/jndi-provider/src/test/org/apache/eve/jndi/ListTest.java
Mon Nov  1 11:36:30 2004
@@ -0,0 +1,42 @@
+/*
+ *   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;
+
+
+import javax.naming.NamingException;
+import javax.naming.NamingEnumeration;
+import javax.naming.NameClassPair;
+
+
+/**
+ * Document this class.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ListTest extends AbstractJndiTest
+{
+    public void testList() throws NamingException
+    {
+        NamingEnumeration list = sysRoot.list( "" );
+        while ( list.hasMore() )
+        {
+            NameClassPair ncp = ( NameClassPair ) list.next();
+            System.out.println( ncp );
+        }
+    }
+}

Mime
View raw message