directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r483930 [1/3] - in /directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src: main/java/org/apache/directory/ldapstudio/dsmlv2/ test/java/org/apache/directory/ldapstudio/dsmlv2/addRequest/ test/java/org/apache/directory/ldapstudio...
Date Fri, 08 Dec 2006 11:08:17 GMT
Author: pamarcelot
Date: Fri Dec  8 03:08:09 2006
New Revision: 483930

URL: http://svn.apache.org/viewvc?view=rev&rev=483930
Log:
Updating DSML Parser. Resolving Jira DIRSTUDIO-2 (DSML Parser doesn't parse well base64 Data).

Base64 encoded values can be found in the following tags :
- <initial>, <any>, <final> of a Substrings Filter
- <value> in a ExtensibleMatch Filter
- <value> in a EqualityMatch Filter, GreaterOrEqual Filter, LessOrEqual Filter, ApproxMatch Filter
- <value> in a <assertion> tag in a CompareRequest
- <value> in a <attr> tag in SearchResultEntry and AddRequest
- <value> in a <modification> tag in ModifyRequest

Resolving problem where an exception was thrown if a value in a response was empty (<value></value>)

Added:
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/ParserUtils.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/addRequest/request_with_1_attr_with_base64_value.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/addResponse/response_with_1_control_empty_value.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/addResponse/response_with_1_empty_referral.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/addResponse/response_with_empty_error_message.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/authResponse/response_with_1_control_empty_value.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/authResponse/response_with_1_empty_referral.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/authResponse/response_with_empty_error_message.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/compareRequest/request_with_1_complete_assertion_base64_value.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/compareResponse/response_with_1_control_empty_value.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/compareResponse/response_with_1_empty_referral.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/compareResponse/response_with_empty_error_message.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/delResponse/response_with_1_control_empty_value.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/delResponse/response_with_1_empty_referral.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/delResponse/response_with_empty_error_message.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/errorResponse/response_with_empty_message.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/extendedRequest/request_with_base64_requestValue.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/extendedResponse/response_with_1_control_empty_value.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/extendedResponse/response_with_1_empty_referral.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/extendedResponse/response_with_base64_response.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/extendedResponse/response_with_empty_error_message.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/extendedResponse/response_with_empty_response.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/extendedResponse/response_with_empty_responseName.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/modDNResponse/response_with_1_control_empty_value.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/modDNResponse/response_with_1_empty_referral.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/modDNResponse/response_with_empty_error_message.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/modifyRequest/request_with_1_modification_base64_value.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/modifyResponse/response_with_1_control_empty_value.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/modifyResponse/response_with_1_empty_referral.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/modifyResponse/response_with_empty_error_message.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/searchRequest/filters/request_with_approxMatch_base64_value.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/searchRequest/filters/request_with_equalityMatch_base64_value.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/searchRequest/filters/request_with_extensibleMatch_base64_value.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/searchRequest/filters/request_with_greaterOrEqual_base64_value.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/searchRequest/filters/request_with_lessOrEqual_base64_value.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/searchRequest/filters/request_with_substrings_1_base64_any.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/searchRequest/filters/request_with_substrings_1_base64_final.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/searchRequest/filters/request_with_substrings_1_base64_initial.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/searchResponse/searchResultDone/response_with_1_control_empty_value.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/searchResponse/searchResultDone/response_with_1_empty_referral.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/searchResponse/searchResultDone/response_with_empty_error_message.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/searchResponse/searchResultEntry/response_with_1_attr_1_base64_value.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/searchResponse/searchResultEntry/response_with_1_attr_1_empty_value.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/searchResponse/searchResultEntry/response_with_1_control_empty_value.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/searchResponse/searchResultReference/response_with_1_control_empty_value.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/searchResponse/searchResultReference/response_with_1_empty_ref.xml
Modified:
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2Grammar.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2Parser.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseGrammar.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseParser.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/addRequest/AddRequestTest.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/addResponse/AddResponseTest.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/authResponse/AuthResponseTest.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/compareRequest/CompareRequestTest.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/compareResponse/CompareResponseTest.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/delResponse/DelResponseTest.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/errorResponse/ErrorResponseTest.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/extendedRequest/ExtendedRequestTest.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/extendedResponse/ExtendedResponseTest.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/modDNResponse/ModifyDNResponseTest.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/modifyRequest/ModifyRequestTest.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/modifyResponse/ModifyResponseTest.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/searchRequest/SearchRequestTest.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/searchResponse/searchResultDone/SearchResultDoneTest.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/searchResponse/searchResultEntry/SearchResultEntryTest.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/searchResponse/searchResultReference/SearchResultReferenceTest.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/extendedRequest/request_with_2_requestValue.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/extendedRequest/request_with_empty_requestName.xml
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/resources/org/apache/directory/ldapstudio/dsmlv2/extendedRequest/request_with_requestValue.xml

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2Grammar.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2Grammar.java?view=diff&rev=483930&r1=483929&r2=483930
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2Grammar.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2Grammar.java Fri Dec  8 03:08:09 2006
@@ -67,9 +67,6 @@
  */
 public class Dsmlv2Grammar extends AbstractGrammar implements IGrammar
 {
-    private static final String XML_SCHEMA_URI = "http://www.w3c.org/2001/XMLSchema";
-    private static final String XML_SCHEMA_INSTANCE_URI = "http://www.w3c.org/2001/XMLSchema-instance";
-
     /** The instance of grammar. Dsmlv2Grammar is a singleton */
     private static Dsmlv2Grammar instance = new Dsmlv2Grammar();
 
@@ -1248,10 +1245,21 @@
             XmlPullParser xpp = container.getParser();
             try
             {
+                // We have to catch the type Attribute Value before going to the next Text node
+                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
+                
+                // Getting the value
                 String nextText = xpp.nextText();
                 if ( !nextText.equals( "" ) )
                 {
-                    addRequest.addAttributeValue( nextText.trim() );
+                    if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
+                    {
+                        addRequest.addAttributeValue( Base64.decode( nextText.trim().toCharArray() ) );
+                    }
+                    else
+                    {
+                        addRequest.addAttributeValue( nextText.trim() );
+                    }
                 }
             }
             catch ( IOException e )
@@ -1399,10 +1407,22 @@
             XmlPullParser xpp = container.getParser();
             try
             {
+                // We have to catch the type Attribute Value before going to the next Text node
+                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
+                
+                // Getting the value
                 String nextText = xpp.nextText();
                 if ( !nextText.equals( "" ) )
                 {
-                    compareRequest.setAssertionValue( nextText.trim() );
+                    if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
+                    {
+                        compareRequest.setAssertionValue( Base64.decode( nextText.trim().toCharArray() ) );
+                    }
+                    else
+                    {
+
+                        compareRequest.setAssertionValue( nextText.trim() );
+                    }
                 }
             }
             catch ( IOException e )
@@ -1534,10 +1554,21 @@
             XmlPullParser xpp = container.getParser();
             try
             {
+                // We have to catch the type Attribute Value before going to the next Text node
+                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
+                
+                // Getting the value
                 String nextText = xpp.nextText();
                 if ( !nextText.equals( "" ) )
                 {
-                    extendedRequest.setRequestValue( nextText.trim().getBytes() );
+                    if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
+                    {
+                        extendedRequest.setRequestValue( Base64.decode( nextText.trim().toCharArray() ) );
+                    }
+                    else
+                    {
+                        extendedRequest.setRequestValue( nextText.trim().getBytes() );
+                    }
                 }
             }
             catch ( IOException e )
@@ -1759,8 +1790,21 @@
             XmlPullParser xpp = container.getParser();
             try
             {
+                // We have to catch the type Attribute Value before going to the next Text node
+                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
+                
+                // Getting the value
                 String nextText = xpp.nextText();
-                modifyRequest.addAttributeValue( nextText.trim() );
+                // We are testing if nextText equals "" since a modification can be "".
+                
+                if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
+                {
+                    modifyRequest.addAttributeValue( Base64.decode( nextText.trim().toCharArray() ) );
+                }
+                else
+                {
+                    modifyRequest.addAttributeValue( nextText.trim() );
+                }
             }
             catch ( IOException e )
             {
@@ -2007,10 +2051,21 @@
             XmlPullParser xpp = container.getParser();
             try
             {
+                // We have to catch the type Attribute Value before going to the next Text node
+                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
+                
+                // Getting the value
                 String nextText = xpp.nextText();
                 if ( !nextText.equals( "" ) )
                 {
-                    substringFilter.setInitialSubstrings( nextText.trim() );
+                    if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
+                    {
+                        substringFilter.setInitialSubstrings( new String( Base64.decode( nextText.trim().toCharArray() ) ) );
+                    }
+                    else
+                    {
+                        substringFilter.setInitialSubstrings( nextText.trim() );
+                    }
                 }
             }
             catch ( IOException e )
@@ -2033,10 +2088,21 @@
             XmlPullParser xpp = container.getParser();
             try
             {
+                // We have to catch the type Attribute Value before going to the next Text node
+                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
+                
+                // Getting the value
                 String nextText = xpp.nextText();
                 if ( !nextText.equals( "" ) )
                 {
-                    substringFilter.addAnySubstrings( nextText.trim() );
+                    if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
+                    {
+                        substringFilter.addAnySubstrings( new String( Base64.decode( nextText.trim().toCharArray() ) ) );
+                    }
+                    else
+                    {
+                        substringFilter.addAnySubstrings( nextText.trim() );
+                    }
                 }
             }
             catch ( IOException e )
@@ -2059,10 +2125,21 @@
             XmlPullParser xpp = container.getParser();
             try
             {
+                // We have to catch the type Attribute Value before going to the next Text node
+                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
+                
+                // Getting the value
                 String nextText = xpp.nextText();
                 if ( !nextText.equals( "" ) )
                 {
-                    substringFilter.setFinalSubstrings( nextText.trim() );
+                    if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
+                    {
+                        substringFilter.setFinalSubstrings( new String( Base64.decode( nextText.trim().toCharArray() ) ) );
+                    }
+                    else
+                    {
+                        substringFilter.setFinalSubstrings( nextText.trim() );
+                    }
                 }
             }
             catch ( IOException e )
@@ -2390,10 +2467,21 @@
             XmlPullParser xpp = container.getParser();
             try
             {
+                // We have to catch the type Attribute Value before going to the next Text node
+                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
+                
+                // Getting the value
                 String nextText = xpp.nextText();
                 if ( !nextText.equals( "" ) )
                 {
-                    assertion.setAssertionValue( nextText.trim() );
+                    if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
+                    {
+                        assertion.setAssertionValue( Base64.decode( nextText.trim().toCharArray() ) );
+                    }
+                    else
+                    {
+                        assertion.setAssertionValue( nextText.trim() );
+                    }
                 }
             }
             catch ( IOException e )
@@ -2514,10 +2602,21 @@
             XmlPullParser xpp = container.getParser();
             try
             {
+                // We have to catch the type Attribute Value before going to the next Text node
+                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
+                
+                // Getting the value
                 String nextText = xpp.nextText();
                 if ( !nextText.equals( "" ) )
                 {
-                    filter.setMatchValue( nextText.trim() );
+                    if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
+                    {
+                        filter.setMatchValue( Base64.decode( nextText.trim().toCharArray() ) );
+                    }
+                    else
+                    {
+                        filter.setMatchValue( nextText.trim() );
+                    }
                 }
             }
             catch ( IOException e )
@@ -2545,9 +2644,11 @@
             attributeValue = xpp.getAttributeValue( "", "type" );
             if ( attributeValue != null )
             {
-                // TODO Add a verification for a match with NumericOid format (see
-                // DSMLv2 specifications)
-                control.setControlType( attributeValue ); // TODO LDAPString uses UTF8 bytes, so the charset must be verified before doing this.  
+                if ( !OID.isOID( attributeValue ) )
+                {
+                    throw new XmlPullParserException( "Incorrect value for 'type' attribute. This is not an OID.", xpp, null );
+                }
+                control.setControlType( attributeValue );
             }
             else
             {
@@ -2585,13 +2686,14 @@
             XmlPullParser xpp = container.getParser();
             try
             {
-                String typeValue = getXsiTypeAttributeValue( xpp );
+                // We have to catch the type Attribute Value before going to the next Text node
+                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
                 
                 // Getting the value
                 String nextText = xpp.nextText();
                 if ( !nextText.equals( "" ) )
                 {
-                    if ( isBase64BinaryValue( xpp, typeValue ) )
+                    if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
                     {
                         control.setControlValue( Base64.decode( nextText.trim().toCharArray() ) );
                     }
@@ -2617,48 +2719,5 @@
     public static Dsmlv2Grammar getInstance()
     {
         return instance;
-    }
-    
-    /**
-     * Returns the value of the attribute 'type' of the "XMLSchema-instance' namespace if it exists
-     *
-     * @param xpp the XPP parser to use
-     * @return the value of the attribute 'type' of the "XMLSchema-instance' namespace if it exists
-     */
-    private String getXsiTypeAttributeValue( XmlPullParser xpp )
-    {
-        String type = null;
-        int nbAttributes = xpp.getAttributeCount();
-        for ( int i = 0; i < nbAttributes; i++ )
-        {
-            // Checking if the attribute 'type' from XML Schema Instance namespace is used.
-            if ( xpp.getAttributeName( i ).equals( "type" ) && xpp.getNamespace( xpp.getAttributePrefix( i ) ).equals( XML_SCHEMA_INSTANCE_URI ))
-            {
-                type = xpp.getAttributeValue( i );
-                break;
-            }
-        }
-        return type;
-    }
-    
-    /**
-     * Returns true if the value of the current tag is Base64Binary encoded
-     *
-     * @param parser the XPP parser to use
-     * @param attrValue the attribute value
-     * @return true if the value of the current tag is Base64BinaryEncoded, false if not
-     */
-    private boolean isBase64BinaryValue( XmlPullParser parser, String attrValue )
-    {
-        if ( attrValue == null )
-        {
-            return false;
-        }
-        // We are looking for something that should look like that: "aNameSpace:base64Binary"
-        // We split the String. The first element should be the namespace prefix and the second "base64Binary"
-        String [] splitedString = attrValue.split( ":" );
-        return ( splitedString.length == 2 ) 
-                && ( XML_SCHEMA_URI.equals( parser.getNamespace( splitedString[0] ) ) ) 
-                && ( "base64Binary".equals( splitedString[1] ) );
     }
 }

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2Parser.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2Parser.java?view=diff&rev=483930&r1=483929&r2=483930
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2Parser.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2Parser.java Fri Dec  8 03:08:09 2006
@@ -131,7 +131,6 @@
 
             if ( transition.hasAction() )
             {
-                //                    System.out.println( transition.getAction().toString() );// TODO Suppress
                 transition.getAction().action( container );
             }
         }

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseGrammar.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseGrammar.java?view=diff&rev=483930&r1=483929&r2=483930
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseGrammar.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseGrammar.java Fri Dec  8 03:08:09 2006
@@ -51,6 +51,7 @@
 import org.apache.directory.shared.ldap.codec.util.LdapURL;
 import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.util.Base64;
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserException;
 
@@ -188,23 +189,18 @@
         //  Transitions concerning : ERROR RESPONSE
         //====================================================
         super.transitions[Dsmlv2StatesEnum.ERROR_RESPONSE] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.MESSAGE_START] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.MESSAGE_END] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.DETAIL_START] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.DETAIL_END] = new HashMap<Tag, GrammarTransition>();
 
         // State: [ERROR_RESPONSE] - Tag: <message>
         super.transitions[Dsmlv2StatesEnum.ERROR_RESPONSE].put( new Tag( "message", Tag.START ), new GrammarTransition(
-            Dsmlv2StatesEnum.ERROR_RESPONSE, Dsmlv2StatesEnum.MESSAGE_START, errorResponseAddMessage ) );
+            Dsmlv2StatesEnum.ERROR_RESPONSE, Dsmlv2StatesEnum.MESSAGE_END, errorResponseAddMessage ) );
 
         // State: [ERROR_RESPONSE] - Tag: <detail>
         super.transitions[Dsmlv2StatesEnum.ERROR_RESPONSE].put( new Tag( "detail", Tag.START ), new GrammarTransition(
             Dsmlv2StatesEnum.ERROR_RESPONSE, Dsmlv2StatesEnum.DETAIL_START, errorResponseAddDetail ) );
 
