directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1550227 - in /directory: apacheds/trunk/server-integ/src/test/java/org/apache/directory/dsml/engine/ apacheds/trunk/server-integ/src/test/resources/ shared/trunk/dsml/engine/src/main/java/org/apache/directory/api/dsmlv2/engine/
Date Wed, 11 Dec 2013 18:53:34 GMT
Author: kayyagari
Date: Wed Dec 11 18:53:33 2013
New Revision: 1550227

URL: http://svn.apache.org/r1550227
Log:
o fixed the missing 'requestID' attribute of BatchResponse
o updated test (DIRAPI-160)

Modified:
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/dsml/engine/Dsmlv2EngineIT.java
    directory/apacheds/trunk/server-integ/src/test/resources/dsml-search-req.xml
    directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/api/dsmlv2/engine/Dsmlv2Engine.java

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/dsml/engine/Dsmlv2EngineIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/dsml/engine/Dsmlv2EngineIT.java?rev=1550227&r1=1550226&r2=1550227&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/dsml/engine/Dsmlv2EngineIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/dsml/engine/Dsmlv2EngineIT.java
Wed Dec 11 18:53:33 2013
@@ -95,6 +95,8 @@ public class Dsmlv2EngineIT extends Abst
 
         assertNotNull( batchResp );
 
+        assertEquals( 101, batchResp.getRequestID() );
+        
         SearchResponse searchResp = ( SearchResponse ) batchResp.getCurrentResponse().getDecorated();
 
         assertEquals( 5, searchResp.getSearchResultEntryList().size() );
@@ -124,7 +126,9 @@ public class Dsmlv2EngineIT extends Abst
         BatchResponseDsml batchResp = respParser.getBatchResponse();
 
         assertNotNull( batchResp );
-
+        
+        assertEquals( 101, batchResp.getRequestID() );
+        
         SearchResponse searchResp = ( SearchResponse ) batchResp.getCurrentResponse().getDecorated();
 
         assertEquals( 5, searchResp.getSearchResultEntryList().size() );

Modified: directory/apacheds/trunk/server-integ/src/test/resources/dsml-search-req.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/resources/dsml-search-req.xml?rev=1550227&r1=1550226&r2=1550227&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/resources/dsml-search-req.xml (original)
+++ directory/apacheds/trunk/server-integ/src/test/resources/dsml-search-req.xml Wed Dec 11
18:53:33 2013
@@ -17,7 +17,7 @@
   specific language governing permissions and limitations
   under the License.
 -->
-<batchRequest xmlns="urn:oasis:names:tc:DSML:2:0:core"
+<batchRequest requestID="101" xmlns="urn:oasis:names:tc:DSML:2:0:core"
 	xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 	<searchRequest dn="ou=system" scope="singleLevel"
 		derefAliases="neverDerefAliases" typesOnly="false" >

Modified: directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/api/dsmlv2/engine/Dsmlv2Engine.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/api/dsmlv2/engine/Dsmlv2Engine.java?rev=1550227&r1=1550226&r2=1550227&view=diff
==============================================================================
--- directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/api/dsmlv2/engine/Dsmlv2Engine.java
(original)
+++ directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/api/dsmlv2/engine/Dsmlv2Engine.java
Wed Dec 11 18:53:33 2013
@@ -289,20 +289,6 @@ public class Dsmlv2Engine
 
                 respWriter.write( "><Body>" );
             }
-
-            respWriter.write( "<batchResponse " );
-
-            ParserUtils.DSML_NAMESPACE.write( respWriter );
-
-            respWriter.write( " " ); // a space to separate the namespace declarations
-
-            ParserUtils.XSD_NAMESPACE.write( respWriter );
-
-            respWriter.write( " " ); // a space to separate the namespace declarations
-
-            ParserUtils.XSI_NAMESPACE.write( respWriter );
-
-            respWriter.write( '>' ); // the end tag
         }
 
         // Binding to LDAP Server
@@ -319,16 +305,18 @@ public class Dsmlv2Engine
             ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.COULD_NOT_CONNECT,
e
                 .getLocalizedMessage() );
 
+            batchResponse.addResponse( errorResponse );
+
             if ( respWriter != null )
             {
-                writeResponse( respWriter, errorResponse );
-                respWriter.write( "</batchResponse>" );
+                respWriter.write( batchResponse.toDsml() );
+                if( generateSoapResp )
+                {
+                    respWriter.write( "</Body></Envelope>" );
+                }
+                
                 respWriter.flush();
             }
-            else
-            {
-                batchResponse.addResponse( errorResponse );
-            }
 
             return;
         }
@@ -346,20 +334,45 @@ public class Dsmlv2Engine
             ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.MALFORMED_REQUEST,
I18n.err(
                 I18n.ERR_03001, e.getLocalizedMessage(), e.getLineNumber(), e.getColumnNumber()
) );
 
+            batchResponse.addResponse( errorResponse );
+
             if ( respWriter != null )
             {
-                writeResponse( respWriter, errorResponse );
-                respWriter.write( "</batchResponse>" );
+                respWriter.write( batchResponse.toDsml() );
+                if( generateSoapResp )
+                {
+                    respWriter.write( "</Body></Envelope>" );
+                }
+                
                 respWriter.flush();
             }
-            else
-            {
-                batchResponse.addResponse( errorResponse );
-            }
 
             return;
         }
 
+        if( respWriter != null )
+        {
+            StringBuilder sb = new StringBuilder();
+            
+            sb.append( "<batchResponse " );
+
+            sb.append( ParserUtils.DSML_NAMESPACE.asXML() );
+
+            sb.append( " " ); // a space to separate the namespace declarations
+
+            sb.append( ParserUtils.XSD_NAMESPACE.asXML() );
+
+            sb.append( " " ); // a space to separate the namespace declarations
+
+            sb.append( ParserUtils.XSI_NAMESPACE.asXML() );
+
+            sb.append( " requestID=\"" );
+            sb.append( batchRequest.getRequestID() );
+            sb.append( "\">" );
+            
+            respWriter.write( sb.toString() );
+        }
+        
         // Processing each request:
         //    - Getting a new request
         //    - Checking if the request is well formed
@@ -382,16 +395,19 @@ public class Dsmlv2Engine
             ErrorResponse errorResponse = new ErrorResponse( reqId, ErrorResponseType.MALFORMED_REQUEST,
I18n.err(
                 I18n.ERR_03001, e.getLocalizedMessage(), e.getLineNumber(), e.getColumnNumber()
) );
 
+            batchResponse.addResponse( errorResponse );
+
             if ( respWriter != null )
             {
-                writeResponse( respWriter, errorResponse );
-                respWriter.write( "</batchResponse>" );
+                respWriter.write( batchResponse.toDsml() );
+
+                if( generateSoapResp )
+                {
+                    respWriter.write( "</Body></Envelope>" );
+                }
+                
                 respWriter.flush();
             }
-            else
-            {
-                batchResponse.addResponse( errorResponse );
-            }
 
             return;
         }
@@ -480,8 +496,7 @@ public class Dsmlv2Engine
 
             if ( generateSoapResp )
             {
-                respWriter.write( "</Body>" );
-                respWriter.write( "</Envelope>" );
+                respWriter.write( "</Body></Envelope>" );
             }
 
             respWriter.flush();



Mime
View raw message