directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r979356 [3/3] - in /directory: apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/ apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operational/ apacheds/trunk/core-integ/src/test/java/org/apache/...
Date Mon, 26 Jul 2010 16:44:00 GMT
Modified: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java?rev=979356&r1=979355&r2=979356&view=diff
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java (original)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java Mon Jul 26 16:44:00 2010
@@ -77,18 +77,18 @@ public interface LdapConnection
     // Add operations                                                      //
     //---------------------------------------------------------------------//
     /**
-     * Add an entry to the server. This is a blocking add : the user has 
+     * Add an entry to the server. This is a blocking add : the user has
      * to wait for the response until the AddResponse is returned.
-     * 
+     *
      * @param entry The entry to add
-     * @result the add operation's response 
+     * @result the add operation's response
      */
     public abstract AddResponse add( Entry entry ) throws LdapException;
 
 
     /**
      * Add an entry present in the AddRequest to the server.
-     * 
+     *
      * @param addRequest the request object containing an entry and controls(if any)
      * @return the add operation's response
      * @throws LdapException
@@ -98,10 +98,10 @@ public interface LdapConnection
 
     /**
      * Abandons a request submitted to the server for performing a particular operation
-     * 
+     *
      * The abandonRequest is always non-blocking, because no response is expected
-     * 
-     * @param messageId the ID of the request message sent to the server 
+     *
+     * @param messageId the ID of the request message sent to the server
      */
     public abstract void abandon( int messageId );
 
@@ -109,18 +109,18 @@ public interface LdapConnection
     /**
      * An abandon request essentially with the request message ID of the operation to be cancelled
      * and/or potentially some controls and timeout (the controls and timeout are not mandatory).
-     * 
+     *
      * The abandonRequest is always non-blocking, because no response is expected
-     *  
+     *
      * @param abandonRequest the abandon operation's request
      */
     public abstract void abandon( AbandonRequest abandonRequest );
 
 
     /**
-     * Anonymous Bind on a server. 
+     * Anonymous Bind on a server.
      *
-     * @return The BindResponse LdapResponse 
+     * @return The BindResponse LdapResponse
      */
     public abstract BindResponse bind() throws LdapException, IOException;
 
@@ -128,10 +128,10 @@ public interface LdapConnection
     /**
      * Simple Bind on a server.
      *
-     * @param name The name we use to authenticate the user. It must be a 
+     * @param name The name we use to authenticate the user. It must be a
      * valid DN
-     * @param credentials The password. It can't be null 
-     * @return The BindResponse LdapResponse 
+     * @param credentials The password. It can't be null
+     * @return The BindResponse LdapResponse
      */
     public abstract BindResponse bind( String name, String credentials ) throws LdapException, IOException;
 
@@ -139,10 +139,10 @@ public interface LdapConnection
     /**
      * Simple Bind on a server.
      *
-     * @param name The name we use to authenticate the user. It must be a 
+     * @param name The name we use to authenticate the user. It must be a
      * valid DN
-     * @param credentials The password. It can't be null 
-     * @return The BindResponse LdapResponse 
+     * @param credentials The password. It can't be null
+     * @return The BindResponse LdapResponse
      */
     public abstract BindResponse bind( DN name, String credentials ) throws LdapException, IOException;
 
@@ -151,7 +151,7 @@ public interface LdapConnection
      * Bind to the server using a BindRequest object.
      *
      * @param bindRequest The BindRequest POJO containing all the needed
-     * parameters 
+     * parameters
      * @return A LdapResponse containing the result
      */
     public abstract BindResponse bind( BindRequest bindRequest ) throws LdapException, IOException;
@@ -167,12 +167,33 @@ public interface LdapConnection
      * TypesOnly : false
      * Attributes : all the user's attributes.
      * This method is blocking.
-     * 
+     *
      * @param baseDn The base for the search. It must be a valid
      * DN, and can't be emtpy
      * @param filterString The filter to use for this search. It can't be empty
-     * @param scope The sarch scope : OBJECT, ONELEVEL or SUBTREE 
-     * @return A cursor on the result. 
+     * @param scope The sarch scope : OBJECT, ONELEVEL or SUBTREE
+     * @return A cursor on the result.
+     */
+    public abstract Cursor<SearchResponse> search( DN baseDn, String filter, SearchScope scope,
+        String... attributes ) throws LdapException;
+
+
+    /**
+     * Do a search, on the base object, using the given filter. The
+     * SearchRequest parameters default to :
+     * Scope : ONE
+     * DerefAlias : ALWAYS
+     * SizeLimit : none
+     * TimeLimit : none
+     * TypesOnly : false
+     * Attributes : all the user's attributes.
+     * This method is blocking.
+     *
+     * @param baseDn The base for the search. It must be a valid
+     * DN, and can't be emtpy
+     * @param filterString The filter to use for this search. It can't be empty
+     * @param scope The sarch scope : OBJECT, ONELEVEL or SUBTREE
+     * @return A cursor on the result.
      */
     public abstract Cursor<SearchResponse> search( String baseDn, String filter, SearchScope scope,
         String... attributes ) throws LdapException;
@@ -180,7 +201,7 @@ public interface LdapConnection
 
     /**
      * Performs search in a synchronous mode.
-     *  
+     *
      * @param searchRequest The search configuration
      * @return A {@link Cursor} containing Entries and Referencs
      * @throws LdapException @TODO
@@ -198,7 +219,7 @@ public interface LdapConnection
 
 
     /**
-     * Set the timeOut for the responses. We wont wait longer than this 
+     * Set the timeOut for the responses. We wont wait longer than this
      * value.
      *
      * @param timeOut The timeout, in milliseconds
@@ -207,7 +228,7 @@ public interface LdapConnection
 
 
     /**
-     * 
+     *
      * Applies all the modifications to the entry specified by its DN
      *
      * @param DN The entry's DN
@@ -217,9 +238,21 @@ public interface LdapConnection
      */
     public abstract ModifyResponse modify( DN dn, Modification... modifications ) throws LdapException;
 
-    
+
+    /**
+    *
+    * Applies all the modifications to the entry specified by its DN
+    *
+    * @param DN The entry's DN
+    * @param modifications The list of modifications to be applied
+    * @return the modify operation's response
+    * @throws LdapException in case of modify operation failure or timeout happens
+    */
+   public abstract ModifyResponse modify( String dn, Modification... modifications ) throws LdapException;
+
+
     /**
-     * 
+     *
      * modifies all the attributes present in the entry by applying the same operation.
      *
      * @param entry the entry with the attributes to be modified
@@ -231,7 +264,7 @@ public interface LdapConnection
 
 
     /**
-     * Performs an modify operation based on the modifications present in 
+     * Performs an modify operation based on the modifications present in
      * the ModifyRequest.
      *
      * @param modRequest the request for modify operation
@@ -262,8 +295,8 @@ public interface LdapConnection
 
 
     /**
-     * 
-     * renames the given entryDn with new RDN and deletes the old Rdn if 
+     *
+     * renames the given entryDn with new RDN and deletes the old Rdn if
      * deleteOldRdn is set to true.
      *
      * @param entryDn the target DN
@@ -276,7 +309,7 @@ public interface LdapConnection
 
 
     /**
-     * @see #move(DN, DN) 
+     * @see #move(DN, DN)
      */
     public abstract ModifyDnResponse move( String entryDn, String newSuperiorDn ) throws LdapException;
 