-        // State: [MESSAGE_START] - Tag: </message>
-        super.transitions[Dsmlv2StatesEnum.MESSAGE_START].put( new Tag( "message", Tag.END ), new GrammarTransition(
-            Dsmlv2StatesEnum.MESSAGE_START, Dsmlv2StatesEnum.MESSAGE_END, null ) );
-
         // State: [MESSAGE_END] - Tag: </errorResponse>
         super.transitions[Dsmlv2StatesEnum.MESSAGE_END].put( new Tag( "errorResponse", Tag.END ),
             new GrammarTransition( Dsmlv2StatesEnum.MESSAGE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
@@ -231,17 +227,12 @@
         super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_VALUE_START] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_VALUE_END] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_START] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_START] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_START] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.RESPONSE_NAME_START] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.RESPONSE_NAME_END] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.RESPONSE_START] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.RESPONSE_END] = new HashMap<Tag, GrammarTransition>();
 
         // State: [EXTENDED_RESPONSE] - Tag: <control>
@@ -252,13 +243,7 @@
         // State: [EXTENDED_RESPONSE_CONTROL_START] - Tag: <controlValue>
         super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START].put( new Tag( "controlValue", Tag.START ),
             new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START,
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_VALUE_START, ldapResultControlValueCreation ) );
-
-        // State: [EXTENDED_RESPONSE_CONTROL_VALUE_START] - Tag: </controlValue>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_VALUE_START].put(
-            new Tag( "controlValue", Tag.END ), new GrammarTransition(
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_VALUE_START,
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_VALUE_END, null ) );
+                Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_VALUE_END, ldapResultControlValueCreation ) );
 
         // State: [EXTENDED_RESPONSE_CONTROL_VALUE_END] - Tag: </control>
         super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_VALUE_END].put( new Tag( "control", Tag.END ),
@@ -294,22 +279,22 @@
         super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END].put(
             new Tag( "errorMessage", Tag.START ), new GrammarTransition(
                 Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END,
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_START, extendedResponseAddErrorMessage ) );
+                Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END, extendedResponseAddErrorMessage ) );
 
         // State: [EXTENDED_RESPONSE_RESULT_CODE_END] - Tag: <referral>
         super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END].put( new Tag( "referral", Tag.START ),
             new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END,
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_START, extendedResponseAddReferral ) );
+                Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, extendedResponseAddReferral ) );
 
         // State: [EXTENDED_RESPONSE_RESULT_CODE_END] - Tag: <responseName>
         super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END].put(
             new Tag( "responseName", Tag.START ), new GrammarTransition(
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END, Dsmlv2StatesEnum.RESPONSE_NAME_START,
+                Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END, Dsmlv2StatesEnum.RESPONSE_NAME_END,
                 extendedResponseAddResponseName ) );
 
         // State: [EXTENDED_RESPONSE_RESULT_CODE_END] - Tag: <response>
         super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END].put( new Tag( "response", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END, Dsmlv2StatesEnum.RESPONSE_START,
+            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END, Dsmlv2StatesEnum.RESPONSE_END,
                 extendedResponseAddResponse ) );
 
         // State: [EXTENDED_RESPONSE_RESULT_CODE_END] - Tag: </extendedResponse>
