Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 10610 invoked from network); 20 Jul 2010 01:10:47 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 20 Jul 2010 01:10:47 -0000 Received: (qmail 32132 invoked by uid 500); 20 Jul 2010 01:10:47 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 32073 invoked by uid 500); 20 Jul 2010 01:10:47 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 32066 invoked by uid 99); 20 Jul 2010 01:10:47 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jul 2010 01:10:47 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jul 2010 01:10:35 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E905C2388A84; Tue, 20 Jul 2010 01:09:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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... Date: Tue, 20 Jul 2010 01:09:41 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100720010941.E905C2388A84@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 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 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();