You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2004/12/02 03:37:47 UTC

svn commit: r109436 - /incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/RootNexus.java /incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveJndiProvider.java

Author: akarasulu
Date: Wed Dec  1 18:37:46 2004
New Revision: 109436

URL: http://svn.apache.org/viewcvs?view=rev&rev=109436
Log:
Changes ...

 o added functionality to treat searches for RootDSE specifically
 o fixed situations where we get TargetInvocation exceptions wrapping others
 o throw LdapNameNotFound when searching for Root DSE with one or subtree scope


Modified:
   incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/RootNexus.java
   incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveJndiProvider.java

Modified: incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/RootNexus.java
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/RootNexus.java?view=diff&rev=109436&p1=incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/RootNexus.java&r1=109435&p2=incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/RootNexus.java&r2=109436
==============================================================================
--- incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/RootNexus.java	(original)
+++ incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/RootNexus.java	Wed Dec  1 18:37:46 2004
@@ -23,14 +23,14 @@
 import javax.naming.NamingException;
 import javax.naming.ldap.LdapContext;
 import javax.naming.NamingEnumeration;
-import javax.naming.directory.Attributes;
 import javax.naming.NameNotFoundException;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.ModificationItem;
-import javax.naming.directory.Attribute;
+import javax.naming.directory.*;
 
 import org.apache.ldap.common.filter.ExprNode;
+import org.apache.ldap.common.filter.PresenceNode;
 import org.apache.ldap.common.NotImplementedException;
+import org.apache.ldap.common.exception.LdapNameNotFoundException;
+import org.apache.ldap.common.util.SingletonEnumeration;
 import org.apache.ldap.common.message.LockableAttributeImpl;
 import org.apache.ldap.common.message.LockableAttributes;
 import org.apache.ldap.common.message.LockableAttributesImpl;
@@ -245,6 +245,25 @@
                                      SearchControls searchCtls )
         throws NamingException
     {
+
+        if ( base.size() == 0 )
+        {
+            /*
+             * if basedn is "", filter is "(objectclass=*)" and scope is object
+             * then we have a request for the rootDSE
+             */
+            if ( filter instanceof PresenceNode &&
+                 searchCtls.getSearchScope() == SearchControls.OBJECT_SCOPE &&
+                 ( ( PresenceNode ) filter ).getAttribute().equalsIgnoreCase( "objectclass" ) )
+            {
+                Attributes attrs = getRootDSE();
+                SearchResult result = new SearchResult( "", null, attrs, false );
+                return new SingletonEnumeration( result );
+            }
+
+            throw new LdapNameNotFoundException();
+        }
+
         ContextPartition backend = getBackend( base );
         return backend.search( base, env, filter, searchCtls );
     }

Modified: incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveJndiProvider.java
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveJndiProvider.java?view=diff&rev=109436&p1=incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveJndiProvider.java&r1=109435&p2=incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveJndiProvider.java&r2=109436
==============================================================================
--- incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveJndiProvider.java	(original)
+++ incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveJndiProvider.java	Wed Dec  1 18:37:46 2004
@@ -28,6 +28,7 @@
 import java.lang.reflect.Proxy;
 import java.lang.reflect.Method;
 import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
 
 import javax.naming.NamingException;
 import javax.naming.Context;
@@ -203,15 +204,37 @@
          */
         if ( invocation.getState() == InvocationStateEnum.PREINVOCATION )
         {
+            NamingException target = null;
+
             try
             {
                 Object retVal = method.invoke( nexus, invocation.getParameters() );
                 invocation.setReturnValue( retVal );
                 invocation.setState( InvocationStateEnum.POSTINVOCATION );
             }
-            catch ( Throwable throwable )
+            catch ( InvocationTargetException ite )
+            {
+                if ( ite.getTargetException() != null )
+                {
+                    if ( ite.getTargetException() instanceof NamingException )
+                    {
+                        target = ( NamingException ) ite.getTargetException();
+                    }
+                }
+                else
+                {
+                    target = new NamingException();
+                    target.setRootCause( ite );
+                }
+                
+                invocation.setThrowable( target );
+                invocation.setState( InvocationStateEnum.FAILUREHANDLING );
+            }
+            catch ( Throwable t )
             {
-                invocation.setThrowable( throwable );
+                target = new NamingException();
+                target.setRootCause( t );
+                invocation.setThrowable( target );
                 invocation.setState( InvocationStateEnum.FAILUREHANDLING );
             }