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 2010/07/20 03:09:41 UTC
svn commit: r965706 - in /directory/clients/ldap/trunk: ./
ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/
ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/future/
ldap-client-api/src/main/java/org/apache/directory...
Author: elecharny
Date: Tue Jul 20 01:09:41 2010
New Revision: 965706
URL: http://svn.apache.org/viewvc?rev=965706&view=rev
Log:
merged back the subtree branch into trunk
Modified:
directory/clients/ldap/trunk/ (props changed)
directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/future/ResponseFuture.java
directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolEncoder.java
Propchange: directory/clients/ldap/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Jul 20 01:09:41 2010
@@ -0,0 +1 @@
+/directory/clients/ldap/branches/ldap-client-subtree:965547-965686
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=965706&r1=965705&r2=965706&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 Tue Jul 20 01:09:41 2010
@@ -24,6 +24,7 @@ import org.apache.directory.ldap.client.
import org.apache.directory.shared.asn1.primitives.OID;
import org.apache.directory.shared.ldap.cursor.Cursor;
import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.Modification;
import org.apache.directory.shared.ldap.entry.ModificationOperation;
import org.apache.directory.shared.ldap.entry.Value;
import org.apache.directory.shared.ldap.exception.LdapException;
@@ -207,9 +208,21 @@ public interface LdapConnection
/**
*
+ * 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( DN dn, Modification... modifications ) throws LdapException;
+
+
+ /**
+ *
* modifies all the attributes present in the entry by applying the same operation.
*
- * @param entry the entry whise attributes to be modified
+ * @param entry the entry with the attributes to be modified
* @param modOp the operation to be applied on all the attributes of the above entry
* @return the modify operation's response
* @throws LdapException in case of modify operation failure or timeout happens
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=965706&r1=965705&r2=965706&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 Tue Jul 20 01:09:41 2010
@@ -86,6 +86,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
import org.apache.directory.shared.ldap.codec.LdapResultCodec;
import org.apache.directory.shared.ldap.codec.LdapTransformer;
+import org.apache.directory.shared.ldap.codec.MessageEncoderException;
import org.apache.directory.shared.ldap.codec.abandon.AbandonRequestCodec;
import org.apache.directory.shared.ldap.codec.add.AddRequestCodec;
import org.apache.directory.shared.ldap.codec.add.AddResponseCodec;
@@ -117,6 +118,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.entry.DefaultEntry;
import org.apache.directory.shared.ldap.entry.Entry;
import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Modification;
import org.apache.directory.shared.ldap.entry.ModificationOperation;
import org.apache.directory.shared.ldap.entry.Value;
import org.apache.directory.shared.ldap.exception.LdapException;
@@ -148,6 +150,7 @@ import org.apache.mina.core.service.IoCo
import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
+import org.apache.mina.filter.codec.ProtocolEncoderException;
import org.apache.mina.filter.ssl.SslFilter;
import org.apache.mina.transport.socket.nio.NioSocketConnector;
import org.slf4j.Logger;
@@ -166,7 +169,6 @@ import org.slf4j.LoggerFactory;
*/
public class LdapNetworkConnection extends IoHandlerAdapter implements LdapAsyncConnection
{
-
/** logger for reporting errors that might not be handled properly upstream */
private static final Logger LOG = LoggerFactory.getLogger( LdapNetworkConnection.class );
@@ -1383,6 +1385,13 @@ public class LdapNetworkConnection exten
throw new LdapException( TIME_OUT_ERROR );
}
+
+ // Chekc that the future hasn't be canceled
+ if ( searchFuture.isCancelled() )
+ {
+ // Thow an exception here
+ throw new LdapException( searchFuture.getCause() );
+ }
// Ok, done return the future
return searchFuture;
@@ -1477,6 +1486,27 @@ public class LdapNetworkConnection exten
/**
+ * Handle the exception we got.
+ */
+ 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.
*/
@@ -1901,6 +1931,24 @@ public class LdapNetworkConnection exten
/**
* {@inheritDoc}
*/
+ public ModifyResponse modify( DN dn, Modification... modifications ) throws LdapException
+ {
+ if ( dn == null )
+ {
+ LOG.debug( "received a null dn for modification" );
+ throw new IllegalArgumentException( "The DN to be modified cannot be null" );
+ }
+
+ ModifyRequest modReq = new ModifyRequest( dn );
+ modReq.addModification( modifications );
+
+ return modify( modReq );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
public ModifyResponse modify( ModifyRequest modRequest ) throws LdapException
{
ModifyFuture modifyFuture = modifyAsync( modRequest );
Modified: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/future/ResponseFuture.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/future/ResponseFuture.java?rev=965706&r1=965705&r2=965706&view=diff
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/future/ResponseFuture.java (original)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/future/ResponseFuture.java Tue Jul 20 01:09:41 2010
@@ -43,6 +43,9 @@ public class ResponseFuture<R> implement
/** flag to determine if this future is cancelled */
protected boolean cancelled = false;
+
+ /** If the request has been cancelled because of an exception it will be stored here */
+ protected Throwable cause;
/** The messageID for this future */
protected int messageId;
@@ -144,6 +147,24 @@ public class ResponseFuture<R> implement
{
throw new UnsupportedOperationException( "Operation not supported" );
}
+
+
+ /**
+ * @return the cause
+ */
+ public Throwable getCause()
+ {
+ return cause;
+ }
+
+
+ /**
+ * @param cause the cause to set
+ */
+ public void setCause( Throwable cause )
+ {
+ this.cause = cause;
+ }
public String toString()
Modified: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolEncoder.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolEncoder.java?rev=965706&r1=965705&r2=965706&view=diff
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolEncoder.java (original)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/protocol/LdapProtocolEncoder.java Tue Jul 20 01:09:41 2010
@@ -47,6 +47,7 @@ public class LdapProtocolEncoder impleme
if ( request instanceof LdapMessageCodec )
{
LdapMessageCodec ldapRequest = (LdapMessageCodec)request;
+
ByteBuffer bb = ldapRequest.encode();
bb.flip();