@@ -317,56 +302,40 @@
             new Tag( "extendedResponse", Tag.END ), new GrammarTransition(
                 Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
 
-        // State: [EXTENDED_RESPONSE_ERROR_MESSAGE_START] - Tag: </errorMessage>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_START].put(
-            new Tag( "errorMessage", Tag.END ), new GrammarTransition(
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_START,
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END, null ) );
-
         // State: [EXTENDED_RESPONSE_ERROR_MESSAGE_END] - Tag: <referral>
         super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END].put( new Tag( "referral", Tag.START ),
             new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END,
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_START, extendedResponseAddReferral ) );
+                Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, extendedResponseAddReferral ) );
 
         // State: [EXTENDED_RESPONSE_ERROR_MESSAGE_END] - Tag: <responseName>
         super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END].put(
             new Tag( "responseName", Tag.START ), new GrammarTransition(
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END, Dsmlv2StatesEnum.RESPONSE_NAME_START,
+                Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END, Dsmlv2StatesEnum.RESPONSE_NAME_END,
                 extendedResponseAddResponseName ) );
 
         // State: [EXTENDED_RESPONSE_ERROR_MESSAGE_END] - Tag: <response>
         super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END].put( new Tag( "response", Tag.START ),
             new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END,
-                Dsmlv2StatesEnum.RESPONSE_START, extendedResponseAddResponse ) );
+                Dsmlv2StatesEnum.RESPONSE_END, extendedResponseAddResponse ) );
 
         // State: [EXTENDED_RESPONSE_ERROR_MESSAGE_END] - Tag: </extendedResponse>
         super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END].put( new Tag( "extendedResponse",
             Tag.END ), new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END,
             Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
 
-        // State: [EXTENDED_RESPONSE_REFERRAL_START] - Tag: <referral>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_START].put( new Tag( "referral", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_START,
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, null ) );
-
-        // State: [EXTENDED_RESPONSE_REFERRAL_START] - Tag: <referral>
-        super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_START].put( new Tag( "referral", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_START,
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, null ) );
-
         // State: [EXTENDED_RESPONSE_REFERRAL_END] - Tag: <referral>
         super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END].put( new Tag( "referral", Tag.START ),
             new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END,
-                Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_START, extendedResponseAddReferral ) );
+                Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, extendedResponseAddReferral ) );
 
         // State: [EXTENDED_RESPONSE_REFERRAL_END] - Tag: <responseName>
         super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END].put( new Tag( "responseName", Tag.START ),
             new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END,
-                Dsmlv2StatesEnum.RESPONSE_NAME_START, extendedResponseAddResponseName ) );
+                Dsmlv2StatesEnum.RESPONSE_NAME_END, extendedResponseAddResponseName ) );
 
         // State: [EXTENDED_RESPONSE_REFERRAL_END] - Tag: <reponse>
         super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END].put( new Tag( "reponse", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, Dsmlv2StatesEnum.RESPONSE_START,
+            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, Dsmlv2StatesEnum.RESPONSE_END,
                 extendedResponseAddResponse ) );
 
         // State: [EXTENDED_RESPONSE_REFERRAL_END] - Tag: </extendedResponse>
