From 617b205225d505fc6a17d792b2d3d183aa080321 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Fri, 27 Sep 2013 14:28:00 +0000
Subject: [PATCH] Fix OPENDJ-972 - OpenDJ should set size limit to 1 when performing single entry searches Review CR-2378

---
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/SearchRequest.java |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/SearchRequest.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/SearchRequest.java
index ce830bf..9de33bd 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/SearchRequest.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/SearchRequest.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2009-2010 Sun Microsystems, Inc.
- *      Portions copyright 2012 ForgeRock AS.
+ *      Portions copyright 2012-2013 ForgeRock AS.
  */
 
 package org.forgerock.opendj.ldap.requests;
@@ -147,6 +147,19 @@
     int getSizeLimit();
 
     /**
+     * Indicates whether search result is expected to be limited to a single entry.
+     * <p>
+     * It is the case if size limit is equal to 1 or if scope is equal to <code>SearchScope.BASE_OBJECT</code>.
+     * <p>
+     * If search results contain more than one entry, the search operation will throw
+     * a <code>MultipleEntriesFoundException</code>.
+     *
+     * @return {@code true} if the search is limited to a single entry result,
+     *         or {@code false} (the default) otherwise.
+     */
+    boolean isSingleEntrySearch();
+
+    /**
      * Returns the time limit that should be used in order to restrict the
      * maximum time (in seconds) allowed for the search.
      * <p>
@@ -270,6 +283,8 @@
      * A value of zero (the default) in this field indicates that no
      * client-requested size limit restrictions are in effect. Servers may also
      * enforce a maximum number of entries to return.
+     * <p>
+     * This method overrides the size limit set using a previous call to {@link #setSingleEntrySearch()}.
      *
      * @param limit
      *            The size limit that should be used in order to restrict the

--
Gitblit v1.10.0