directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1069393 - in /directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec: ./ actions/ actions/searchRequest/ actions/searchRequest/filter/
Date Thu, 10 Feb 2011 13:53:38 GMT
Author: elecharny
Date: Thu Feb 10 13:53:38 2011
New Revision: 1069393

URL: http://svn.apache.org/viewvc?rev=1069393&view=rev
Log:
Moved the last actions out of the grammar

Added:
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/InitSearchRequestAttributeDescList.java
      - copied, changed from r1069154, directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitAttributeDescListAction.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreAny.java
      - copied, changed from r1069320, directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/StoreAny.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreFinal.java
      - copied, changed from r1069320, directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/StoreFinal.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreInitial.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreMatchValue.java
      - copied, changed from r1069320, directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/StoreMatchValue.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreMatchingRuleDnAttributes.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreSubstringFilterType.java
Removed:
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitAttributeDescListAction.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/StoreAny.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/StoreFinal.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/StoreMatchValue.java
Modified:
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/StoreSearchRequestDerefAlias.java

Modified: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java?rev=1069393&r1=1069392&r2=1069393&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java (original)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java Thu Feb 10 13:53:38 2011
@@ -28,18 +28,15 @@ import static org.apache.directory.share
 import static org.apache.directory.shared.asn1.ber.tlv.UniversalTag.SET;
 
 import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.actions.CheckNotNullLength;
 import org.apache.directory.shared.asn1.ber.grammar.AbstractGrammar;
 import org.apache.directory.shared.asn1.ber.grammar.Grammar;
 import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
 import org.apache.directory.shared.asn1.ber.grammar.GrammarTransition;
-import org.apache.directory.shared.asn1.ber.tlv.BooleanDecoder;
-import org.apache.directory.shared.asn1.ber.tlv.BooleanDecoderException;
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
-import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.codec.actions.AllowGrammarEnd;
 import org.apache.directory.shared.ldap.codec.actions.CheckLengthNotNull;
-import org.apache.directory.shared.ldap.codec.actions.InitAttributeDescListAction;
 import org.apache.directory.shared.ldap.codec.actions.abandonRequest.InitAbandonRequest;
 import org.apache.directory.shared.ldap.codec.actions.addRequest.AddAddRequestAttributeType;
 import org.apache.directory.shared.ldap.codec.actions.addRequest.AddAttributeValue;
@@ -96,9 +93,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.actions.modifyRequest.StoreOperationType;
 import org.apache.directory.shared.ldap.codec.actions.modifyResponse.InitModifyResponse;
 import org.apache.directory.shared.ldap.codec.actions.searchRequest.InitSearchRequest;
-import org.apache.directory.shared.ldap.codec.actions.searchRequest.StoreAny;
-import org.apache.directory.shared.ldap.codec.actions.searchRequest.StoreFinal;
-import org.apache.directory.shared.ldap.codec.actions.searchRequest.StoreMatchValue;
+import org.apache.directory.shared.ldap.codec.actions.searchRequest.InitSearchRequestAttributeDescList;
 import org.apache.directory.shared.ldap.codec.actions.searchRequest.StoreSearchRequestAttributeDesc;
 import org.apache.directory.shared.ldap.codec.actions.searchRequest.StoreSearchRequestBaseObject;
 import org.apache.directory.shared.ldap.codec.actions.searchRequest.StoreSearchRequestDerefAlias;
@@ -119,6 +114,12 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.actions.searchRequest.filter.InitOrFilter;
 import org.apache.directory.shared.ldap.codec.actions.searchRequest.filter.InitPresentFilter;
 import org.apache.directory.shared.ldap.codec.actions.searchRequest.filter.InitSubstringsFilter;
+import org.apache.directory.shared.ldap.codec.actions.searchRequest.filter.StoreAny;
+import org.apache.directory.shared.ldap.codec.actions.searchRequest.filter.StoreFinal;
+import org.apache.directory.shared.ldap.codec.actions.searchRequest.filter.StoreInitial;
+import org.apache.directory.shared.ldap.codec.actions.searchRequest.filter.StoreMatchValue;
+import org.apache.directory.shared.ldap.codec.actions.searchRequest.filter.StoreMatchingRuleDnAttributes;
+import org.apache.directory.shared.ldap.codec.actions.searchRequest.filter.StoreSubstringFilterType;
 import org.apache.directory.shared.ldap.codec.actions.searchResultDone.InitSearchResultDone;
 import org.apache.directory.shared.ldap.codec.actions.searchResultEntry.AddAttributeType;
 import org.apache.directory.shared.ldap.codec.actions.searchResultEntry.InitSearchResultEntry;
