From 6385fb6984cb076c5a4a3ef5233deed798dc81c2 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Thu, 02 Jun 2011 01:01:18 +0000
Subject: [PATCH] Fix OPENDJ-183: Add support for RequestContext and RequestHandlers

---
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractConnection.java |   28 ++++++++++++----------------
 1 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractConnection.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractConnection.java
index 70957e4..46288cb 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractConnection.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractConnection.java
@@ -32,6 +32,7 @@
 import static org.forgerock.opendj.ldap.CoreMessages.ERR_NO_SEARCH_RESULT_ENTRIES;
 import static org.forgerock.opendj.ldap.CoreMessages.ERR_UNEXPECTED_SEARCH_RESULT_ENTRIES;
 import static org.forgerock.opendj.ldap.CoreMessages.ERR_UNEXPECTED_SEARCH_RESULT_REFERENCES;
+import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult;
 
 import java.util.Collection;
 import java.util.concurrent.BlockingQueue;
@@ -433,31 +434,26 @@
     if (handler.entryCount == 0)
     {
       // Did not find any entries.
-      final Result result = Responses.newResult(
-          ResultCode.CLIENT_SIDE_NO_RESULTS_RETURNED).setDiagnosticMessage(
+      throw newErrorResult(
+          ResultCode.CLIENT_SIDE_NO_RESULTS_RETURNED,
           ERR_NO_SEARCH_RESULT_ENTRIES.get().toString());
-      throw ErrorResultException.wrap(result);
     }
     else if (handler.entryCount > 1)
     {
       // Got more entries than expected.
-      final Result result = Responses.newResult(
-          ResultCode.CLIENT_SIDE_UNEXPECTED_RESULTS_RETURNED)
-          .setDiagnosticMessage(
-              ERR_UNEXPECTED_SEARCH_RESULT_ENTRIES.get(handler.entryCount)
-                  .toString());
-      throw ErrorResultException.wrap(result);
+      throw newErrorResult(
+          ResultCode.CLIENT_SIDE_UNEXPECTED_RESULTS_RETURNED,
+          ERR_UNEXPECTED_SEARCH_RESULT_ENTRIES
+              .get(handler.entryCount).toString());
     }
     else if (handler.firstReference != null)
     {
       // Got an unexpected search result reference.
-      final Result result = Responses.newResult(
-          ResultCode.CLIENT_SIDE_UNEXPECTED_RESULTS_RETURNED)
-          .setDiagnosticMessage(
-              ERR_UNEXPECTED_SEARCH_RESULT_REFERENCES.get(
-                  handler.firstReference.getURIs().iterator().next())
-                  .toString());
-      throw ErrorResultException.wrap(result);
+      throw newErrorResult(
+          ResultCode.CLIENT_SIDE_UNEXPECTED_RESULTS_RETURNED,
+          ERR_UNEXPECTED_SEARCH_RESULT_REFERENCES.get(
+              handler.firstReference.getURIs().iterator().next())
+              .toString());
     }
     else
     {

--
Gitblit v1.10.0