From commits-return-31793-apmail-directory-commits-archive=directory.apache.org@directory.apache.org Wed May 11 17:55:03 2011 Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2E7224B0B for ; Wed, 11 May 2011 17:55:03 +0000 (UTC) Received: (qmail 45291 invoked by uid 500); 11 May 2011 17:55:03 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 45258 invoked by uid 500); 11 May 2011 17:55:03 -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 45250 invoked by uid 99); 11 May 2011 17:55:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 May 2011 17:55:03 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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; Wed, 11 May 2011 17:54:59 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3062F23889B1; Wed, 11 May 2011 17:54:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1101999 - in /directory: apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/ shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/ shared/trunk/ldap/model/src/main/java/org/apache/directory/sh... Date: Wed, 11 May 2011 17:54:38 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110511175438.3062F23889B1@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Wed May 11 17:54:37 2011 New Revision: 1101999 URL: http://svn.apache.org/viewvc?rev=1101999&view=rev Log: Added some helper methods in the SearcCursor interface to ease the access to entries, referrals, etc Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/EntryToResponseCursor.java directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/cursor/SearchCursor.java Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/EntryToResponseCursor.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/EntryToResponseCursor.java?rev=1101999&r1=1101998&r2=1101999&view=diff ============================================================================== --- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/EntryToResponseCursor.java (original) +++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/EntryToResponseCursor.java Wed May 11 17:54:37 2011 @@ -28,6 +28,10 @@ import org.apache.directory.shared.i18n. import org.apache.directory.shared.ldap.model.cursor.ClosureMonitor; import org.apache.directory.shared.ldap.model.cursor.Cursor; import org.apache.directory.shared.ldap.model.cursor.SearchCursor; +import org.apache.directory.shared.ldap.model.entry.Entry; +import org.apache.directory.shared.ldap.model.exception.LdapException; +import org.apache.directory.shared.ldap.model.message.IntermediateResponse; +import org.apache.directory.shared.ldap.model.message.Referral; import org.apache.directory.shared.ldap.model.message.Response; import org.apache.directory.shared.ldap.model.message.ResultCodeEnum; import org.apache.directory.shared.ldap.model.message.SearchResultDone; @@ -219,4 +223,79 @@ public class EntryToResponseCursor imple throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName() .concat( "." ).concat( "isLast()" ) ) ); } + + + /** + * {@inheritDoc} + */ + public boolean isDone() + { + return done; + } + + + /** + * {@inheritDoc} + */ + public boolean isReferral() + { + return false; + } + + + /** + * {@inheritDoc} + */ + public Referral getReferral() throws LdapException + { + throw new LdapException(); + } + + + /** + * {@inheritDoc} + */ + public boolean isEntry() + { + return true; + } + + + /** + * {@inheritDoc} + */ + public Entry getEntry() throws LdapException + { + if ( !done && wrapped.available() ) + { + try + { + return wrapped.get(); + } + catch ( Exception e ) + { + throw new LdapException( e ); + } + } + + throw new LdapException(); + } + + + /** + * {@inheritDoc} + */ + public boolean isIntermediate() + { + return false; + } + + + /** + * {@inheritDoc} + */ + public IntermediateResponse getIntermediate() throws LdapException + { + throw new LdapException(); + } } Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java?rev=1101999&r1=1101998&r2=1101999&view=diff ============================================================================== --- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java (original) +++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java Wed May 11 17:54:37 2011 @@ -28,9 +28,14 @@ import org.apache.directory.shared.i18n. import org.apache.directory.shared.ldap.model.cursor.AbstractCursor; import org.apache.directory.shared.ldap.model.cursor.InvalidCursorPositionException; import org.apache.directory.shared.ldap.model.cursor.SearchCursor; +import org.apache.directory.shared.ldap.model.entry.Entry; import org.apache.directory.shared.ldap.model.exception.LdapException; +import org.apache.directory.shared.ldap.model.message.IntermediateResponse; +import org.apache.directory.shared.ldap.model.message.Referral; import org.apache.directory.shared.ldap.model.message.Response; import org.apache.directory.shared.ldap.model.message.SearchResultDone; +import org.apache.directory.shared.ldap.model.message.SearchResultEntry; +import org.apache.directory.shared.ldap.model.message.SearchResultReference; /** @@ -290,4 +295,81 @@ public class SearchCursorImpl extends Ab .concat( "." ).concat( "previous()" ) ) ); } + + /** + * {@inheritDoc} + */ + public boolean isDone() + { + return done; + } + + + /** + * {@inheritDoc} + */ + public boolean isReferral() + { + return response instanceof SearchResultReference; + } + + + /** + * {@inheritDoc} + */ + public Referral getReferral() throws LdapException + { + if ( isReferral() ) + { + return ((SearchResultReference)response).getReferral(); + } + + throw new LdapException(); + } + + + /** + * {@inheritDoc} + */ + public boolean isEntry() + { + return response instanceof SearchResultEntry; + } + + + /** + * {@inheritDoc} + */ + public Entry getEntry() throws LdapException + { + if ( isEntry() ) + { + return ((SearchResultEntry)response).getEntry(); + } + + throw new LdapException(); + } + + + /** + * {@inheritDoc} + */ + public boolean isIntermediate() + { + return response instanceof IntermediateResponse; + } + + + /** + * {@inheritDoc} + */ + public IntermediateResponse getIntermediate() throws LdapException + { + if ( isEntry() ) + { + return (IntermediateResponse)response; + } + + throw new LdapException(); + } } Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/cursor/SearchCursor.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/cursor/SearchCursor.java?rev=1101999&r1=1101998&r2=1101999&view=diff ============================================================================== --- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/cursor/SearchCursor.java (original) +++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/cursor/SearchCursor.java Wed May 11 17:54:37 2011 @@ -21,6 +21,10 @@ package org.apache.directory.shared.ldap.model.cursor; +import org.apache.directory.shared.ldap.model.entry.Entry; +import org.apache.directory.shared.ldap.model.exception.LdapException; +import org.apache.directory.shared.ldap.model.message.IntermediateResponse; +import org.apache.directory.shared.ldap.model.message.Referral; import org.apache.directory.shared.ldap.model.message.Response; import org.apache.directory.shared.ldap.model.message.SearchResultDone; @@ -33,9 +37,51 @@ import org.apache.directory.shared.ldap. public interface SearchCursor extends Cursor { /** + * @return true if the cursor has processed all the elements we were searching + */ + boolean isDone(); + + /** * gives the SearchResultDone message received at the end of search results * * @return the SearchResultDone message, null if the search operation fails for any reason */ - public SearchResultDone getSearchResultDone(); + SearchResultDone getSearchResultDone(); + + + /** + * @return true if the next element in the cursor is a referral + */ + boolean isReferral(); + + + /** + * @return The next referral element, if it's a referral + * @throws LdapException If the + */ + Referral getReferral() throws LdapException; + + + /** + * @return true if the next element in the cursor is an entry + */ + boolean isEntry(); + + /** + * @return The next entry element, if it's an entry + * @throws LdapException If the + */ + Entry getEntry() throws LdapException; + + + /** + * @return true if the next element in the cursor is an intermediate response + */ + boolean isIntermediate(); + + /** + * @return The next intermediate response element, if it's an intermediate response + * @throws LdapException If the + */ + IntermediateResponse getIntermediate() throws LdapException; }