@@ -131,7 +132,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.decorators.MessageDecorator;
 import org.apache.directory.shared.ldap.codec.decorators.SearchRequestDecorator;
 import org.apache.directory.shared.ldap.codec.search.ExtensibleMatchFilter;
-import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
 import org.apache.directory.shared.ldap.model.message.Message;
 import org.apache.directory.shared.util.Strings;
 import org.slf4j.Logger;
@@ -184,7 +184,7 @@ public final class LdapMessageGrammar<E>
             new GrammarTransition<LdapMessageContainer<MessageDecorator<? extends Message>>>(
                 LdapStatesEnum.START_STATE,
                 LdapStatesEnum.LDAP_MESSAGE_STATE,
-                SEQUENCE.getValue(),
+                SEQUENCE,
                 new InitLdapMessage() );
 
         // --------------------------------------------------------------------------------------------
@@ -800,7 +800,7 @@ public final class LdapMessageGrammar<E>
             new GrammarTransition(
                 LdapStatesEnum.OBJECT_NAME_STATE,
                 LdapStatesEnum.ATTRIBUTES_SR_STATE,
-                SEQUENCE.getValue(),
+                SEQUENCE,
                 new AllowGrammarEnd() );
 
         // --------------------------------------------------------------------------------------------
@@ -818,7 +818,7 @@ public final class LdapMessageGrammar<E>
             new GrammarTransition(
                 LdapStatesEnum.ATTRIBUTES_SR_STATE,
                 LdapStatesEnum.PARTIAL_ATTRIBUTES_LIST_STATE,
-                SEQUENCE.getValue(),
+                SEQUENCE,
                 null );
 
         // --------------------------------------------------------------------------------------------
@@ -871,7 +871,7 @@ public final class LdapMessageGrammar<E>
             new GrammarTransition(
                 LdapStatesEnum.TYPE_SR_STATE,
                 LdapStatesEnum.VALS_SR_STATE,
-                SET.getValue(),
+                SET,
                 new AllowGrammarEnd() );
 
         // --------------------------------------------------------------------------------------------
@@ -1131,7 +1131,7 @@ public final class LdapMessageGrammar<E>
             new GrammarTransition(
                 LdapStatesEnum.TYPE_MOD_STATE,
                 LdapStatesEnum.VALS_STATE,
-                SET.getValue(),
+                SET,
                 new InitAttributeVals() );
 
         // --------------------------------------------------------------------------------------------
@@ -2244,7 +2244,7 @@ public final class LdapMessageGrammar<E>
             new GrammarTransition(
                 LdapStatesEnum.CONTROLS_STATE,
                 LdapStatesEnum.CONTROL_STATE,
-                SEQUENCE.getValue(),
+                SEQUENCE,
                 new CheckLengthNotNull() );
 
         // ============================================================================================
@@ -2319,7 +2319,7 @@ public final class LdapMessageGrammar<E>
             new GrammarTransition(
                 LdapStatesEnum.CONTROL_TYPE_STATE,
                 LdapStatesEnum.CONTROL_STATE,
-                SEQUENCE.getValue(),
+                SEQUENCE,
                 new CheckLengthNotNull() );
 
         // ============================================================================================
@@ -2334,7 +2334,7 @@ public final class LdapMessageGrammar<E>
             new GrammarTransition(
                 LdapStatesEnum.CRITICALITY_STATE,
                 LdapStatesEnum.CONTROL_STATE,
-                SEQUENCE.getValue(),
+                SEQUENCE,
                 new CheckLengthNotNull() );
 
         // ============================================================================================
@@ -2349,7 +2349,7 @@ public final class LdapMessageGrammar<E>
             new GrammarTransition(
                 LdapStatesEnum.CONTROL_VALUE_STATE,
                 LdapStatesEnum.CONTROL_STATE,
-                SEQUENCE.getValue(),
+                SEQUENCE,
                 new CheckLengthNotNull() );
 
         // --------------------------------------------------------------------------------------------
