You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by er...@apache.org on 2006/07/23 13:33:03 UTC

svn commit: r424718 - /directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/

Author: ersiner
Date: Sun Jul 23 04:33:03 2006
New Revision: 424718

URL: http://svn.apache.org/viewvc?rev=424718&view=rev
Log:
Setup for new Stored Procedure Call Request Codec.

Added:
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCall.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallContainer.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallDecoder.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallGrammar.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallStatesEnum.java

Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCall.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCall.java?rev=424718&view=auto
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCall.java (added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCall.java Sun Jul 23 04:33:03 2006
@@ -0,0 +1,235 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed 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.extended.operations;
+
+
+import java.nio.ByteBuffer;
+import java.util.List;
+
+import org.apache.directory.shared.asn1.Asn1Object;
+import org.apache.directory.shared.asn1.codec.EncoderException;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+/**
+ * A bean representing a Stored Procedure Call Extended Operation.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoredProcedureCall extends Asn1Object
+{
+
+    private String name;
+
+    /** Language/Scheme option */
+    private String languageScheme;
+
+    /**  Search Context option */
+    private SearchContext searchContext;
+
+    private List/*<StoredProcedureParameter>*/parameters;
+
+    private transient StoredProcedureParameter currentParameter;
+
+    private transient int storedProcedureCallRequestLength;
+
+    private transient int languageSchemeLength;
+
+    private transient int searchContextLength;
+
+    private transient int parametersLength;
+
+
+    /**
+     * TODO: Add more length variables.
+     */
+
+    public StoredProcedureParameter getCurrentParameter()
+    {
+        return currentParameter;
+    }
+
+
+    public void setCurrentParameter( StoredProcedureParameter currentParameter )
+    {
+        this.currentParameter = currentParameter;
+    }
+
+
+    public String getLanguageScheme()
+    {
+        return languageScheme;
+    }
+
+
+    public void setLanguageScheme( String languageScheme )
+    {
+        this.languageScheme = languageScheme;
+    }
+
+
+    public String getName()
+    {
+        return name;
+    }
+
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+
+    public List getParameters()
+    {
+        return parameters;
+    }
+
+
+    public void setParameters( List parameters )
+    {
+        this.parameters = parameters;
+    }
+
+
+    public SearchContext getSearchContext()
+    {
+        return searchContext;
+    }
+
+
+    public void setSearchContext( SearchContext searchContext )
+    {
+        this.searchContext = searchContext;
+    }
+
+    public static class SearchContext
+    {
+        private LdapDN context;
+
+        private Scope scope = Scope.BASE_OBJECT;
+
+
+        public LdapDN getContext()
+        {
+            return context;
+        }
+
+
+        public void setContext( LdapDN context )
+        {
+            this.context = context;
+        }
+
+
+        public Scope getScope()
+        {
+            return scope;
+        }
+
+
+        public void setScope( Scope scope )
+        {
+            this.scope = scope;
+        }
+
+        public static class Scope
+        {
+            public static Scope BASE_OBJECT = new Scope( "baseObject" );
+
+            public static Scope SINGLE_LEVEL = new Scope( "scopeLevel" );
+
+            public static Scope WHOLE_SUBTREE = new Scope( "wholeSubtree" );
+
+            private String name;
+
+
+            private Scope( String name )
+            {
+                this.name = name;
+            }
+
+
+            public String getName()
+            {
+                return name;
+            }
+
+
+            public String toString()
+            {
+                return getName();
+            }
+
+        }
+
+    }
+
+    public static class StoredProcedureParameter
+    {
+        private byte[] type;
+
+        private byte[] value;
+
+
+        public byte[] getType()
+        {
+            return type;
+        }
+
+
+        public void setType( byte[] type )
+        {
+            this.type = type;
+        }
+
+
+        public byte[] getValue()
+        {
+            return value;
+        }
+
+
+        public void setValue( byte[] value )
+        {
+            this.value = value;
+        }
+    }
+
+
+    public int computeLength()
+    {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        // TODO Auto-generated method stub
+        return super.encode( buffer );
+    }
+
+
+    public String toString()
+    {
+        // TODO Auto-generated method stub
+        return super.toString();
+    }
+
+}

Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallContainer.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallContainer.java?rev=424718&view=auto
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallContainer.java (added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallContainer.java Sun Jul 23 04:33:03 2006
@@ -0,0 +1,89 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed 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.extended.operations;
+
+
+import org.apache.directory.shared.asn1.ber.AbstractContainer;
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.IGrammar;
+
+
+/**
+ * A container for the StoredProcedureCall codec.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoredProcedureCallContainer extends AbstractContainer implements IAsn1Container
+{
+    // ~ Instance fields ------------------------------------------------------
+
+    /** StoredProcedureCall */
+    private StoredProcedureCall storedProcedureCall;
+
+
+    // ~ Constructors ---------------------------------------------------------
+
+    public StoredProcedureCallContainer()
+    {
+        super();
+        currentGrammar = 0;
+        grammars = new IGrammar[1];
+        grammarStack = new IGrammar[1];
+        stateStack = new int[1];
+        nbGrammars = 0;
+
+        grammars[StoredProcedureCallStatesEnum.STORED_PROCEDURE_CALL_GRAMMAR] = StoredProcedureCallGrammar
+            .getInstance();
+
+        grammarStack[currentGrammar] = grammars[StoredProcedureCallStatesEnum.STORED_PROCEDURE_CALL_GRAMMAR];
+
+        states = StoredProcedureCallStatesEnum.getInstance();
+    }
+
+
+    // ~ Methods
+    // ------------------------------------------------------------------------------------
+    /**
+     * @return Returns the ldapMessage.
+     */
+    public StoredProcedureCall getStoredProcedureCall()
+    {
+        return storedProcedureCall;
+    }
+
+
+    /**
+     * Set a StoredProcedureCall object into the container.
+     * It will be completed by the ldapDecoder.
+     * 
+     * @param ldapMessage
+     *            The ldapMessage to set.
+     */
+    public void setStoredProcedureCall( StoredProcedureCall storedProcedureCall )
+    {
+        this.storedProcedureCall = storedProcedureCall;
+    }
+
+
+    public void clean()
+    {
+        super.clean();
+
+        storedProcedureCall = null;
+    }
+}

Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallDecoder.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallDecoder.java?rev=424718&view=auto
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallDecoder.java (added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallDecoder.java Sun Jul 23 04:33:03 2006
@@ -0,0 +1,36 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed 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.extended.operations;
+
+
+import org.apache.directory.shared.asn1.ber.Asn1Decoder;
+
+
+/**
+ * StoredProcedureCall Decoder.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoredProcedureCallDecoder extends Asn1Decoder
+{
+
+    public StoredProcedureCallDecoder()
+    {
+    }
+
+}

Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallGrammar.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallGrammar.java?rev=424718&view=auto
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallGrammar.java (added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallGrammar.java Sun Jul 23 04:33:03 2006
@@ -0,0 +1,74 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed 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.extended.operations;
+
+
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.AbstractGrammar;
+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.grammar.IGrammar;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.apache.log4j.Logger;
+import org.apache.directory.shared.ldap.codec.extended.operations.StoredProcedureCall.StoredProcedureParameter;
+
+
+/**
+ * ASN.1 BER Grammar for Stored Procedure Call Extended Operation
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoredProcedureCallGrammar extends AbstractGrammar implements IGrammar
+{
+    // ~ Static fields/initializers -------------------------------------------
+
+    /** The logger */
+    private static final Logger log = Logger.getLogger( StoredProcedureCallGrammar.class );
+
+    /** The instance of grammar. StoredProcedureGrammar is a singleton. */
+    private static IGrammar instance = new StoredProcedureCallGrammar();
+
+
+    // ~ Constructors ---------------------------------------------------------
+
+    /**
+     * Creates a new StoredProcedureCallGrammar object.
+     */
+    private StoredProcedureCallGrammar()
+    {
+        /**
+         * TODO: Complete the grammar.
+         */
+    }
+
+
+    // ~ Methods --------------------------------------------------------------
+
+    /**
+     * Get the instance of this grammar.
+     *
+     * @return An instance on the StoredProcedureCall Grammar
+     */
+    public static IGrammar getInstance()
+    {
+        return instance;
+    }
+}

Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallStatesEnum.java?rev=424718&view=auto
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallStatesEnum.java (added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCallStatesEnum.java Sun Jul 23 04:33:03 2006
@@ -0,0 +1,219 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed 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.extended.operations;
+
+
+import org.apache.directory.shared.asn1.ber.grammar.IGrammar;
+import org.apache.directory.shared.asn1.ber.grammar.IStates;
+
+
+/**
+ * Constants for StoredProcedureCallGrammar.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoredProcedureCallStatesEnum implements IStates
+{
+    // ~ Static fields/initializers -------------------------------------------
+
+    //=========================================================================
+    // Tags and values
+    //=========================================================================
+    /** StoredProcedureCall Tag */
+    public static int STORED_PROCEDURE_CALL_TAG = 0;
+
+    /** StoredProcedureCall Value */
+    public static int STORED_PROCEDURE_CALL_VALUE = 1;
+
+    // Name -------------------------------------------------------------------
+    /** Name Tag */
+    public static int NAME_TAG = 2;
+
+    /** Name Value */
+    public static int NAME_VALUE = 3;
+
+    // Options ----------------------------------------------------------------
+    /** Options Tag */
+    public static int OPTIONS_TAG = 4;
+
+    /** Options Value */
+    public static int OPTIONS_VALUE = 5;
+
+    // --- Language Scheme ----------------------------------------------------
+    /** Language Scheme Tag */
+    public static int LANGUAGE_SCHEME_TAG = 6;
+
+    /** Language Scheme Value */
+    public static int LANGUAGE_SCHEME_VALUE = 7;
+
+    // --- Search Context -----------------------------------------------------
+    /** Search Context Tag */
+    public static int SEARCH_CONTEXT_TAG = 8;
+
+    /** Search Context Value */
+    public static int SEARCH_CONTEXT_VALUE = 9;
+
+    // ------ Context ---------------------------------------------------------
+    /** Context Tag */
+    public static int CONTEXT_TAG = 10;
+
+    /** Context Value */
+    public static int CONTEXT_VALUE = 11;
+
+    // ------ Scope -----------------------------------------------------------
+    /** Scope Tag */
+    public static int SCOPE_TAG = 12;
+
+    /** Scope Value */
+    public static int SCOPE_VALUE = 13;
+
+    // Parameters -------------------------------------------------------------
+    /** Parameters Tag */
+    public static int PARAMETERS_TAG = 14;
+
+    /** Parameters Value */
+    public static int PARAMETERS_VALUE = 15;
+
+    // --- Parameter ----------------------------------------------------------
+    /** Parameter Tag */
+    public static int PARAMETER_TAG = 16;
+
+    /** Parameter Value */
+    public static int PARAMETER_VALUE = 17;
+
+    // ------ Parameter type --------------------------------------------------
+    /** Parameter type Tag */
+    public static int PARAMETER_TYPE_TAG = 18;
+
+    /** Parameter type Value */
+    public static int PARAMETER_TYPE_VALUE = 19;
+
+    // ------ Parameter value -------------------------------------------------
+    /** Parameter value Tag */
+    public static int PARAMETER_VALUE_TAG = 20;
+
+    /** Parameter value Value */
+    public static int PARAMETER_VALUE_VALUE = 21;
+
+    public static int LAST_STORED_PROCEDURE_CALL_STATE = 22;
+
+    //=========================================================================
+    // Grammar declarations
+    //=========================================================================
+    /** Ldap Message grammar */
+    public static final int STORED_PROCEDURE_CALL_GRAMMAR_SWITCH = 0x0100;
+
+    /** Ldap Message grammar number */
+    public static final int STORED_PROCEDURE_CALL_GRAMMAR = 0;
+
+    /** The total number of grammars used */
+    public static final int NB_GRAMMARS = 1;
+
+    //=========================================================================
+    // Grammar switches debug strings 
+    //=========================================================================
+    /** A string representation of grammars */
+    private static String[] GrammarSwitchString = new String[]
+        { "STORED_PROCEDURE_CALL_GRAMMAR_SWITCH", };
+
+    //=========================================================================
+    // States debug strings 
+    //=========================================================================
+    /** A string representation of all the states */
+    private static String[] StoredProcedureCallString = new String[]
+        { "STORED_PROCEDURE_CALL_TAG", "STORED_PROCEDURE_CALL_VALUE",
+          "NAME_TAG", "NAME_VALUE",
+          "OPTIONS_TAG", "OPTIONS_VALUE",
+          "LANGUAGE_SCHEME_TAG", "LANGUAGE_SCHEME_VALUE",
+          "SEARCH_CONTEXT_TAG", "SEARCH_CONTEXT_VALUE",
+          "CONTEXT_TAG", "CONTEXT_VALUE",
+          "SCOPE_TAG", "SCOPE_VALUE",
+          "PARAMETERS_TAG", "PARAMETERS_VALUE",
+          "PARAMETER_TYPE_TAG", "PARAMETER_TYPE_VALUE",
+          "PARAMETER_VALUE_TAG", "PARAMETER_VALUE_VALUE" };
+
+    /** The instance */
+    private static StoredProcedureCallStatesEnum instance = new StoredProcedureCallStatesEnum();
+
+
+    // ~ Constructors ---------------------------------------------------------
+
+    private StoredProcedureCallStatesEnum()
+    {
+    }
+
+
+    // ~ Methods --------------------------------------------------------------
+
+    public static IStates getInstance()
+    {
+        return instance;
+    }
+
+
+    public String getGrammarName( int grammar )
+    {
+        switch ( grammar )
+        {
+            case STORED_PROCEDURE_CALL_GRAMMAR:
+                return "STORED_PROCEDURE_CALL_GRAMMAR";
+
+            default:
+                return "UNKNOWN";
+        }
+    }
+
+
+    public String getGrammarName( IGrammar grammar )
+    {
+        if ( grammar instanceof StoredProcedureGrammar )
+        {
+            return "STORED_PROCEDURE_GRAMMAR";
+        }
+        else
+        {
+            return "UNKNOWN GRAMMAR";
+        }
+    }
+
+
+    public String getState( int grammar, int state )
+    {
+
+        if ( ( state & GRAMMAR_SWITCH_MASK ) != 0 )
+        {
+            return ( state == END_STATE )
+                ? "END_STATE"
+                : GrammarSwitchString[( ( state & GRAMMAR_SWITCH_MASK ) >> 8 ) - 1];
+        }
+        else
+        {
+            switch ( grammar )
+            {
+
+                case STORED_PROCEDURE_CALL_GRAMMAR:
+                    return( ( state == GRAMMAR_END )
+                        ? "STORED_PROCEDURE_CALL_END_STATE"
+                        : StoredProcedureCallString[state] );
+
+                default:
+                    return "UNKNOWN";
+            }
+        }
+    }
+}