You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2009/04/09 20:02:27 UTC
svn commit: r763751 - in
/directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api:
./ messages/
Author: elecharny
Date: Thu Apr 9 18:02:27 2009
New Revision: 763751
URL: http://svn.apache.org/viewvc?rev=763751&view=rev
Log:
o Added some more toString() methods.
o No need anymore to connect before binding, it's done automatically
o Unbind and Abandon request fixed.
Modified:
directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/LdapConnection.java
directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonRequestImpl.java
directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbstractResponseWithResult.java
directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/UnbindRequestImpl.java
Modified: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/LdapConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/LdapConnection.java?rev=763751&r1=763750&r2=763751&view=diff
==============================================================================
--- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/LdapConnection.java (original)
+++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/LdapConnection.java Thu Apr 9 18:02:27 2009
@@ -194,8 +194,7 @@
/** A queue used to store the incoming intermediate responses */
private BlockingQueue<LdapMessageCodec> intermediateResponseQueue;
-
-
+
/** An operation mutex to guarantee the operation order */
private Semaphore operationMutex;
@@ -532,13 +531,13 @@
* Connect to the remote LDAP server.
*
* @return <code>true</code> if the connection is established, false otherwise
- * @throws IOException if some I/O error occurs
+ * @throws LdapException if some error has occured
*/
- public boolean connect() throws IOException
+ private boolean connect() throws LdapException
{
if ( ( ldapSession != null ) && ldapSession.isConnected() )
{
- throw new IllegalStateException( "Already connected. Disconnect first." );
+ return true;
}
// Create the connector if needed
@@ -836,7 +835,7 @@
bindRequest.setName( name );
bindRequest.setCredentials( credentials );
- BindResponse response = bind( bindRequest );
+ BindResponse response = bindInternal( bindRequest );
if ( response.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
{
@@ -936,6 +935,9 @@
*/
private BindFuture bindAsyncInternal( BindRequest bindRequest, BindListener bindListener ) throws LdapException
{
+ // First try to connect, if we aren't already connected.
+ connect();
+
// If the session has not been establish, or is closed, we get out immediately
checkSession();
@@ -1244,10 +1246,13 @@
// Unbind operations //
//---------------------------------------------------------------------//
/**
- * UnBind from a server
+ * UnBind from a server. this is a request which expect no response.
*/
public void unBind() throws Exception
{
+ // First try to connect, if we aren't already connected.
+ connect();
+
// If the session has not been establish, or is closed, we get out immediately
checkSession();
@@ -1275,10 +1280,10 @@
// Send the request to the server
ldapSession.write( unbindMessage );
- // We also have to reset the response queues
- bindResponseQueue.clear();
-
+ // Release the LdapSession
operationMutex.release();
+
+ // And get out
LOG.debug( "Unbind successful" );
}
Modified: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonRequestImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonRequestImpl.java?rev=763751&r1=763750&r2=763751&view=diff
==============================================================================
--- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonRequestImpl.java (original)
+++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonRequestImpl.java Thu Apr 9 18:02:27 2009
@@ -69,4 +69,22 @@
return this;
}
+
+
+ /**
+ * Return a String representing an AbandonRequest
+ *
+ * @return A String representing the AbandonRequest
+ */
+ public String toString()
+ {
+
+ StringBuffer sb = new StringBuffer();
+
+ sb.append( super.toString() );
+ sb.append( " Abandon Request :\n" );
+ sb.append( " Message Id : " ).append( abandonedMessageId ).append( '\n' );
+
+ return sb.toString();
+ }
}
Modified: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbstractResponseWithResult.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbstractResponseWithResult.java?rev=763751&r1=763750&r2=763751&view=diff
==============================================================================
--- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbstractResponseWithResult.java (original)
+++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbstractResponseWithResult.java Thu Apr 9 18:02:27 2009
@@ -61,4 +61,24 @@
{
this.ldapResult = ldapResult;
}
+
+
+ /**
+ * Get a String representation of an Response
+ *
+ * @return An Response String
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( super.toString() );
+
+ if ( ldapResult != null )
+ {
+ sb.append( ldapResult );
+ }
+
+ return sb.toString();
+ }
}
Modified: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/UnbindRequestImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/UnbindRequestImpl.java?rev=763751&r1=763750&r2=763751&view=diff
==============================================================================
--- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/UnbindRequestImpl.java (original)
+++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/UnbindRequestImpl.java Thu Apr 9 18:02:27 2009
@@ -35,4 +35,20 @@
{
super();
}
+
+
+ /**
+ * Get a String representation of a UnBindRequest
+ *
+ * @return A UnBindRequest String
+ */
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+
+ sb.append( super.toString() );
+ sb.append( " UnBind Request\n" );
+
+ return sb.toString();
+ }
}