@@ -3633,8 +3633,8 @@ public final class LdapMessageGrammar<E>
             new GrammarTransition(
                 LdapStatesEnum.ASSERTION_VALUE_FILTER_STATE,
                 LdapStatesEnum.ATTRIBUTE_DESCRIPTION_LIST_STATE,
-                SEQUENCE.getValue(),
-                new InitAttributeDescListAction() );
+                SEQUENCE,
+                new InitSearchRequestAttributeDescList() );
 
         // --------------------------------------------------------------------------------------------
         // Transition from Attribute Description List to AttributeDescription
@@ -3756,36 +3756,12 @@ public final class LdapMessageGrammar<E>
         //     ...
         //
         // Init substring type
-        super.transitions[LdapStatesEnum.SUBSTRING_FILTER_STATE.ordinal()][OCTET_STRING.getValue()] = new GrammarTransition(
-            LdapStatesEnum.SUBSTRING_FILTER_STATE, LdapStatesEnum.TYPE_SUBSTRING_STATE, OCTET_STRING,
-            new GrammarAction<LdapMessageContainer<SearchRequestDecorator>>( "Store substring filter type" )
-            {
-                public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException
-                {
-                    SearchRequestDecorator searchRequestDecorator = container.getMessage();
-
-                    TLV tlv = container.getCurrentTLV();
-
-                    // Store the value.
-                    SubstringFilter substringFilter = ( SubstringFilter ) searchRequestDecorator.getTerminalFilter();
-
-                    if ( tlv.getLength() == 0 )
-                    {
-                        String msg = I18n.err( I18n.ERR_04106 );
-                        LOG.error( msg );
-                        throw new DecoderException( msg );
-                    }
-                    else
-                    {
-                        String type = Strings.utf8ToString( tlv.getValue().getData() );
-                        substringFilter.setType( type );
-
-                        // We now have to get back to the nearest filter which
-                        // is not terminal.
-                        searchRequestDecorator.setTerminalFilter( substringFilter );
-                    }
-                }
-            } );
+        super.transitions[LdapStatesEnum.SUBSTRING_FILTER_STATE.ordinal()][OCTET_STRING.getValue()] =
+            new GrammarTransition(
+                LdapStatesEnum.SUBSTRING_FILTER_STATE,
+                LdapStatesEnum.TYPE_SUBSTRING_STATE,
+                OCTET_STRING,
+                new StoreSubstringFilterType() );
 
         // --------------------------------------------------------------------------------------------
         // Transition from typeSubstring to substrings
@@ -3801,21 +3777,12 @@ public final class LdapMessageGrammar<E>
         //     ...
         //
         // Init substring type
-        super.transitions[LdapStatesEnum.TYPE_SUBSTRING_STATE.ordinal()][SEQUENCE.getValue()] = new GrammarTransition(
-            LdapStatesEnum.TYPE_SUBSTRING_STATE, LdapStatesEnum.SUBSTRINGS_STATE, SEQUENCE.getValue(),
-            new GrammarAction<LdapMessageContainer<MessageDecorator<? extends Message>>>( "Substring Filter substringsSequence " )
-            {
-                public void action( LdapMessageContainer<MessageDecorator<? extends Message>> container ) throws DecoderException
-                {
-                    TLV tlv = container.getCurrentTLV();
-
-                    if ( tlv.getLength() == 0 )
-                    {
-                        LOG.error( I18n.err( I18n.ERR_04107 ) );
-                        throw new DecoderException( "The substring sequence is empty" );
-                    }
-                }
-            } );
+        super.transitions[LdapStatesEnum.TYPE_SUBSTRING_STATE.ordinal()][SEQUENCE.getValue()] =
+            new GrammarTransition(
+                LdapStatesEnum.TYPE_SUBSTRING_STATE,
+                LdapStatesEnum.SUBSTRINGS_STATE,
+                SEQUENCE,
+                new CheckNotNullLength<LdapMessageContainer<SearchRequestDecorator>>() );
 
         // --------------------------------------------------------------------------------------------
         // Transition from substrings to Initial
@@ -3827,33 +3794,12 @@ public final class LdapMessageGrammar<E>
         //         ...
         //
         // Store initial value