@@ -374,23 +343,15 @@
             new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END,
                 Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
 
-        // State: [RESPONSE_NAME_START] - Tag: </responseName>
-        super.transitions[Dsmlv2StatesEnum.RESPONSE_NAME_START].put( new Tag( "responseName", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.RESPONSE_NAME_START, Dsmlv2StatesEnum.RESPONSE_NAME_END, null ) );
-
         // State: [RESPONSE_NAME_END] - Tag: <response>
         super.transitions[Dsmlv2StatesEnum.RESPONSE_NAME_END].put( new Tag( "response", Tag.START ),
-            new GrammarTransition( Dsmlv2StatesEnum.RESPONSE_NAME_END, Dsmlv2StatesEnum.RESPONSE_START,
+            new GrammarTransition( Dsmlv2StatesEnum.RESPONSE_NAME_END, Dsmlv2StatesEnum.RESPONSE_END,
                 extendedResponseAddResponse ) );
 
         // State: [RESPONSE_NAME_END] - Tag: </extendedResponse>
         super.transitions[Dsmlv2StatesEnum.RESPONSE_NAME_END].put( new Tag( "extendedResponse", Tag.END ),
             new GrammarTransition( Dsmlv2StatesEnum.RESPONSE_NAME_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
 
-        // State: [RESPONSE_START] - Tag: </response>
-        super.transitions[Dsmlv2StatesEnum.RESPONSE_START].put( new Tag( "response", Tag.END ), new GrammarTransition(
-            Dsmlv2StatesEnum.RESPONSE_START, Dsmlv2StatesEnum.RESPONSE_END, null ) );
-
         // State: [RESPONSE_END] - Tag: </extendedResponse>
         super.transitions[Dsmlv2StatesEnum.RESPONSE_END].put( new Tag( "extendedResponse", Tag.END ),
             new GrammarTransition( Dsmlv2StatesEnum.RESPONSE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
@@ -401,13 +362,10 @@
         super.transitions[Dsmlv2StatesEnum.LDAP_RESULT] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_VALUE_START] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_VALUE_END] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_START] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_START] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_START] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_DONE_END] = new HashMap<Tag, GrammarTransition>();
 
@@ -422,12 +380,7 @@
         // State: [LDAP_RESULT_CONTROL_START] - Tag: <controlValue>
         super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START].put( new Tag( "controlValue", Tag.START ),
             new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START,
-                Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_VALUE_START, ldapResultControlValueCreation ) );
-
-        // State: [LDAP_RESULT_CONTROL_VALUE_START] - Tag: </controlValue>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_VALUE_START].put( new Tag( "controlValue", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_VALUE_START,
-                Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_VALUE_END, null ) );
+                Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_VALUE_END, ldapResultControlValueCreation ) );
 
         // State: [LDAP_RESULT_CONTROL_VALUE_END] - Tag: </control>
         super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_VALUE_END].put( new Tag( "control", Tag.END ),
@@ -457,12 +410,12 @@
         // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: <errorMessage>
         super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END].put( new Tag( "errorMessage", Tag.START ),
             new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END,
-                Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_START, ldapResultAddErrorMessage ) );
+                Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END, ldapResultAddErrorMessage ) );
 
         // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: <referral>
         super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END].put( new Tag( "referral", Tag.START ),
             new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END,
-                Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_START, ldapResultAddReferral ) );
+                Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, ldapResultAddReferral ) );
 
         // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </addResponse>
         super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END].put( new Tag( "addResponse", Tag.END ),
@@ -504,15 +457,10 @@
             .put( new Tag( "searchResponse", Tag.END ), new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_DONE_END,
                 Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
 
-        // State: [LDAP_RESULT_ERROR_MESSAGE_START] - Tag: </errorMessage>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_START].put( new Tag( "errorMessage", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_START,
-                Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END, null ) );
-
         // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: <referral>
         super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END].put( new Tag( "referral", Tag.START ),
             new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END,
-                Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_START, ldapResultAddReferral ) );
+                Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, ldapResultAddReferral ) );
 
         // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </addResponse>
         super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END].put( new Tag( "addResponse", Tag.END ),
@@ -549,15 +497,10 @@
             new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END,
                 Dsmlv2StatesEnum.SEARCH_RESULT_DONE_END, null ) );
 
-        // State: [LDAP_RESULT_REFERRAL_START] - Tag: </referral>
-        super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_START].put( new Tag( "referral", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_START,
-                Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, null ) );
-
         // State: [LDAP_RESULT_REFERRAL_END] - Tag: <referral>
         super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END].put( new Tag( "referral", Tag.START ),
             new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END,
-                Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_START, ldapResultAddReferral ) );
+                Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, ldapResultAddReferral ) );
 
         // State: [LDAP_RESULT_REFERRAL_END] - Tag: </addResponse>
         super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END].put( new Tag( "addResponse", Tag.END ),
@@ -620,11 +563,9 @@
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_VALUE_START] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_VALUE_END] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_START] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END] = new HashMap<Tag, GrammarTransition>();
 
         // State: [SEARCH_RESULT_ENTRY] - Tag: <control>