@@ -294,7 +327,7 @@ public interface LdapConnection
 
     /**
      * Moves and renames the given entryDn.The old RDN will be deleted
-     * 
+     *
      * @see #moveAndRename(DN, DN, boolean)
      */
     public abstract ModifyDnResponse moveAndRename( DN entryDn, DN newDn ) throws LdapException;
@@ -302,7 +335,7 @@ public interface LdapConnection
 
     /**
      * Moves and renames the given entryDn.The old RDN will be deleted
-     * 
+     *
      * @see #moveAndRename(DN, DN, boolean)
      */
     public abstract ModifyDnResponse moveAndRename( String entryDn, String newDn ) throws LdapException;
@@ -310,7 +343,7 @@ public interface LdapConnection
 
     /**
      * Moves and renames the given entryDn.The old RDN will be deleted if requested
-     * 
+     *
      * @param entryDn The original entry DN
      * @param newDn The new Entry DN
      * @param deleteOldRdn Tells if the old RDN must be removed
@@ -320,7 +353,7 @@ public interface LdapConnection
 
     /**
      * Moves and renames the given entryDn.The old RDN will be deleted if requested
-     * 
+     *
      * @param entryDn The original entry DN
      * @param newDn The new Entry DN
      * @param deleteOldRdn Tells if the old RDN must be removed
@@ -329,7 +362,7 @@ public interface LdapConnection
 
 
     /**
-     * 
+     *
      * performs the modifyDn operation based on the given ModifyDnRequest.
      *
      * @param modDnRequest the request
@@ -341,7 +374,7 @@ public interface LdapConnection
 
     /**
      * deletes the entry with the given DN
-     *  
+     *
      * @param dn the target entry's DN as a String
      * @throws LdapException If the DN is not valid or if the deletion failed
      */
@@ -350,7 +383,7 @@ public interface LdapConnection
 
     /**
      * deletes the entry with the given DN
-     *  
+     *
      * @param dn the target entry's DN
      * @throws LdapException If the DN is not valid or if the deletion failed
      */
@@ -359,7 +392,7 @@ public interface LdapConnection
 
     /**
      * Performs a delete operation based on the delete request object.
-     *  
+     *
      * @param deleteRequest the delete operation's request
      * @return delete operation's response, null if a non-null listener value is provided
      * @throws LdapException If the DN is not valid or if the deletion failed
@@ -368,7 +401,7 @@ public interface LdapConnection
 
 
     /**
-     * Compares a whether a given attribute's value matches that of the 
+     * Compares a whether a given attribute's value matches that of the
      * existing value of the attribute present in the entry with the given DN
      *
      * @param dn the target entry's String DN
@@ -381,7 +414,7 @@ public interface LdapConnection
 
 
     /**
-     * Compares a whether a given attribute's value matches that of the 
+     * Compares a whether a given attribute's value matches that of the
      * existing value of the attribute present in the entry with the given DN
      *
      * @param dn the target entry's String DN
@@ -394,7 +427,7 @@ public interface LdapConnection
 
 
     /**
-     * Compares a whether a given attribute's value matches that of the 
+     * Compares a whether a given attribute's value matches that of the
      * existing value of the attribute present in the entry with the given DN
      *
      * @param dn the target entry's String DN
@@ -407,7 +440,7 @@ public interface LdapConnection
 
 
     /**
-     * Compares a whether a given attribute's value matches that of the 
+     * Compares a whether a given attribute's value matches that of the
      * existing value of the attribute present in the entry with the given DN
      *
      * @param dn the target entry's DN
@@ -420,7 +453,7 @@ public interface LdapConnection
 
 
     /**
-     * Compares a whether a given attribute's value matches that of the 
+     * Compares a whether a given attribute's value matches that of the
      * existing value of the attribute present in the entry with the given DN
      *
      * @param dn the target entry's DN
@@ -433,7 +466,7 @@ public interface LdapConnection
 
 
     /**
-     * Compares a whether a given attribute's value matches that of the 
+     * Compares a whether a given attribute's value matches that of the
      * existing value of the attribute present in the entry with the given DN
      *
      * @param dn the target entry's DN
@@ -447,7 +480,7 @@ public interface LdapConnection
 
     /**
      * compares an entry's attribute's value with that of the given value
-     *   
+     *
      * @param compareRequest the CompareRequest which contains the target DN, attribute name and value
      * @return compare operation's response
      * @throws LdapException
@@ -495,6 +528,12 @@ public interface LdapConnection
 
 
     /**
+     * @see #lookup(DN, String...)
+     */
+    public abstract SearchResponse lookup( DN dn ) throws LdapException;
+
+
+    /**
      * @see #lookup(String, String...)
      */
     public abstract SearchResponse lookup( String dn ) throws LdapException;
@@ -508,12 +547,23 @@ public interface LdapConnection
      * @return the Entry with the given DN or null if no entry exists with that DN
      * @throws LdapException in case of any problems while searching for the DN
      */
+    public abstract SearchResponse lookup( DN dn, String... attributes ) throws LdapException;
+
+
+    /**
+     * searches for an entry having the given DN
+     *
+     * @param dn the DN of the entry to be fetched
+     * @param attributes the attributes to be returned along with entry
+     * @return the Entry with the given DN or null if no entry exists with that DN
+     * @throws LdapException in case of any problems while searching for the DN
+     */
     public abstract SearchResponse lookup( String dn, String... attributes ) throws LdapException;
 
 
     /**
      * checks if a control with the given OID is supported
-     * 
+     *
      * @param controlOID the OID of the control
      * @return true if the control is supported, false otherwise
      */
@@ -541,8 +591,8 @@ public interface LdapConnection
 
 
     /**
-     * checks if there is a ResponseFuture associated with the given message id 
-     * 
+     * checks if there is a ResponseFuture associated with the given message id
+     *
      * @param messageId ID of the request
      * @return true if there is a non-null future exists, false otherwise
      */

Modified: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java?rev=979356&r1=979355&r2=979356&view=diff
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java (original)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java Mon Jul 26 16:44:00 2010
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.ldap.client.api;
 
@@ -160,7 +160,7 @@ import org.slf4j.LoggerFactory;
 /**
  * This class is the base for every operations sent or received to and
  * from a LDAP server.
- * 
+ *
  * A connection instance is necessary to send requests to the server. The connection
  * is valid until either the client closes it, the server closes it or the
  * client does an unbind.
@@ -189,7 +189,7 @@ public class LdapNetworkConnection exten
     /** The Ldap codec */
     private IoFilter ldapProtocolFilter = new ProtocolCodecFilter( new LdapProtocolCodecFactory() );
 
-    /**  
+    /**
      * The created session, created when we open a connection with
      * the Ldap server.
      */
@@ -206,10 +206,10 @@ public class LdapNetworkConnection exten
 
     /** The ROOT DSE entry */
     private Entry rootDSE;
-    
+
     /** A flag indicating that the BindRequest has been issued and successfully authenticated the user */
     private AtomicBoolean authenticated = new AtomicBoolean( false );
-    
+
     /** A flag indicating that the connection is connected or not */
     private AtomicBoolean connected = new AtomicBoolean( false );
 
