directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
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 GMT
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<Response>
 {
     /**
+     * @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;
 }



Mime
View raw message