@@ -646,12 +587,7 @@
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START].put(
             new Tag( "controlValue", Tag.START ), new GrammarTransition(
                 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START,
-                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_VALUE_START, searchResultEntryControlValueCreation ) );
-
-        // State: [SEARCH_RESULT_ENTRY_CONTROL_VALUE_START] - Tag: </controlValue>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_VALUE_START].put( new Tag( "controlValue",
-            Tag.END ), new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_VALUE_START,
-            Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_VALUE_END, null ) );
+                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_VALUE_END, searchResultEntryControlValueCreation ) );
 
         // State: [SEARCH_RESULT_ENTRY_CONTROL_VALUE_END] - Tag: </control>
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_VALUE_END].put( new Tag( "control", Tag.END ),
@@ -686,7 +622,7 @@
         // State: [SEARCH_RESULT_ENTRY_ATTR_START] - Tag: <value>
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START].put( new Tag( "value", Tag.START ),
             new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START,
-                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_START, searchResultEntryAddValue ) );
+                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END, searchResultEntryAddValue ) );
 
         // State: [SEARCH_RESULT_ENTRY_ATTR_END] - Tag: <attr>
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END].put( new Tag( "attr", Tag.START ),
@@ -698,15 +634,10 @@
             new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END,
                 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP, null ) );
 
-        // State: [SEARCH_RESULT_ENTRY_VALUE_START] - Tag: </value>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_START].put( new Tag( "value", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_START,
-                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END, null ) );
-
         // State: [SEARCH_RESULT_ENTRY_VALUE_END] - Tag: <value>
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END].put( new Tag( "value", Tag.START ),
             new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END,
-                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_START, searchResultEntryAddValue ) );
+                Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END, searchResultEntryAddValue ) );
 
         // State: [SEARCH_RESULT_ENTRY_VALUE_END] - Tag: </attr>
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END].put( new Tag( "attr", Tag.END ),
@@ -740,9 +671,7 @@
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_VALUE_START] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END] = new HashMap<Tag, GrammarTransition>();
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_START] = new HashMap<Tag, GrammarTransition>();
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END] = new HashMap<Tag, GrammarTransition>();
 
         // State: [SEARCH_RESULT_REFERENCE] - Tag: <control>
@@ -753,17 +682,12 @@
         // State: [SEARCH_RESULT_REFERENCE] - Tag: <ref>
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE].put( new Tag( "ref", Tag.START ),
             new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE,
-                Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_START, searchResultReferenceAddRef ) );
+                Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END, searchResultReferenceAddRef ) );
 
         // State: [SEARCH_RESULT_REFERENCE_CONTROL_START] - Tag: <controlValue>
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START].put( new Tag( "controlValue",
             Tag.START ), new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START,
-            Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_VALUE_START, searchResultReferenceControlValueCreation ) );
-
-        // State: [SEARCH_RESULT_REFERENCE_CONTROL_VALUE_START] - Tag: </controlValue>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_VALUE_START].put( new Tag( "controlValue",
-            Tag.END ), new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_VALUE_START,
-            Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END, null ) );
+            Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END, searchResultReferenceControlValueCreation ) );
 
         // State: [sEARCH_RESULT_REFERENCE_CONTROL_VALUE_END] - Tag: </control>
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END].put(
@@ -784,17 +708,12 @@
         // State: [SEARCH_RESULT_REFERENCE_CONTROL_END] - Tag: <ref>
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END].put( new Tag( "ref", Tag.START ),
             new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END,
-                Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_START, searchResultReferenceAddRef ) );
-
-        // State: [SEARCH_RESULT_REFERENCE_REF_START] - Tag: </ref>
-        super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_START].put( new Tag( "ref", Tag.END ),
-            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_START,
-                Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END, null ) );
+                Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END, searchResultReferenceAddRef ) );
 
         // State: [SEARCH_RESULT_REFERENCE_REF_END] - Tag: <ref>
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END].put( new Tag( "ref", Tag.START ),
             new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END,
-                Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_START, searchResultReferenceAddRef ) );
+                Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END, searchResultReferenceAddRef ) );
 
         // State: [SEARCH_RESULT_REFERENCE_REF_END] - Tag: </searchResultReference>
         super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END].put( new Tag( "searchResultReference",
@@ -1269,23 +1188,20 @@
         public void action( Dsmlv2Container container ) throws XmlPullParserException
         {
             ErrorResponse errorResponse = ( ErrorResponse ) container.getBatchResponse().getCurrentResponse();
-
+            
             XmlPullParser xpp = container.getParser();
-
-            int eventType = 0;
             try
             {
-                eventType = xpp.next();
+                String nextText = xpp.nextText();
+                if ( !nextText.equals( "" ) )
+                {
+                    errorResponse.setMessage( nextText.trim() );
+                }
             }
             catch ( IOException e )
             {
                 throw new XmlPullParserException( e.getMessage(), xpp, null );
             }
-
-            if ( eventType == XmlPullParser.TEXT )
-            {
-                errorResponse.setMessage( xpp.getText().trim() );
-            }
         }
     };
 
@@ -1315,9 +1231,11 @@
         attributeValue = xpp.getAttributeValue( "", "type" );
         if ( attributeValue != null )
         {
-            // TODO Add a verification for a match with NumericOid format (see
-            // DSMLv2 specifications)
-            control.setControlType( attributeValue ); // TODO LDAPString uses UTF8 bytes, so the charset must be verified before doing this.
+            if ( !OID.isOID( attributeValue ) )
+            {
+                throw new XmlPullParserException( "Incorrect value for 'type' attribute. This is not an OID.", xpp, null );
+            }
+            control.setControlType( attributeValue );
         }
         else
         {
@@ -1401,25 +1319,28 @@
         Control control = parent.getCurrentControl();
 
         XmlPullParser xpp = container.getParser();
-
-        int eventType = 0;
         try
         {
-            eventType = xpp.next();
+            // We have to catch the type Attribute Value before going to the next Text node
+            String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
+            
+            // Getting the value
+            String nextText = xpp.nextText();
+            if ( !nextText.equals( "" ) )
+            {
+                if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
+                {
+                    control.setControlValue( Base64.decode( nextText.trim().toCharArray() ) );
+                }
+                else
+                {
+                    control.setControlValue( nextText.trim() );
+                }
+            }
         }
         catch ( IOException e )
         {
-            throw new XmlPullParserException( "name attribute is required", xpp, null );
-        }
-
-        if ( eventType != XmlPullParser.TEXT )
-        {
-            // TODO we insert a blank value
-            control.setControlValue( "" );
-        }
-        else
-        {
-            control.setControlValue( xpp.getText().trim() );
+            throw new XmlPullParserException( "An unexpected error ocurred : " + e.getMessage(), xpp, null );
         }
     }
 
@@ -1552,24 +1473,17 @@
             }
 
             XmlPullParser xpp = container.getParser();
