Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 12611 invoked from network); 2 Apr 2009 23:27:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Apr 2009 23:27:59 -0000 Received: (qmail 11888 invoked by uid 500); 2 Apr 2009 23:27:58 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 11834 invoked by uid 500); 2 Apr 2009 23:27:58 -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 11825 invoked by uid 99); 2 Apr 2009 23:27:58 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Apr 2009 23:27:58 +0000 X-ASF-Spam-Status: No, hits=-1998.8 required=10.0 tests=ALL_TRUSTED,FS_REPLICA 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; Thu, 02 Apr 2009 23:27:56 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id DE21123888EB; Thu, 2 Apr 2009 23:27:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r761472 - /directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/ Date: Thu, 02 Apr 2009 23:27:34 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090402232735.DE21123888EB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Thu Apr 2 23:27:34 2009 New Revision: 761472 URL: http://svn.apache.org/viewvc?rev=761472&view=rev Log: Temporary commit with the latest version of most of the Classes and Interfaces needed for the client messages. Added: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonableRequest.java directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbstractMessage.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/IntermediateResponse.java directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/IntermediateResponseImpl.java directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/LdapResult.java directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/LdapResultImpl.java directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/Request.java directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/RequestWithResponse.java directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/Response.java directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/ResponseWithResult.java directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/SearchRequest.java directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/SearchRequestImpl.java directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/SearchResponse.java directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/UnbindRequest.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/messages/AbandonRequest.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/AbstractRequest.java directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequest.java directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequestImpl.java directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindResponse.java directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindResponseImpl.java directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/Message.java Modified: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonRequest.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/AbandonRequest.java?rev=761472&r1=761471&r2=761472&view=diff ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonRequest.java (original) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonRequest.java Thu Apr 2 23:27:34 2009 @@ -20,11 +20,11 @@ package org.apache.directory.shared.ldap.client.api.messages; /** - * Abandon protocol operation request. It abandon the given message. + * Abandon protocol operation request. It abandons the given message. * * @author Apache Directory Project */ -public interface AbandonRequest extends Message +public interface AbandonRequest extends Request { /** * Get the abandoned message ID 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=761472&r1=761471&r2=761472&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 2 23:27:34 2009 @@ -38,6 +38,16 @@ /** + * + * Creates a new instance of AbandonRequestImpl. + */ + public AbandonRequestImpl() + { + super(); + } + + + /** * Get the abandoned message ID * * @return Returns the abandoned MessageId. Added: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonableRequest.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/AbandonableRequest.java?rev=761472&view=auto ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonableRequest.java (added) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonableRequest.java Thu Apr 2 23:27:34 2009 @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.shared.ldap.client.api.messages; + + +/** + * A request which can be abandoned. + * + * @author Apache Directory Project + */ +public interface AbandonableRequest extends Request +{ +} Added: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbstractMessage.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/AbstractMessage.java?rev=761472&view=auto ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbstractMessage.java (added) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbstractMessage.java Thu Apr 2 23:27:34 2009 @@ -0,0 +1,141 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.shared.ldap.client.api.messages; + +import java.util.HashMap; +import java.util.Map; + +import javax.naming.ldap.Control; + +import org.apache.directory.shared.ldap.client.api.exception.LdapException; + + +/** + * Abstract message base class. + * + * @author Apache Directory Project + * @version $Rev: 760984 $ + */ +public abstract class AbstractMessage implements Message +{ + /** Map of message controls using OID Strings for keys and Control values */ + private Map controls; + + /** The session unique message sequence identifier */ + private int messageId = -1; + + /** + * Completes the instanciation of a Message. + * + * @param messageId the seq id of the message + */ + protected AbstractMessage() + { + controls = new HashMap(); + } + + + /** + * Gets the session unique message sequence id for this message. Requests + * and their responses if any have the same message id. Clients at the + * initialization of a session start with the first message's id set to 1 + * and increment it with each transaction. + * + * @return the session unique message id. + */ + public int getMessageId() + { + return messageId; + } + + + /** + * {@inheritDoc} + * + * @param messageId + */ + public void setMessageId( int messageId ) + { + this.messageId = messageId; + } + + + /** + * {@inheritDoc} + */ + public Message add( Control... controls ) throws LdapException + { + if ( this.controls == null ) + { + this.controls = new HashMap(); + } + + if ( controls != null ) + { + for ( Control control:controls ) + { + this.controls.put( control.getID(), control ); + } + } + + return this; + } + + + /** + * {@inheritDoc} + */ + public Map getControls() + { + return controls; + } + + + /** + * {@inheritDoc} + */ + public boolean hasControl( String oid ) + { + return ( controls != null ) && ( controls.size() > 0 ); + } + + + /** + * {@inheritDoc} + */ + public Message remove( Control... controls ) throws LdapException + { + if ( this.controls == null ) + { + // We don't have any controls, so we can just exit + return this; + } + + if ( controls != null ) + { + for ( Control ctrl:controls ) + { + this.controls.remove( ctrl.getID() ); + } + } + + return this; + } +} Modified: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbstractRequest.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/AbstractRequest.java?rev=761472&r1=761471&r2=761472&view=diff ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbstractRequest.java (original) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbstractRequest.java Thu Apr 2 23:27:34 2009 @@ -19,59 +19,27 @@ */ package org.apache.directory.shared.ldap.client.api.messages; -import java.util.HashMap; -import java.util.Map; - -import javax.naming.ldap.Control; - -import org.apache.directory.shared.ldap.message.MessageException; - /** * An abstract class containing the Controls and timeout for all the requests. * * @author Apache Directory Project * @version $Rev$, $Date$ */ -public class AbstractRequest implements Message +public class AbstractRequest extends AbstractMessage implements Request { - /** The set of controls */ - private Map controls; - /** The client request timeout */ private long timeout = 0; - - - /** - * {@inheritDoc} - */ - public Message add( Control... controls ) throws MessageException - { - if ( this.controls == null ) - { - this.controls = new HashMap(); - } - - if ( controls != null ) - { - for ( Control control:controls ) - { - this.controls.put( control.getID(), control ); - } - } - - return this; - } - - + + /** - * {@inheritDoc} + * Creates a new instance of AbstractRequest. */ - public Map getControls() + protected AbstractRequest() { - return controls; + super(); } - + /** * {@inheritDoc} */ @@ -84,38 +52,6 @@ /** * {@inheritDoc} */ - public boolean hasControl( String oid ) - { - return ( controls != null ) && ( controls.size() > 0 ); - } - - - /** - * {@inheritDoc} - */ - public Message remove( Control... controls ) throws MessageException - { - if ( this.controls == null ) - { - // We don't have any controls, so we can just exit - return this; - } - - if ( controls != null ) - { - for ( Control ctrl:controls ) - { - this.controls.remove( ctrl.getID() ); - } - } - - return this; - } - - - /** - * {@inheritDoc} - */ public Message setTimeout( long timeout ) { this.timeout = timeout; Added: 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=761472&view=auto ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbstractResponseWithResult.java (added) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbstractResponseWithResult.java Thu Apr 2 23:27:34 2009 @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.shared.ldap.client.api.messages; + + +/** + * A request who's one or more responses contains an LdapResult. + * + * @author Apache Directory Project + * @version $Rev: 760984 $ + */ +public abstract class AbstractResponseWithResult extends AbstractMessage implements ResponseWithResult +{ + private LdapResult ldapResult; + + /** + * If called for the first time, this method creates a result containing + * response object for this request. + * + * @return a result containing response with defaults and the messageId set + * in response to this specific request + */ + public LdapResult getLdapResult() + { + return ldapResult; + } + + + public void setLdapResult( LdapResult ldapResult ) + { + this.ldapResult = ldapResult; + } +} Modified: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequest.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/BindRequest.java?rev=761472&r1=761471&r2=761472&view=diff ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequest.java (original) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequest.java Thu Apr 2 23:27:34 2009 @@ -25,7 +25,7 @@ * * @author Apache Directory Project */ -public interface BindRequest extends Message +public interface BindRequest extends AbandonableRequest, RequestWithResponse { /** * Checks to see if the authentication mechanism is simple and not SASL Modified: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequestImpl.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/BindRequestImpl.java?rev=761472&r1=761471&r2=761472&view=diff ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequestImpl.java (original) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequestImpl.java Thu Apr 2 23:27:34 2009 @@ -52,6 +52,7 @@ */ public BindRequestImpl() { + super(); } Modified: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindResponse.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/BindResponse.java?rev=761472&r1=761471&r2=761472&view=diff ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindResponse.java (original) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindResponse.java Thu Apr 2 23:27:34 2009 @@ -28,7 +28,7 @@ * @author Apache Directory Project * @version $Rev: 760724 $ */ -public interface BindResponse extends Message +public interface BindResponse extends ResponseWithResult { /** * Gets the optional property holding SASL authentication response parameters @@ -38,4 +38,10 @@ * @return the sasl mech. specific credentials or null of auth. is simple */ byte[] getServerSaslCreds(); + + + /** + * {@inheritDoc} + */ + void setServerSaslCreds( byte[] credentials ); } Modified: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindResponseImpl.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/BindResponseImpl.java?rev=761472&r1=761471&r2=761472&view=diff ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindResponseImpl.java (original) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindResponseImpl.java Thu Apr 2 23:27:34 2009 @@ -26,11 +26,17 @@ * @author Apache Directory Project * @version $Rev$, $Date$ */ -public class BindResponseImpl extends AbstractRequest implements BindResponse +public class BindResponseImpl extends AbstractResponseWithResult implements BindResponse { /** optional property holding SASL authentication response parameters */ private byte[] credentials; + + public BindResponseImpl() + { + super(); + } + /** * {@inheritDoc} Added: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/IntermediateResponse.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/IntermediateResponse.java?rev=761472&view=auto ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/IntermediateResponse.java (added) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/IntermediateResponse.java Thu Apr 2 23:27:34 2009 @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.shared.ldap.client.api.messages; + + +/** + * An interface for Intermediate responses. + * + * @author Apache Directory Project + */ +public interface IntermediateResponse extends Message +{ + String getResponseName(); + + void setResponseName( String responseName ); + + byte[] getResponseValue(); + + void setResponseValue( byte[] responseValue ); +} Added: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/IntermediateResponseImpl.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/IntermediateResponseImpl.java?rev=761472&view=auto ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/IntermediateResponseImpl.java (added) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/IntermediateResponseImpl.java Thu Apr 2 23:27:34 2009 @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.shared.ldap.client.api.messages; + + +/** + * An interface for Intermediate responses. + * + * @author Apache Directory Project + */ +public class IntermediateResponseImpl extends AbstractMessage implements IntermediateResponse +{ + /** The Response OID */ + private String responseName; + + /** The response value */ + private byte[] responseValue; + + public String getResponseName() + { + return responseName; + } + + + public void setResponseName( String responseName ) + { + this.responseName = responseName; + } + + + public byte[] getResponseValue() + { + return responseValue; + } + + + public void setResponseValue( byte[] responseValue ) + { + this.responseValue = responseValue; + } +} Added: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/LdapResult.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/LdapResult.java?rev=761472&view=auto ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/LdapResult.java (added) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/LdapResult.java Thu Apr 2 23:27:34 2009 @@ -0,0 +1,140 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.directory.shared.ldap.client.api.messages; + +import org.apache.directory.shared.ldap.message.Referral; +import org.apache.directory.shared.ldap.message.ResultCodeEnum; +import org.apache.directory.shared.ldap.name.LdapDN; + + +/** + * LDAPv3 result structure embedded into Responses. See section 4.1.10 in RFC 2251 for a description of the LDAPResult ASN.1 structure, + * here's a snippet from it: + * + *
+ *   The LDAPResult is the construct used in this protocol to return
+ *   success or failure indications from servers to clients. In response
+ *   to various requests servers will return responses containing fields
+ *   of type LDAPResult to indicate the final status of a protocol
+ *   operation request.
+ * 
+ * + * @author Apache Directory Project + * @version $Revision: 437007 $ + */ +public interface LdapResult +{ + /** + * Gets the result code enumeration associated with the response. + * Corresponds to the resultCode field within the LDAPResult ASN.1 + * structure. + * + * @return the result code enum value. + */ + ResultCodeEnum getResultCode(); + + + /** + * Sets the result code enumeration associated with the response. + * Corresponds to the resultCode field within the LDAPResult ASN.1 + * structure. + * + * @param resultCode + * the result code enum value. + */ + void setResultCode( ResultCodeEnum resultCode ); + + + /** + * Gets the lowest entry in the directory that was matched. For result codes + * of noSuchObject, aliasProblem, invalidDNSyntax and + * aliasDereferencingProblem, the matchedDN field is set to the name of the + * lowest entry (object or alias) in the directory that was matched. If no + * aliases were dereferenced while attempting to locate the entry, this will + * be a truncated form of the name provided, or if aliases were + * dereferenced, of the resulting name, as defined in section 12.5 of X.511 + * [8]. The matchedDN field is to be set to a zero length string with all + * other result codes. + * + * @return the Dn of the lowest matched entry. + */ + LdapDN getMatchedDn(); + + + /** + * Sets the lowest entry in the directory that was matched. + * + * @see #getMatchedDn() + * @param dn + * the Dn of the lowest matched entry. + */ + void setMatchedDn( LdapDN dn ); + + + /** + * Gets the descriptive error message associated with the error code. May be + * null for SUCCESS, COMPARETRUE, COMPAREFALSE and REFERRAL operations. + * + * @return the descriptive error message. + */ + String getErrorMessage(); + + + /** + * Sets the descriptive error message associated with the error code. May be + * null for SUCCESS, COMPARETRUE, and COMPAREFALSE operations. + * + * @param errorMessage + * the descriptive error message. + */ + void setErrorMessage( String errorMessage ); + + + /** + * Gets whether or not this result represents a Referral. For referrals the + * error code is set to REFERRAL and the referral property is not null. + * + * @return true if this result represents a referral. + */ + boolean isReferral(); + + + /** + * Gets the Referral associated with this LdapResult if the resultCode + * property is set to the REFERRAL ResultCodeEnum. + * + * @return the referral on REFERRAL errors, null on all others. + */ + Referral getReferral(); + + + /** + * Sets the Referral associated with this LdapResult if the resultCode + * property is set to the REFERRAL ResultCodeEnum. Setting this property + * will result in a true return from isReferral and the resultCode should be + * set to REFERRAL. + * + * @param referral + * optional referral on REFERRAL errors. + */ + void setReferral( Referral referral ); +} Added: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/LdapResultImpl.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/LdapResultImpl.java?rev=761472&view=auto ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/LdapResultImpl.java (added) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/LdapResultImpl.java Thu Apr 2 23:27:34 2009 @@ -0,0 +1,523 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.directory.shared.ldap.client.api.messages; + +import org.apache.directory.shared.ldap.message.Referral; +import org.apache.directory.shared.ldap.message.ResultCodeEnum; +import org.apache.directory.shared.ldap.name.LdapDN; + + +/** + * LdapResult implementation. + * + * @author Apache Directory Project + * @version $Revision: 760984 $ + */ +public class LdapResultImpl implements LdapResult +{ + /** Lowest matched entry Dn - defaults to empty string */ + private LdapDN matchedDn; + + /** Referral associated with this LdapResult if the errorCode is REFERRAL */ + private Referral referral; + + /** Decriptive error message - defaults to empty string */ + private String errorMessage; + + /** Resultant operation error code - defaults to SUCCESS */ + private ResultCodeEnum resultCode = ResultCodeEnum.SUCCESS; + + + // ------------------------------------------------------------------------ + // LdapResult Interface Method Implementations + // ------------------------------------------------------------------------ + + /** + * Gets the descriptive error message associated with the error code. May be + * null for SUCCESS, COMPARETRUE, COMPAREFALSE and REFERRAL operations. + * + * @return the descriptive error message. + */ + public String getErrorMessage() + { + return errorMessage; + } + + + /** + * Sets the descriptive error message associated with the error code. May be + * null for SUCCESS, COMPARETRUE, and COMPAREFALSE operations. + * + * @param errorMessage + * the descriptive error message. + */ + public void setErrorMessage( String errorMessage ) + { + this.errorMessage = errorMessage; + } + + + /** + * Gets the lowest entry in the directory that was matched. For result codes + * of noSuchObject, aliasProblem, invalidDNSyntax and + * aliasDereferencingProblem, the matchedDN field is set to the name of the + * lowest entry (object or alias) in the directory that was matched. If no + * aliases were dereferenced while attempting to locate the entry, this will + * be a truncated form of the name provided, or if aliases were + * dereferenced, of the resulting name, as defined in section 12.5 of X.511 + * [8]. The matchedDN field is to be set to a zero length string with all + * other result codes. + * + * @return the Dn of the lowest matched entry. + */ + public LdapDN getMatchedDn() + { + return matchedDn; + } + + + /** + * Sets the lowest entry in the directory that was matched. + * + * @see #getMatchedDn() + * @param matchedDn + * the Dn of the lowest matched entry. + */ + public void setMatchedDn( LdapDN matchedDn ) + { + this.matchedDn = matchedDn; + } + + + /** + * Gets the result code enumeration associated with the response. + * Corresponds to the resultCode field within the LDAPResult ASN.1 + * structure. + * + * @return the result code enum value. + */ + public ResultCodeEnum getResultCode() + { + return resultCode; + } + + + /** + * Sets the result code enumeration associated with the response. + * Corresponds to the resultCode field within the LDAPResult ASN.1 + * structure. + * + * @param resultCode + * the result code enum value. + */ + public void setResultCode( ResultCodeEnum resultCode ) + { + this.resultCode = resultCode; + } + + + /** + * Gets the Referral associated with this LdapResult if the resultCode + * property is set to the REFERRAL ResultCodeEnum. + * + * @return the referral on REFERRAL errors, null on all others. + */ + public Referral getReferral() + { + return referral; + } + + + /** + * Gets whether or not this result represents a Referral. For referrals the + * error code is set to REFERRAL and the referral property is not null. + * + * @return true if this result represents a referral. + */ + public boolean isReferral() + { + return referral != null; + } + + + /** + * Sets the Referral associated with this LdapResult if the resultCode + * property is set to the REFERRAL ResultCodeEnum. Setting this property + * will result in a true return from isReferral and the resultCode should be + * set to REFERRAL. + * + * @param referral + * optional referral on REFERRAL errors. + */ + public void setReferral( Referral referral ) + { + this.referral = referral; + } + + + /** + * @param obj The object to compare with + * @return true if both objects are equals + */ + public boolean equals( Object obj ) + { + // quickly return true if this is the obj + if ( obj == this ) + { + return true; + } + + // return false if object does not implement interface + if ( !( obj instanceof LdapResult ) ) + { + return false; + } + + // compare all the like elements of the two LdapResult objects + LdapResult result = ( LdapResult ) obj; + + if ( referral == null && result.getReferral() != null ) + { + return false; + } + + if ( result.getReferral() == null && referral != null ) + { + return false; + } + + if ( referral != null && result.getReferral() != null ) + { + if ( !referral.equals( result.getReferral() ) ) + { + return false; + } + } + + if ( !resultCode.equals( result.getResultCode() ) ) + { + return false; + } + + // Handle Error Messages where "" is considered equivalent to null + String errMsg0 = errorMessage; + String errMsg1 = result.getErrorMessage(); + + if ( errMsg0 == null ) + { + errMsg0 = ""; + } + + if ( errMsg1 == null ) + { + errMsg1 = ""; + } + + if ( !errMsg0.equals( errMsg1 ) ) + { + return false; + } + + if ( matchedDn != null ) + { + if ( !matchedDn.equals( result.getMatchedDn() ) ) + { + return false; + } + } + else if ( result.getMatchedDn() != null ) // one is null other is not + { + return false; + } + + return true; + } + + + /** + * Get a String representation of a LdapResult + * + * @return A LdapResult String + */ + public String toString() + { + + StringBuffer sb = new StringBuffer(); + + sb.append( " Ldap Result\n" ); + sb.append( " Result code : (" ).append( resultCode ).append( ')' ); + + switch ( resultCode ) + { + + case SUCCESS : + sb.append( " success\n" ); + break; + + case OPERATIONS_ERROR : + sb.append( " operationsError\n" ); + break; + + case PROTOCOL_ERROR : + sb.append( " protocolError\n" ); + break; + + case TIME_LIMIT_EXCEEDED : + sb.append( " timeLimitExceeded\n" ); + break; + + case SIZE_LIMIT_EXCEEDED : + sb.append( " sizeLimitExceeded\n" ); + break; + + case COMPARE_FALSE : + sb.append( " compareFalse\n" ); + break; + + case COMPARE_TRUE : + sb.append( " compareTrue\n" ); + break; + + case AUTH_METHOD_NOT_SUPPORTED : + sb.append( " authMethodNotSupported\n" ); + break; + + case STRONG_AUTH_REQUIRED : + sb.append( " strongAuthRequired\n" ); + break; + + case REFERRAL : + sb.append( " referral -- new\n" ); + break; + + case ADMIN_LIMIT_EXCEEDED : + sb.append( " adminLimitExceeded -- new\n" ); + break; + + case UNAVAILABLE_CRITICAL_EXTENSION : + sb.append( " unavailableCriticalExtension -- new\n" ); + break; + + case CONFIDENTIALITY_REQUIRED : + sb.append( " confidentialityRequired -- new\n" ); + break; + + case SASL_BIND_IN_PROGRESS : + sb.append( " saslBindInProgress -- new\n" ); + break; + + case NO_SUCH_ATTRIBUTE : + sb.append( " noSuchAttribute\n" ); + break; + + case UNDEFINED_ATTRIBUTE_TYPE : + sb.append( " undefinedAttributeType\n" ); + break; + + case INAPPROPRIATE_MATCHING : + sb.append( " inappropriateMatching\n" ); + break; + + case CONSTRAINT_VIOLATION : + sb.append( " constraintViolation\n" ); + break; + + case ATTRIBUTE_OR_VALUE_EXISTS : + sb.append( " attributeOrValueExists\n" ); + break; + + case INVALID_ATTRIBUTE_SYNTAX : + sb.append( " invalidAttributeSyntax\n" ); + break; + + case NO_SUCH_OBJECT : + sb.append( " noSuchObject\n" ); + break; + + case ALIAS_PROBLEM : + sb.append( " aliasProblem\n" ); + break; + + case INVALID_DN_SYNTAX : + sb.append( " invalidDNSyntax\n" ); + break; + + case ALIAS_DEREFERENCING_PROBLEM : + sb.append( " aliasDereferencingProblem\n" ); + break; + + case INAPPROPRIATE_AUTHENTICATION : + sb.append( " inappropriateAuthentication\n" ); + break; + + case INVALID_CREDENTIALS : + sb.append( " invalidCredentials\n" ); + break; + + case INSUFFICIENT_ACCESS_RIGHTS : + sb.append( " insufficientAccessRights\n" ); + break; + + case BUSY : + sb.append( " busy\n" ); + break; + + case UNAVAILABLE : + sb.append( " unavailable\n" ); + break; + + case UNWILLING_TO_PERFORM : + sb.append( " unwillingToPerform\n" ); + break; + + case LOOP_DETECT : + sb.append( " loopDetect\n" ); + break; + + case NAMING_VIOLATION : + sb.append( " namingViolation\n" ); + break; + + case OBJECT_CLASS_VIOLATION : + sb.append( " objectClassViolation\n" ); + break; + + case NOT_ALLOWED_ON_NON_LEAF : + sb.append( " notAllowedOnNonLeaf\n" ); + break; + + case NOT_ALLOWED_ON_RDN : + sb.append( " notAllowedOnRDN\n" ); + break; + + case ENTRY_ALREADY_EXISTS : + sb.append( " entryAlreadyExists\n" ); + break; + + case OBJECT_CLASS_MODS_PROHIBITED : + sb.append( " objectClassModsProhibited\n" ); + break; + + case AFFECTS_MULTIPLE_DSAS : + sb.append( " affectsMultipleDSAs -- new\n" ); + break; + + case OTHER : + sb.append( " other\n" ); + break; + + default : + switch ( resultCode.getResultCode() ) + { + case 9 : + sb.append( " -- 9 reserved --\n" ); + break; + + case 22 : + case 23: + case 24 : + case 25 : + case 26 : + case 27 : + case 28 : + case 29 : + case 30 : + case 31 : + sb.append( " -- 22-31 unused --\n" ); + break; + + case 35 : + sb.append( " -- 35 reserved for undefined isLeaf --\n" ); + break; + + case 37 : + case 38 : + case 39 : + case 40 : + case 41 : + case 42 : + case 43 : + case 44 : + case 45 : + case 46 : + case 47 : + sb.append( " -- 37-47 unused --\n" ); + break; + + case 55 : + case 56 : + case 57 : + case 58 : + case 59 : + case 60 : + case 61 : + case 62 : + case 63 : + sb.append( " -- 55-63 unused --\n" ); + break; + + case 70 : + sb.append( " -- 70 reserved for CLDAP --\n" ); + break; + + case 72 : + case 73 : + case 74 : + case 75 : + case 76 : + case 77 : + case 78 : + case 79 : + sb.append( " -- 72-79 unused --\n" ); + break; + + case 81 : + case 82 : + case 83 : + case 84 : + case 85 : + case 86 : + case 87 : + case 88 : + case 89 : + case 90 : + sb.append( " -- 81-90 reserved for APIs --" ); + break; + + default : + sb.append( "Unknown error code : " ).append( resultCode ); + break; + } + } + + sb.append( " Matched DN : '" ).append( matchedDn ).append( "'\n" ); + sb.append( " Error message : '" ).append( errorMessage ).append( "'\n" ); + + if ( referral != null ) + { + sb.append( " Referrals :\n" ); + + sb.append( " Referral :" ).append( referral.toString() ).append( '\n' ); + } + + return sb.toString(); + } +} Modified: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/Message.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/Message.java?rev=761472&r1=761471&r2=761472&view=diff ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/Message.java (original) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/Message.java Thu Apr 2 23:27:34 2009 @@ -24,7 +24,7 @@ import javax.naming.ldap.Control; -import org.apache.directory.shared.ldap.message.MessageException; +import org.apache.directory.shared.ldap.client.api.exception.LdapException; /** @@ -35,21 +35,19 @@ public interface Message { /** - * Get the client message timeout. When the timeout is reached, the - * request is canceled. + * Get the request messageId * - * @return The timeout + * @return The request message ID */ - long getTimeout(); + int getMessageId(); /** - * Set a request client timeout. When this timeout is reached, the request - * will be canceled. If <= 0, then we wait for the response forever. + * Set the request message ID * - * @param timeout The new timeout, expressed in milliseconds + * @param messageId The request message ID */ - Message setTimeout( long timeout ); + void setMessageId( int messageId ); /** @@ -71,24 +69,21 @@ /** - * Adds a control to this Message. + * Adds controls to this Message. * - * @param control - * the control to add. - * @throws MessageException - * if controls cannot be added to this Message or the control is - * not known etc. + * @param controls the controls to add. + * @throws MessageException if controls cannot be added to this Message + * or the control is not known etc. */ - Message add( Control... control ) throws MessageException; + Message add( Control... controls ) throws LdapException; /** - * Deletes a control removing it from this Message. + * Deletes controls, removing them from this Message. * - * @param control the control to remove. - * @throws MessageException - * if controls cannot be added to this Message or the control is - * not known etc. + * @param controls the controls to remove. + * @throws LdapException if controls cannot be added to this Message + * or the control is not known etc. */ - Message remove( Control... control ) throws MessageException; + Message remove( Control... control ) throws LdapException; } Added: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/Request.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/Request.java?rev=761472&view=auto ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/Request.java (added) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/Request.java Thu Apr 2 23:27:34 2009 @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.shared.ldap.client.api.messages; + + +/** + * Ldap protocol request messages derive from this super interface. + * + * @author Apache Directory Project + * @version $Rev: 760984 $ + */ +public interface Request extends Message +{ + /** + * Get the client message timeout. When the timeout is reached, the + * request is canceled. + * + * @return The timeout + */ + long getTimeout(); + + + /** + * Set a request client timeout. When this timeout is reached, the request + * will be canceled. If <= 0, then we wait for the response forever. + * + * @param timeout The new timeout, expressed in milliseconds + */ + Message setTimeout( long timeout ); +} Added: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/RequestWithResponse.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/RequestWithResponse.java?rev=761472&view=auto ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/RequestWithResponse.java (added) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/RequestWithResponse.java Thu Apr 2 23:27:34 2009 @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.shared.ldap.client.api.messages; + + +/** + * An interface used to indicate that a Request has a response. + * + * @author Apache Directory Project + */ +public interface RequestWithResponse extends Request +{ +} Added: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/Response.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/Response.java?rev=761472&view=auto ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/Response.java (added) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/Response.java Thu Apr 2 23:27:34 2009 @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.shared.ldap.client.api.messages; + + +/** + * Super interface used as a marker for all protocol response type messages. + * + * @author Apache Directory Project + */ +public interface Response extends Message +{ +} Added: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/ResponseWithResult.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/ResponseWithResult.java?rev=761472&view=auto ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/ResponseWithResult.java (added) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/ResponseWithResult.java Thu Apr 2 23:27:34 2009 @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.shared.ldap.client.api.messages; + + +/** + * A request who's one or more responses contains an LdapResult. + * + * @author Apache Directory Project + * @version $Rev: 760984 $ + */ +public interface ResponseWithResult extends Response +{ + /** + * If called for the first time, this method creates a result containing + * response object for this request. + * + * @return a result containing response with defaults and the messageId set + * in response to this specific request + */ + LdapResult getLdapResult(); + + void setLdapResult( LdapResult ldapResult ); +} Added: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/SearchRequest.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/SearchRequest.java?rev=761472&view=auto ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/SearchRequest.java (added) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/SearchRequest.java Thu Apr 2 23:27:34 2009 @@ -0,0 +1,208 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.shared.ldap.client.api.messages; + + +import java.util.Set; + +import org.apache.directory.shared.ldap.filter.SearchScope; +import org.apache.directory.shared.ldap.message.AliasDerefMode; + + +/** + * Search request protocol message interface. + * + * @author Apache Directory Project + * @version $Rev: 760724 $ + */ +public interface SearchRequest extends AbandonableRequest, RequestWithResponse +{ + /** + * Gets the search base as a distinguished name. + * + * @return the search base + */ + String getBaseDn(); + + + /** + * Sets the search base as a distinguished name. + * + * @param baseDn the search base + */ + void setBaseDn( String baseDn ); + + + /** + * Gets the search scope parameter enumeration. + * + * @return the scope enumeration parameter. + */ + SearchScope getScope(); + + + /** + * Sets the search scope parameter enumeration. + * + * @param scope the scope enumeration parameter. + */ + void setScope( SearchScope scope ); + + + /** + * Gets the alias handling parameter. + * + * @return the alias handling parameter enumeration. + */ + AliasDerefMode getDerefAliases(); + + + /** + * Sets the alias handling parameter. + * + * @param aliasDerefAliases the alias handling parameter enumeration. + */ + void setDerefAliases( AliasDerefMode aliasDerefAliases ); + + + /** + * A sizelimit that restricts the maximum number of entries to be returned + * as a result of the search. A value of 0 in this field indicates that no + * client-requested sizelimit restrictions are in effect for the search. + * Servers may enforce a maximum number of entries to return. + * + * @return search size limit. + */ + int getSizeLimit(); + + + /** + * Sets sizelimit that restricts the maximum number of entries to be + * returned as a result of the search. A value of 0 in this field indicates + * that no client-requested sizelimit restrictions are in effect for the + * search. Servers may enforce a maximum number of entries to return. + * + * @param entriesMax maximum search result entries to return. + */ + void setSizeLimit( int entriesMax ); + + + /** + * Gets the timelimit that restricts the maximum time (in seconds) allowed + * for a search. A value of 0 in this field indicates that no client- + * requested timelimit restrictions are in effect for the search. + * + * @return the search time limit in seconds. + */ + int getTimeLimit(); + + + /** + * Sets the timelimit that restricts the maximum time (in seconds) allowed + * for a search. A value of 0 in this field indicates that no client- + * requested timelimit restrictions are in effect for the search. + * + * @param secondsMax the search time limit in seconds. + */ + void setTimeLimit( int secondsMax ); + + + /** + * An indicator as to whether search results will contain both attribute + * types and values, or just attribute types. Setting this field to TRUE + * causes only attribute types (no values) to be returned. Setting this + * field to FALSE causes both attribute types and values to be returned. + * + * @return true for only types, false for types and values. + */ + boolean getTypesOnly(); + + + /** + * An indicator as to whether search results will contain both attribute + * types and values, or just attribute types. Setting this field to TRUE + * causes only attribute types (no values) to be returned. Setting this + * field to FALSE causes both attribute types and values to be returned. + * + * @param typesOnly + * true for only types, false for types and values. + */ + void setTypesOnly( boolean typesOnly ); + + + /** + * Gets the search filter associated with this search request. + * + * @return the expression node for the root of the filter expression tree. + */ + String getFilter(); + + + /** + * Sets the search filter associated with this search request. + * + * @param filter the expression node for the root of the filter + * expression tree. + */ + void setFilter( String filter ); + + + /** + * Gets a list of the attributes to be returned from each entry which + * matches the search filter. There are two special values which may be + * used: an empty list with no attributes, and the attribute description + * string "*". Both of these signify that all user attributes are to be + * returned. (The "*" allows the client to request all user attributes in + * addition to specific operational attributes). Attributes MUST be named at + * most once in the list, and are returned at most once in an entry. If + * there are attribute descriptions in the list which are not recognized, + * they are ignored by the server. If the client does not want any + * attributes returned, it can specify a list containing only the attribute + * with OID "1.1". This OID was chosen arbitrarily and does not correspond + * to any attribute in use. Client implementors should note that even if all + * user attributes are requested, some attributes of the entry may not be + * included in search results due to access control or other restrictions. + * Furthermore, servers will not return operational attributes, such as + * objectClasses or attributeTypes, unless they are listed by name, since + * there may be extremely large number of values for certain operational + * attributes. + * + * @return the attributes to return for this request + */ + Set getAttributes(); + + + /** + * Adds attributes to the set of entry attributes to return. + * + * @param attributes the attributes description or identifier. + * @return The object itself, to allow chaining + */ + SearchRequest addAttributes( String... attribute ); + + + /** + * Removes attributes to the set of entry attributes to return. + * + * @param attributes the attributes description or identifier. + * @return The object itself, to allow chaining + */ + SearchRequest removeAttributes( String... attributes ); +} Added: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/SearchRequestImpl.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/SearchRequestImpl.java?rev=761472&view=auto ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/SearchRequestImpl.java (added) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/SearchRequestImpl.java Thu Apr 2 23:27:34 2009 @@ -0,0 +1,277 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.shared.ldap.client.api.messages; + + +import java.util.HashSet; +import java.util.Set; + +import org.apache.directory.shared.ldap.filter.SearchScope; +import org.apache.directory.shared.ldap.message.AliasDerefMode; + + +/** + * SearchRequest implementation. + * + * @author Apache Directory Project + */ +public class SearchRequestImpl extends AbstractRequest implements SearchRequest +{ + /** Search base distinguished name */ + private String baseDn; + + /** Search filter expression tree's root node */ + private String filter; + + /** Search scope enumeration value */ + private SearchScope scope; + + /** Types only return flag */ + private boolean typesOnly; + + /** Max size in entries to return */ + private int sizeLimit; + + /** Max seconds to wait for search to complete */ + private int timeLimit; + + /** Alias dereferencing mode enumeration value */ + private AliasDerefMode aliasDerefMode; + + /** Attributes to return */ + private Set attributes = new HashSet(); + + + /** + * + * Creates a new instance of SearchRequestImpl. + * + * @param messageId The message ID + */ + public SearchRequestImpl() + { + super(); + } + + + // ------------------------------------------------------------------------ + // SearchRequest Interface Method Implementations + // ------------------------------------------------------------------------ + /** + * Gets a list of the attributes to be returned from each entry which + * matches the search filter. There are two special values which may be + * used: an empty list with no attributes, and the attribute description + * string "*". Both of these signify that all user attributes are to be + * returned. (The "*" allows the client to request all user attributes in + * addition to specific operational attributes). Attributes MUST be named at + * most once in the list, and are returned at most once in an entry. If + * there are attribute descriptions in the list which are not recognized, + * they are ignored by the server. If the client does not want any + * attributes returned, it can specify a list containing only the attribute + * with OID "1.1". This OID was chosen arbitrarily and does not correspond + * to any attribute in use. Client implementors should note that even if all + * user attributes are requested, some attributes of the entry may not be + * included in search results due to access control or other restrictions. + * Furthermore, servers will not return operational attributes, such as + * objectClasses or attributeTypes, unless they are listed by name, since + * there may be extremely large number of values for certain operational + * attributes. + * + * @return the collection of attributes to return for each entry + */ + public Set getAttributes() + { + return attributes; + } + + + /** + * {@inheritDoc} + */ + public String getBaseDn() + { + return baseDn; + } + + + /** + * {@inheritDoc} + */ + public void setBaseDn( String baseDn ) + { + this.baseDn = baseDn; + } + + + /** + * {@inheritDoc} + */ + public AliasDerefMode getDerefAliases() + { + return aliasDerefMode; + } + + + /** + * {@inheritDoc} + */ + public void setDerefAliases( AliasDerefMode aliasDerefAliases ) + { + this.aliasDerefMode = aliasDerefAliases; + } + + + /** + * {@inheritDoc} + */ + public String getFilter() + { + return filter; + } + + + /** + * {@inheritDoc} + */ + public void setFilter( String filter ) + { + this.filter = filter; + } + + + /** + * {@inheritDoc} + */ + public SearchScope getScope() + { + return scope; + } + + + /** + * {@inheritDoc} + */ + public void setScope( SearchScope scope ) + { + this.scope = scope; + } + + + /** + * {@inheritDoc} + */ + public int getSizeLimit() + { + return sizeLimit; + } + + + /** + * {@inheritDoc} + */ + public void setSizeLimit( int entriesMax ) + { + sizeLimit = entriesMax; + } + + + /** + * {@inheritDoc} + */ + public int getTimeLimit() + { + return timeLimit; + } + + + /** + * {@inheritDoc} + */ + public void setTimeLimit( int secondsMax ) + { + timeLimit = secondsMax; + } + + + /** + * {@inheritDoc} + */ + public boolean getTypesOnly() + { + return typesOnly; + } + + + /** + * {@inheritDoc} + */ + public void setTypesOnly( boolean typesOnly ) + { + this.typesOnly = typesOnly; + } + + + /** + * {@inheritDoc} + */ + public SearchRequest addAttributes( String... attributes ) + { + if ( ( attributes == null ) || ( attributes.length == 0 ) ) + { + return this; + } + + if ( this.attributes == null ) + { + this.attributes = new HashSet( attributes.length ); + } + + for ( String attribute:attributes ) + { + this.attributes.add( attribute ); + } + + return this; + } + + + /** + * {@inheritDoc} + */ + public SearchRequest removeAttributes( String... attributes ) + { + if ( ( attributes == null ) || ( attributes.length == 0 ) ) + { + return this; + } + + if ( this.attributes == null ) + { + this.attributes = new HashSet( attributes.length ); + } + + for ( String attribute:attributes ) + { + this.attributes.remove( attribute ); + } + + return this; + } +} \ No newline at end of file Added: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/SearchResponse.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/SearchResponse.java?rev=761472&view=auto ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/SearchResponse.java (added) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/SearchResponse.java Thu Apr 2 23:27:34 2009 @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.shared.ldap.client.api.messages; + + +/** + * An interface for all the search responses. + * + * @author Apache Directory Project + * @version $Revision: 760984 $ + */ +public interface SearchResponse extends Response +{ +} Added: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/UnbindRequest.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/UnbindRequest.java?rev=761472&view=auto ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/UnbindRequest.java (added) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/UnbindRequest.java Thu Apr 2 23:27:34 2009 @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.shared.ldap.client.api.messages; + + +/** + * Unbind protocol request message used to end a client session. + * + * @author Apache Directory Project + */ +public interface UnbindRequest extends Request +{ +} Added: 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=761472&view=auto ============================================================================== --- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/UnbindRequestImpl.java (added) +++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/UnbindRequestImpl.java Thu Apr 2 23:27:34 2009 @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.shared.ldap.client.api.messages; + + +/** + * Unbind protocol request message used to end a client session. + * + * @author Apache Directory Project + */ +public class UnbindRequestImpl extends AbstractRequest implements UnbindRequest +{ + /** + * + * Creates a new instance of UnbindRequestImpl. + */ + public UnbindRequestImpl() + { + super(); + } +}