-        super.transitions[LdapStatesEnum.SUBSTRINGS_STATE.ordinal()][LdapConstants.SUBSTRINGS_FILTER_INITIAL_TAG] = new GrammarTransition(
-            LdapStatesEnum.SUBSTRINGS_STATE, LdapStatesEnum.INITIAL_STATE, LdapConstants.SUBSTRINGS_FILTER_INITIAL_TAG,
-            new GrammarAction<LdapMessageContainer<SearchRequestDecorator>>( "Store substring filter initial Value" )
-            {
-                public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException
-                {
-                    SearchRequestDecorator searchRequestDecorator = container.getMessage();
-
-                    TLV tlv = container.getCurrentTLV();
-
-                    // Store the value.
-                    SubstringFilter substringFilter = ( SubstringFilter ) searchRequestDecorator.getTerminalFilter();
-
-                    if ( tlv.getLength() == 0 )
-                    {
-                        String msg = I18n.err( I18n.ERR_04108 );
-                        LOG.error( msg );
-                        throw new DecoderException( msg );
-                    }
-
-                    substringFilter.setInitialSubstrings( Strings.utf8ToString(tlv.getValue().getData()) );
-
-                    // We now have to get back to the nearest filter which is
-                    // not terminal.
-                    searchRequestDecorator.unstackFilters( container );
-                }
-            } );
+        super.transitions[LdapStatesEnum.SUBSTRINGS_STATE.ordinal()][LdapConstants.SUBSTRINGS_FILTER_INITIAL_TAG] =
+            new GrammarTransition(
+                LdapStatesEnum.SUBSTRINGS_STATE,
+                LdapStatesEnum.INITIAL_STATE,
+                LdapConstants.SUBSTRINGS_FILTER_INITIAL_TAG,
+                new StoreInitial() );
 
         // --------------------------------------------------------------------------------------------
         // Transition from substrings to any
@@ -3941,8 +3887,8 @@ public final class LdapMessageGrammar<E>
             new GrammarTransition(
                 LdapStatesEnum.INITIAL_STATE,
                 LdapStatesEnum.ATTRIBUTE_DESCRIPTION_LIST_STATE,
-                SEQUENCE.getValue(),
-                new InitAttributeDescListAction() );
+                SEQUENCE,
+                new InitSearchRequestAttributeDescList() );
 
         // --------------------------------------------------------------------------------------------
         // Transition from initial to AND filter
@@ -4204,8 +4150,8 @@ public final class LdapMessageGrammar<E>
             new GrammarTransition(
                 LdapStatesEnum.ANY_STATE,
                 LdapStatesEnum.ATTRIBUTE_DESCRIPTION_LIST_STATE,
-                SEQUENCE.getValue(),
-                new InitAttributeDescListAction() );
+                SEQUENCE,
+                new InitSearchRequestAttributeDescList() );
 
         // --------------------------------------------------------------------------------------------
         // Transition from any to AND filter
@@ -4432,8 +4378,8 @@ public final class LdapMessageGrammar<E>
             new GrammarTransition(
                 LdapStatesEnum.FINAL_STATE,
                 LdapStatesEnum.ATTRIBUTE_DESCRIPTION_LIST_STATE,
-                SEQUENCE.getValue(),
-                new InitAttributeDescListAction() );
+                SEQUENCE,
+                new InitSearchRequestAttributeDescList() );
 
         // --------------------------------------------------------------------------------------------
         // Transition from final to AND filter
@@ -4869,8 +4815,8 @@ public final class LdapMessageGrammar<E>
             new GrammarTransition(
                 LdapStatesEnum.PRESENT_STATE,
                 LdapStatesEnum.ATTRIBUTE_DESCRIPTION_LIST_STATE,
-                SEQUENCE.getValue(),
-                new InitAttributeDescListAction() );
+                SEQUENCE,
+                new InitSearchRequestAttributeDescList() );
 
         // --------------------------------------------------------------------------------------------
         // Transition from Approx Match to Attribute Desc Filter
@@ -5045,49 +4991,12 @@ public final class LdapMessageGrammar<E>
         //     dnAttributes [4] BOOLEAN DEFAULT FALSE }
         //
         // Store the dnAttributes flag
