directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1087091 - /directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/shared/dsmlv2/engine/Dsmlv2Engine.java
Date Wed, 30 Mar 2011 21:44:16 GMT
Author: kayyagari
Date: Wed Mar 30 21:44:16 2011
New Revision: 1087091

URL: http://svn.apache.org/viewvc?rev=1087091&view=rev
Log:
o do not append search response tag when no search results are present

Modified:
    directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/shared/dsmlv2/engine/Dsmlv2Engine.java

Modified: directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/shared/dsmlv2/engine/Dsmlv2Engine.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/shared/dsmlv2/engine/Dsmlv2Engine.java?rev=1087091&r1=1087090&r2=1087091&view=diff
==============================================================================
--- directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/shared/dsmlv2/engine/Dsmlv2Engine.java
(original)
+++ directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/shared/dsmlv2/engine/Dsmlv2Engine.java
Wed Mar 30 21:44:16 2011
@@ -215,7 +215,7 @@ public class Dsmlv2Engine
      */
     public void processDSMLFile( File file, OutputStream respStream ) throws Exception
     {
-        parser = new Dsmlv2Parser();
+        parser = new Dsmlv2Parser(grammar);
         parser.setInputFile( file.getAbsolutePath() );
 
         processDSML( respStream );
@@ -244,7 +244,7 @@ public class Dsmlv2Engine
      */
     public void processDSML( InputStream inputStream, String inputEncoding, OutputStream
out ) throws Exception
     {
-        parser = new Dsmlv2Parser();
+        parser = new Dsmlv2Parser(grammar);
         parser.setInput( inputStream, inputEncoding );
         processDSML( out );
     }
@@ -606,28 +606,35 @@ public class Dsmlv2Engine
             case SEARCH_REQUEST:
                 SearchCursor searchResponses = connection.search( ( SearchRequest ) request
);
                 
-                if ( respWriter != null )
-                {
-                    StringBuilder sb = new StringBuilder();
-                    sb.append( "<searchResponse" );
-                    
-                    if ( request.getDecorated().getMessageId() > 0 )
-                    {
-                        sb.append( " requestID=\"" );
-                        sb.append( request.getDecorated().getMessageId() );
-                        sb.append( '"' );
-                    }
-                    
-                    sb.append( '>' );
-                    
-                    respWriter.write( sb.toString() );
-                }
-
                 SearchResponseDsml searchResponseDsml = new SearchResponseDsml( connection.getCodecService()
);
                 searchResponseDsml.setMessageId( request.getDecorated().getMessageId() );
                 
+                boolean first = true;
+                
                 while ( searchResponses.next() )
                 {
+                    if( first )
+                    {
+                        if ( respWriter != null )
+                        {
+                            StringBuilder sb = new StringBuilder();
+                            sb.append( "<searchResponse" );
+                            
+                            if ( request.getDecorated().getMessageId() > 0 )
+                            {
+                                sb.append( " requestID=\"" );
+                                sb.append( request.getDecorated().getMessageId() );
+                                sb.append( '"' );
+                            }
+                            
+                            sb.append( '>' );
+                            
+                            respWriter.write( sb.toString() );
+                        }
+                        
+                        first = false;
+                    }
+                    
                     Response searchResponse = searchResponses.get();
 
                     if ( searchResponse.getType() == MessageTypeEnum.SEARCH_RESULT_ENTRY
)
@@ -667,18 +674,22 @@ public class Dsmlv2Engine
                 }
 
                 SearchResultDone srDone = searchResponses.getSearchResultDone();
-                resultCode = srDone.getLdapResult().getResultCode();
-                
-                SearchResultDoneDsml srdDsml = new SearchResultDoneDsml( connection.getCodecService(),
srDone );
-                writeResponse( respWriter, srdDsml);
 
-                if ( respWriter != null )
-                {
-                    respWriter.write( "</searchResponse>" );
-                }
-                else
+                if ( srDone != null )
                 {
-                    batchResponse.addResponse( searchResponseDsml );
+                    resultCode = srDone.getLdapResult().getResultCode();
+                    
+                    SearchResultDoneDsml srdDsml = new SearchResultDoneDsml( connection.getCodecService(),
srDone );
+                    writeResponse( respWriter, srdDsml);
+                    
+                    if ( respWriter != null )
+                    {
+                        respWriter.write( "</searchResponse>" );
+                    }
+                    else
+                    {
+                        batchResponse.addResponse( searchResponseDsml );
+                    }
                 }
                 
                 break;



Mime
View raw message