@@ -217,7 +217,7 @@ public class LdapNetworkConnection exten
      *  connection's session gets closed cause of network issues
      */
     private List<ConnectionClosedEventListener> conCloseListeners;
-    
+
     /** the schema manager */
     private SchemaManager schemaManager;
 
@@ -269,24 +269,24 @@ public class LdapNetworkConnection exten
             throw new InvalidConnectionException( "Cannot connect on the server, the connection is invalid" );
         }
     }
-    
-    
+
+
     private void addToFutureMap( int messageId, ResponseFuture<? extends Response> future )
     {
         LOG.debug( "Adding <" + messageId + ", " + future.getClass().getName() + ">" );
         futureMap.put( messageId, future );
     }
-    
-    
+
+
     private ResponseFuture<? extends Response> getFromFutureMap( int messageId )
     {
         ResponseFuture<? extends Response> future = futureMap.remove( messageId );
-        
+
         if ( future != null )
         {
             LOG.debug( "Removing <" + messageId + ", " + future.getClass().getName() + ">" );
         }
-        
+
         return future;
     }
 
@@ -294,13 +294,13 @@ public class LdapNetworkConnection exten
     private ResponseFuture<? extends Response> peekFromFutureMap( int messageId )
     {
         ResponseFuture<? extends Response> future = futureMap.get( messageId );
-        
+
         // future can be null if there was a abandon operation on that messageId
         if( future != null )
         {
             LOG.debug( "Getting <" + messageId + ", " + future.getClass().getName() + ">" );
         }
-        
+
         return future;
     }
 
@@ -395,7 +395,7 @@ public class LdapNetworkConnection exten
             // currently we only support IR for search and extended operations
             throw new UnsupportedOperationException( "Unknown ResponseFuture type " + responseFuture.getClass().getName() );
         }
-        
+
         intermediateResponse.setResponseName( intermediateResponseCodec.getResponseName() );
         intermediateResponse.setResponseValue( intermediateResponseCodec.getResponseValue() );
 
@@ -510,7 +510,7 @@ public class LdapNetworkConnection exten
 
 
     /**
-     * 
+     *
      * Creates a new instance of LdapConnection with the given connection configuration.
      *
      * @param config the configuration of the LdapConnection
@@ -519,14 +519,14 @@ public class LdapNetworkConnection exten
     {
         this.config = config;
         messageId = new AtomicInteger( 0 );
-        
+
     }
 
 
     /**
      * Create a new instance of a LdapConnection on localhost,
      * port 389 if the SSL flag is off, or 636 otherwise.
-     * 
+     *
      * @param useSsl A flag to tell if it's a SSL connection or not.
      */
     public LdapNetworkConnection( boolean useSsl )
@@ -555,7 +555,7 @@ public class LdapNetworkConnection exten
 
     /**
      * Create a new instance of a LdapConnection on a given
-     * server, using the default port (389) if the SSL flag 
+     * server, using the default port (389) if the SSL flag
      * is off, or 636 otherwise.
      *
      * @param server The server we want to be connected to
@@ -571,7 +571,7 @@ public class LdapNetworkConnection exten
 
 
     /**
-     * Create a new instance of a LdapConnection on a 
+     * Create a new instance of a LdapConnection on a
      * given server and a given port. We don't use ssl.
      *
      * @param server The server we want to be connected to
@@ -683,10 +683,10 @@ public class LdapNetworkConnection exten
         // And inject the current Ldap container into the session
         IAsn1Container ldapMessageContainer = new LdapMessageContainer();
 
-        // Store the container into the session 
+        // Store the container into the session
         ldapSession.setAttribute( "LDAP-Container", ldapMessageContainer );
-        
-        // Initialize the MessageId 
+
+        // Initialize the MessageId
         messageId.set( 0 );
 
         // And return
@@ -713,7 +713,7 @@ public class LdapNetworkConnection exten
             connector.dispose();
             connector = null;
         }
-        
+
         // Reset the messageId
         messageId.set( 0 );
 
@@ -770,15 +770,15 @@ public class LdapNetworkConnection exten
             long timeout = getTimeout( addRequest.getTimeout() );
 
             // Get the response, blocking
-            AddResponse addResponse = ( AddResponse ) addFuture.get( timeout, TimeUnit.MILLISECONDS );
-            
+            AddResponse addResponse = addFuture.get( timeout, TimeUnit.MILLISECONDS );
+
             if ( addResponse == null )
             {
                 // We didn't received anything : this is an error
                 LOG.error( "Add failed : timeout occured" );
                 throw new LdapException( TIME_OUT_ERROR );
             }
-            
+
             if ( addResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
             {
                 // Everything is fine, return the response
@@ -832,7 +832,7 @@ public class LdapNetworkConnection exten
         AddRequestCodec addReqCodec = new AddRequestCodec();
 
         int newId = messageId.incrementAndGet();
-        
+
         addRequest.setMessageId( newId );
         addReqCodec.setMessageId( newId );
 
@@ -847,14 +847,14 @@ public class LdapNetworkConnection exten
         WriteFuture writeFuture = ldapSession.write( addReqCodec );
 
         // Wait for the message to be sent to the server
-        if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) ) 
+        if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) )
         {
             // We didn't received anything : this is an error
             LOG.error( "Add failed : timeout occured" );
 
             throw new LdapException( TIME_OUT_ERROR );
         }
-        
+
         // Ok, done return the future
         return addFuture;
     }
@@ -923,7 +923,7 @@ public class LdapNetworkConnection exten
         // Send the request to the server
         ldapSession.write( request );
 
-        // remove the associated listener if any 
+        // remove the associated listener if any
         int abandonId = abandonRequest.getAbandonedMessageId();
 
         ResponseFuture<? extends Response> rf = getFromFutureMap( abandonId );
@@ -1001,7 +1001,7 @@ public class LdapNetworkConnection exten
     public BindFuture bindAsync( String name, String credentials ) throws LdapException, IOException
     {
         LOG.debug( "Bind request : {}", name );
-        
+
         // Create the BindRequest
         BindRequest bindRequest = new BindRequest();
         bindRequest.setName( name );
@@ -1030,7 +1030,7 @@ public class LdapNetworkConnection exten
         {
             bindRequest.setName( name.getName() );
         }
-        
+
         return bind( bindRequest );
     }
 
@@ -1054,7 +1054,7 @@ public class LdapNetworkConnection exten
         {
             bindRequest.setName( name.getName() );
         }
-        
+
         return bindAsync( bindRequest );
     }
 
@@ -1073,15 +1073,15 @@ public class LdapNetworkConnection exten
             long timeout = getTimeout( bindRequest.getTimeout() );
 
             // Get the response, blocking
-            BindResponse bindResponse = ( BindResponse ) bindFuture.get( timeout, TimeUnit.MILLISECONDS );
-            
+            BindResponse bindResponse = bindFuture.get( timeout, TimeUnit.MILLISECONDS );
+
             if ( bindResponse == null )
             {
                 // We didn't received anything : this is an error
                 LOG.error( "Bind failed : timeout occured" );
                 throw new LdapException( TIME_OUT_ERROR );
             }
-            
+
             if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
             {
                 authenticated.set( true );
@@ -1125,8 +1125,8 @@ public class LdapNetworkConnection exten
             throw ldapException;
         }
     }
-    
-    
+
+
     /**
      * Create a SearchRequestCodec ready to be sent.
      */