-        super.transitions[LdapStatesEnum.MATCH_VALUE_STATE.ordinal()][LdapConstants.DN_ATTRIBUTES_FILTER_TAG] = new GrammarTransition(
-            LdapStatesEnum.MATCH_VALUE_STATE, LdapStatesEnum.DN_ATTRIBUTES_STATE,
-            LdapConstants.DN_ATTRIBUTES_FILTER_TAG,
-            new GrammarAction<LdapMessageContainer<SearchRequestDecorator>>( "Store matching dnAttributes Value" )
-            {
-                public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException
-                {
-                    SearchRequestDecorator searchRequest = container.getMessage();
-
-                    TLV tlv = container.getCurrentTLV();
-
-                    // Store the value.
-                    ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) searchRequest.getTerminalFilter();
-
-                    // We get the value. If it's a 0, it's a FALSE. If it's
-                    // a FF, it's a TRUE. Any other value should be an error,
-                    // but we could relax this constraint. So if we have
-                    // something
-                    // which is not 0, it will be interpreted as TRUE, but we
-                    // will generate a warning.
-                    Value value = tlv.getValue();
-
-                    try
-                    {
-                        extensibleMatchFilter.setDnAttributes( BooleanDecoder.parse( value ) );
-                    }
-                    catch ( BooleanDecoderException bde )
-                    {
-                        LOG.error( I18n
-                            .err( I18n.ERR_04110, Strings.dumpBytes(value.getData()), bde.getMessage() ) );
-
-                        throw new DecoderException( bde.getMessage() );
-                    }
-
-                    if ( IS_DEBUG )
-                    {
-                        LOG.debug( "Dn Attributes : {}", Boolean.valueOf( extensibleMatchFilter.isDnAttributes() ) );
-                    }
-
-                    // unstack the filters if needed
-                    searchRequest.unstackFilters( container );
-                }
-            } );
+        super.transitions[LdapStatesEnum.MATCH_VALUE_STATE.ordinal()][LdapConstants.DN_ATTRIBUTES_FILTER_TAG] =
+            new GrammarTransition(
+                LdapStatesEnum.MATCH_VALUE_STATE,
+                LdapStatesEnum.DN_ATTRIBUTES_STATE,
+                LdapConstants.DN_ATTRIBUTES_FILTER_TAG,
+                new StoreMatchingRuleDnAttributes() );
 
         // --------------------------------------------------------------------------------------------
         // Transition from match value to AND filter
@@ -5314,8 +5223,8 @@ public final class LdapMessageGrammar<E>
             new GrammarTransition(
                 LdapStatesEnum.MATCH_VALUE_STATE,
                 LdapStatesEnum.ATTRIBUTE_DESCRIPTION_LIST_STATE,
-                SEQUENCE.getValue(),
-                new InitAttributeDescListAction() );
+                SEQUENCE,
+                new InitSearchRequestAttributeDescList() );
 
         // --------------------------------------------------------------------------------------------
         // Transition from dnAttributes to AND filter
@@ -5542,8 +5451,8 @@ public final class LdapMessageGrammar<E>
             new GrammarTransition(
                 LdapStatesEnum.DN_ATTRIBUTES_STATE,
                 LdapStatesEnum.ATTRIBUTE_DESCRIPTION_LIST_STATE,
-                SEQUENCE.getValue(),
-                new InitAttributeDescListAction() );
+                SEQUENCE,
+                new InitSearchRequestAttributeDescList() );
     }
 
 

