directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ersi...@apache.org
Subject svn commit: r415450 - /directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/extended/
Date Mon, 19 Jun 2006 22:54:16 GMT
Author: ersiner
Date: Mon Jun 19 15:54:15 2006
New Revision: 415450

URL: http://svn.apache.org/viewvc?rev=415450&view=rev
Log:
Modified SP code to return SP result back to client. However, we have problems with this.

Modified:
    directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/extended/JavaStoredProcedureExtendedOperationHandler.java
    directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/extended/LanguageSpecificStoredProceureExtendedOperationHandler.java
    directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/extended/StoredProcedureExtendedOperationHandler.java

Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/extended/JavaStoredProcedureExtendedOperationHandler.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/extended/JavaStoredProcedureExtendedOperationHandler.java?rev=415450&r1=415449&r2=415450&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/extended/JavaStoredProcedureExtendedOperationHandler.java
(original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/extended/JavaStoredProcedureExtendedOperationHandler.java
Mon Jun 19 15:54:15 2006
@@ -18,8 +18,9 @@
 
 
 import java.io.ByteArrayInputStream;
-import java.io.IOException;
+import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -47,8 +48,8 @@
 {
     private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
     
-    public void handleStoredProcedureExtendedOperation( ServerLdapContext ctx, StoredProcedure
pojo ) 
-        throws ClassNotFoundException, NamingException
+    public byte[] handleStoredProcedureExtendedOperation( ServerLdapContext ctx, StoredProcedure
pojo ) 
+        throws NamingException
     {
         List types = new ArrayList( pojo.getParameters().size() );
         List values = new ArrayList( pojo.getParameters().size() );
@@ -59,7 +60,17 @@
             StoredProcedureParameter pPojo = ( StoredProcedureParameter ) it.next();
             
             // Get type from String even if it holds a primitive type name
-            Class type = SpringClassUtils.forName( StringTools.utf8ToString( pPojo.getType()
) ); 
+            Class type;
+            try
+            {
+                type = SpringClassUtils.forName( StringTools.utf8ToString( pPojo.getType()
) );
+            }
+            catch ( ClassNotFoundException e )
+            {
+                NamingException ne = new NamingException();
+                ne.setRootCause( e );
+                throw ne;
+            } 
             
             types.add( type );
             
@@ -96,23 +107,36 @@
                         ).readObject()
                     );
                 }
-                catch (IOException e)
+                catch ( Exception e )
                 {
-                    // TODO Auto-generated catch block
-                    e.printStackTrace();
-                }
-                catch (ClassNotFoundException e)
-                {
-                    // TODO Auto-generated catch block
-                    e.printStackTrace();
+                    NamingException ne = new NamingException();
+                    ne.setRootCause( e );
+                    throw ne;
                 }
             }
             
         }
         
         // TODO determine what to do with the exception
-        executeProcedure( ctx, StringTools.utf8ToString( pojo.getProcedure() ), 
+        Object response = executeProcedure( ctx, StringTools.utf8ToString( pojo.getProcedure()
), 
                 ( Class[] ) types.toArray( EMPTY_CLASS_ARRAY ), values.toArray() );
+        
+        ByteArrayOutputStream baos;
+        try
+        {
+            baos = new ByteArrayOutputStream();
+            ObjectOutputStream oos = new ObjectOutputStream( baos );
+            oos.writeObject( response );
+        }
+        catch ( Exception e )
+        {
+            NamingException ne = new NamingException();
+            ne.setRootCause( e );
+            throw ne;
+        }
+        
+        return baos.toByteArray();
+        
     }
 
     

Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/extended/LanguageSpecificStoredProceureExtendedOperationHandler.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/extended/LanguageSpecificStoredProceureExtendedOperationHandler.java?rev=415450&r1=415449&r2=415450&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/extended/LanguageSpecificStoredProceureExtendedOperationHandler.java
(original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/extended/LanguageSpecificStoredProceureExtendedOperationHandler.java
Mon Jun 19 15:54:15 2006
@@ -30,5 +30,5 @@
  */
 public interface LanguageSpecificStoredProceureExtendedOperationHandler 
 {
-    void handleStoredProcedureExtendedOperation( ServerLdapContext ctx, StoredProcedure spBean
) throws Exception;
+    byte[] handleStoredProcedureExtendedOperation( ServerLdapContext ctx, StoredProcedure
spBean ) throws Exception;
 }

Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/extended/StoredProcedureExtendedOperationHandler.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/extended/StoredProcedureExtendedOperationHandler.java?rev=415450&r1=415449&r2=415450&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/extended/StoredProcedureExtendedOperationHandler.java
(original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/extended/StoredProcedureExtendedOperationHandler.java
Mon Jun 19 15:54:15 2006
@@ -37,6 +37,7 @@
 import org.apache.directory.shared.ldap.codec.extended.operations.StoredProcedureContainer;
 import org.apache.directory.shared.ldap.codec.extended.operations.StoredProcedureDecoder;
 import org.apache.directory.shared.ldap.message.ExtendedRequest;
+import org.apache.directory.shared.ldap.message.ExtendedResponse;
 import org.apache.directory.shared.ldap.message.extended.StoredProcedureRequest;
 import org.apache.directory.shared.ldap.message.extended.StoredProcedureResponse;
 import org.apache.mina.common.IoSession;
@@ -67,20 +68,25 @@
         
         LanguageSpecificStoredProceureExtendedOperationHandler handler = null;
         
+        byte[] responseStream = null;
+        
         /**
          * TODO This part may be replaced by a better handler determiner.
          */
         if ( spBean.getLanguage().equalsIgnoreCase( "Java" ) )
         {
             handler = new JavaStoredProcedureExtendedOperationHandler();
-            handler.handleStoredProcedureExtendedOperation( serverLdapContext, spBean );
+            responseStream = handler.handleStoredProcedureExtendedOperation( serverLdapContext,
spBean );
         }
         
         /**
-         * TODO: Temporarily added this response to make things work.
-         * We need to send back the SP result btw.
+         * FIXME: We may have issues sending SP result back to the client.
          */
+        
+        ( ( ExtendedResponse )( req.getResultResponse() ) ).setResponse( responseStream );
+        
         session.write( req.getResultResponse() );
+        
     }
     
     private StoredProcedure decodeBean( byte[] payload )



Mime
View raw message