@@ -1135,7 +1135,7 @@ public class LdapNetworkConnection exten
         // Create a new codec SearchRequest object
         SearchRequestCodec request = new SearchRequestCodec();
 
-        // Creates the messageID and stores it into the 
+        // Creates the messageID and stores it into the
         // initial message and the transmitted message.
         int newId = messageId.incrementAndGet();
         searchRequest.setMessageId( newId );
@@ -1221,7 +1221,7 @@ public class LdapNetworkConnection exten
 
         // clear the mappings if any (in case of a second call to bind() without calling unBind())
         //clearMaps();
-        
+
         // Set the new messageId
         int newId = messageId.incrementAndGet();
         bindRequest.setMessageId( newId );
@@ -1280,7 +1280,7 @@ public class LdapNetworkConnection exten
     {
         // First switch to anonymous state
         authenticated.set( false );
-        
+
         // try to connect, if we aren't already connected.
         connect();
 
@@ -1304,14 +1304,14 @@ public class LdapNetworkConnection exten
         WriteFuture writeFuture = ldapSession.write( bindMessage );
 
         // Wait for the message to be sent to the server
-        if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) ) 
+        if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) )
         {
             // We didn't received anything : this is an error
             LOG.error( "Bind failed : timeout occured" );
 
             throw new LdapException( TIME_OUT_ERROR );
         }
-        
+
         // Ok, done return the future
         return bindFuture;
     }
@@ -1320,9 +1320,15 @@ public class LdapNetworkConnection exten
     /**
      * {@inheritDoc}
      */
-    public Cursor<SearchResponse> search( String baseDn, String filter, SearchScope scope, String... attributes )
+    public Cursor<SearchResponse> search( DN baseDn, String filter, SearchScope scope, String... attributes )
         throws LdapException
     {
+        if ( baseDn == null )
+        {
+            LOG.debug( "received a null dn for a search" );
+            throw new IllegalArgumentException( "The base DN cannot be null" );
+        }
+
         // Create a new SearchRequest object
         SearchRequest searchRequest = new SearchRequest();
 
@@ -1340,7 +1346,17 @@ public class LdapNetworkConnection exten
     /**
      * {@inheritDoc}
      */
-    public SearchFuture searchAsync( String baseDn, String filter, SearchScope scope, String... attributes )
+    public Cursor<SearchResponse> search( String baseDn, String filter, SearchScope scope, String... attributes )
+        throws LdapException
+    {
+        return search( new DN( baseDn ), filter, scope, attributes );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public SearchFuture searchAsync( DN baseDn, String filter, SearchScope scope, String... attributes )
         throws LdapException
     {
         // Create a new SearchRequest object
@@ -1360,6 +1376,16 @@ public class LdapNetworkConnection exten
     /**
      * {@inheritDoc}
      */
+    public SearchFuture searchAsync( String baseDn, String filter, SearchScope scope, String... attributes )
+        throws LdapException
+    {
+        return searchAsync( new DN( baseDn ), filter, scope, attributes );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
     public SearchFuture searchAsync( SearchRequest searchRequest ) throws LdapException
     {
         // If the session has not been establish, or is closed, we get out immediately
@@ -1378,7 +1404,7 @@ public class LdapNetworkConnection exten
         WriteFuture writeFuture = ldapSession.write( request );
 
         // Wait for the message to be sent to the server
-        if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) ) 
+        if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) )
         {
             // We didn't received anything : this is an error
             LOG.error( "Search failed : timeout occured" );
@@ -1392,7 +1418,7 @@ public class LdapNetworkConnection exten
             // Thow an exception here
             throw new LdapException( searchFuture.getCause() );
         }
-        
+
         // Ok, done return the future
         return searchFuture;
 
@@ -1407,7 +1433,7 @@ public class LdapNetworkConnection exten
         SearchFuture searchFuture = searchAsync( searchRequest );
 
         long timeout = getTimeout( searchRequest.getTimeout() );
-        
+
         return new SearchCursor( searchFuture, timeout, TimeUnit.MILLISECONDS );
     }
 
@@ -1426,7 +1452,7 @@ public class LdapNetworkConnection exten
         // Create the UnbindRequest
         UnBindRequestCodec unbindRequest = new UnBindRequestCodec();
 
-        // Creates the messageID and stores it into the 
+        // Creates the messageID and stores it into the
         // initial message and the transmitted message.
         int newId = messageId.incrementAndGet();
         unbindRequest.setMessageId( newId );
@@ -1440,12 +1466,12 @@ public class LdapNetworkConnection exten
         //LOG.debug( "waiting for unbindFuture" );
         //unbindFuture.awaitUninterruptibly();
         //LOG.debug( "unbindFuture done" );
-        
+
         authenticated.set( false );
 
         // clear the mappings
         clearMaps();
-        
+
         //  We now have to close the session
         if ( ( ldapSession != null ) && connected.get() )
         {
@@ -1456,7 +1482,7 @@ public class LdapNetworkConnection exten
             LOG.debug( "closeFuture done" );
             connected.set( false );
         }
-        
+
         // Last, not least, reset the MessageId value
         messageId.set(0);
 
@@ -1488,33 +1514,33 @@ public class LdapNetworkConnection exten
     /**
      * Handle the exception we got.
      */
-    public void exceptionCaught( IoSession session, Throwable cause ) throws Exception 
+    public void exceptionCaught( IoSession session, Throwable cause ) throws Exception
     {
         if ( cause instanceof ProtocolEncoderException )
         {
             Throwable realCause = ((ProtocolEncoderException)cause).getCause();
-            
+
             if ( realCause instanceof MessageEncoderException )
             {
                 int messageId = ((MessageEncoderException)realCause).getMessageId();
-                
+
                 ResponseFuture<?> response = futureMap.get( messageId );
                 response.cancel( true );
                 response.setCause( realCause );
             }
         }
     }
-    
-    
+
+
     /**
-     * Handle the incoming LDAP messages. This is where we feed the cursor for search 
-     * requests, or call the listener. 
+     * Handle the incoming LDAP messages. This is where we feed the cursor for search
+     * requests, or call the listener.
      */
     public void messageReceived( IoSession session, Object message ) throws Exception
     {
         // Feed the response and store it into the session
         LdapMessageCodec response = ( LdapMessageCodec ) message;
-        
+
         LOG.debug( "-------> {} Message received <-------", response );
 
         // this check is necessary to prevent adding an abandoned operation's
@@ -1539,7 +1565,7 @@ public class LdapNetworkConnection exten
                 addRespCodec.setMessageId( messageId );
 
                 AddResponse addResponse = convert( addRespCodec );
-                
+
                 AddFuture addFuture = (AddFuture)responseFuture;
 
                 if ( addFuture == null )
@@ -1547,7 +1573,7 @@ public class LdapNetworkConnection exten
                     LOG.error( "AddFuture is null" );
                     throw new LdapException( "AddFuture is null"  );
                 }