Copied: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/InitSearchRequestAttributeDescList.java (from r1069154, directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitAttributeDescListAction.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/InitSearchRequestAttributeDescList.java?p2=directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/InitSearchRequestAttributeDescList.java&p1=directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitAttributeDescListAction.java&r1=1069154&r2=1069393&rev=1069393&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitAttributeDescListAction.java (original)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/InitSearchRequestAttributeDescList.java Thu Feb 10 13:53:38 2011
@@ -6,18 +6,18 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
-package org.apache.directory.shared.ldap.codec.actions;
+package org.apache.directory.shared.ldap.codec.actions.searchRequest;
 
 
 import org.apache.directory.shared.asn1.DecoderException;
@@ -31,13 +31,21 @@ import org.slf4j.LoggerFactory;
 
 /**
  * The action used to initialize the AttributeDesc list
- * 
+ * <pre>
+ * SearchRequest ::= [APPLICATION 3] SEQUENCE {
+ *     ...
+ *     filter      Filter,
+ *     attributes  AttributeDescriptionList }
+ *
+ * AttributeDescriptionList ::= SEQUENCE OF
+ *     AttributeDescription
+ * </pre>
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class InitAttributeDescListAction extends GrammarAction<LdapMessageContainer<SearchRequestDecorator>>
+public class InitSearchRequestAttributeDescList extends GrammarAction<LdapMessageContainer<SearchRequestDecorator>>
 {
     /** The logger */
-    private static final Logger LOG = LoggerFactory.getLogger( InitAttributeDescListAction.class );
+    private static final Logger LOG = LoggerFactory.getLogger( InitSearchRequestAttributeDescList.class );
 
     /** Speedup for logs */
     private static final boolean IS_DEBUG = LOG.isDebugEnabled();
@@ -45,7 +53,7 @@ public class InitAttributeDescListAction
     /**
      * Instantiates a new init attribute desc list action.
      */
-    public InitAttributeDescListAction()
+    public InitSearchRequestAttributeDescList()
     {
         super( "Initialize AttributeDesc list" );
     }
@@ -58,9 +66,9 @@ public class InitAttributeDescListAction
         // Here, we have to inject the decoded filter into the SearchRequest
         SearchRequestDecorator searchRequestDecorator = container.getMessage();
         SearchRequest searchRequest = searchRequestDecorator.getDecorated();
-        
+
         searchRequest.setFilter( searchRequestDecorator.getFilterNode() );
-        
+
         // We can have an END transition
         container.setGrammarEndAllowed( true );
 

Modified: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/StoreSearchRequestDerefAlias.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/StoreSearchRequestDerefAlias.java?rev=1069393&r1=1069392&r2=1069393&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/StoreSearchRequestDerefAlias.java (original)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/StoreSearchRequestDerefAlias.java Thu Feb 10 13:53:38 2011
@@ -41,14 +41,12 @@ import org.slf4j.LoggerFactory;
  * <pre>
  * SearchRequest ::= [APPLICATION 3] SEQUENCE {
  *     ...
- *     ...
  *     derefAliases ENUMERATED {
  *         neverDerefAliases   (0),
  *         derefInSearching    (1),
  *         derefFindingBaseObj (2),
  *         derefAlways         (3) },
  *     ...
- *     ...
  * </pre>
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -65,7 +63,7 @@ public class StoreSearchRequestDerefAlia
      */
     public StoreSearchRequestDerefAlias()
     {
-        super( "Store SearchRequest derefAlias  flag" );
+        super( "Store SearchRequest derefAlias flag" );
     }
 
 
@@ -118,7 +116,4 @@ public class StoreSearchRequestDerefAlia
             }
         }
     }
-}
-
-
-
+}
\ No newline at end of file