-
-            int eventType = 0;
             try
             {
-                eventType = xpp.next();
+                String nextText = xpp.nextText();
+                if ( !nextText.equals( "" ) )
+                {
+                    ldapResult.setErrorMessage( nextText.trim() );
+                }
             }
             catch ( IOException e )
             {
-                throw new XmlPullParserException( e.getMessage(), xpp, null );
-            }
-
-            if ( eventType != XmlPullParser.TEXT )
-            {
-                throw new XmlPullParserException( "An error has ocurred.", xpp, null );
-            }
-            else
-            {
-                ldapResult.setErrorMessage( xpp.getText().trim() );
+                throw new XmlPullParserException( "An unexpected error ocurred : " + e.getMessage(), xpp, null );
             }
         }
     };
@@ -1604,31 +1518,24 @@
             }
 
             XmlPullParser xpp = container.getParser();
-
-            int eventType = 0;
             try
             {
-                eventType = xpp.next();
+                String nextText = xpp.nextText();
+                if ( !nextText.equals( "" ) )
+                {
+                    try
+                    {
+                        ldapResult.addReferral( new LdapURL( nextText.trim() ) );
+                    }
+                    catch ( LdapURLEncodingException e )
+                    {
+                        throw new XmlPullParserException( e.getMessage(), xpp, null );
+                    }
+                }
             }
             catch ( IOException e )
             {
-                throw new XmlPullParserException( e.getMessage(), xpp, null );
-            }
-
-            if ( eventType != XmlPullParser.TEXT )
-            {
-                throw new XmlPullParserException( "An error has ocurred.", xpp, null );
-            }
-            else
-            {
-                try
-                {
-                    ldapResult.addReferral( new LdapURL( xpp.getText().trim() ) );
-                }
-                catch ( LdapURLEncodingException e )
-                {
-                    throw new XmlPullParserException( e.getMessage(), xpp, null );
-                }
+                throw new XmlPullParserException( "An unexpected error ocurred : " + e.getMessage(), xpp, null );
             }
         }
     };
@@ -1835,28 +1742,28 @@
         public void action( Dsmlv2Container container ) throws XmlPullParserException
         {
             SearchResponse searchResponse = ( SearchResponse ) container.getBatchResponse().getCurrentResponse();
-
             SearchResultEntry searchResultEntry = searchResponse.getCurrentSearchResultEntry();
 
             XmlPullParser xpp = container.getParser();
-
-            int eventType = 0;
             try
             {
-                eventType = xpp.next();
+                // We have to catch the type Attribute Value before going to the next Text node
+                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
+                
+                // Getting the value
+                String nextText = xpp.nextText();
+                if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
+                {
+                    searchResultEntry.addAttributeValue( Base64.decode( nextText.toCharArray() ) );
+                }
+                else
+                {
+                    searchResultEntry.addAttributeValue( nextText );
+                }
             }
             catch ( IOException e )
             {
-                throw new XmlPullParserException( e.getMessage(), xpp, null );
-            }
-
-            if ( eventType != XmlPullParser.TEXT )
-            {
-                throw new XmlPullParserException( "An error has ocurred.", xpp, null );
-            }
-            else
-            {
-                searchResultEntry.addAttributeValue( xpp.getText() );
+                throw new XmlPullParserException( "An unexpected error ocurred : " + e.getMessage(), xpp, null );
             }
         }
     };
@@ -1870,35 +1777,24 @@
         public void action( Dsmlv2Container container ) throws XmlPullParserException
         {
             SearchResponse searchResponse = ( SearchResponse ) container.getBatchResponse().getCurrentResponse();
-
             SearchResultReference searchResultReference = searchResponse.getCurrentSearchResultReference();
 
             XmlPullParser xpp = container.getParser();
-
-            int eventType = 0;
             try
             {
-                eventType = xpp.next();
+                String nextText = xpp.nextText();
+                if ( !nextText.equals( "" ) )
+                {
+                    searchResultReference.addSearchResultReference( new LdapURL( nextText ) );
+                }
             }
             catch ( IOException e )
             {
-                throw new XmlPullParserException( e.getMessage(), xpp, null );
+                throw new XmlPullParserException( "An unexpected error ocurred : " + e.getMessage(), xpp, null );
             }
-
-            if ( eventType != XmlPullParser.TEXT )
+            catch ( LdapURLEncodingException e )
             {
-                throw new XmlPullParserException( "An error has ocurred.", xpp, null );
-            }
-            else
-            {
-                try
-                {
-                    searchResultReference.addSearchResultReference( new LdapURL( xpp.getText() ) );
-                }
-                catch ( LdapURLEncodingException e )
-                {
-                    throw new XmlPullParserException( e.getMessage(), xpp, null );
-                }
+                throw new XmlPullParserException( e.getMessage(), xpp, null );
             }
         }
     };
@@ -1929,31 +1825,22 @@
             ExtendedResponse extendedResponse = ( ExtendedResponse ) container.getBatchResponse().getCurrentResponse();
 
             XmlPullParser xpp = container.getParser();
-
-            int eventType = 0;
             try
             {
-                eventType = xpp.next();
+                String nextText = xpp.nextText();
+                if ( !nextText.equals( "" ) )
+                {
+                    extendedResponse.setResponseName( new OID( nextText.trim() ) );
+                }
+                
             }
             catch ( IOException e )
             {
-                throw new XmlPullParserException( e.getMessage(), xpp, null );
+                throw new XmlPullParserException( "An unexpected error ocurred : " + e.getMessage(), xpp, null );
             }
-
-            if ( eventType != XmlPullParser.TEXT )
+            catch ( DecoderException e )
             {
-                throw new XmlPullParserException( "An error has ocurred.", xpp, null );
-            }
-            else
-            {
-                try
-                {
-                    extendedResponse.setResponseName( new OID( xpp.getText().trim() ) );
-                }
-                catch ( DecoderException e )
-                {
-                    throw new XmlPullParserException( e.getMessage(), xpp, null );
-                }
+                throw new XmlPullParserException( e.getMessage(), xpp, null );
             }
         }
     };
@@ -1968,24 +1855,25 @@
             ExtendedResponse extendedResponse = ( ExtendedResponse ) container.getBatchResponse().getCurrentResponse();
 
             XmlPullParser xpp = container.getParser();
-
-            int eventType = 0;
             try
             {
-                eventType = xpp.next();
+                // We have to catch the type Attribute Value before going to the next Text node
+                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
+                
+                // Getting the value
+                String nextText = xpp.nextText();
+                if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
+                {
+                    extendedResponse.setResponse( Base64.decode( nextText.trim().toCharArray() ) );
+                }
+                else
+                {
+                    extendedResponse.setResponse( nextText.trim() );
+                }
             }
             catch ( IOException e )
             {
-                throw new XmlPullParserException( e.getMessage(), xpp, null );
-            }
-
-            if ( eventType != XmlPullParser.TEXT )
-            {
-                throw new XmlPullParserException( "An error has ocurred.", xpp, null );
-            }
-            else
-            {
-                extendedResponse.setResponse( xpp.getText().trim() );
+                throw new XmlPullParserException( "An unexpected error ocurred : " + e.getMessage(), xpp, null );
             }
         }
     };

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseParser.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseParser.java?view=diff&rev=483930&r1=483929&r2=483930
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseParser.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseParser.java Fri Dec  8 03:08:09 2006
@@ -46,7 +46,7 @@
         this.container.setGrammar( Dsmlv2ResponseGrammar.getInstance() );
 
         XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