-                
+
                 // remove the listener from the listener map
                 if ( LOG.isDebugEnabled() )
                 {
@@ -1565,10 +1591,10 @@ public class LdapNetworkConnection exten
 
                 // Store the response into the future
                 addFuture.set( addResponse );
-                
+
                 // Remove the future from the map
                 removeFromFutureMaps( messageId );
-                
+
                 break;
 
             case BIND_RESPONSE:
@@ -1585,7 +1611,7 @@ public class LdapNetworkConnection exten
                     LOG.error( "BindFuture is null" );
                     throw new LdapException( "BindFuture is null"  );
                 }
-                
+
                 // remove the listener from the listener map
                 if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
                 {
@@ -1615,7 +1641,7 @@ public class LdapNetworkConnection exten
                 compResCodec.addControls( response.getControls() );
 
                 CompareResponse compareResponse = convert( compResCodec );
-                
+
                 CompareFuture compareFuture = (CompareFuture)responseFuture;
 
                 if ( compareFuture == null )
@@ -1623,7 +1649,7 @@ public class LdapNetworkConnection exten
                     LOG.error( "CompareFuture is null" );
                     throw new LdapException( "CompareFuture is null"  );
                 }
-                
+
                 // remove the listener from the listener map
                 if ( LOG.isDebugEnabled() )
                 {
@@ -1641,10 +1667,10 @@ public class LdapNetworkConnection exten
 
                 // Store the response into the future
                 compareFuture.set( compareResponse );
-                
+
                 // Remove the future from the map
                 removeFromFutureMaps( messageId );
-                
+
                 break;
 
             case DEL_RESPONSE:
@@ -1654,7 +1680,7 @@ public class LdapNetworkConnection exten
                 delRespCodec.setMessageId( messageId );
 
                 DeleteResponse deleteResponse = convert( delRespCodec );
-                
+
                 DeleteFuture deleteFuture = (DeleteFuture)responseFuture;
 
                 if ( deleteFuture == null )
@@ -1662,7 +1688,7 @@ public class LdapNetworkConnection exten
                     LOG.error( "DeleteFuture is null" );
                     throw new LdapException( "DeleteFuture is null"  );
                 }
