directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1091840 - in /directory/shared/trunk/dsml: engine/src/main/java/org/apache/directory/shared/dsmlv2/engine/ parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/ parser/src/main/java/org/apache/directory/shared/dsmlv2/request/ pa...
Date Wed, 13 Apr 2011 16:09:08 GMT
Author: kayyagari
Date: Wed Apr 13 16:09:08 2011
New Revision: 1091840

URL: http://svn.apache.org/viewvc?rev=1091840&view=rev
Log:
o fixed the grammar to store the filter properly by handling the attributes and control tags
present in searchrequest
o added some warn level log statements
o throw IllegalStateException when a searchrequest doesn't contain a filter, changed the test
case accordingly
o fixed a NPE in SearchResultEntryDsml while adding namespace to the doc root (in streaming
mode there won't be a doc)

Modified:
    directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/shared/dsmlv2/engine/Dsmlv2Engine.java
    directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/SearchResultEntryDsml.java
    directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/Dsmlv2Grammar.java
    directory/shared/trunk/dsml/parser/src/test/java/org/apache/directory/shared/dsmlv2/AbstractTest.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=1091840&r1=1091839&r2=1091840&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 Apr 13 16:09:08 2011
@@ -319,6 +319,8 @@ public class Dsmlv2Engine
         }
         catch ( Exception e )
         {
+            LOG.warn( "Failed to bind", e );
+            
             // Unable to connect to server
             // We create a new ErrorResponse and return the XML response.
             ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.COULD_NOT_CONNECT,
e
@@ -376,8 +378,16 @@ public class Dsmlv2Engine
         }
         catch ( XmlPullParserException e )
         {
+            LOG.warn( "Failed while getting next request", e );
+            
+            int reqId = 0;
+            if ( request != null )
+            {
+                reqId = request.getDecorated().getMessageId();
+            }
+            
             // We create a new ErrorResponse and return the XML response.
-            ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.MALFORMED_REQUEST,
I18n.err(
+            ErrorResponse errorResponse = new ErrorResponse( reqId, ErrorResponseType.MALFORMED_REQUEST,
I18n.err(
                 I18n.ERR_03001, e.getLocalizedMessage(), e.getLineNumber(), e.getColumnNumber()
) );
             if ( respWriter != null )
             {
@@ -421,8 +431,10 @@ public class Dsmlv2Engine
             }
             catch ( Exception e )
             {
+                LOG.warn( "Failed to process request", e );
+                
                 // We create a new ErrorResponse and return the XML response.
-                ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.GATEWAY_INTERNAL_ERROR,
I18n.err(
+                ErrorResponse errorResponse = new ErrorResponse( request.getDecorated().getMessageId(),
ErrorResponseType.GATEWAY_INTERNAL_ERROR, I18n.err(
                     I18n.ERR_03003, e.getMessage() ) );
                 if ( respWriter != null )
                 {
@@ -607,7 +619,6 @@ public class Dsmlv2Engine
                 SearchCursor searchResponses = connection.search( ( SearchRequest ) request
);
                 
                 SearchResponseDsml searchResponseDsml = new SearchResponseDsml( connection.getCodecService()
);
-                searchResponseDsml.setMessageId( request.getDecorated().getMessageId() );
                 
                 boolean first = true;
                 

Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/SearchResultEntryDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/SearchResultEntryDsml.java?rev=1091840&r1=1091839&r2=1091840&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/SearchResultEntryDsml.java
(original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/SearchResultEntryDsml.java
Wed Apr 13 16:09:08 2011
@@ -22,15 +22,16 @@ package org.apache.directory.shared.dsml
 
 import org.apache.directory.shared.dsmlv2.ParserUtils;
 import org.apache.directory.shared.ldap.codec.api.LdapCodecService;
+import org.apache.directory.shared.ldap.model.entry.Attribute;
 import org.apache.directory.shared.ldap.model.entry.DefaultAttribute;
 import org.apache.directory.shared.ldap.model.entry.Entry;
-import org.apache.directory.shared.ldap.model.entry.Attribute;
 import org.apache.directory.shared.ldap.model.entry.Value;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.message.MessageTypeEnum;
 import org.apache.directory.shared.ldap.model.message.SearchResultEntry;
 import org.apache.directory.shared.ldap.model.message.SearchResultEntryImpl;
 import org.apache.directory.shared.ldap.model.name.Dn;
+import org.dom4j.Document;
 import org.dom4j.Element;
 import org.dom4j.Namespace;
 import org.dom4j.QName;
@@ -154,8 +155,14 @@ public class SearchResultEntryDsml 
                 {
                     Namespace xsdNamespace = new Namespace( ParserUtils.XSD, ParserUtils.XML_SCHEMA_URI
);
                     Namespace xsiNamespace = new Namespace( ParserUtils.XSI, ParserUtils.XML_SCHEMA_INSTANCE_URI
);
-                    attributeElement.getDocument().getRootElement().add( xsdNamespace );
-                    attributeElement.getDocument().getRootElement().add( xsiNamespace );
+                    Document doc = attributeElement.getDocument();
+                    
+                    if ( doc !=null )
+                    {
+                        Element docRoot = doc.getRootElement();
+                        docRoot.add( xsdNamespace );
+                        docRoot.add( xsiNamespace );
+                    }
 
                     Element valueElement = attributeElement.addElement( "value" ).addText(
                         ParserUtils.base64Encode( value.getValue() ) );

Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/Dsmlv2Grammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/Dsmlv2Grammar.java?rev=1091840&r1=1091839&r2=1091840&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/Dsmlv2Grammar.java
(original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/Dsmlv2Grammar.java
Wed Apr 13 16:09:08 2011
@@ -706,6 +706,11 @@ public final class Dsmlv2Grammar extends
         super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROL_END_TAG.ordinal()].put(
new Tag( "control", Tag.START ),
             new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROL_END_TAG,
                 Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROL_START_TAG, controlCreation ) );
+        
+        // State: [SEARCH_REQUEST_FILTER_END_TAG] - Tag: </searchRequest>
+        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROL_END_TAG.ordinal()].put(
new Tag( "searchRequest", Tag.END ),
+            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROL_END_TAG, Dsmlv2StatesEnum.BATCHREQUEST_LOOP,
+                storeFilter ) );
 
         // State: [SEARCH_REQUEST_ATTRIBUTES_START_TAG] - Tag: </attributes>
         super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTES_START_TAG.ordinal()].put(
new Tag( "attributes", Tag.END ),
@@ -735,7 +740,7 @@ public final class Dsmlv2Grammar extends
         // State: [SEARCH_REQUEST_ATTRIBUTES_END_TAG] - Tag: </searchRequest>
         super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTES_END_TAG.ordinal()].put(
new Tag( "searchRequest", Tag.END ),
             new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTES_END_TAG,
-                Dsmlv2StatesEnum.BATCHREQUEST_LOOP, null ) );
+                Dsmlv2StatesEnum.BATCHREQUEST_LOOP, storeFilter ) );
 
         //====================================================
         //  Transitions concerning : FILTER