-        // factory.setNamespaceAware(true);
+        factory.setNamespaceAware(true);
         XmlPullParser xpp = factory.newPullParser();
 
         container.setParser( xpp );
@@ -131,7 +131,6 @@
 
             if ( transition.hasAction() )
             {
-                //                    System.out.println( transition.getAction().toString() );// TODO Suppress
                 transition.getAction().action( container );
             }
         }

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/ParserUtils.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/ParserUtils.java?view=auto&rev=483930
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/ParserUtils.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/ParserUtils.java Fri Dec  8 03:08:09 2006
@@ -0,0 +1,54 @@
+
+package org.apache.directory.ldapstudio.dsmlv2;
+
+import org.xmlpull.v1.XmlPullParser;
+
+public class ParserUtils
+{
+    private static final String XML_SCHEMA_URI = "http://www.w3c.org/2001/XMLSchema";
+    private static final String XML_SCHEMA_INSTANCE_URI = "http://www.w3c.org/2001/XMLSchema-instance";
+
+    
+    /**
+     * Returns the value of the attribute 'type' of the "XMLSchema-instance' namespace if it exists
+     *
+     * @param xpp the XPP parser to use
+     * @return the value of the attribute 'type' of the "XMLSchema-instance' namespace if it exists
+     */
+    public static String getXsiTypeAttributeValue( XmlPullParser xpp )
+    {
+        String type = null;
+        int nbAttributes = xpp.getAttributeCount();
+        for ( int i = 0; i < nbAttributes; i++ )
+        {
+            // Checking if the attribute 'type' from XML Schema Instance namespace is used.
+            if ( xpp.getAttributeName( i ).equals( "type" ) && xpp.getNamespace( xpp.getAttributePrefix( i ) ).equals( XML_SCHEMA_INSTANCE_URI ))
+            {
+                type = xpp.getAttributeValue( i );
+                break;
+            }
+        }
+        return type;
+    }
+    
+    /**
+     * Returns true if the value of the current tag is Base64Binary encoded
+     *
+     * @param parser the XPP parser to use
+     * @param attrValue the attribute value
+     * @return true if the value of the current tag is Base64BinaryEncoded, false if not
+     */
+    public static boolean isBase64BinaryValue( XmlPullParser parser, String attrValue )
+    {
+        if ( attrValue == null )
+        {
+            return false;
+        }
+        // We are looking for something that should look like that: "aNameSpace:base64Binary"
+        // We split the String. The first element should be the namespace prefix and the second "base64Binary"
+        String [] splitedString = attrValue.split( ":" );
+        return ( splitedString.length == 2 ) 
+                && ( XML_SCHEMA_URI.equals( parser.getNamespace( splitedString[0] ) ) ) 
+                && ( "base64Binary".equals( splitedString[1] ) );
+    }
+}

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/addRequest/AddRequestTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/addRequest/AddRequestTest.java?view=diff&rev=483930&r1=483929&r2=483930
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/addRequest/AddRequestTest.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/addRequest/AddRequestTest.java Fri Dec  8 03:08:09 2006
@@ -358,7 +358,7 @@
 
 
     /**
-     * Test parsing of a request with an Attr elements without value
+     * Test parsing of a request with an Attr elements with value
      */
     public void testRequestWith1AttrWithValue()
     {
@@ -419,6 +419,70 @@
         }
 
         assertEquals( "top", value );
+    }
+    
+    /**
+     * Test parsing of a request with an Attr elements with value
+     */
+    public void testRequestWith1AttrWithBase64Value()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+
+            parser.setInputFile( AddRequestTest.class.getResource( "request_with_1_attr_with_base64_value.xml" ).getFile() );
+
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
+
+        Attributes attributes = addRequest.getAttributes();
+
+        assertEquals( 1, attributes.size() );
+
+        // Getting the Attribute       
+        NamingEnumeration ne = attributes.getAll();
+
+        Attribute attribute = null;
+        try
+        {
+            attribute = ( Attribute ) ne.next();
+        }
+        catch ( NamingException e )
+        {
+            fail( e.getMessage() );
+        }
+
+        assertEquals( "objectclass", attribute.getID() );
+
+        // Getting the Value
+        NamingEnumeration ne2 = null;
+        try
+        {
+            ne2 = attribute.getAll();
+        }
+        catch ( NamingException e )
+        {
+            fail( e.getMessage() );
+        }
+
+        Object value = null;
+        try
+        {
+            value = ne2.next();
+        }
+        catch ( NamingException e )
+        {
+            fail( e.getMessage() );
+        }
+
+        assertEquals( "DSMLv2.0 rocks!!", new String( (byte[]) value ) );
     }
 
 

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/addResponse/AddResponseTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/addResponse/AddResponseTest.java?view=diff&rev=483930&r1=483929&r2=483930
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/addResponse/AddResponseTest.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/addResponse/AddResponseTest.java Fri Dec  8 03:08:09 2006
@@ -99,6 +99,33 @@
         assertEquals( "Some text", StringTools.utf8ToString( ( byte[] ) control.getControlValue() ) );
     }
 
+    /**
+     * Test parsing of a response with a (optional) Control element with emptyValue
+     */
+    public void testResponseWith1ControlEmptyValue()
+    {
+        Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+
+            parser.setInputFile( AddResponseTest.class.getResource( "response_with_1_control_empty_value.xml" ).getFile() );
+
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
+        Control control = addResponse.getCurrentControl();
+        
+        assertEquals( 1, addResponse.getControls().size() );
+        assertTrue( control.getCriticality() );
+        assertEquals( "1.2.840.113556.1.4.643", control.getControlType() );
+        assertEquals( StringTools.EMPTY_BYTES,  ( byte[] ) control.getControlValue() );
+    }
 
     /**
      * Test parsing of a response with 2 (optional) Control elements
@@ -238,6 +265,32 @@
         assertEquals( "Unrecognized extended operation EXTENSION_OID: 1.2.6.1.4.1.18060.1.1.1.100.2", ldapResult
             .getErrorMessage() );
     }
+    
+    /**
+     * Test parsing of a response with empty Error Message
+     */
+    public void testResponseWithEmptyErrorMessage()
+    {
+        Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+
+            parser.setInputFile( AddResponseTest.class.getResource( "response_with_empty_error_message.xml" ).getFile() );
+
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
+
+        LdapResult ldapResult = addResponse.getLdapResult();
+
+        assertNull( ldapResult.getErrorMessage() );
+    }
 
 
     /**
@@ -277,6 +330,34 @@
         {
             fail();
         }
+    }
+    
+    /**
+     * Test parsing of a response with an empty Referral
+     */
+    public void testResponseWith1EmptyReferral()
+    {
+        Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+
+            parser.setInputFile( AddResponseTest.class.getResource( "response_with_1_empty_referral.xml" ).getFile() );
+
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
+
+        LdapResult ldapResult = addResponse.getLdapResult();
+
+        List referrals = ldapResult.getReferrals();
+
+        assertEquals( 0, referrals.size() );
     }
 
 

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/authResponse/AuthResponseTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/authResponse/AuthResponseTest.java?view=diff&rev=483930&r1=483929&r2=483930
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/authResponse/AuthResponseTest.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/authResponse/AuthResponseTest.java Fri Dec  8 03:08:09 2006
@@ -98,6 +98,34 @@
 
         assertEquals( "Some text", StringTools.utf8ToString( ( byte[] ) control.getControlValue() ) );
     }