-                
+
                 if ( LOG.isDebugEnabled() )
                 {
                     if ( deleteResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
@@ -1679,10 +1705,10 @@ public class LdapNetworkConnection exten
 
                 // Store the response into the future
                 deleteFuture.set( deleteResponse );
-                
+
                 // Remove the future from the map
                 removeFromFutureMaps( messageId );
-                
+
                 break;
 
             case EXTENDED_RESPONSE:
@@ -1730,7 +1756,7 @@ public class LdapNetworkConnection exten
                 intermediateResponseCodec.addControls( response.getControls() );
 
                 setIResponse( intermediateResponseCodec, responseFuture );
-                
+
                 break;
 
             case MODIFY_RESPONSE:
@@ -1740,7 +1766,7 @@ public class LdapNetworkConnection exten
                 modRespCodec.addControls( response.getControls() );
 
                 ModifyResponse modifyResp = convert( modRespCodec );
-                
+
                 ModifyFuture modifyFuture = (ModifyFuture)responseFuture;
 
                 if ( modifyFuture == null )
@@ -1748,7 +1774,7 @@ public class LdapNetworkConnection exten
                     LOG.error( "ModifyFuture is null" );
                     throw new LdapException( "ModifyFuture is null"  );
                 }
-                
+
                 if ( LOG.isDebugEnabled() )
                 {
                     if ( modifyResp.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
@@ -1765,10 +1791,10 @@ public class LdapNetworkConnection exten
 
                 // Store the response into the future
                 modifyFuture.set( modifyResp );
-                
+
                 // Remove the future from the map
                 removeFromFutureMaps( messageId );
-                
+
                 break;
 
             case MODIFYDN_RESPONSE:
@@ -1778,7 +1804,7 @@ public class LdapNetworkConnection exten
                 modDnRespCodec.addControls( response.getControls() );
 
                 ModifyDnResponse modifyDnResp = convert( modDnRespCodec );
-                
+
                 ModifyDnFuture modifyDnFuture = (ModifyDnFuture)responseFuture;
 
                 if ( modifyDnFuture == null )
@@ -1786,7 +1812,7 @@ public class LdapNetworkConnection exten
                     LOG.error( "ModifyDNFuture is null" );
                     throw new LdapException( "ModifyDNFuture is null"  );
                 }
-                
+
                 if ( LOG.isDebugEnabled() )
                 {
                     if ( modifyDnResp.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
@@ -1803,12 +1829,12 @@ public class LdapNetworkConnection exten
 
                 // Store the response into the future
                 modifyDnFuture.set( modifyDnResp );
-                
+
                 // Remove the future from the map
                 removeFromFutureMaps( messageId );
-                
+
                 break;
-                
+
             case SEARCH_RESULT_DONE:
                 // Store the response into the responseQueue
                 SearchResultDoneCodec searchResultDoneCodec = (SearchResultDoneCodec)response;
@@ -1817,13 +1843,13 @@ public class LdapNetworkConnection exten
                 SearchResultDone searchResultDone = convert( searchResultDoneCodec );
 
                 SearchFuture searchFuture = (SearchFuture)responseFuture;
-                
+
                 if ( searchFuture == null )
                 {
                     LOG.error( "SearchFuture is null" );
                     throw new LdapException( "SearchFuture is null"  );
                 }
-                
+
                 if ( LOG.isDebugEnabled() )
                 {
                     if ( searchResultDone.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
@@ -1840,7 +1866,7 @@ public class LdapNetworkConnection exten
 
                 // Store the response into the future
                 searchFuture.set( searchResultDone );
-                
+
                 // Remove the future from the map
                 removeFromFutureMaps( messageId );
 
@@ -1855,13 +1881,13 @@ public class LdapNetworkConnection exten
                 SearchResultEntry srchEntry = convert( searchResultEntryCodec );
 
                 searchFuture = (SearchFuture)responseFuture;
-                
+
                 if ( searchFuture == null )
                 {
                     LOG.error( "SearchFuture is null" );
                     throw new LdapException( "SearchFuture is null"  );
                 }
-                
+
                 if ( LOG.isDebugEnabled() )
                 {
                     LOG.debug( "Search entry found : {}", srchEntry );
@@ -1869,7 +1895,7 @@ public class LdapNetworkConnection exten
 
                 // Store the response into the future
                 searchFuture.set( srchEntry );
-                
+
                 break;
 
             case SEARCH_RESULT_REFERENCE:
@@ -1881,13 +1907,13 @@ public class LdapNetworkConnection exten
                 SearchResultReference searchResultReference = convert( searchResultReferenceCodec );
 
                 searchFuture = (SearchFuture)responseFuture;
-                
+
                 if ( searchFuture == null )
                 {
                     LOG.error( "SearchFuture is null" );
                     throw new LdapException( "SearchFuture is null"  );
                 }
-                
+
                 if ( LOG.isDebugEnabled() )
                 {
                     LOG.debug( "Search reference found : {}", searchResultReference );
@@ -1895,7 +1921,7 @@ public class LdapNetworkConnection exten
 
                 // Store the response into the future
                 searchFuture.set( searchResultReference );
-                
+
                 break;
 
             default:
@@ -1949,10 +1975,19 @@ public class LdapNetworkConnection exten
     /**
      * {@inheritDoc}
      */
+    public ModifyResponse modify( String dn, Modification... modifications ) throws LdapException
+    {
+        return modify ( new DN( dn ), modifications );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
     public ModifyResponse modify( ModifyRequest modRequest ) throws LdapException
     {
         ModifyFuture modifyFuture = modifyAsync( modRequest );
-        
+
         // Get the result from the future
         try
         {
@@ -1960,15 +1995,15 @@ public class LdapNetworkConnection exten
             long timeout = getTimeout( modRequest.getTimeout() );
 
             // Get the response, blocking
-            ModifyResponse modifyResponse = ( ModifyResponse ) modifyFuture.get( timeout, TimeUnit.MILLISECONDS );
-            
+            ModifyResponse modifyResponse = modifyFuture.get( timeout, TimeUnit.MILLISECONDS );
+
             if ( modifyResponse == null )
             {
                 // We didn't received anything : this is an error
                 LOG.error( "Modify failed : timeout occured" );
                 throw new LdapException( TIME_OUT_ERROR );
             }
-            
+
             if ( modifyResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
             {
                 // Everything is fine, return the response
@@ -2029,7 +2064,7 @@ public class LdapNetworkConnection exten
         modReqCodec.setObject( modRequest.getDn() );
 
         setControls( modRequest.getControls(), modReqCodec );
-        
+
         ModifyFuture modifyFuture = new ModifyFuture( this, newId );
         addToFutureMap( newId, modifyFuture );
 
@@ -2037,14 +2072,14 @@ public class LdapNetworkConnection exten
         WriteFuture writeFuture = ldapSession.write( modReqCodec );
 
         // Wait for the message to be sent to the server
-        if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) ) 
+        if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) )
         {
             // We didn't received anything : this is an error
             LOG.error( "Modify failed : timeout occured" );
 
             throw new LdapException( TIME_OUT_ERROR );
         }
-        
+
         // Ok, done return the future
         return modifyFuture;
     }
@@ -2149,7 +2184,7 @@ public class LdapNetworkConnection exten
 
     /**
      * Moves and renames the given entryDn.The old RDN will be deleted
-     * 
+     *
      * @see #moveAndRename(DN, DN, boolean)
      */
     public ModifyDnResponse moveAndRename( DN entryDn, DN newDn ) throws LdapException
@@ -2160,7 +2195,7 @@ public class LdapNetworkConnection exten
 
     /**
      * Moves and renames the given entryDn.The old RDN will be deleted
-     * 
+     *
      * @see #moveAndRename(DN, DN, boolean)
      */
     public ModifyDnResponse moveAndRename( String entryDn, String newDn ) throws LdapException
@@ -2171,7 +2206,7 @@ public class LdapNetworkConnection exten
 
     /**
      * Moves and renames the given entryDn.The old RDN will be deleted if requested
-     * 
+     *
      * @param entryDn The original entry DN
      * @param newDn The new Entry DN
      * @param deleteOldRdn Tells if the old RDN must be removed
@@ -2179,40 +2214,40 @@ public class LdapNetworkConnection exten
     public ModifyDnResponse moveAndRename( DN entryDn, DN newDn, boolean deleteOldRdn ) throws LdapException
     {
         // Check the parameters first
-        if ( entryDn == null ) 
+        if ( entryDn == null )
         {
             throw new IllegalArgumentException( "The entry DN must not be null" );
         }
-        
+
         if ( entryDn.isRootDSE() )
         {
             throw new IllegalArgumentException( "The RootDSE cannot be moved" );
         }
-        
-        if ( newDn == null ) 
+
+        if ( newDn == null )
         {
             throw new IllegalArgumentException( "The new DN must not be null" );
         }
-        
+
         if ( newDn.isRootDSE() )
         {
             throw new IllegalArgumentException( "The RootDSE cannot be the target" );
         }
-        
+
         // Create the request
         ModifyDnRequest modDnRequest = new ModifyDnRequest();
         modDnRequest.setEntryDn( entryDn );
         modDnRequest.setNewRdn( newDn.getRdn() );
         modDnRequest.setNewSuperior( newDn.getParent() );
         modDnRequest.setDeleteOldRdn( deleteOldRdn );
-        
+
         return modifyDn( modDnRequest );
     }
 
 
     /**
      * Moves and renames the given entryDn.The old RDN will be deleted if requested
-     * 
+     *
      * @param entryDn The original entry DN
      * @param newDn The new Entry DN
      * @param deleteOldRdn Tells if the old RDN must be removed
@@ -2229,7 +2264,7 @@ public class LdapNetworkConnection exten
     public ModifyDnResponse modifyDn( ModifyDnRequest modDnRequest ) throws LdapException
     {
         ModifyDnFuture modifyDnFuture = modifyDnAsync( modDnRequest );
-        
+
         // Get the result from the future
         try
         {
@@ -2237,15 +2272,15 @@ public class LdapNetworkConnection exten
             long timeout = getTimeout( modDnRequest.getTimeout() );
 
             // Get the response, blocking
-            ModifyDnResponse modifyDnResponse = ( ModifyDnResponse ) modifyDnFuture.get( timeout, TimeUnit.MILLISECONDS );
-            
+            ModifyDnResponse modifyDnResponse = modifyDnFuture.get( timeout, TimeUnit.MILLISECONDS );
+
             if ( modifyDnResponse == null )
             {
                 // We didn't received anything : this is an error
                 LOG.error( "ModifyDN failed : timeout occured" );
                 throw new LdapException( TIME_OUT_ERROR );
             }
-            
+
             if ( modifyDnResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
             {
                 // Everything is fine, return the response
@@ -2316,14 +2351,14 @@ public class LdapNetworkConnection exten
         WriteFuture writeFuture = ldapSession.write( modDnCodec );
 
         // Wait for the message to be sent to the server
-        if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) ) 
+        if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) )
         {
             // We didn't received anything : this is an error
             LOG.error( "Modify failed : timeout occured" );
 
             throw new LdapException( TIME_OUT_ERROR );
         }
-        
+
         // Ok, done return the future
         return modifyDnFuture;
     }
@@ -2349,17 +2384,7 @@ public class LdapNetworkConnection exten
      */
     public DeleteResponse delete( String dn ) throws LdapException
     {
-        try
-        {
-            DeleteRequest deleteRequest = new DeleteRequest( new DN( dn ) );
-
-            return delete( deleteRequest );
-        }
-        catch ( LdapInvalidDnException e )
-        {
-            LOG.error( e.getMessage(), e );
-            throw new LdapException( e.getMessage(), e );
-        }
+        return delete( new DN( dn ) );
     }
 
 
@@ -2376,7 +2401,7 @@ public class LdapNetworkConnection exten
 
     /**
      * deletes the entry with the given DN, and all its children
-     *  
+     *
      * @param dn the target entry's DN
      * @return operation's response
      * @throws LdapException If the DN is not valid or if the deletion failed
@@ -2403,7 +2428,7 @@ public class LdapNetworkConnection exten
 
     /**
      * deletes the entry with the given DN, and all its children
-     *  
+     *
      * @param dn the target entry's DN as a String
      * @return operation's response
      * @throws LdapException If the DN is not valid or if the deletion failed
@@ -2439,33 +2464,33 @@ public class LdapNetworkConnection exten
 
     /**
      * removes all child entries present under the given DN and finally the DN itself
-     * 
+     *
      * Working:
      *          This is a recursive function which maintains a Map<DN,Cursor>.
-     *          The way the cascade delete works is by checking for children for a 
+     *          The way the cascade delete works is by checking for children for a
      *          given DN(i.e opening a search cursor) and if the cursor is empty
      *          then delete the DN else for each entry's DN present in cursor call
      *          deleteChildren() with the DN and the reference to the map.
-     *          
+     *
      *          The reason for opening a search cursor is based on an assumption
      *          that an entry *might* contain children, consider the below DIT fragment
-     *          
+     *
      *          parent
      *          /     \
      *        child1   child2
      *                 /     \
      *               grand21  grand22
-     *               
-     *           The below method works better in the case where the tree depth is >1 
-     *          
+     *
+     *           The below method works better in the case where the tree depth is >1
+     *
      *   In the case of passing a non-null DeleteListener, the return value will always be null, cause the
      *   operation is treated as asynchronous and response result will be sent using the listener callback
-     *   
+     *
      *  //FIXME provide another method for optimizing delete operation for a tree with depth <=1
-     *          
+     *
      * @param dn the DN which will be removed after removing its children
      * @param map a map to hold the Cursor related to a DN
-     * @param listener  the delete operation response listener 
+     * @param listener  the delete operation response listener
      * @throws LdapException If the DN is not valid or if the deletion failed
      */
     private DeleteResponse deleteRecursive( DN dn, Map<DN, Cursor<SearchResponse>> cursorMap,
@@ -2543,15 +2568,15 @@ public class LdapNetworkConnection exten
             long timeout = getTimeout( deleteRequest.getTimeout() );
 
             // Get the response, blocking
-            DeleteResponse delResponse = ( DeleteResponse ) deleteFuture.get( timeout, TimeUnit.MILLISECONDS );
-            
+            DeleteResponse delResponse = deleteFuture.get( timeout, TimeUnit.MILLISECONDS );
+
             if ( delResponse == null )
             {
                 // We didn't received anything : this is an error
                 LOG.error( "Delete failed : timeout occured" );
                 throw new LdapException( TIME_OUT_ERROR );
             }
-            
+
             if ( delResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
             {
                 // Everything is fine, return the response
@@ -2593,8 +2618,8 @@ public class LdapNetworkConnection exten
             throw ldapException;
         }
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -2605,7 +2630,7 @@ public class LdapNetworkConnection exten
         DelRequestCodec delReqCodec = new DelRequestCodec();
 
         int newId = messageId.incrementAndGet();
-        
+
         delRequest.setMessageId( newId );
         delReqCodec.setMessageId( newId );
 
@@ -2619,14 +2644,14 @@ public class LdapNetworkConnection exten
         WriteFuture writeFuture = ldapSession.write( delReqCodec );
 
         // Wait for the message to be sent to the server
-        if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) ) 
+        if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) )
         {
             // We didn't received anything : this is an error
             LOG.error( "Delete failed : timeout occured" );
 
             throw new LdapException( TIME_OUT_ERROR );
         }
-        
+
         // Ok, done return the future
         return deleteFuture;
     }
@@ -2637,20 +2662,7 @@ public class LdapNetworkConnection exten
      */
     public CompareResponse compare( String dn, String attributeName, String value ) throws LdapException
     {
-        try
-        {
-            CompareRequest compareRequest = new CompareRequest();
-            compareRequest.setEntryDn( new DN( dn ) );
-            compareRequest.setAttrName( attributeName );
-            compareRequest.setValue( value );
-
-            return compare( compareRequest );
-        }
-        catch ( Exception e )
-        {
-            LOG.error( COMPARE_FAILED, e );
-            throw new LdapException( COMPARE_FAILED, e );
-        }
+        return compare( new DN( dn ), attributeName, value );
     }
 
 
@@ -2659,20 +2671,7 @@ public class LdapNetworkConnection exten
      */
     public CompareResponse compare( String dn, String attributeName, byte[] value ) throws LdapException
     {
-        try
-        {
-            CompareRequest compareRequest = new CompareRequest();
-            compareRequest.setEntryDn( new DN( dn ) );
-            compareRequest.setAttrName( attributeName );
-            compareRequest.setValue( value );
-
-            return compare( compareRequest );
-        }
-        catch ( Exception e )
-        {
-            LOG.error( COMPARE_FAILED, e );
-            throw new LdapException( COMPARE_FAILED, e );
-        }
+        return compare( new DN( dn ), attributeName, value );
     }
 
 
@@ -2681,20 +2680,7 @@ public class LdapNetworkConnection exten
      */
     public CompareResponse compare( String dn, String attributeName, Value<?> value ) throws LdapException
     {
-        try
-        {
-            CompareRequest compareRequest = new CompareRequest();
-            compareRequest.setEntryDn( new DN( dn ) );
-            compareRequest.setAttrName( attributeName );
-            compareRequest.setValue( value );
-
-            return compare( compareRequest );
-        }
-        catch ( Exception e )
-        {
-            LOG.error( COMPARE_FAILED, e );
-            throw new LdapException( COMPARE_FAILED, e );
-        }
+        return compare( new DN( dn ), attributeName, value );
     }
 
 
@@ -2754,15 +2740,15 @@ public class LdapNetworkConnection exten
             long timeout = getTimeout( compareRequest.getTimeout() );
 
             // Get the response, blocking
-            CompareResponse compareResponse = ( CompareResponse ) compareFuture.get( timeout, TimeUnit.MILLISECONDS );
-            
+            CompareResponse compareResponse = compareFuture.get( timeout, TimeUnit.MILLISECONDS );
+
             if ( compareResponse == null )
             {
                 // We didn't received anything : this is an error
                 LOG.error( "Compare failed : timeout occured" );
                 throw new LdapException( TIME_OUT_ERROR );
             }
-            
+
             if ( compareResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
             {
                 // Everything is fine, return the response
@@ -2816,7 +2802,7 @@ public class LdapNetworkConnection exten
         CompareRequestCodec compareReqCodec = new CompareRequestCodec();
 
         int newId = messageId.incrementAndGet();
-        
+
         compareRequest.setMessageId( newId );
         compareReqCodec.setMessageId( newId );
 
@@ -2832,14 +2818,14 @@ public class LdapNetworkConnection exten
         WriteFuture writeFuture = ldapSession.write( compareReqCodec );
 
         // Wait for the message to be sent to the server
-        if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) ) 
+        if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) )
         {
             // We didn't received anything : this is an error
             LOG.error( "Compare failed : timeout occured" );
 
             throw new LdapException( TIME_OUT_ERROR );
         }
-        
+
         // Ok, done return the future
         return compareFuture;
     }
@@ -2870,7 +2856,7 @@ public class LdapNetworkConnection exten
         response.setMessageId( delRespCodec.getMessageId() );
         response.setLdapResult( convert( delRespCodec.getLdapResult() ) );
         addControls( delRespCodec, response );
-        
+
         return response;
     }
 
@@ -2937,7 +2923,7 @@ public class LdapNetworkConnection exten
             long timeout = getTimeout( extendedRequest.getTimeout() );
 
             // Get the response, blocking
-            ExtendedResponse extendedResponse = ( ExtendedResponse ) extendedFuture.get( timeout, TimeUnit.MILLISECONDS );
+            ExtendedResponse extendedResponse = extendedFuture.get( timeout, TimeUnit.MILLISECONDS );
 
             if ( extendedResponse == null )
             {
@@ -3026,6 +3012,16 @@ public class LdapNetworkConnection exten
         return extendedFuture;
     }
 
+
+    /**
+     * {@inheritDoc}
+     */
+    public SearchResponse lookup( DN dn ) throws LdapException
+    {
+        return lookup( dn, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
+    }
+
+
     /**
      * {@inheritDoc}
      */
@@ -3033,29 +3029,29 @@ public class LdapNetworkConnection exten
     {
         return lookup( dn, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
-    public SearchResponse lookup( String dn, String... attributes ) throws LdapException
+    public SearchResponse lookup( DN dn, String... attributes ) throws LdapException
     {
         SearchResponse resp = null;
-        
+
         try
         {
             Cursor<SearchResponse> cursor = search( dn, "(objectClass=*)", SearchScope.OBJECT, attributes );
-            
+
             // Read the response
             if ( cursor.next() )
             {
                 resp = cursor.get();
             }
-            
+
             // Pass through the SaerchResultDone, or stop
             // if we have other responses
             cursor.next();
-            
+
             // And close the cursor
             cursor.close();
         }
@@ -3066,7 +3062,16 @@ public class LdapNetworkConnection exten
 
         return resp;
     }
-    
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public SearchResponse lookup( String dn, String... attributes ) throws LdapException
+    {
+        return lookup( new DN( dn ), attributes );
+    }
+
 
     /**
      * converts the ExtendedResponseCodec to ExtendedResponse.
@@ -3085,7 +3090,7 @@ public class LdapNetworkConnection exten
         }
         catch ( DecoderException e )
         {
-            // can happen in case of a PROTOCOL_ERROR result, ignore 
+            // can happen in case of a PROTOCOL_ERROR result, ignore
             //LOG.error( "invalid response name {}", extRespCodec.getResponseName() );
         }
 
@@ -3093,9 +3098,9 @@ public class LdapNetworkConnection exten
         extResponse.setValue( extRespCodec.getResponse() );
         extResponse.setMessageId( extRespCodec.getMessageId() );
         extResponse.setLdapResult( convert( extRespCodec.getLdapResult() ) );
-        
+
         addControls( extRespCodec, extResponse );
-        
+
         return extResponse;
     }
 
@@ -3127,7 +3132,7 @@ public class LdapNetworkConnection exten
         supportedControls = new ArrayList<String>();
 
         EntryAttribute attr = rootDSE.get( SchemaConstants.SUPPORTED_CONTROL_AT );
-        
+
         for (Value<?> value:attr)
         {
             supportedControls.add( value.getString() );
@@ -3136,7 +3141,7 @@ public class LdapNetworkConnection exten
         return supportedControls;
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
@@ -3147,7 +3152,7 @@ public class LdapNetworkConnection exten
             JarLdifSchemaLoader jarSchemaLoader = new JarLdifSchemaLoader();
 
             schemaManager = new DefaultSchemaManager( jarSchemaLoader );
-            
+
             // we enale all the schemas so that need not check with server for enabled schemas
             Collection<Schema> schemas = schemaManager.getLoader().getAllSchemas();
             for( Schema s : schemas )
@@ -3156,7 +3161,7 @@ public class LdapNetworkConnection exten
             }
 
             schemaManager.loadAllEnabled();
-            
+
             if( ! schemaManager.getErrors().isEmpty() )
             {
                 String msg = "there are errors while loading the schema";
@@ -3175,7 +3180,7 @@ public class LdapNetworkConnection exten
         }
     }
 
-    
+
     /**
      * parses the given schema file present in OpenLDAP schema format
      * and adds all the SchemaObjects present in it to the SchemaManager
@@ -3191,25 +3196,25 @@ public class LdapNetworkConnection exten
             {
                 loadSchema();
             }
-            
+
             OpenLdapSchemaParser olsp = new OpenLdapSchemaParser();
             olsp.setQuirksMode( true );
             olsp.parse( schemaFile );
-            
+
             List<AttributeType> atList = olsp.getAttributeTypes();
             AttributeTypeRegistry atRegistry = schemaManager.getRegistries().getAttributeTypeRegistry();
             for( AttributeType atType : atList )
             {
                 atRegistry.addMappingFor( atType );
             }
-            
+
             List<ObjectClass> ocList = olsp.getObjectClassTypes();
             ObjectClassRegistry ocRegistry = schemaManager.getRegistries().getObjectClassRegistry();
             for( ObjectClass oc : ocList )
             {
                 ocRegistry.register( oc );
             }
-            
+
             LOG.info( "successfully loaded the schema from file {}", schemaFile.getAbsolutePath() );
         }
         catch( Exception e )
@@ -3218,8 +3223,8 @@ public class LdapNetworkConnection exten
             throw new LdapException( e );
         }
     }
-    
-    
+
+
     /**
      * @see #addSchema(File)
      */
@@ -3227,8 +3232,8 @@ public class LdapNetworkConnection exten
     {
         addSchema( new File( schemaFileName ) );
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -3278,7 +3283,7 @@ public class LdapNetworkConnection exten
 
     /**
      * gives the configuration information of the connection
-     * 
+     *
      * @return the configuration of the connection
      */
     public LdapConnectionConfig getConfig()
@@ -3313,15 +3318,15 @@ public class LdapNetworkConnection exten
     /**
      * removes the Objects associated with the given message ID
      * from future and response queue maps
-     * 
-     * @param msgId id of the message 
+     *
+     * @param msgId id of the message
      */
     private void removeFromFutureMaps( int msgId )
     {
         getFromFutureMap( msgId );
     }
-    
-    
+
+
     /**
      * clears the async listener, responseQueue and future mapppings to the corresponding request IDs
      */
@@ -3329,8 +3334,8 @@ public class LdapNetworkConnection exten
     {
         futureMap.clear();
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -3338,15 +3343,15 @@ public class LdapNetworkConnection exten
     {
         return futureMap.get( messageId ) != null;
     }
-    
-    
+
+
     public void addConnectionClosedEventListener( ConnectionClosedEventListener ccListenr )
     {
         if( conCloseListeners == null )
         {
             conCloseListeners = new ArrayList<ConnectionClosedEventListener>();
         }
-        
+
         conCloseListeners.add( ccListenr );
     }
 
@@ -3359,20 +3364,20 @@ public class LdapNetworkConnection exten
         {
             return;
         }
-        
+
         ldapSession.close( true );
         connected.set( false );
         // Reset the messageId
         messageId.set( 0 );
-        
+
         // DO NOT call connector.dispose(), it is hanging when there is no network connection
         // set localConnector flag to false to avoid NPE when close() is called after this sessionClosed() method
         // gets called
         localConnector = false;
         connector = null;
-        
+
         clearMaps();
-        
+
         if( conCloseListeners != null )
         {
             LOG.debug( "notifying the registered ConnectionClosedEventListeners.." );
@@ -3382,5 +3387,5 @@ public class LdapNetworkConnection exten
             }
         }
     }
-    
+
 }



Mime
View raw message