directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r796383 [3/23] - in /directory/shared/trunk: ./ dsml-parser/ dsml-parser/src/ dsml-parser/src/main/ dsml-parser/src/main/java/ dsml-parser/src/main/java/org/ dsml-parser/src/main/java/org/apache/ dsml-parser/src/main/java/org/apache/directo...
Date Tue, 21 Jul 2009 17:04:29 GMT
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/LdapMessageDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/LdapMessageDecorator.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/LdapMessageDecorator.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/LdapMessageDecorator.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,478 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.dsmlv2;
+
+
+import java.nio.ByteBuffer;
+import java.util.List;
+
+import org.apache.directory.shared.asn1.AbstractAsn1Object;
+import org.apache.directory.shared.asn1.Asn1Object;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.asn1.codec.EncoderException;
+import org.apache.directory.shared.ldap.codec.ControlCodec;
+import org.apache.directory.shared.ldap.codec.LdapMessageCodec;
+import org.apache.directory.shared.ldap.codec.LdapResponseCodec;
+import org.apache.directory.shared.ldap.codec.abandon.AbandonRequestCodec;
+import org.apache.directory.shared.ldap.codec.add.AddRequestCodec;
+import org.apache.directory.shared.ldap.codec.add.AddResponseCodec;
+import org.apache.directory.shared.ldap.codec.bind.BindRequestCodec;
+import org.apache.directory.shared.ldap.codec.bind.BindResponseCodec;
+import org.apache.directory.shared.ldap.codec.compare.CompareRequestCodec;
+import org.apache.directory.shared.ldap.codec.compare.CompareResponseCodec;
+import org.apache.directory.shared.ldap.codec.del.DelRequestCodec;
+import org.apache.directory.shared.ldap.codec.del.DelResponseCodec;
+import org.apache.directory.shared.ldap.codec.extended.ExtendedRequestCodec;
+import org.apache.directory.shared.ldap.codec.extended.ExtendedResponseCodec;
+import org.apache.directory.shared.ldap.codec.modify.ModifyRequestCodec;
+import org.apache.directory.shared.ldap.codec.modify.ModifyResponseCodec;
+import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNRequestCodec;
+import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNResponseCodec;
+import org.apache.directory.shared.ldap.codec.search.SearchRequestCodec;
+import org.apache.directory.shared.ldap.codec.search.SearchResultDoneCodec;
+import org.apache.directory.shared.ldap.codec.search.SearchResultEntryCodec;
+import org.apache.directory.shared.ldap.codec.search.SearchResultReferenceCodec;
+import org.apache.directory.shared.ldap.codec.unbind.UnBindRequestCodec;
+
+
+/**
+ * Decorator class for LDAP Message. This is the top level class, the one 
+ * that holds the instance.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class LdapMessageDecorator extends LdapMessageCodec
+{
+    /** The decorated instance */
+    protected LdapMessageCodec instance;
+
+
+    /**
+     * Creates a new instance of LdapMessageDecorator.
+     *
+     * @param ldapMessage
+     *      the message to decorate
+     */
+    public LdapMessageDecorator( LdapMessageCodec ldapMessage )
+    {
+        instance = ldapMessage;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#addControl(org.apache.directory.shared.ldap.codec.Control)
+     */
+    @Override
+    public void addControl( ControlCodec control )
+    {
+        instance.addControl( control );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#computeLength()
+     */
+    @Override
+    public int computeLength()
+    {
+        return instance.computeLength();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#encode(java.nio.ByteBuffer)
+     */
+    @Override
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        return instance.encode( buffer );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getAbandonRequest()
+     */
+    @Override
+    public AbandonRequestCodec getAbandonRequest()
+    {
+        return instance.getAbandonRequest();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getAddRequest()
+     */
+    @Override
+    public AddRequestCodec getAddRequest()
+    {
+        return instance.getAddRequest();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getAddResponse()
+     */
+    @Override
+    public AddResponseCodec getAddResponse()
+    {
+        return instance.getAddResponse();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getBindRequest()
+     */
+    @Override
+    public BindRequestCodec getBindRequest()
+    {
+        return instance.getBindRequest();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getBindResponse()
+     */
+    @Override
+    public BindResponseCodec getBindResponse()
+    {
+        return instance.getBindResponse();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getCompareRequest()
+     */
+    @Override
+    public CompareRequestCodec getCompareRequest()
+    {
+        return instance.getCompareRequest();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getCompareResponse()
+     */
+    @Override
+    public CompareResponseCodec getCompareResponse()
+    {
+        return instance.getCompareResponse();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getControls()
+     */
+    @Override
+    public List<ControlCodec> getControls()
+    {
+        return instance.getControls();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getControls(int)
+     */
+    @Override
+    public ControlCodec getControls( int i )
+    {
+        return instance.getControls( i );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getCurrentControl()
+     */
+    @Override
+    public ControlCodec getCurrentControl()
+    {
+        return instance.getCurrentControl();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getDelRequest()
+     */
+    @Override
+    public DelRequestCodec getDelRequest()
+    {
+        return instance.getDelRequest();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getDelResponse()
+     */
+    @Override
+    public DelResponseCodec getDelResponse()
+    {
+        return instance.getDelResponse();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getExtendedRequest()
+     */
+    @Override
+    public ExtendedRequestCodec getExtendedRequest()
+    {
+        return instance.getExtendedRequest();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getExtendedResponse()
+     */
+    @Override
+    public ExtendedResponseCodec getExtendedResponse()
+    {
+        return instance.getExtendedResponse();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getLdapResponse()
+     */
+    @Override
+    public LdapResponseCodec getLdapResponse()
+    {
+        return instance.getLdapResponse();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getMessageId()
+     */
+    @Override
+    public int getMessageId()
+    {
+        return instance.getMessageId();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getMessageType()
+     */
+    @Override
+    public int getMessageType()
+    {
+        return instance.getMessageType();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getMessageTypeName()
+     */
+    @Override
+    public String getMessageTypeName()
+    {
+        return instance.getMessageTypeName();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getModifyDNRequest()
+     */
+    @Override
+    public ModifyDNRequestCodec getModifyDNRequest()
+    {
+        return instance.getModifyDNRequest();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getModifyDNResponse()
+     */
+    @Override
+    public ModifyDNResponseCodec getModifyDNResponse()
+    {
+        return instance.getModifyDNResponse();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getModifyRequest()
+     */
+    @Override
+    public ModifyRequestCodec getModifyRequest()
+    {
+        return instance.getModifyRequest();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getModifyResponse()
+     */
+    @Override
+    public ModifyResponseCodec getModifyResponse()
+    {
+        return instance.getModifyResponse();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getSearchRequest()
+     */
+    @Override
+    public SearchRequestCodec getSearchRequest()
+    {
+        return instance.getSearchRequest();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getSearchResultDone()
+     */
+    @Override
+    public SearchResultDoneCodec getSearchResultDone()
+    {
+        return instance.getSearchResultDone();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getSearchResultEntry()
+     */
+    @Override
+    public SearchResultEntryCodec getSearchResultEntry()
+    {
+        return instance.getSearchResultEntry();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getSearchResultReference()
+     */
+    @Override
+    public SearchResultReferenceCodec getSearchResultReference()
+    {
+        return instance.getSearchResultReference();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#getUnBindRequest()
+     */
+    @Override
+    public UnBindRequestCodec getUnBindRequest()
+    {
+        return instance.getUnBindRequest();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#setMessageId(int)
+     */
+    @Override
+    public void setMessageId( int messageId )
+    {
+        instance.setMessageId( messageId );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#setProtocolOP(org.apache.directory.shared.asn1.Asn1Object)
+     */
+    @Override
+    public void setProtocolOP( Asn1Object protocolOp )
+    {
+        instance.setProtocolOP( protocolOp );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.codec.LdapMessageCodec#toString()
+     */
+    @Override
+    public String toString()
+    {
+        return instance.toString();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.asn1.Asn1Object#addLength(int)
+     */
+    @Override
+    public void addLength( int length ) throws DecoderException
+    {
+        instance.addLength( length );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.asn1.Asn1Object#getCurrentLength()
+     */
+    @Override
+    public int getCurrentLength()
+    {
+        return instance.getCurrentLength();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.asn1.Asn1Object#getExpectedLength()
+     */
+    @Override
+    public int getExpectedLength()
+    {
+        return instance.getExpectedLength();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.asn1.Asn1Object#getParent()
+     */
+    @Override
+    public AbstractAsn1Object getParent()
+    {
+        return instance.getParent();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.asn1.Asn1Object#setCurrentLength(int)
+     */
+    @Override
+    public void setCurrentLength( int currentLength )
+    {
+        instance.setCurrentLength( currentLength );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.asn1.Asn1Object#setExpectedLength(int)
+     */
+    @Override
+    public void setExpectedLength( int expectedLength )
+    {
+        instance.setExpectedLength( expectedLength );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.asn1.Asn1Object#setParent(org.apache.directory.shared.asn1.Asn1Object)
+     */
+    public void setParent( AbstractAsn1Object parent )
+    {
+        instance.setParent( parent );
+    }
+}

Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/ParserUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/ParserUtils.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/ParserUtils.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/ParserUtils.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,309 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.dsmlv2;
+
+
+import java.util.List;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.directory.shared.ldap.codec.ControlCodec;
+import org.apache.directory.shared.ldap.ldif.LdifUtils;
+import org.apache.directory.shared.ldap.util.Base64;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.apache.directory.studio.dsmlv2.engine.Dsmlv2Engine;
+import org.apache.directory.studio.dsmlv2.request.BatchRequest;
+import org.apache.directory.studio.dsmlv2.request.BatchRequest.Processing;
+import org.apache.directory.studio.dsmlv2.request.BatchRequest.ResponseOrder;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.Namespace;
+import org.dom4j.QName;
+import org.dom4j.io.DocumentResult;
+import org.dom4j.io.DocumentSource;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+
+/**
+ * This class is a Helper class for the DSML Parser
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ParserUtils
+{
+    public static final String XML_SCHEMA_URI = "http://www.w3c.org/2001/XMLSchema";
+    public static final String XML_SCHEMA_INSTANCE_URI = "http://www.w3c.org/2001/XMLSchema-instance";
+    public static final String BASE64BINARY = "base64Binary";
+    public static final String XSI = "xsi";
+    public static final String XSD = "xsd";
+
+
+    /**
+     * 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;
+    }
+
+
+    /**
+     * Tells is the given value is a Base64 binary value
+     * 
+     * @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] ) );
+    }
+
+
+    /**
+     * Indicates if the value needs to be encoded as Base64
+     *
+     * @param value 
+     *      the value to check
+     * @return 
+     *      true if the value needs to be encoded as Base64
+     */
+    public static boolean needsBase64Encoding( Object value )
+    {
+        if ( value instanceof byte[] )
+        {
+            return true;
+        }
+        else if ( value instanceof String )
+        {
+            return !LdifUtils.isLDIFSafe( ( String ) value );
+        }
+        return true;
+    }
+
+
+    /**
+     * Encodes the value as a Base64 String
+     *
+     * @param value 
+     *      the value to encode
+     * @return 
+     *      the value encoded as a Base64 String 
+     */
+    public static String base64Encode( Object value )
+    {
+        if ( value instanceof byte[] )
+        {
+            return new String( Base64.encode( ( byte[] ) value ) );
+        }
+        else if ( value instanceof String )
+        {
+            return new String( Base64.encode( StringTools.getBytesUtf8( ( String ) value ) ) );
+        }
+
+        return "";
+    }
+
+
+    /**
+     * Parses and verify the parsed value of the requestID
+     * 
+     * @param attributeValue 
+     *      the value of the attribute
+     * @param xpp 
+     *      the XmlPullParser
+     * @return
+     *      the int value of the resquestID
+     * @throws XmlPullParserException
+     *      if RequestID isn't an Integer and if requestID equals 0
+     */
+    public static int parseAndVerifyRequestID( String attributeValue, XmlPullParser xpp ) throws XmlPullParserException
+    {
+        try
+        {
+            int requestID = Integer.parseInt( attributeValue );
+
+            if ( requestID == 0 )
+            {
+                throw new XmlPullParserException( "The attribute requestID can't be equal to 0", xpp, null );
+            }
+
+            return requestID;
+        }
+        catch ( NumberFormatException e )
+        {
+            throw new XmlPullParserException( "the given requestID is not an integer", xpp, null );
+        }
+    }
+
+
+    /**
+     * Adds Controls to the given Element.
+     *
+     * @param element
+     *      the element to add the Controls to
+     * @param controls
+     *      a List of Controls
+     */
+    public static void addControls( Element element, List<ControlCodec> controls )
+    {
+        if ( controls != null )
+        {
+            for ( int i = 0; i < controls.size(); i++ )
+            {
+                ControlCodec control = controls.get( i );
+
+                Element controlElement = element.addElement( "control" );
+
+                if ( control.getControlType() != null )
+                {
+                    controlElement.addAttribute( "type", control.getControlType() );
+                }
+
+                if ( control.getCriticality() )
+                {
+                    controlElement.addAttribute( "criticality", "true" );
+                }
+
+                Object value = control.getControlValue();
+                if ( value != null )
+                {
+                    if ( ParserUtils.needsBase64Encoding( value ) )
+                    {
+                        Namespace xsdNamespace = new Namespace( ParserUtils.XSD, ParserUtils.XML_SCHEMA_URI );
+                        Namespace xsiNamespace = new Namespace( ParserUtils.XSI, ParserUtils.XML_SCHEMA_INSTANCE_URI );
+                        element.getDocument().getRootElement().add( xsdNamespace );
+                        element.getDocument().getRootElement().add( xsiNamespace );
+
+                        Element valueElement = controlElement.addElement( "controlValue" ).addText(
+                            ParserUtils.base64Encode( value ) );
+                        valueElement.addAttribute( new QName( "type", xsiNamespace ), ParserUtils.XSD + ":"
+                            + ParserUtils.BASE64BINARY );
+                    }
+                    else
+                    {
+                        controlElement.addElement( "controlValue" ).setText( ( String ) value );
+                    }
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Indicates if a request ID is needed.
+     *
+     * @param container
+     *      the associated container
+     * @return
+     *      true if a request ID is needed (ie Processing=Parallel and ResponseOrder=Unordered)
+     * @throws XmlPullParserException
+     *      if the batch request has not been parsed yet
+     */
+    public static boolean isRequestIdNeeded( Dsmlv2Container container ) throws XmlPullParserException
+    {
+        BatchRequest batchRequest = container.getBatchRequest();
+
+        if ( batchRequest == null )
+        {
+            throw new XmlPullParserException( "unable to find the batch request", container.getParser(), null );
+        }
+
+        return ( ( batchRequest.getProcessing() == Processing.PARALLEL ) && ( batchRequest.getResponseOrder() == ResponseOrder.UNORDERED ) );
+    }
+
+
+    /**
+     * XML Pretty Printer XSLT Tranformation
+     * 
+     * @param document
+     *      the Dom4j Document
+     * @return
+     *      the transformed document
+     */
+    public static Document styleDocument( Document document )
+    {
+        // load the transformer using JAXP
+        TransformerFactory factory = TransformerFactory.newInstance();
+        Transformer transformer = null;
+        try
+        {
+            transformer = factory.newTransformer( new StreamSource( Dsmlv2Engine.class
+                .getResourceAsStream( "DSMLv2.xslt" ) ) );
+        }
+        catch ( TransformerConfigurationException e1 )
+        {
+            // TODO Auto-generated catch block
+            e1.printStackTrace();
+        }
+
+        // now lets style the given document
+        DocumentSource source = new DocumentSource( document );
+        DocumentResult result = new DocumentResult();
+        try
+        {
+            transformer.transform( source, result );
+        }
+        catch ( TransformerException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+        // return the transformed document
+        Document transformedDoc = result.getDocument();
+        return transformedDoc;
+    }
+}

Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Tag.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Tag.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Tag.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Tag.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,157 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.dsmlv2;
+
+
+/**
+ * This class represents a XML tag.
+ * A XML tag is defined with :
+ * <ul>
+ *      <li>a name</li>
+ *      <li>a type (START tag or END tag)</li>
+ * </ul>
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class Tag
+{
+    /** The name of the tag */
+    private String name;
+
+    /** The type of the tag */
+    private int type;
+
+    /** This int represents a START tag */
+    public static int START = 0;
+
+    /** This int represents a END tag */
+    public static int END = 1;
+
+
+    /**
+     * Creates a new instance of Tag.
+     *
+     * @param name
+     *      the name of the tag
+     * @param type
+     *      the type of the tag
+     */
+    public Tag( String name, int type )
+    {
+        setName( name );
+        setType( type );
+    }
+
+
+    /**
+     * Gets the name of the tag
+     *
+     * @return
+     *      the name of the tag
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+
+    /**
+     * Sets the name of the tag
+     *
+     * @param name
+     *      the name to set
+     */
+    public void setName( String name )
+    {
+        this.name = name.toLowerCase();
+    }
+
+
+    /**
+     * Gets the type of the tag
+     *
+     * @return
+     *      the type of the tag
+     */
+    public int getType()
+    {
+        return type;
+    }
+
+
+    /**
+     * Sets the type of the tag
+     *
+     * @param type
+     *      the type to set
+     */
+    public void setType( int type )
+    {
+        this.type = type;
+    }
+
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( obj instanceof Tag )
+        {
+            Tag tag = ( Tag ) obj;
+            return ( ( this.name.equals( tag.getName() ) ) && ( this.type == tag.getType() ) );
+
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode()
+    {
+        return name.hashCode() + type << 24;
+    }
+
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString()
+    {
+        if ( name != null )
+        {
+            return "<" + ( ( type == Tag.END ) ? "/" : "" ) + name + ">";
+        }
+        else
+        {
+            return "Unknown tag";
+        }
+    }
+}

Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/engine/Dsmlv2Engine.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/engine/Dsmlv2Engine.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/engine/Dsmlv2Engine.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/engine/Dsmlv2Engine.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,649 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.dsmlv2.engine;
+
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.net.UnknownHostException;
+import java.nio.ByteBuffer;
+import java.nio.channels.SocketChannel;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.asn1.ber.Asn1Decoder;
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.tlv.TLVStateEnum;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.asn1.codec.EncoderException;
+import org.apache.directory.shared.ldap.codec.ControlCodec;
+import org.apache.directory.shared.ldap.codec.LdapConstants;
+import org.apache.directory.shared.ldap.codec.LdapDecoder;
+import org.apache.directory.shared.ldap.codec.LdapMessageCodec;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.LdapResponseCodec;
+import org.apache.directory.shared.ldap.codec.add.AddResponseCodec;
+import org.apache.directory.shared.ldap.codec.bind.BindRequestCodec;
+import org.apache.directory.shared.ldap.codec.bind.BindResponseCodec;
+import org.apache.directory.shared.ldap.codec.bind.LdapAuthentication;
+import org.apache.directory.shared.ldap.codec.bind.SimpleAuthentication;
+import org.apache.directory.shared.ldap.codec.compare.CompareResponseCodec;
+import org.apache.directory.shared.ldap.codec.del.DelResponseCodec;
+import org.apache.directory.shared.ldap.codec.extended.ExtendedResponseCodec;
+import org.apache.directory.shared.ldap.codec.modify.ModifyResponseCodec;
+import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNResponseCodec;
+import org.apache.directory.shared.ldap.codec.search.SearchResultDoneCodec;
+import org.apache.directory.shared.ldap.codec.search.SearchResultEntryCodec;
+import org.apache.directory.shared.ldap.codec.search.SearchResultReferenceCodec;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.apache.directory.studio.dsmlv2.Dsmlv2Parser;
+import org.apache.directory.studio.dsmlv2.reponse.AddResponseDsml;
+import org.apache.directory.studio.dsmlv2.reponse.AuthResponseDsml;
+import org.apache.directory.studio.dsmlv2.reponse.BatchResponseDsml;
+import org.apache.directory.studio.dsmlv2.reponse.CompareResponseDsml;
+import org.apache.directory.studio.dsmlv2.reponse.DelResponseDsml;
+import org.apache.directory.studio.dsmlv2.reponse.ErrorResponse;
+import org.apache.directory.studio.dsmlv2.reponse.ExtendedResponseDsml;
+import org.apache.directory.studio.dsmlv2.reponse.ModDNResponseDsml;
+import org.apache.directory.studio.dsmlv2.reponse.ModifyResponseDsml;
+import org.apache.directory.studio.dsmlv2.reponse.SearchResponseDsml;
+import org.apache.directory.studio.dsmlv2.reponse.SearchResultDoneDsml;
+import org.apache.directory.studio.dsmlv2.reponse.SearchResultEntryDsml;
+import org.apache.directory.studio.dsmlv2.reponse.SearchResultReferenceDsml;
+import org.apache.directory.studio.dsmlv2.reponse.ErrorResponse.ErrorResponseType;
+import org.apache.directory.studio.dsmlv2.request.BatchRequest;
+import org.apache.directory.studio.dsmlv2.request.BatchRequest.OnError;
+import org.apache.directory.studio.dsmlv2.request.BatchRequest.Processing;
+import org.apache.directory.studio.dsmlv2.request.BatchRequest.ResponseOrder;
+import org.xmlpull.v1.XmlPullParserException;
+
+
+/**
+ * This is the DSMLv2Engine. It can be use to execute operations on a LDAP Server and get the results of these operations.
+ * The format used for request and responses is the DSMLv2 format.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class Dsmlv2Engine
+{
+    /** Socket used to connect to the server */
+    private SocketChannel channel;
+    private SocketAddress serverAddress;
+
+    // server configuration
+    private int port;
+    private String host;
+    private String user;
+    private String password;
+
+    private Asn1Decoder ldapDecoder = new LdapDecoder();
+
+    private IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+    private Dsmlv2Parser parser;
+
+    private boolean continueOnError;
+    private boolean exit = false;
+
+    private int bbLimit;
+
+    private int bbposition;
+    private BatchRequest batchRequest;
+    private BatchResponseDsml batchResponse;
+
+
+    /**
+     * Creates a new instance of Dsmlv2Engine.
+     * 
+     * @param host 
+     *      the server host
+     * @param port 
+     *      the server port
+     * @param user 
+     *      the server admin DN
+     * @param password 
+     *      the server admin's password
+     */
+    public Dsmlv2Engine( String host, int port, String user, String password )
+    {
+        this.host = host;
+        this.port = port;
+        this.user = user;
+        this.password = password;
+    }
+
+
+    /**
+     * Processes the file given and return the result of the operations
+     * 
+     * @param dsmlInput 
+     *      the DSMLv2 formatted request input
+     * @return
+     *      the XML response in DSMLv2 Format
+     * @throws XmlPullParserException
+     *      if an error occurs in the parser
+     */
+    public String processDSML( String dsmlInput ) throws XmlPullParserException
+    {
+        parser = new Dsmlv2Parser();
+        parser.setInput( dsmlInput );
+        return processDSML();
+    }
+
+
+    /**
+     * Processes the file given and return the result of the operations
+     * 
+     * @param fileName 
+     *      the path to the file
+     * @return 
+     *      the XML response in DSMLv2 Format
+     * @throws XmlPullParserException
+     *      if an error occurs in the parser
+     * @throws FileNotFoundException
+     *      if the file does not exist
+     */
+    public String processDSMLFile( String fileName ) throws XmlPullParserException, FileNotFoundException
+    {
+        parser = new Dsmlv2Parser();
+        parser.setInputFile( fileName );
+        return processDSML();
+    }
+
+
+    /**
+     * Processes the file given and return the result of the operations
+     * 
+     * @param inputStream 
+     *      contains a raw byte input stream of possibly unknown encoding (when inputEncoding is null).
+     * @param inputEncoding 
+     *      if not null it MUST be used as encoding for inputStream
+     * @return 
+     *      the XML response in DSMLv2 Format
+     * @throws XmlPullParserException
+     *      if an error occurs in the parser
+     */
+    public String processDSML( InputStream inputStream, String inputEncoding ) throws XmlPullParserException
+    {
+        parser = new Dsmlv2Parser();
+        parser.setInput( inputStream, inputEncoding );
+        return processDSML();
+    }
+
+
+    /**
+     * Processes the Request document
+     * 
+     * @return 
+     *      the XML response in DSMLv2 Format
+     */
+    private String processDSML()
+    {
+        batchResponse = new BatchResponseDsml();
+
+        // Binding to LDAP Server
+        try
+        {
+            bind( 1 );
+        }
+        catch ( Exception e )
+        {
+            // Unable to connect to server
+            // We create a new ErrorResponse and return the XML response.
+            ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.COULD_NOT_CONNECT, e.getMessage() );
+            batchResponse.addResponse( errorResponse );
+            return batchResponse.toDsml();
+        }
+
+        // Processing BatchRequest:
+        //    - Parsing and Getting BatchRequest
+        //    - Getting and registering options from BatchRequest
+        try
+        {
+            processBatchRequest();
+        }
+        catch ( XmlPullParserException e )
+        {
+            // We create a new ErrorResponse and return the XML response.
+            ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.MALFORMED_REQUEST, e.getMessage()
+                + " - Line " + e.getLineNumber() + " - Column " + e.getColumnNumber() );
+            batchResponse.addResponse( errorResponse );
+            return batchResponse.toDsml();
+        }
+
+        // Processing each request:
+        //    - Getting a new request
+        //    - Checking if the request is well formed
+        //    - Sending the request to the server
+        //    - Getting and converting reponse(s) as XML
+        //    - Looping until last request
+        LdapMessageCodec request = null;
+        try
+        {
+            request = parser.getNextRequest();
+        }
+        catch ( XmlPullParserException e )
+        {
+            // We create a new ErrorResponse and return the XML response.
+            ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.MALFORMED_REQUEST, e.getMessage()
+                + " - Line " + e.getLineNumber() + " - Column " + e.getColumnNumber() );
+            batchResponse.addResponse( errorResponse );
+            return batchResponse.toDsml();
+        }
+
+        while ( request != null ) // (Request == null when there's no more request to process)
+        {
+            // Checking the request has a requestID attribute if Processing = Parallel and ResponseOrder = Unordered
+            if ( ( batchRequest.getProcessing().equals( Processing.PARALLEL ) )
+                && ( batchRequest.getResponseOrder().equals( ResponseOrder.UNORDERED ) )
+                && ( request.getMessageId() == 0 ) )
+            {
+                // Then we have to send an errorResponse
+                ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.MALFORMED_REQUEST,
+                    "A requestID must be specified to each request when Processing is Parallel and ReponseOrder is Unordered." );
+                batchResponse.addResponse( errorResponse );
+                return batchResponse.toDsml();
+            }
+
+            try
+            {
+                processRequest( request );
+            }
+            catch ( Exception e )
+            {
+                // We create a new ErrorResponse and return the XML response.
+                ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.GATEWAY_INTERNAL_ERROR,
+                    "Internal Error: " + e.getMessage() );
+                batchResponse.addResponse( errorResponse );
+                return batchResponse.toDsml();
+            }
+
+            // Checking if we need to exit processing (if an error has ocurred if onError == Exit)
+            if ( exit )
+            {
+                break;
+            }
+
+            // Getting next request
+            try
+            {
+                request = parser.getNextRequest();
+            }
+            catch ( XmlPullParserException e )
+            {
+                // We create a new ErrorResponse and return the XML response.
+                ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.MALFORMED_REQUEST, e.getMessage()
+                    + " - Line " + e.getLineNumber() + " - Column " + e.getColumnNumber() );
+                batchResponse.addResponse( errorResponse );
+                return batchResponse.toDsml();
+            }
+        }
+
+        return batchResponse.toDsml();
+    }
+
+
+    /**
+     * Processes a single request
+     * 
+     * @param request 
+     *      the request to process
+     * @throws EncoderException 
+     * @throws IOException 
+     * @throws NamingException 
+     * @throws DecoderException 
+     */
+    private void processRequest( LdapMessageCodec request ) throws EncoderException, IOException, DecoderException,
+        NamingException
+    {
+        LdapMessageCodec message = new LdapMessageCodec();
+
+        message.setProtocolOP( request );
+
+        message.setMessageId( request.getMessageId() );
+
+        ByteBuffer bb = null;
+
+        bb = message.encode( null );
+
+        bb.flip();
+
+        sendMessage( bb );
+
+        bb.clear();
+        bb.position( bb.capacity() );
+        // Get the response
+        LdapMessageCodec response = null;
+
+        response = readResponse( bb );
+
+        if ( LdapConstants.ADD_RESPONSE == response.getMessageType() )
+        {
+            AddResponseCodec addResponse = response.getAddResponse();
+            copyMessageIdAndControls( response, addResponse );
+
+            AddResponseDsml addResponseDsml = new AddResponseDsml( addResponse );
+            batchResponse.addResponse( addResponseDsml );
+        }
+        else if ( LdapConstants.BIND_RESPONSE == response.getMessageType() )
+        {
+            BindResponseCodec bindResponse = response.getBindResponse();
+            copyMessageIdAndControls( response, bindResponse );
+
+            AuthResponseDsml authResponseDsml = new AuthResponseDsml( bindResponse );
+            batchResponse.addResponse( authResponseDsml );
+        }
+        else if ( LdapConstants.COMPARE_RESPONSE == response.getMessageType() )
+        {
+            CompareResponseCodec compareResponse = response.getCompareResponse();
+            copyMessageIdAndControls( response, compareResponse );
+
+            CompareResponseDsml authResponseDsml = new CompareResponseDsml( compareResponse );
+            batchResponse.addResponse( authResponseDsml );
+        }
+        else if ( LdapConstants.DEL_RESPONSE == response.getMessageType() )
+        {
+            DelResponseCodec delResponse = response.getDelResponse();
+            copyMessageIdAndControls( response, delResponse );
+
+            DelResponseDsml delResponseDsml = new DelResponseDsml( delResponse );
+            batchResponse.addResponse( delResponseDsml );
+        }
+        else if ( LdapConstants.MODIFY_RESPONSE == response.getMessageType() )
+        {
+            ModifyResponseCodec modifyResponse = response.getModifyResponse();
+            copyMessageIdAndControls( response, modifyResponse );
+
+            ModifyResponseDsml modifyResponseDsml = new ModifyResponseDsml( modifyResponse );
+            batchResponse.addResponse( modifyResponseDsml );
+        }
+        else if ( LdapConstants.MODIFYDN_RESPONSE == response.getMessageType() )
+        {
+            ModifyDNResponseCodec modifyDNResponse = response.getModifyDNResponse();
+            copyMessageIdAndControls( response, modifyDNResponse );
+
+            ModDNResponseDsml modDNResponseDsml = new ModDNResponseDsml( modifyDNResponse );
+            batchResponse.addResponse( modDNResponseDsml );
+        }
+        else if ( LdapConstants.EXTENDED_RESPONSE == response.getMessageType() )
+        {
+            ExtendedResponseCodec extendedResponse = response.getExtendedResponse();
+            copyMessageIdAndControls( response, extendedResponse );
+
+            ExtendedResponseDsml extendedResponseDsml = new ExtendedResponseDsml( extendedResponse );
+            batchResponse.addResponse( extendedResponseDsml );
+        }
+        else if ( ( LdapConstants.SEARCH_RESULT_ENTRY == response.getMessageType() )
+            || ( LdapConstants.SEARCH_RESULT_REFERENCE == response.getMessageType() )
+            || ( LdapConstants.SEARCH_RESULT_DONE == response.getMessageType() ) )
+        {
+            // A SearchResponse can contains multiple responses of 3 types:
+            //     - 0 to n SearchResultEntry
+            //     - O to n SearchResultReference
+            //     - 1 (only) SearchResultDone
+            // So we have to include those individual reponses in a "General" SearchResponse
+            //            Element searchResponse = xmlResponse.getRootElement().addElement( "searchResponse" );
+            SearchResponseDsml searchResponseDsml = new SearchResponseDsml();
+
+            // RequestID
+            int requestID = response.getMessageId();
+            if ( requestID != 0 )
+            {
+                searchResponseDsml.setMessageId( requestID );
+            }
+
+            while ( LdapConstants.SEARCH_RESULT_DONE != response.getMessageType() )
+            {
+                if ( LdapConstants.SEARCH_RESULT_ENTRY == response.getMessageType() )
+                {
+                    SearchResultEntryCodec sre = response.getSearchResultEntry();
+                    copyMessageIdAndControls( response, sre );
+
+                    SearchResultEntryDsml searchResultEntryDsml = new SearchResultEntryDsml( sre );
+                    searchResponseDsml.addResponse( searchResultEntryDsml );
+                }
+                else if ( LdapConstants.SEARCH_RESULT_REFERENCE == response.getMessageType() )
+                {
+                    SearchResultReferenceCodec srr = response.getSearchResultReference();
+                    copyMessageIdAndControls( response, srr );
+
+                    SearchResultReferenceDsml searchResultReferenceDsml = new SearchResultReferenceDsml( srr );
+                    searchResponseDsml.addResponse( searchResultReferenceDsml );
+                }
+
+                response = readResponse( bb );
+            }
+
+            SearchResultDoneCodec srd = response.getSearchResultDone();
+            copyMessageIdAndControls( response, srd );
+
+            SearchResultDoneDsml searchResultDoneDsml = new SearchResultDoneDsml( srd );
+            searchResponseDsml.addResponse( searchResultDoneDsml );
+        }
+
+        LdapResponseCodec realResponse = response.getLdapResponse();
+
+        if ( !continueOnError )
+        {
+            if ( ( realResponse.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS )
+                && ( realResponse.getLdapResult().getResultCode() != ResultCodeEnum.COMPARE_TRUE )
+                && ( realResponse.getLdapResult().getResultCode() != ResultCodeEnum.COMPARE_FALSE )
+                && ( realResponse.getLdapResult().getResultCode() != ResultCodeEnum.REFERRAL ) )
+            {
+                // Turning on Exit flag
+                exit = true;
+            }
+        }
+
+    }
+
+
+    private void copyMessageIdAndControls( LdapMessageCodec from, LdapMessageCodec to )
+    {
+        to.setMessageId( from.getMessageId() );
+        for ( ControlCodec control : from.getControls() )
+        {
+            to.addControl( control );
+        }
+    }
+
+
+    /**
+     * Processes the BatchRequest
+     * <ul>
+     *     <li>Parsing and Getting BatchRequest</li>
+     *     <li>Getting and registering options from BatchRequest</li>
+     * </ul>
+     *     
+     * @throws XmlPullParserException
+     *      if an error occurs in the parser
+     */
+    private void processBatchRequest() throws XmlPullParserException
+    {
+        // Parsing BatchRequest
+        parser.parseBatchRequest();
+
+        // Getting BatchRequest
+        batchRequest = parser.getBatchRequest();
+
+        if ( OnError.RESUME.equals( batchRequest.getOnError() ) )
+        {
+            continueOnError = true;
+        }
+        else if ( OnError.EXIT.equals( batchRequest.getOnError() ) )
+        {
+            continueOnError = false;
+        }
+
+        if ( batchRequest.getRequestID() != 0 )
+        {
+            batchResponse.setRequestID( batchRequest.getRequestID() );
+        }
+    }
+
+
+    /**
+     * Connect to the LDAP server through a socket and establish the Input and
+     * Output Streams. All the required information for the connection should be
+     * in the options from the command line, or the default values.
+     * 
+     * @throws UnknownHostException
+     *      if the hostname or the Address of server could not be found
+     * @throws IOException
+     *      if there was a error opening or establishing the socket
+     */
+    private void connect() throws UnknownHostException, IOException
+    {
+        serverAddress = new InetSocketAddress( host, port );
+        channel = SocketChannel.open( serverAddress );
+        channel.configureBlocking( true );
+    }
+
+
+    /**
+     * Sends a message
+     * 
+     * @param bb
+     *      the message as a byte buffer
+     * @throws IOException
+     *      if the message could not be sent
+     */
+    private void sendMessage( ByteBuffer bb ) throws IOException
+    {
+        channel.write( bb );
+        bb.clear();
+    }
+
+
+    /**
+     * Reads the response to a request
+     * 
+     * @param bb
+     *      the response as a byte buffer
+     * @return the response
+     *      the response as a LDAP message
+     * @throws IOException
+     * @throws DecoderException
+     * @throws NamingException
+     */
+    private LdapMessageCodec readResponse( ByteBuffer bb ) throws IOException, DecoderException, NamingException
+    {
+
+        LdapMessageCodec messageResp = null;
+
+        if ( bb.hasRemaining() )
+        {
+            bb.position( bbposition );
+            bb.limit( bbLimit );
+            ldapDecoder.decode( bb, ldapMessageContainer );
+            bbposition = bb.position();
+            bbLimit = bb.limit();
+        }
+        bb.flip();
+        while ( ldapMessageContainer.getState() != TLVStateEnum.PDU_DECODED )
+        {
+
+            int nbRead = channel.read( bb );
+
+            if ( nbRead == -1 )
+            {
+                System.err.println( "fsdfsdfsdfsd" );
+            }
+
+            bb.flip();
+            ldapDecoder.decode( bb, ldapMessageContainer );
+            bbposition = bb.position();
+            bbLimit = bb.limit();
+            bb.flip();
+        }
+
+        messageResp = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
+
+        if ( messageResp instanceof BindResponseCodec )
+        {
+            BindResponseCodec resp = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage().getBindResponse();
+
+            if ( resp.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS )
+            {
+                System.err.println( "Error : " + resp.getLdapResult().getErrorMessage() );
+            }
+        }
+        else if ( messageResp instanceof ExtendedResponseCodec )
+        {
+            ExtendedResponseCodec resp = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage()
+                .getExtendedResponse();
+
+            if ( resp.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS )
+            {
+                System.err.println( "Error : " + resp.getLdapResult().getErrorMessage() );
+            }
+        }
+
+        ( ( LdapMessageContainer ) ldapMessageContainer ).clean();
+
+        return messageResp;
+    }
+
+
+    /**
+     * Binds to the ldap server
+     * 
+     * @param messageId 
+     *      the message Id
+     * @throws EncoderException
+     * @throws DecoderException
+     * @throws IOException
+     * @throws NamingException
+     */
+    private void bind( int messageId ) throws EncoderException, DecoderException, IOException, NamingException
+    {
+        BindRequestCodec bindRequest = new BindRequestCodec();
+        LdapMessageCodec message = new LdapMessageCodec();
+        LdapAuthentication authentication = new SimpleAuthentication();
+        ( ( SimpleAuthentication ) authentication ).setSimple( StringTools.getBytesUtf8( password ) );
+
+        bindRequest.setAuthentication( authentication );
+        bindRequest.setName( new LdapDN( user ) );
+        bindRequest.setVersion( 3 );
+
+        message.setProtocolOP( bindRequest );
+        message.setMessageId( messageId );
+
+        // Encode and send the bind request
+        ByteBuffer bb = message.encode( null );
+        bb.flip();
+
+        connect();
+        sendMessage( bb );
+
+        bb.clear();
+
+        bb.position( bb.limit() );
+
+        readResponse( bb );
+    }
+}

Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/AddResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/AddResponseDsml.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/AddResponseDsml.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/AddResponseDsml.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,78 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.dsmlv2.reponse;
+
+
+import org.apache.directory.shared.ldap.codec.add.AddResponseCodec;
+import org.apache.directory.studio.dsmlv2.DsmlDecorator;
+import org.dom4j.Element;
+
+
+/**
+ * DSML Decorator for AddResponse
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AddResponseDsml extends LdapResponseDecorator implements DsmlDecorator
+{
+    /**
+     * Creates a new instance of AddResponseDsml.
+     */
+    public AddResponseDsml()
+    {
+        super( new AddResponseCodec() );
+    }
+
+
+    /**
+     * Creates a new instance of AddResponseDsml.
+     *
+     * @param ldapMessage
+     *      the message to decorate
+     */
+    public AddResponseDsml( AddResponseCodec ldapMessage )
+    {
+        super( ldapMessage );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.dsmlv2.reponse.LdapMessageDecorator#getMessageType()
+     */
+    public int getMessageType()
+    {
+        return instance.getMessageType();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.dsmlv2.reponse.DsmlDecorator#toDsml(org.dom4j.Element)
+     */
+    public Element toDsml( Element root )
+    {
+        Element element = root.addElement( "addResponse" );
+
+        LdapResultDsml ldapResultDsml = new LdapResultDsml( ( ( AddResponseCodec ) instance ).getLdapResult(), instance );
+        ldapResultDsml.toDsml( element );
+        return element;
+    }
+}

Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/AuthResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/AuthResponseDsml.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/AuthResponseDsml.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/AuthResponseDsml.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,78 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.dsmlv2.reponse;
+
+
+import org.apache.directory.shared.ldap.codec.bind.BindResponseCodec;
+import org.apache.directory.studio.dsmlv2.DsmlDecorator;
+import org.dom4j.Element;
+
+
+/**
+ * DSML Decorator for AuthResponse
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AuthResponseDsml extends LdapResponseDecorator implements DsmlDecorator
+{
+    /**
+     * Creates a new instance of AuthResponseDsml.
+     */
+    public AuthResponseDsml()
+    {
+        super( new BindResponseCodec() );
+    }
+
+
+    /**
+     * Creates a new instance of AuthResponseDsml.
+     *
+     * @param ldapMessage
+     *      the message to decorate
+     */
+    public AuthResponseDsml( BindResponseCodec ldapMessage )
+    {
+        super( ldapMessage );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.dsmlv2.reponse.LdapMessageDecorator#getMessageType()
+     */
+    public int getMessageType()
+    {
+        return instance.getMessageType();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.dsmlv2.reponse.DsmlDecorator#toDsml(org.dom4j.Element)
+     */
+    public Element toDsml( Element root )
+    {
+        Element element = root.addElement( "authResponse" );
+
+        LdapResultDsml ldapResultDsml = new LdapResultDsml( ( ( BindResponseCodec ) instance ).getLdapResult(), instance );
+        ldapResultDsml.toDsml( element );
+        return element;
+    }
+}

Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/BatchResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/BatchResponse.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/BatchResponse.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/BatchResponse.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,118 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.dsmlv2.reponse;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.shared.ldap.codec.LdapResponseCodec;
+
+
+/**
+ * This class represents the Batch Response of a DSML Response
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BatchResponse
+{
+
+    /**
+     * The responses contained in the Batch Response
+     */
+    private List<LdapResponseCodec> responses;
+
+    /**
+     * The ID of the response
+     */
+    private int requestID;
+
+
+    /**
+     * Creates a new instance of BatchResponse.
+     */
+    public BatchResponse()
+    {
+        responses = new ArrayList<LdapResponseCodec>();
+    }
+
+
+    /**
+     * Adds a reponse
+     *
+     * @param response
+     *      the response to add
+     * @return
+     *      true (as per the general contract of the Collection.add method)
+     */
+    public boolean addResponse( LdapResponseCodec response )
+    {
+        return responses.add( response );
+    }
+
+
+    /**
+     * Gets the current reponse
+     *
+     * @return
+     *      the current response
+     */
+    public LdapResponseCodec getCurrentResponse()
+    {
+        return responses.get( responses.size() - 1 );
+    }
+
+
+    /**
+     * Gets the ID of the response
+     * @return
+     *      the ID of the response
+     */
+    public int getRequestID()
+    {
+        return requestID;
+    }
+
+
+    /**
+     * Sets the ID of the response
+     *
+     * @param requestID
+     *      the ID to set
+     */
+    public void setRequestID( int requestID )
+    {
+        this.requestID = requestID;
+    }
+
+
+    /**
+     * Gets the List of all the reponses
+     *
+     * @return
+     *      the List of all the responses
+     */
+    public List getResponses()
+    {
+        return responses;
+    }
+}

Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/BatchResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/BatchResponseDsml.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/BatchResponseDsml.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/BatchResponseDsml.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,129 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.dsmlv2.reponse;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.studio.dsmlv2.DsmlDecorator;
+import org.apache.directory.studio.dsmlv2.ParserUtils;
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+
+/**
+ * This class represents the Batch Response. It can be used to generate an the XML String of a BatchResponse.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BatchResponseDsml
+{
+    /** The Responses list */
+    private List<DsmlDecorator> responses;
+
+    /** The ID of the response */
+    private int requestID;
+
+
+    /**
+     * Creates a new instance of BatchResponseDsml.
+     */
+    public BatchResponseDsml()
+    {
+        responses = new ArrayList<DsmlDecorator>();
+    }
+
+
+    /**
+     * Adds a request to the Batch Response DSML.
+     *
+     * @param response
+     *      the request to add
+     * @return
+     *      true (as per the general contract of the Collection.add method).
+     */
+    public boolean addResponse( DsmlDecorator response )
+    {
+        return responses.add( response );
+    }
+
+
+    /**
+     * Removes a request from the Batch Response DSML.
+     *
+     * @param response
+     *      the request to remove
+     * @return
+     *      true if this list contained the specified element.
+     */
+    public boolean removeResponse( DsmlDecorator response )
+    {
+        return responses.remove( response );
+    }
+
+
+    /**
+     * Gets the ID of the response
+     * @return
+     *      the ID of the response
+     */
+    public int getRequestID()
+    {
+        return requestID;
+    }
+
+
+    /**
+     * Sets the ID of the response
+     *
+     * @param requestID
+     *      the ID to set
+     */
+    public void setRequestID( int requestID )
+    {
+        this.requestID = requestID;
+    }
+
+
+    /**
+     * Converts the Batch Response to its XML representation in the DSMLv2 format.
+     */
+    public String toDsml()
+    {
+        Document document = DocumentHelper.createDocument();
+        Element element = document.addElement( "batchResponse" );
+
+        // RequestID
+        if ( requestID != 0 )
+        {
+            element.addAttribute( "requestID", "" + requestID );
+        }
+
+        for ( DsmlDecorator response : responses )
+        {
+            response.toDsml( element );
+        }
+
+        return ParserUtils.styleDocument( document ).asXML();
+    }
+}

Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/CompareResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/CompareResponseDsml.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/CompareResponseDsml.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/CompareResponseDsml.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,78 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.dsmlv2.reponse;
+
+
+import org.apache.directory.shared.ldap.codec.compare.CompareResponseCodec;
+import org.apache.directory.studio.dsmlv2.DsmlDecorator;
+import org.dom4j.Element;
+
+
+/**
+ * DSML Decorator for CompareResponse
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CompareResponseDsml extends LdapResponseDecorator implements DsmlDecorator
+{
+    /**
+     * Creates a new instance of CompareResponseDsml.
+     */
+    public CompareResponseDsml()
+    {
+        super( new CompareResponseCodec() );
+    }
+
+
+    /**
+     * Creates a new instance of CompareResponseDsml.
+     *
+     * @param ldapMessage
+     *      the message to decorate
+     */
+    public CompareResponseDsml( CompareResponseCodec ldapMessage )
+    {
+        super( ldapMessage );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.dsmlv2.reponse.LdapMessageDecorator#getMessageType()
+     */
+    public int getMessageType()
+    {
+        return instance.getMessageType();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.dsmlv2.reponse.DsmlDecorator#toDsml(org.dom4j.Element)
+     */
+    public Element toDsml( Element root )
+    {
+        Element element = root.addElement( "compareResponse" );
+
+        LdapResultDsml ldapResultDsml = new LdapResultDsml( ( ( CompareResponseCodec ) instance ).getLdapResult(), instance );
+        ldapResultDsml.toDsml( element );
+        return element;
+    }
+}

Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/DelResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/DelResponseDsml.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/DelResponseDsml.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/DelResponseDsml.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,78 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.dsmlv2.reponse;
+
+
+import org.apache.directory.shared.ldap.codec.del.DelResponseCodec;
+import org.apache.directory.studio.dsmlv2.DsmlDecorator;
+import org.dom4j.Element;
+
+
+/**
+ * DSML Decorator for DelResponse
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class DelResponseDsml extends LdapResponseDecorator implements DsmlDecorator
+{
+    /**
+     * Creates a new instance of DelResponseDsml.
+     */
+    public DelResponseDsml()
+    {
+        super( new DelResponseCodec() );
+    }
+
+
+    /**
+     * Creates a new instance of DelResponseDsml.
+     *
+     * @param ldapMessage
+     *      the message to decorate
+     */
+    public DelResponseDsml( DelResponseCodec ldapMessage )
+    {
+        super( ldapMessage );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.dsmlv2.reponse.LdapMessageDecorator#getMessageType()
+     */
+    public int getMessageType()
+    {
+        return instance.getMessageType();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.dsmlv2.reponse.DsmlDecorator#toDsml(org.dom4j.Element)
+     */
+    public Element toDsml( Element root )
+    {
+        Element element = root.addElement( "delResponse" );
+
+        LdapResultDsml ldapResultDsml = new LdapResultDsml( ( ( DelResponseCodec ) instance ).getLdapResult(), instance );
+        ldapResultDsml.toDsml( element );
+        return element;
+    }
+}



Mime
View raw message