@@ -2693,6 +2698,11 @@ public final class Dsmlv2Grammar extends
                 container.getBatchRequest().getCurrentRequest();
             SearchRequest searchRequest = searchRequestDecorator.getDecorated();
 
+            if ( searchRequestDecorator.getFilterNode() == null )
+            {
+                throw new IllegalStateException( "No filter element present in the DSML search
request" );
+            }
+            
             searchRequest.setFilter( searchRequestDecorator.getFilterNode() );
         }
     };

Modified: directory/shared/trunk/dsml/parser/src/test/java/org/apache/directory/shared/dsmlv2/AbstractTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/test/java/org/apache/directory/shared/dsmlv2/AbstractTest.java?rev=1091840&r1=1091839&r2=1091840&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/test/java/org/apache/directory/shared/dsmlv2/AbstractTest.java
(original)
+++ directory/shared/trunk/dsml/parser/src/test/java/org/apache/directory/shared/dsmlv2/AbstractTest.java
Wed Apr 13 16:09:08 2011
@@ -80,6 +80,11 @@ public abstract class AbstractTest
             assertTrue( e.getMessage(), true );
             return;
         }
+        catch ( IllegalStateException e )
+        {
+            assertTrue( e.getMessage(), true );
+            return;
+        }
         catch ( Exception e )
         {
             fail( e.getMessage() );



Mime
View raw message