Copied: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreAny.java (from r1069320, directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/StoreAny.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreAny.java?p2=directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreAny.java&p1=directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/StoreAny.java&r1=1069320&r2=1069393&rev=1069393&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/StoreAny.java (original)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreAny.java Thu Feb 10 13:53:38 2011
@@ -6,23 +6,23 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
-package org.apache.directory.shared.ldap.codec.actions.searchRequest;
+package org.apache.directory.shared.ldap.codec.actions.searchRequest.filter;
 
 
+import org.apache.directory.shared.asn1.DecoderException;
 import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
-import org.apache.directory.shared.asn1.DecoderException;
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.decorators.SearchRequestDecorator;
@@ -34,7 +34,14 @@ import org.slf4j.LoggerFactory;
 
 /**
  * The action used to store a any value into a substring filter
- * 
+ * <pre>
+ * SubstringFilter ::= SEQUENCE {
+ *     ...
+ *     substrings SEQUENCE OF CHOICE {
+ *         ...
+ *         any  [1] LDAPSTRING,
+ *         ...
+ * </pre>
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class StoreAny extends GrammarAction<LdapMessageContainer<SearchRequestDecorator>>

Copied: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreFinal.java (from r1069320, directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/StoreFinal.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreFinal.java?p2=directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreFinal.java&p1=directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/StoreFinal.java&r1=1069320&r2=1069393&rev=1069393&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/StoreFinal.java (original)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreFinal.java Thu Feb 10 13:53:38 2011
@@ -6,18 +6,18 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
-package org.apache.directory.shared.ldap.codec.actions.searchRequest;
+package org.apache.directory.shared.ldap.codec.actions.searchRequest.filter;
 
 
 import org.apache.directory.shared.asn1.DecoderException;
@@ -27,7 +27,6 @@ import org.apache.directory.shared.i18n.
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.decorators.SearchRequestDecorator;
 import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
-
 import org.apache.directory.shared.util.Strings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -35,7 +34,14 @@ import org.slf4j.LoggerFactory;
 
 /**
  * The action used to store a final value into a substring filter
- * 
+ * <pre>
+ * SubstringFilter ::= SEQUENCE {
+ *     ...
+ *     substrings SEQUENCE OF CHOICE {
+ *         ...
+ *         final  [2] LDAPSTRING }
+ * </pre>
+
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class StoreFinal extends GrammarAction<LdapMessageContainer<SearchRequestDecorator>>

Added: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreInitial.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreInitial.java?rev=1069393&view=auto
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreInitial.java (added)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreInitial.java Thu Feb 10 13:53:38 2011
@@ -0,0 +1,86 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.codec.actions.searchRequest.filter;
+
+
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.decorators.SearchRequestDecorator;
+import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
+import org.apache.directory.shared.util.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store an initial value into a substring filter
+ * <pre>
+ * SubstringFilter ::= SEQUENCE {
+ *     ...
+ *     substrings SEQUENCE OF CHOICE {
+ *         initial  [0] LDAPSTRING,
+ *         ...
+ * </pre>
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreInitial extends GrammarAction<LdapMessageContainer<SearchRequestDecorator>>
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( StoreInitial.class );
+
+    /**
+     * Instantiates a new store any action.
+     */
+    public StoreInitial()
+    {
+        super( "Store an initial value" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException
+    {
+        SearchRequestDecorator searchRequestDecorator = container.getMessage();
+
+        TLV tlv = container.getCurrentTLV();
+
+        // Store the value.
+        SubstringFilter substringFilter = ( SubstringFilter ) searchRequestDecorator.getTerminalFilter();
+
+        if ( tlv.getLength() == 0 )
+        {
+            String msg = I18n.err( I18n.ERR_04108 );
+            LOG.error( msg );
+            throw new DecoderException( msg );
+        }
+
+        substringFilter.setInitialSubstrings( Strings.utf8ToString(tlv.getValue().getData()) );
+
+        // We now have to get back to the nearest filter which is
+        // not terminal.
+        searchRequestDecorator.unstackFilters( container );
+    }
+}

Copied: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreMatchValue.java (from r1069320, directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/StoreMatchValue.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreMatchValue.java?p2=directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreMatchValue.java&p1=directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/StoreMatchValue.java&r1=1069320&r2=1069393&rev=1069393&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/StoreMatchValue.java (original)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreMatchValue.java Thu Feb 10 13:53:38 2011
@@ -6,23 +6,23 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
-package org.apache.directory.shared.ldap.codec.actions.searchRequest;
+package org.apache.directory.shared.ldap.codec.actions.searchRequest.filter;
 
 
+import org.apache.directory.shared.asn1.DecoderException;
 import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
-import org.apache.directory.shared.asn1.DecoderException;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.decorators.SearchRequestDecorator;
 import org.apache.directory.shared.ldap.codec.search.ExtensibleMatchFilter;
@@ -33,7 +33,16 @@ import org.slf4j.LoggerFactory;
 
 /**
  * The action used to store a match value
- * 
+ * <pre>
+ * Filter ::= CHOICE {
+ *     ...
+ *     extensibleMatch  [9] MatchingRuleAssertion }
+ *
+ * MatchingRuleAssertion ::= SEQUENCE {
+ *     ...
+ *     matchValue [3] AssertionValue,
+ *     ...
+ * </pre>
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class StoreMatchValue extends GrammarAction<LdapMessageContainer<SearchRequestDecorator>>

Added: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreMatchingRuleDnAttributes.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreMatchingRuleDnAttributes.java?rev=1069393&view=auto
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreMatchingRuleDnAttributes.java (added)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreMatchingRuleDnAttributes.java Thu Feb 10 13:53:38 2011
@@ -0,0 +1,106 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.codec.actions.searchRequest.filter;
+
+
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.BooleanDecoder;
+import org.apache.directory.shared.asn1.ber.tlv.BooleanDecoderException;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.ber.tlv.Value;
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.decorators.SearchRequestDecorator;
+import org.apache.directory.shared.ldap.codec.search.ExtensibleMatchFilter;
+import org.apache.directory.shared.util.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a matchingRuleAssertion dnAttributes
+ * <pre>
+ * Filter ::= CHOICE {
+ *     ...
+ *     extensibleMatch  [9] MatchingRuleAssertion }
+ *
+ * MatchingRuleAssertion ::= SEQUENCE {
+ *     ...
+ *     dnAttributes [4] BOOLEAN DEFAULT FALSE }
+ * </pre>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreMatchingRuleDnAttributes extends GrammarAction<LdapMessageContainer<SearchRequestDecorator>>
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( StoreMatchingRuleDnAttributes.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+
+    /**
+     * Instantiates a new StoreMatchingRuleDnAttributes.
+     */
+    public StoreMatchingRuleDnAttributes()
+    {
+        super( "Store matchingRuleAssertion dnAttributes" );
+    }
+
+
+    public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException
+    {
+        SearchRequestDecorator searchRequest = container.getMessage();
+
+        TLV tlv = container.getCurrentTLV();
+
+        // Store the value.
+        ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) searchRequest.getTerminalFilter();
+
+        // We get the value. If it's a 0, it's a FALSE. If it's
+        // a FF, it's a TRUE. Any other value should be an error,
+        // but we could relax this constraint. So if we have
+        // something
+        // which is not 0, it will be interpreted as TRUE, but we
+        // will generate a warning.
+        Value value = tlv.getValue();
+
+        try
+        {
+            extensibleMatchFilter.setDnAttributes( BooleanDecoder.parse( value ) );
+        }
+        catch ( BooleanDecoderException bde )
+        {
+            LOG.error( I18n
+                .err( I18n.ERR_04110, Strings.dumpBytes(value.getData()), bde.getMessage() ) );
+
+            throw new DecoderException( bde.getMessage() );
+        }
+
+        if ( IS_DEBUG )
+        {
+            LOG.debug( "Dn Attributes : {}", Boolean.valueOf( extensibleMatchFilter.isDnAttributes() ) );
+        }
+
+        // unstack the filters if needed
+        searchRequest.unstackFilters( container );
+    }
+}

Added: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreSubstringFilterType.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreSubstringFilterType.java?rev=1069393&view=auto
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreSubstringFilterType.java (added)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchRequest/filter/StoreSubstringFilterType.java Thu Feb 10 13:53:38 2011
@@ -0,0 +1,91 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.codec.actions.searchRequest.filter;
+
+
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.decorators.SearchRequestDecorator;
+import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
+import org.apache.directory.shared.util.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store the Substring Filter type
+ * <pre>
+ * Filter ::= CHOICE {
+ *     ...
+ *     substrings  [4] SubstringFilter,
+ *     ...
+ *
+ * SubstringFilter ::= SEQUENCE {
+ *     type   AttributeDescription,
+ *     ...
+ * </pre>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreSubstringFilterType extends GrammarAction<LdapMessageContainer<SearchRequestDecorator>>
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( StoreSubstringFilterType.class );
+
+    /**
+     * Instantiates a new action.
+     */
+    public StoreSubstringFilterType()
+    {
+        super( "Store Substring filter type" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException
+    {
+        SearchRequestDecorator searchRequestDecorator = container.getMessage();
+
+        TLV tlv = container.getCurrentTLV();
+
+        // Store the value.
+        SubstringFilter substringFilter = ( SubstringFilter ) searchRequestDecorator.getTerminalFilter();
+
+        if ( tlv.getLength() == 0 )
+        {
+            String msg = I18n.err( I18n.ERR_04106 );
+            LOG.error( msg );
+            throw new DecoderException( msg );
+        }
+        else
+        {
+            String type = Strings.utf8ToString( tlv.getValue().getData() );
+            substringFilter.setType( type );
+
+            // We now have to get back to the nearest filter which
+            // is not terminal.
+            searchRequestDecorator.setTerminalFilter( substringFilter );
+        }
+    }
+}



Mime
View raw message