directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1063696 - in /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec: LdapEncoder.java LdapMessageGrammar.java actions/InitAttributeDescListAction.java decorators/SearchRequestDecorator.java
Date Wed, 26 Jan 2011 12:51:01 GMT
Author: elecharny
Date: Wed Jan 26 12:51:01 2011
New Revision: 1063696

URL: http://svn.apache.org/viewvc?rev=1063696&view=rev
Log:
Fixed the Filter encoding and decoding

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapEncoder.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitAttributeDescListAction.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchRequestDecorator.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapEncoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapEncoder.java?rev=1063696&r1=1063695&r2=1063696&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapEncoder.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapEncoder.java
Wed Jan 26 12:51:01 2011
@@ -1166,6 +1166,7 @@ public class LdapEncoder
         searchRequestLength += 1 + 1 + 1;
 
         // The filter
+        searchRequestDecorator.setFilter( searchRequest.getFilter() );
         searchRequestLength += searchRequestDecorator.getFilter().computeLength();
 
         // The attributes description list
@@ -2228,7 +2229,7 @@ public class LdapEncoder
             Value.encode( buffer, searchRequest.getTypesOnly() );
 
             // The filter
-            decorator.getCurrentFilter().encode( buffer );
+            decorator.getFilter().encode( buffer );
 
             // The attributeDescriptionList
             buffer.put( UniversalTag.SEQUENCE.getValue() );

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java?rev=1063696&r1=1063695&r2=1063696&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
Wed Jan 26 12:51:01 2011
@@ -5049,12 +5049,12 @@ public final class LdapMessageGrammar ex
                 public void action( Asn1Container container ) throws DecoderException
                 {
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
container;
-                    SearchRequestDecorator searchRequest = ldapMessageContainer.getSearchRequestDecorator();
+                    SearchRequestDecorator searchRequestDecorator = ldapMessageContainer.getSearchRequestDecorator();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
                     // Store the value.
-                    SubstringFilter substringFilter = ( SubstringFilter ) searchRequest.getTerminalFilter();
+                    SubstringFilter substringFilter = ( SubstringFilter ) searchRequestDecorator.getTerminalFilter();
 
                     if ( tlv.getLength() == 0 )
                     {
@@ -5069,7 +5069,7 @@ public final class LdapMessageGrammar ex
 
                         // We now have to get back to the nearest filter which
                         // is not terminal.
-                        searchRequest.setTerminalFilter( substringFilter );
+                        searchRequestDecorator.setTerminalFilter( substringFilter );
                     }
                 }
             } );
@@ -5123,12 +5123,12 @@ public final class LdapMessageGrammar ex
                 public void action( Asn1Container container ) throws DecoderException
                 {
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
container;
-                    SearchRequestDecorator searchRequest = ldapMessageContainer.getSearchRequestDecorator();
+                    SearchRequestDecorator searchRequestDecorator = ldapMessageContainer.getSearchRequestDecorator();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
                     // Store the value.
-                    SubstringFilter substringFilter = ( SubstringFilter ) searchRequest.getTerminalFilter();
+                    SubstringFilter substringFilter = ( SubstringFilter ) searchRequestDecorator.getTerminalFilter();
 
                     if ( tlv.getLength() == 0 )
                     {
@@ -5141,7 +5141,7 @@ public final class LdapMessageGrammar ex
 
                     // We now have to get back to the nearest filter which is
                     // not terminal.
-                    searchRequest.unstackFilters( container );
+                    searchRequestDecorator.unstackFilters( container );
                 }
             } );
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitAttributeDescListAction.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitAttributeDescListAction.java?rev=1063696&r1=1063695&r2=1063696&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitAttributeDescListAction.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitAttributeDescListAction.java
Wed Jan 26 12:51:01 2011
@@ -24,6 +24,8 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.Asn1Container;
 import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.decorators.SearchRequestDecorator;
+import org.apache.directory.shared.ldap.model.message.SearchRequest;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -56,6 +58,12 @@ public class InitAttributeDescListAction
     {
         LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
         
+        // Here, we have to inject the decoded filter into the SearchRequest
+        SearchRequestDecorator searchRequestDecorator = ldapMessageContainer.getSearchRequestDecorator();
+        SearchRequest searchRequest = (SearchRequest)searchRequestDecorator.getMessage();
+        
+        searchRequest.setFilter( searchRequestDecorator.getFilterNode() );
+        
         // We can have an END transition
         ldapMessageContainer.setGrammarEndAllowed( true );
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchRequestDecorator.java?rev=1063696&r1=1063695&r2=1063696&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchRequestDecorator.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchRequestDecorator.java
Wed Jan 26 12:51:01 2011
@@ -165,7 +165,18 @@ public class SearchRequestDecorator exte
      */
     public Filter getFilter()
     {
-        return transform( getSearchRequest().getFilter() );
+        return topFilter;
+    }
+
+
+    /**
+     * Gets the search filter associated with this search request.
+     *
+     * @return the expression node for the root of the filter expression tree.
+     */
+    public ExprNode getFilterNode()
+    {
+        return transform( topFilter );
     }
 
 
@@ -196,7 +207,7 @@ public class SearchRequestDecorator exte
      */
     public void setFilter( ExprNode filter )
     {
-        getSearchRequest().setFilter( filter );
+        topFilter = transform( filter );
     }
 
 
@@ -282,7 +293,6 @@ public class SearchRequestDecorator exte
             if ( localParent.getId() != parentTlvId )
             {
                 localParent = localParent.getParent();
-
             }
             else
             {



Mime
View raw message