You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2006/11/16 17:38:51 UTC
svn commit: r475805 [7/17] - in
/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser: ./
META-INF/ src/ src/main/ src/main/java/ src/main/java/org/
src/main/java/org/apache/ src/main/java/org/apache/directory/
src/main/java/org/apache/direct...
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/engine/Dsmlv2Engine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/engine/Dsmlv2Engine.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/engine/Dsmlv2Engine.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/engine/Dsmlv2Engine.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,657 @@
+/*
+ * 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.ldapstudio.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 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.ldapstudio.dsmlv2.BatchRequest;
+import org.apache.directory.ldapstudio.dsmlv2.Dsmlv2Parser;
+import org.apache.directory.ldapstudio.dsmlv2.BatchRequest.OnError;
+import org.apache.directory.ldapstudio.dsmlv2.BatchRequest.Processing;
+import org.apache.directory.ldapstudio.dsmlv2.BatchRequest.ResponseOrder;
+import org.apache.directory.ldapstudio.dsmlv2.reponse.AddResponseDsml;
+import org.apache.directory.ldapstudio.dsmlv2.reponse.AuthResponseDsml;
+import org.apache.directory.ldapstudio.dsmlv2.reponse.CompareResponseDsml;
+import org.apache.directory.ldapstudio.dsmlv2.reponse.DelResponseDsml;
+import org.apache.directory.ldapstudio.dsmlv2.reponse.ErrorResponse;
+import org.apache.directory.ldapstudio.dsmlv2.reponse.ExtendedResponseDsml;
+import org.apache.directory.ldapstudio.dsmlv2.reponse.ModDNResponseDsml;
+import org.apache.directory.ldapstudio.dsmlv2.reponse.ModifyResponseDsml;
+import org.apache.directory.ldapstudio.dsmlv2.reponse.SearchResultDoneDsml;
+import org.apache.directory.ldapstudio.dsmlv2.reponse.SearchResultEntryDsml;
+import org.apache.directory.ldapstudio.dsmlv2.reponse.SearchResultReferenceDsml;
+import org.apache.directory.ldapstudio.dsmlv2.reponse.ErrorResponse.ErrorResponseType;
+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.LdapConstants;
+import org.apache.directory.shared.ldap.codec.LdapDecoder;
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.LdapResponse;
+import org.apache.directory.shared.ldap.codec.bind.BindRequest;
+import org.apache.directory.shared.ldap.codec.bind.BindResponse;
+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.extended.ExtendedResponse;
+import org.apache.directory.shared.ldap.codec.util.LdapResultEnum;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.io.DocumentResult;
+import org.dom4j.io.DocumentSource;
+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.
+ */
+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 Document xmlResponse;
+ private BatchRequest batchRequest;
+
+ /**
+ * Default Constructor
+ *
+ * @param host the server host
+ * @param port the server port
+ * @param user the server admin DN
+ * @param password the server admin DN'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 fileName The path to the file
+ * @return The XML reponse in DSMLv2 Format
+ * @throws XmlPullParserException
+ * @throws FileNotFoundException
+ */
+ public String processDSML( String fileName ) throws XmlPullParserException, FileNotFoundException
+ {
+ parser = new Dsmlv2Parser();
+
+ parser.setInput( fileName );
+
+ return processDSML();
+ }
+
+
+ /**
+ * Processes the file given and return the result of the operations
+ * @param fileName The path to the file
+ * @return The XML reponse in DSMLv2 Format
+ * @throws XmlPullParserException
+ * @throws FileNotFoundException
+ */
+ 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 reponse in DSMLv2 Format
+ * @throws XmlPullParserException
+ * @throws FileNotFoundException
+ */
+ public String processDSML( InputStream inputStream, String inputEncoding ) throws XmlPullParserException, FileNotFoundException
+ {
+ parser = new Dsmlv2Parser();
+
+ parser.setInput( inputStream, inputEncoding );
+
+ return processDSML();
+ }
+
+ /**
+ * Processes the Request document
+ * @return The XML reponse in DSMLv2 Format
+ */
+ private String processDSML()
+ {
+ // Creating XML Document and root Element 'batchResponse'
+ xmlResponse = DocumentHelper.createDocument();
+ xmlResponse.addElement( "batchResponse" );
+
+ // 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() );
+
+ errorResponse.toDsml( xmlResponse.getRootElement() );
+ return styleDocument( xmlResponse, "DSMLv2.xslt" ).asXML();
+ }
+
+ // 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() );
+
+ errorResponse.toDsml( xmlResponse.getRootElement() );
+ return styleDocument( xmlResponse, "DSMLv2.xslt" ).asXML();
+ }
+
+ // 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
+ LdapMessage 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() );
+
+ errorResponse.toDsml( xmlResponse.getRootElement() );
+ return styleDocument( xmlResponse, "DSMLv2.xslt" ).asXML();
+ }
+
+ 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." );
+
+ errorResponse.toDsml( xmlResponse.getRootElement() );
+ return xmlResponse.asXML();
+ }
+
+ 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() );
+
+ errorResponse.toDsml( xmlResponse.getRootElement() );
+ return styleDocument( xmlResponse, "DSMLv2.xslt" ).asXML();
+ }
+
+ // 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() );
+
+ errorResponse.toDsml( xmlResponse.getRootElement() );
+ return styleDocument( xmlResponse, "DSMLv2.xslt" ).asXML();
+ }
+ }
+
+ return styleDocument( xmlResponse, "DSMLv2.xslt" ).asXML();
+ }
+
+ /**
+ * Processes a single request
+ * @param request the request to process
+ * @throws EncoderException
+ * @throws IOException
+ * @throws NamingException
+ * @throws DecoderException
+ */
+ private void processRequest(LdapMessage request) throws EncoderException, IOException, DecoderException, NamingException
+ {
+ LdapMessage message = new LdapMessage();
+
+ 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
+ LdapMessage response = null;
+
+ response = readResponse( bb );
+
+ if ( LdapConstants.ADD_RESPONSE == response.getMessageType() )
+ {
+ AddResponseDsml addResponseDsml = new AddResponseDsml( response );
+ addResponseDsml.toDsml( xmlResponse.getRootElement() );
+ }
+ else if ( LdapConstants.BIND_RESPONSE == response.getMessageType() )
+ {
+ AuthResponseDsml authResponseDsml = new AuthResponseDsml( response );
+ authResponseDsml.toDsml( xmlResponse.getRootElement() );
+ }
+ else if ( LdapConstants.COMPARE_RESPONSE == response.getMessageType() )
+ {
+ CompareResponseDsml authResponseDsml = new CompareResponseDsml( response );
+ authResponseDsml.toDsml( xmlResponse.getRootElement() );
+ }
+ else if ( LdapConstants.DEL_RESPONSE == response.getMessageType() )
+ {
+ DelResponseDsml delResponseDsml = new DelResponseDsml( response );
+ delResponseDsml.toDsml( xmlResponse.getRootElement() );
+ }
+ else if ( LdapConstants.MODIFY_RESPONSE == response.getMessageType() )
+ {
+ ModifyResponseDsml modifyResponseDsml = new ModifyResponseDsml( response );
+ modifyResponseDsml.toDsml( xmlResponse.getRootElement() );
+ }
+ else if ( LdapConstants.MODIFYDN_RESPONSE == response.getMessageType() )
+ {
+ ModDNResponseDsml modDNResponseDsml = new ModDNResponseDsml( response );
+ modDNResponseDsml.toDsml( xmlResponse.getRootElement() );
+ }
+ else if ( LdapConstants.EXTENDED_RESPONSE == response.getMessageType() )
+ {
+ ExtendedResponseDsml extendedResponseDsml = new ExtendedResponseDsml( response );
+ extendedResponseDsml.toDsml( xmlResponse.getRootElement() );
+ }
+ 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" );
+
+ // RequestID
+ int requestID = response.getMessageId();
+ if ( requestID != 0 )
+ {
+ searchResponse.addAttribute( "requestID", "" + requestID );
+ }
+
+ while ( LdapConstants.SEARCH_RESULT_DONE != response.getMessageType() )
+ {
+ if ( LdapConstants.SEARCH_RESULT_ENTRY == response.getMessageType() )
+ {
+ SearchResultEntryDsml searchResultEntryDsml = new SearchResultEntryDsml( response );
+ searchResultEntryDsml.toDsml( searchResponse );
+ }
+ else if ( LdapConstants.SEARCH_RESULT_REFERENCE == response.getMessageType() )
+ {
+ SearchResultReferenceDsml searchResultReferenceDsml = new SearchResultReferenceDsml( response );
+ searchResultReferenceDsml.toDsml( searchResponse );
+ }
+
+ response = readResponse( bb );
+ }
+
+ SearchResultDoneDsml searchResultDoneDsml = new SearchResultDoneDsml( response );
+ searchResultDoneDsml.toDsml( searchResponse );
+ }
+
+ LdapResponse realResponse = response.getLdapResponse();
+
+ if ( !continueOnError )
+ {
+ if ( ( realResponse.getLdapResult().getResultCode() != LdapResultEnum.SUCCESS )
+ && ( realResponse.getLdapResult().getResultCode() != LdapResultEnum.COMPARE_TRUE )
+ && ( realResponse.getLdapResult().getResultCode() != LdapResultEnum.COMPARE_FALSE )
+ && ( realResponse.getLdapResult().getResultCode() != LdapResultEnum.REFERRAL ) )
+ {
+ // Turning on Exit flag
+ exit = true;
+ }
+ }
+
+ }
+
+ /**
+ * Processes the BatchRequest
+ * - Parsing and Getting BatchRequest
+ * - Getting and registering options from BatchRequest
+ * @throws XmlPullParserException
+ */
+ 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 )
+ {
+ xmlResponse.getRootElement().addAttribute( "requestID", "" + batchRequest.getRequestID() );
+ }
+ }
+
+ /**
+ * XML Pretty Printer XSLT Tranformation
+ * @param document
+ * @param stylesheet
+ * @return
+ */
+ public Document styleDocument( Document document, String stylesheet ){
+ // load the transformer using JAXP
+ TransformerFactory factory = TransformerFactory.newInstance();
+ Transformer transformer = null;
+ try
+ {
+ transformer = factory.newTransformer(
+ new StreamSource( Dsmlv2Engine.class.getResourceAsStream( stylesheet ) )
+ );
+ }
+ 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;
+ }
+
+
+ /**
+ * 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
+ * The hostname or the Address of server could not be found
+ * @throws IOException
+ * There was a error opening or establishing the socket
+ */
+ private void connect() throws UnknownHostException, IOException
+ {
+ serverAddress = new InetSocketAddress( host, port );
+ channel = SocketChannel.open( serverAddress );
+
+// SecurityManager security = System.getSecurityManager();
+// security.checkConnect( host, port );
+// channel = SocketChannel.open();
+// channel.configureBlocking( false );
+// channel.socket().setSoTimeout( 1 );
+// channel.connect( serverAddress );
+
+// try
+// {
+// Socket sock = new Socket();
+// System.out.println( sock.getSendBufferSize() );
+//// sock.setSoLinger( true, 20 );
+// sock.connect( new InetSocketAddress( host, port ) );
+// }
+// catch( IOException ioe )
+// {
+// System.out.println( "error" );
+// }
+
+
+// while ( channel.isConnectionPending() )
+// {
+// System.out.println("pending" + channel.socket().getSoTimeout());
+// try
+// {
+// Thread.sleep( 1000 );
+// }
+// catch ( InterruptedException e )
+// {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+// }
+
+ channel.configureBlocking( true );
+ }
+
+
+ /**
+ * Sends a message
+ * @param bb
+ * @throws IOException
+ */
+ private void sendMessage( ByteBuffer bb ) throws IOException
+ {
+ channel.write( bb );
+ bb.clear();
+ }
+
+ /**
+ * Reads the response to a request
+ * @param bb
+ * @return the response
+ * @throws IOException
+ * @throws DecoderException
+ * @throws NamingException
+ */
+ private LdapMessage readResponse( ByteBuffer bb ) throws IOException, DecoderException, NamingException
+ {
+
+ LdapMessage 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 BindResponse )
+ {
+ BindResponse resp = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage()
+ .getBindResponse();
+
+ if ( resp.getLdapResult().getResultCode() != 0 )
+ {
+ System.err.println( "Error : " + resp.getLdapResult().getErrorMessage() );
+ }
+ }
+ else if ( messageResp instanceof ExtendedResponse )
+ {
+ ExtendedResponse resp = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage()
+ .getExtendedResponse();
+
+ if ( resp.getLdapResult().getResultCode() != 0 )
+ {
+ System.err.println( "Error : " + resp.getLdapResult().getErrorMessage() );
+ }
+ }
+
+ ( ( LdapMessageContainer ) ldapMessageContainer ).clean();
+
+
+ return messageResp;
+ }
+
+
+ /**
+ * Bind to the ldap server
+ *
+ * @param messageId The message Id
+ * @throws NamingException
+ */
+ private void bind( int messageId ) throws EncoderException, DecoderException, IOException, NamingException
+ {
+ BindRequest bindRequest = new BindRequest();
+ LdapMessage message = new LdapMessage();
+ 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/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/engine/MainEngine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/engine/MainEngine.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/engine/MainEngine.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/engine/MainEngine.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,57 @@
+/*
+ * 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.ldapstudio.dsmlv2.engine;
+
+import java.io.FileNotFoundException;
+
+import org.xmlpull.v1.XmlPullParserException;
+
+
+/**
+ * This class is the Main Engine for DSMLv2.
+ */
+public class MainEngine
+{
+
+ /**
+ * @param args
+ */
+ public static void main( String[] args )
+ {
+ Dsmlv2Engine engine = new Dsmlv2Engine( "localhost", 10389, "uid=admin, ou=system", "secret" );
+
+ try
+ {
+ System.out.println( engine.processDSMLFile( "CompleteBatchRequest.xml" ) );
+ }
+ catch ( FileNotFoundException e )
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ catch ( XmlPullParserException e )
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/AddResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/AddResponseDsml.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/AddResponseDsml.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/AddResponseDsml.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,66 @@
+/*
+ * 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.ldapstudio.dsmlv2.reponse;
+
+
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.dom4j.Element;
+
+
+/**
+ * DSML Decorator for AddResponse
+ */
+public class AddResponseDsml extends LdapResponseDecorator implements DsmlDecorator
+{
+ /**
+ * Default constructor
+ * @param ldapMessage the message to decorate
+ */
+ public AddResponseDsml( LdapMessage ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /**
+ * Get the message type
+ * @return Returns the type.
+ */
+ public int getMessageType()
+ {
+ return instance.getAddResponse().getMessageType();
+ }
+
+
+ /**
+ * Convert the request to its XML representation in the DSMLv2 format.
+ * @param root the root dom4j Element
+ * @return the dom4j Element corresponding to the entry.
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = root.addElement( "addResponse" );
+
+ LdapResultDsml ldapResultDsml = new LdapResultDsml( instance.getAddResponse().getLdapResult(), instance );
+ ldapResultDsml.toDsml( element );
+ return element;
+ }
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/AuthResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/AuthResponseDsml.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/AuthResponseDsml.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/AuthResponseDsml.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,67 @@
+/*
+ * 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.ldapstudio.dsmlv2.reponse;
+
+
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.dom4j.Element;
+
+
+/**
+ * DSML Decorator for AuthResponse
+ */
+public class AuthResponseDsml extends LdapResponseDecorator implements DsmlDecorator
+{
+ /**
+ * Default constructor
+ * @param ldapMessage the message to decorate
+ */
+ public AuthResponseDsml( LdapMessage ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /**
+ * Get the message type
+ * @return Returns the type.
+ */
+ public int getMessageType()
+ {
+ return instance.getBindResponse().getMessageType();
+ }
+
+
+ /**
+ * Convert the request to its XML representation in the DSMLv2 format.
+ * @param root the root dom4j Element
+ * @return the dom4j Element corresponding to the entry.
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = root.addElement( "authResponse" );
+
+ LdapResultDsml ldapResultDsml = new LdapResultDsml( instance.getBindResponse().getLdapResult(), instance );
+ ldapResultDsml.toDsml( element );
+ return element;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/CompareResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/CompareResponseDsml.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/CompareResponseDsml.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/CompareResponseDsml.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,67 @@
+/*
+ * 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.ldapstudio.dsmlv2.reponse;
+
+
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.dom4j.Element;
+
+
+/**
+ * DSML Decorator for CompareResponse
+ */
+public class CompareResponseDsml extends LdapResponseDecorator implements DsmlDecorator
+{
+ /**
+ * Default constructor
+ * @param ldapMessage the message to decorate
+ */
+ public CompareResponseDsml( LdapMessage ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /**
+ * Get the message type
+ * @return Returns the type.
+ */
+ public int getMessageType()
+ {
+ return instance.getCompareResponse().getMessageType();
+ }
+
+
+ /**
+ * Convert the request to its XML representation in the DSMLv2 format.
+ * @param root the root dom4j Element
+ * @return the dom4j Element corresponding to the entry.
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = root.addElement( "compareResponse" );
+
+ LdapResultDsml ldapResultDsml = new LdapResultDsml( instance.getCompareResponse().getLdapResult(), instance );
+ ldapResultDsml.toDsml( element );
+ return element;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/DelResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/DelResponseDsml.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/DelResponseDsml.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/DelResponseDsml.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,67 @@
+/*
+ * 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.ldapstudio.dsmlv2.reponse;
+
+
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.dom4j.Element;
+
+
+/**
+ * DSML Decorator for DelResponse
+ */
+public class DelResponseDsml extends LdapResponseDecorator implements DsmlDecorator
+{
+ /**
+ * Default constructor
+ * @param ldapMessage the message to decorate
+ */
+ public DelResponseDsml( LdapMessage ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /**
+ * Get the message type
+ * @return Returns the type.
+ */
+ public int getMessageType()
+ {
+ return instance.getDelResponse().getMessageType();
+ }
+
+
+ /**
+ * Convert the request to its XML representation in the DSMLv2 format.
+ * @param root the root dom4j Element
+ * @return the dom4j Element corresponding to the entry.
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = root.addElement( "delResponse" );
+
+ LdapResultDsml ldapResultDsml = new LdapResultDsml( instance.getDelResponse().getLdapResult(), instance );
+ ldapResultDsml.toDsml( element );
+ return element;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/DsmlDecorator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/DsmlDecorator.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/DsmlDecorator.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/DsmlDecorator.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,39 @@
+/*
+ * 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.ldapstudio.dsmlv2.reponse;
+
+
+import org.dom4j.Element;
+
+
+/**
+ * This interface defines the methods that must be implemented to define a DSML Decorator
+ */
+public interface DsmlDecorator
+{
+ /**
+ * Convert the request to its XML representation in the DSMLv2 format.
+ * @param root the root dom4j Element
+ * @return the dom4j Element corresponding to the entry.
+ */
+ public Element toDsml( Element root );
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/ErrorResponse.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/ErrorResponse.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/ErrorResponse.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/ErrorResponse.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,171 @@
+/*
+ * 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.ldapstudio.dsmlv2.reponse;
+
+
+import org.apache.directory.shared.ldap.codec.LdapResponse;
+import org.dom4j.Element;
+
+
+/**
+ * Class representing Error Response.
+ *
+ * An Error Response has a requestID, a message, and a type which can be :
+ * - NOT_ATTEMPTED,
+ * - COULD_NOT_CONNECT,
+ * - CONNECTION_CLOSED,
+ * - MALFORMED_REQUEST,
+ * - GATEWAY_INTERNAL_ERROR,
+ * - AUTHENTICATION_FAILED,
+ * - UNRESOLVABLE_URI,
+ * - OTHER
+ */
+public class ErrorResponse extends LdapResponse implements DsmlDecorator
+{
+ public enum ErrorResponseType
+ {
+ NOT_ATTEMPTED, COULD_NOT_CONNECT, CONNECTION_CLOSED, MALFORMED_REQUEST, GATEWAY_INTERNAL_ERROR, AUTHENTICATION_FAILED, UNRESOLVABLE_URI, OTHER
+ };
+
+ private ErrorResponseType type;
+
+ private String message;
+
+ private int requestID;
+
+
+ public ErrorResponse()
+ {
+ }
+
+ /**
+ * Default constructor
+ * @param requestID The requestID of the response
+ * @param type The type of the response
+ * @param message The associated message
+ */
+ public ErrorResponse( int requestID, ErrorResponseType type, String message )
+ {
+ this.requestID = requestID;
+ this.type = type;
+ this.message = message;
+ }
+
+
+ /**
+ * Convert the request to its XML representation in the DSMLv2 format.
+ * @param root the root dom4j Element
+ * @return the dom4j Element corresponding to the entry.
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = root.addElement( "errorResponse" );
+
+ // RequestID
+ if ( requestID != 0 )
+ {
+ element.addAttribute( "requestID", "" + requestID );
+ }
+
+ // Type
+ element.addAttribute( "type", getTypeDescr( type ) );
+
+ // TODO Add Detail
+
+ if ( ( message != null ) && ( !"".equals( message ) ) )
+ {
+ Element messageElement = element.addElement( "message" );
+ messageElement.addText( message );
+ }
+
+ return element;
+ }
+
+
+ /**
+ * Returns the String associated to the error response type
+ * @param type the error response type
+ * @return the corresponding String
+ */
+ public String getTypeDescr( ErrorResponseType type )
+ {
+ if ( type.equals( ErrorResponseType.NOT_ATTEMPTED ) )
+ {
+ return "notAttempted";
+ }
+ else if ( type.equals( ErrorResponseType.COULD_NOT_CONNECT ) )
+ {
+ return "couldNotConnect";
+ }
+ else if ( type.equals( ErrorResponseType.CONNECTION_CLOSED ) )
+ {
+ return "connectionClosed";
+ }
+ else if ( type.equals( ErrorResponseType.MALFORMED_REQUEST ) )
+ {
+ return "malformedRequest";
+ }
+ else if ( type.equals( ErrorResponseType.GATEWAY_INTERNAL_ERROR ) )
+ {
+ return "gatewayInternalError";
+ }
+ else if ( type.equals( ErrorResponseType.AUTHENTICATION_FAILED ) )
+ {
+ return "authenticationFailed";
+ }
+ else if ( type.equals( ErrorResponseType.UNRESOLVABLE_URI ) )
+ {
+ return "unresolvableURI";
+ }
+ else if ( type.equals( ErrorResponseType.OTHER ) )
+ {
+ return "other";
+ }
+ else
+ {
+ return "unknown";
+ }
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public int getRequestID() {
+ return requestID;
+ }
+
+ public void setRequestID(int requestID) {
+ this.requestID = requestID;
+ }
+
+ public ErrorResponseType getType() {
+ return type;
+ }
+
+ public void setType(ErrorResponseType type) {
+ this.type = type;
+ }
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/ExtendedResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/ExtendedResponseDsml.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/ExtendedResponseDsml.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/ExtendedResponseDsml.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,71 @@
+/*
+ * 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.ldapstudio.dsmlv2.reponse;
+
+
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.dom4j.Element;
+
+
+/**
+ * DSML Decorator for ExtendedResponse
+ */
+public class ExtendedResponseDsml extends LdapResponseDecorator implements DsmlDecorator
+{
+ /**
+ * Default constructor
+ * @param ldapMessage the message to decorate
+ */
+ public ExtendedResponseDsml( LdapMessage ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /**
+ * Get the message type
+ *
+ * @return Returns the type.
+ */
+ public int getMessageType()
+ {
+ return instance.getExtendedResponse().getMessageType();
+ }
+
+
+ /**
+ * Convert the request to its XML representation in the DSMLv2 format.
+ * @param root the root dom4j Element
+ * @return the dom4j Element corresponding to the entry.
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = root.addElement( "extendedResponse" );
+
+ LdapResultDsml ldapResultDsml = new LdapResultDsml( instance.getExtendedResponse().getLdapResult(), instance );
+ ldapResultDsml.toDsml( element );
+
+ // TODO add management for ReponseName and Response Tag
+
+ return element;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/LdapMessageDecorator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/LdapMessageDecorator.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/LdapMessageDecorator.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/LdapMessageDecorator.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,474 @@
+/*
+ * 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.ldapstudio.dsmlv2.reponse;
+
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+
+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.Control;
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapResponse;
+import org.apache.directory.shared.ldap.codec.abandon.AbandonRequest;
+import org.apache.directory.shared.ldap.codec.add.AddRequest;
+import org.apache.directory.shared.ldap.codec.add.AddResponse;
+import org.apache.directory.shared.ldap.codec.bind.BindRequest;
+import org.apache.directory.shared.ldap.codec.bind.BindResponse;
+import org.apache.directory.shared.ldap.codec.compare.CompareRequest;
+import org.apache.directory.shared.ldap.codec.compare.CompareResponse;
+import org.apache.directory.shared.ldap.codec.del.DelRequest;
+import org.apache.directory.shared.ldap.codec.del.DelResponse;
+import org.apache.directory.shared.ldap.codec.extended.ExtendedRequest;
+import org.apache.directory.shared.ldap.codec.extended.ExtendedResponse;
+import org.apache.directory.shared.ldap.codec.modify.ModifyRequest;
+import org.apache.directory.shared.ldap.codec.modify.ModifyResponse;
+import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNRequest;
+import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNResponse;
+import org.apache.directory.shared.ldap.codec.search.SearchRequest;
+import org.apache.directory.shared.ldap.codec.search.SearchResultDone;
+import org.apache.directory.shared.ldap.codec.search.SearchResultEntry;
+import org.apache.directory.shared.ldap.codec.search.SearchResultReference;
+import org.apache.directory.shared.ldap.codec.unbind.UnBindRequest;
+
+
+/**
+ * Decorator class for LDAP Message. This is the top level class, the one
+ * that holds the instance.
+ */
+public abstract class LdapMessageDecorator extends LdapMessage
+{
+ /** The decorated instance */
+ protected LdapMessage instance;
+
+
+ /**
+ * Default constructor
+ * @param ldapMessage the message to decorate
+ */
+ public LdapMessageDecorator( LdapMessage ldapMessage )
+ {
+ instance = ldapMessage;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#addControl(org.apache.directory.shared.ldap.codec.Control)
+ */
+ @Override
+ public void addControl( Control control )
+ {
+ instance.addControl( control );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#computeLength()
+ */
+ @Override
+ public int computeLength()
+ {
+ return instance.computeLength();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#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.LdapMessage#getAbandonRequest()
+ */
+ @Override
+ public AbandonRequest getAbandonRequest()
+ {
+ return instance.getAbandonRequest();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getAddRequest()
+ */
+ @Override
+ public AddRequest getAddRequest()
+ {
+ return instance.getAddRequest();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getAddResponse()
+ */
+ @Override
+ public AddResponse getAddResponse()
+ {
+ return instance.getAddResponse();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getBindRequest()
+ */
+ @Override
+ public BindRequest getBindRequest()
+ {
+ return instance.getBindRequest();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getBindResponse()
+ */
+ @Override
+ public BindResponse getBindResponse()
+ {
+ return instance.getBindResponse();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getCompareRequest()
+ */
+ @Override
+ public CompareRequest getCompareRequest()
+ {
+ return instance.getCompareRequest();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getCompareResponse()
+ */
+ @Override
+ public CompareResponse getCompareResponse()
+ {
+ return instance.getCompareResponse();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getControls()
+ */
+ @Override
+ public ArrayList getControls()
+ {
+ return instance.getControls();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getControls(int)
+ */
+ @Override
+ public Control getControls( int i )
+ {
+ return instance.getControls( i );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getCurrentControl()
+ */
+ @Override
+ public Control getCurrentControl()
+ {
+ return instance.getCurrentControl();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getDelRequest()
+ */
+ @Override
+ public DelRequest getDelRequest()
+ {
+ return instance.getDelRequest();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getDelResponse()
+ */
+ @Override
+ public DelResponse getDelResponse()
+ {
+ return instance.getDelResponse();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getExtendedRequest()
+ */
+ @Override
+ public ExtendedRequest getExtendedRequest()
+ {
+ return instance.getExtendedRequest();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getExtendedResponse()
+ */
+ @Override
+ public ExtendedResponse getExtendedResponse()
+ {
+ return instance.getExtendedResponse();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getLdapResponse()
+ */
+ @Override
+ public LdapResponse getLdapResponse()
+ {
+ return instance.getLdapResponse();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getMessageId()
+ */
+ @Override
+ public int getMessageId()
+ {
+ return instance.getMessageId();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getMessageType()
+ */
+ @Override
+ public int getMessageType()
+ {
+ return instance.getMessageType();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getMessageTypeName()
+ */
+ @Override
+ public String getMessageTypeName()
+ {
+ return instance.getMessageTypeName();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getModifyDNRequest()
+ */
+ @Override
+ public ModifyDNRequest getModifyDNRequest()
+ {
+ return instance.getModifyDNRequest();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getModifyDNResponse()
+ */
+ @Override
+ public ModifyDNResponse getModifyDNResponse()
+ {
+ return instance.getModifyDNResponse();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getModifyRequest()
+ */
+ @Override
+ public ModifyRequest getModifyRequest()
+ {
+ return instance.getModifyRequest();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getModifyResponse()
+ */
+ @Override
+ public ModifyResponse getModifyResponse()
+ {
+ return instance.getModifyResponse();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getSearchRequest()
+ */
+ @Override
+ public SearchRequest getSearchRequest()
+ {
+ return instance.getSearchRequest();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getSearchResultDone()
+ */
+ @Override
+ public SearchResultDone getSearchResultDone()
+ {
+ return instance.getSearchResultDone();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getSearchResultEntry()
+ */
+ @Override
+ public SearchResultEntry getSearchResultEntry()
+ {
+ return instance.getSearchResultEntry();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getSearchResultReference()
+ */
+ @Override
+ public SearchResultReference getSearchResultReference()
+ {
+ return instance.getSearchResultReference();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#getUnBindRequest()
+ */
+ @Override
+ public UnBindRequest getUnBindRequest()
+ {
+ return instance.getUnBindRequest();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#setMessageId(int)
+ */
+ @Override
+ public void setMessageId( int messageId )
+ {
+ instance.setMessageId( messageId );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapMessage#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.LdapMessage#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 Asn1Object 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)
+ */
+ @Override
+ public void setParent( Asn1Object parent )
+ {
+ instance.setParent( parent );
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/LdapResponseDecorator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/LdapResponseDecorator.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/LdapResponseDecorator.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/LdapResponseDecorator.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,69 @@
+/*
+ * 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.ldapstudio.dsmlv2.reponse;
+
+
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapResponse;
+import org.apache.directory.shared.ldap.codec.LdapResult;
+
+
+/**
+ * Decorator abstract class for LdapResponse
+ */
+public abstract class LdapResponseDecorator extends LdapMessageDecorator
+{
+ /**
+ * Default constructor
+ * @param ldapMessage the message to decorate
+ */
+ public LdapResponseDecorator( LdapMessage ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapResponse#getLdapResponseLength()
+ */
+ public int getLdapResponseLength()
+ {
+ return ( ( LdapResponse ) instance ).getLdapResponseLength();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapResponse#getLdapResult()
+ */
+ public LdapResult getLdapResult()
+ {
+ return ( ( LdapResponse ) instance ).getLdapResult();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapResponse#setLdapResult(org.apache.directory.shared.ldap.codec.LdapResult)
+ */
+ public void setLdapResult( LdapResult ldapResult )
+ {
+ ( ( LdapResponse ) instance ).setLdapResult( ldapResult );
+ }
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/LdapResultDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/LdapResultDsml.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/LdapResultDsml.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/LdapResultDsml.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,102 @@
+/*
+ * 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.ldapstudio.dsmlv2.reponse;
+
+
+import java.util.ArrayList;
+
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapResult;
+import org.dom4j.Element;
+
+
+/**
+ * DSML Decorator for the LdapResult class.
+ */
+public class LdapResultDsml implements DsmlDecorator
+{
+ private LdapMessage message;
+ private LdapResult result;
+
+
+ /**
+ * Default Constructor
+ * @param result the LdapResult to decorate
+ * @param message the message associated
+ */
+ public LdapResultDsml( LdapResult result, LdapMessage message )
+ {
+ this.result = result;
+ this.message = message;
+ }
+
+
+ /**
+ * Convert the request to its XML representation in the DSMLv2 format.
+ * @param root the root dom4j Element
+ * @return the dom4j Element corresponding to the entry.
+ */
+ public Element toDsml( Element root )
+ {
+
+ // RequestID
+ int requestID = message.getMessageId();
+ if ( requestID != 0 )
+ {
+ root.addAttribute( "requestID", "" + requestID );
+ }
+
+ // Matched DN
+ String matchedDN = result.getMatchedDN();
+ if ( !matchedDN.equals( "" ) )
+ {
+ root.addAttribute( "matchedDN", matchedDN );
+ }
+
+ // TODO Add Control values
+
+ // ResultCode
+ Element resultCodeElement = root.addElement( "resultCode" );
+ resultCodeElement.addAttribute( "code", "" + result.getResultCode() );
+ resultCodeElement.addAttribute( "descr", LdapResultEnum.getResultCodeDescr( result.getResultCode() ) );
+
+ // ErrorMessage
+ String errorMessage = ( result.getErrorMessage() );
+ if ( !errorMessage.equals( "" ) )
+ {
+ Element errorMessageElement = root.addElement( "errorMessage" );
+ errorMessageElement.addText( errorMessage );
+ }
+
+ // Referals
+ ArrayList referals = result.getReferrals();
+ if ( referals != null )
+ {
+ for ( int i = 0; i < referals.size(); i++ )
+ {
+ Element referalElement = root.addElement( "referal" );
+ referalElement.addText( referals.get( i ).toString() );
+ }
+ }
+
+ return root;
+ }
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/LdapResultEnum.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/LdapResultEnum.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/LdapResultEnum.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/LdapResultEnum.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,158 @@
+/*
+ * 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.ldapstudio.dsmlv2.reponse;
+
+
+/**
+ * This Class helps to get resultCodeDesc for a ResultCode of a LdapResult.
+ */
+public class LdapResultEnum
+{
+ private static String[] resultStrings;
+
+ static
+ {
+ resultStrings = new String[91];
+
+ resultStrings[0] = "success";
+ resultStrings[1] = "operationsError";
+ resultStrings[2] = "protocolError";
+ resultStrings[3] = "timeLimitExceeded";
+ resultStrings[4] = "sizeLimitExceeded";
+ resultStrings[5] = "compareFalse";
+ resultStrings[6] = "compareTrue";
+ resultStrings[7] = "authMethodNotSupported";
+ resultStrings[8] = "strongAuthRequired";
+ resultStrings[9] = "reserved";
+ resultStrings[10] = "referral";
+ resultStrings[11] = "adminLimitExceeded";
+ resultStrings[12] = "unavailableCriticalExtension";
+ resultStrings[13] = "confidentialityRequired";
+ resultStrings[14] = "saslBindInProgress";
+
+ resultStrings[15] = "unused";
+
+ resultStrings[16] = "noSuchAttribute";
+ resultStrings[17] = "undefinedAttributeType";
+ resultStrings[18] = "inappropriateMatching";
+ resultStrings[19] = "constraintViolation";
+ resultStrings[20] = "attributeOrValueExists";
+ resultStrings[21] = "invalidAttributeSyntax";
+
+ resultStrings[22] = "unused";
+ resultStrings[23] = "unused";
+ resultStrings[24] = "unused";
+ resultStrings[25] = "unused";
+ resultStrings[26] = "unused";
+ resultStrings[27] = "unused";
+ resultStrings[28] = "unused";
+ resultStrings[29] = "unused";
+ resultStrings[30] = "unused";
+ resultStrings[31] = "unused";
+
+ resultStrings[32] = "noSuchObject";
+ resultStrings[33] = "aliasProblem";
+ resultStrings[34] = "invalidDNSyntax";
+ resultStrings[35] = "reserved for undefined isLeaf";
+ resultStrings[36] = "aliasDereferencingProblem";
+
+ resultStrings[37] = "unused";
+ resultStrings[38] = "unused";
+ resultStrings[39] = "unused";
+ resultStrings[40] = "unused";
+ resultStrings[41] = "unused";
+ resultStrings[42] = "unused";
+ resultStrings[43] = "unused";
+ resultStrings[44] = "unused";
+ resultStrings[45] = "unused";
+ resultStrings[46] = "unused";
+ resultStrings[47] = "unused";
+
+ resultStrings[48] = "inappropriateAuthentication";
+ resultStrings[49] = "invalidCredentials";
+ resultStrings[50] = "insufficientAccessRights";
+ resultStrings[51] = "busy";
+ resultStrings[52] = "unavailable";
+ resultStrings[53] = "unwillingToPerform";
+ resultStrings[54] = "loopDetect";
+
+ resultStrings[55] = "unused";
+ resultStrings[56] = "unused";
+ resultStrings[57] = "unused";
+ resultStrings[58] = "unused";
+ resultStrings[59] = "unused";
+ resultStrings[60] = "unused";
+ resultStrings[61] = "unused";
+ resultStrings[62] = "unused";
+ resultStrings[63] = "unused";
+
+ resultStrings[64] = "namingViolation";
+ resultStrings[65] = "objectClassViolation";
+ resultStrings[66] = "notAllowedOnNonLeaf";
+ resultStrings[67] = "notAllowedOnRDN";
+ resultStrings[68] = "entryAlreadyExists";
+ resultStrings[69] = "objectClassModsProhibited";
+
+ resultStrings[70] = "reserved for CLDAP";
+
+ resultStrings[71] = "affectsMultipleDSAs";
+
+ resultStrings[72] = "unused";
+ resultStrings[73] = "unused";
+ resultStrings[74] = "unused";
+ resultStrings[75] = "unused";
+ resultStrings[76] = "unused";
+ resultStrings[77] = "unused";
+ resultStrings[78] = "unused";
+ resultStrings[79] = "unused";
+
+ resultStrings[80] = "other";
+
+ resultStrings[81] = "reserved for APIs";
+ resultStrings[82] = "reserved for APIs";
+ resultStrings[83] = "reserved for APIs";
+ resultStrings[84] = "reserved for APIs";
+ resultStrings[85] = "reserved for APIs";
+ resultStrings[86] = "reserved for APIs";
+ resultStrings[87] = "reserved for APIs";
+ resultStrings[88] = "reserved for APIs";
+ resultStrings[89] = "reserved for APIs";
+ resultStrings[90] = "reserved for APIs";
+ }
+
+
+ /**
+ * Return the String description of a given result code
+ * @param resultCode a result code
+ * @return the String description corresponding to the result code
+ */
+ public static String getResultCodeDescr( int resultCode )
+ {
+ if ( resultCode > 90 )
+ {
+ return "unknown";
+ }
+ else
+ {
+ return resultStrings[resultCode];
+ }
+ }
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/ModDNResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/ModDNResponseDsml.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/ModDNResponseDsml.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/ModDNResponseDsml.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,66 @@
+/*
+ * 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.ldapstudio.dsmlv2.reponse;
+
+
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.dom4j.Element;
+
+
+/**
+ * DSML Decorator for ModDNResponse
+ */
+public class ModDNResponseDsml extends LdapResponseDecorator implements DsmlDecorator
+{
+ /**
+ * Default constructor
+ * @param ldapMessage the message to decorate
+ */
+ public ModDNResponseDsml( LdapMessage ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /**
+ * Get the message type
+ * @return Returns the type.
+ */
+ public int getMessageType()
+ {
+ return instance.getModifyDNResponse().getMessageType();
+ }
+
+
+ /**
+ * Convert the request to its XML representation in the DSMLv2 format.
+ * @param root the root dom4j Element
+ * @return the dom4j Element corresponding to the entry.
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = root.addElement( "modDNResponse" );
+
+ LdapResultDsml ldapResultDsml = new LdapResultDsml( instance.getModifyDNResponse().getLdapResult(), instance );
+ ldapResultDsml.toDsml( element );
+ return element;
+ }
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/ModifyResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/ModifyResponseDsml.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/ModifyResponseDsml.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/ModifyResponseDsml.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,67 @@
+/*
+ * 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.ldapstudio.dsmlv2.reponse;
+
+
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.dom4j.Element;
+
+
+/**
+ * DSML Decorator for ModifyResponse
+ */
+public class ModifyResponseDsml extends LdapResponseDecorator implements DsmlDecorator
+{
+ /**
+ * Default constructor
+ * @param ldapMessage the message to decorate
+ */
+ public ModifyResponseDsml( LdapMessage ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /**
+ * Get the message type
+ * @return Returns the type.
+ */
+ public int getMessageType()
+ {
+ return instance.getModifyResponse().getMessageType();
+ }
+
+
+ /**
+ * Convert the request to its XML representation in the DSMLv2 format.
+ * @param root the root dom4j Element
+ * @return the dom4j Element corresponding to the entry.
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = root.addElement( "modifyResponse" );
+
+ LdapResultDsml ldapResultDsml = new LdapResultDsml( instance.getModifyResponse().getLdapResult(), instance );
+ ldapResultDsml.toDsml( element );
+ return element;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/SearchResponse.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/SearchResponse.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/SearchResponse.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/SearchResponse.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,79 @@
+/*
+ * 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.ldapstudio.dsmlv2.reponse;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.shared.ldap.codec.LdapResponse;
+import org.apache.directory.shared.ldap.codec.search.SearchResultDone;
+import org.apache.directory.shared.ldap.codec.search.SearchResultEntry;
+import org.apache.directory.shared.ldap.codec.search.SearchResultReference;
+
+public class SearchResponse extends LdapResponse
+{
+ private List<SearchResultEntry> searchResultEntryList;
+ private List<SearchResultReference> searchResultReferenceList;
+ private SearchResultDone searchResultDone;
+
+ public SearchResponse()
+ {
+ searchResultEntryList = new ArrayList<SearchResultEntry>();
+ searchResultReferenceList = new ArrayList<SearchResultReference>();
+ }
+
+ public boolean addSearchResultEntry(SearchResultEntry searchResultEntry)
+ {
+ return searchResultEntryList.add( searchResultEntry );
+ }
+
+ public SearchResultEntry getCurrentSearchResultEntry()
+ {
+ return searchResultEntryList.get( searchResultEntryList.size() - 1 );
+ }
+
+ public boolean addSearchResultReference(SearchResultReference searchResultReference)
+ {
+ return searchResultReferenceList.add( searchResultReference );
+ }
+
+ public SearchResultReference getCurrentSearchResultReference()
+ {
+ return searchResultReferenceList.get( searchResultReferenceList.size() - 1 );
+ }
+
+ public SearchResultDone getSearchResultDone() {
+ return searchResultDone;
+ }
+
+ public void setSearchResultDone(SearchResultDone searchResultDone) {
+ this.searchResultDone = searchResultDone;
+ }
+
+ public List<SearchResultEntry> getSearchResultEntryList() {
+ return searchResultEntryList;
+ }
+
+ public List<SearchResultReference> getSearchResultReferenceList() {
+ return searchResultReferenceList;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/SearchResultDoneDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/SearchResultDoneDsml.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/SearchResultDoneDsml.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/SearchResultDoneDsml.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,67 @@
+/*
+ * 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.ldapstudio.dsmlv2.reponse;
+
+
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.dom4j.Element;
+
+
+/**
+ * DSML Decorator for SearchResultDone
+ */
+public class SearchResultDoneDsml extends LdapResponseDecorator implements DsmlDecorator
+{
+ /**
+ * Default constructor
+ * @param ldapMessage the message to decorate
+ */
+ public SearchResultDoneDsml( LdapMessage ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /**
+ * Get the message type
+ * @return Returns the type.
+ */
+ public int getMessageType()
+ {
+ return instance.getSearchResultDone().getMessageType();
+ }
+
+
+ /**
+ * Convert the request to its XML representation in the DSMLv2 format.
+ * @param root the root dom4j Element
+ * @return the dom4j Element corresponding to the entry.
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = root.addElement( "searchResultDone" );
+
+ LdapResultDsml ldapResultDsml = new LdapResultDsml( instance.getSearchResultDone().getLdapResult(), instance );
+ ldapResultDsml.toDsml( element );
+ return element;
+ }
+
+}