+    
+    /**
+     * Test parsing of a response with a (optional) Control element with empty value
+     */
+    public void testResponseWith1ControlEmptyValue()
+    {
+        Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+
+            parser.setInputFile( AuthResponseTest.class.getResource( "response_with_1_control_empty_value.xml" ).getFile() );
+
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();
+        Control control = bindResponse.getCurrentControl();
+        
+        assertEquals( 1, bindResponse.getControls().size() );
+        assertTrue( control.getCriticality() );
+        assertEquals( "1.2.840.113556.1.4.643", control.getControlType() );
+        assertEquals( StringTools.EMPTY_BYTES, ( byte[] ) control.getControlValue() );
+    }
 
 
     /**
@@ -238,6 +266,32 @@
         assertEquals( "Unrecognized extended operation EXTENSION_OID: 1.2.6.1.4.1.18060.1.1.1.100.2", ldapResult
             .getErrorMessage() );
     }
+    
+    /**
+     * Test parsing of a response with Empty Error Message
+     */
+    public void testResponseWithEmptyErrorMessage()
+    {
+        Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+
+            parser.setInputFile( AuthResponseTest.class.getResource( "response_with_empty_error_message.xml" ).getFile() );
+
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();
+
+        LdapResult ldapResult = bindResponse.getLdapResult();
+
+        assertNull( ldapResult.getErrorMessage() );
+    }
 
 
     /**
@@ -277,6 +331,34 @@
         {
             fail();
         }
+    }
+    
+    /**
+     * Test parsing of a response with an empty Referral
+     */
+    public void testResponseWith1EmptyReferral()
+    {
+        Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+
+            parser.setInputFile( AuthResponseTest.class.getResource( "response_with_1_empty_referral.xml" ).getFile() );
+
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();
+
+        LdapResult ldapResult = bindResponse.getLdapResult();
+
+        List referrals = ldapResult.getReferrals();
+
+        assertEquals( 0, referrals.size() );
     }
 
 

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/compareRequest/CompareRequestTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/compareRequest/CompareRequestTest.java?view=diff&rev=483930&r1=483929&r2=483930
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/compareRequest/CompareRequestTest.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/compareRequest/CompareRequestTest.java Fri Dec  8 03:08:09 2006
@@ -288,6 +288,34 @@
         assertEquals( "Johnson", ( String ) compareRequest.getAssertionValue() );
     }
 
+    /**
+     * Test parsing of a request with a complete assertion with base64 value
+     */
+    public void testRequestWith1CompleteAssertionBase64Value()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+
+            parser.setInputFile( CompareRequestTest.class.getResource( "request_with_1_complete_assertion_base64_value.xml" )
+                .getFile() );
+
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        CompareRequest compareRequest = ( CompareRequest ) parser.getBatchRequest().getCurrentRequest();
+
+        assertEquals( "cn=Bob Rush,ou=Dev,dc=Example,dc=COM", ( String ) compareRequest.getEntry().toString() );
+
+        assertEquals( "sn", ( String ) compareRequest.getAttributeDesc() );
+
+        assertEquals( "DSMLv2.0 rocks!!", new String( (byte[]) compareRequest.getAssertionValue() ) );
+    }
 
     /**
      * Test parsing of a request with an Attr elements with empty value

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/compareResponse/CompareResponseTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/compareResponse/CompareResponseTest.java?view=diff&rev=483930&r1=483929&r2=483930
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/compareResponse/CompareResponseTest.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/compareResponse/CompareResponseTest.java Fri Dec  8 03:08:09 2006
@@ -98,6 +98,34 @@
 
         assertEquals( "Some text", StringTools.utf8ToString( ( byte[] ) control.getControlValue() ) );
     }
+    
+    /**
+     * Test parsing of a response with a (optional) Control element with empty value
+     */
+    public void testResponseWith1ControlEmptyValue()
+    {
+        Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+
+            parser.setInputFile( CompareResponseTest.class.getResource( "response_with_1_control_empty_value.xml" ).getFile() );
+
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        CompareResponse compareResponse = ( CompareResponse ) parser.getBatchResponse().getCurrentResponse();
+        Control control = compareResponse.getCurrentControl();
+        
+        assertEquals( 1, compareResponse.getControls().size() );
+        assertTrue( control.getCriticality() );
+        assertEquals( "1.2.840.113556.1.4.643", control.getControlType() );
+        assertEquals( StringTools.EMPTY_BYTES, ( byte[] ) control.getControlValue() );
+    }
 
 
     /**
@@ -238,6 +266,32 @@
         assertEquals( "Unrecognized extended operation EXTENSION_OID: 1.2.6.1.4.1.18060.1.1.1.100.2", ldapResult
             .getErrorMessage() );
     }
+    
+    /**
+     * Test parsing of a response with empty Error Message
+     */
+    public void testResponseWithEmptyErrorMessage()
+    {
+        Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+
+            parser.setInputFile( CompareResponseTest.class.getResource( "response_with_empty_error_message.xml" ).getFile() );
+
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        CompareResponse compareResponse = ( CompareResponse ) parser.getBatchResponse().getCurrentResponse();
+
+        LdapResult ldapResult = compareResponse.getLdapResult();
+
+        assertNull( ldapResult.getErrorMessage() );
+    }
 
 
     /**
@@ -277,6 +331,34 @@
         {
             fail();
         }
+    }
+    
+    /**
+     * Test parsing of a response with an empty Referral
+     */
+    public void testResponseWith1EmptyReferral()
+    {
+        Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+
+            parser.setInputFile( CompareResponseTest.class.getResource( "response_with_1_empty_referral.xml" ).getFile() );
+
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        CompareResponse compareResponse = ( CompareResponse ) parser.getBatchResponse().getCurrentResponse();
+
+        LdapResult ldapResult = compareResponse.getLdapResult();
+
+        List referrals = ldapResult.getReferrals();
+
+        assertEquals( 0, referrals.size() );
     }
 
 



Mime
View raw message