From 867e35d3947bd5f2e6c0baaf502312ca618a00ea Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 05 Aug 2016 18:35:35 +0000
Subject: [PATCH] Partial OPENDJ-2625 Convert all code that uses JNDI to use the SDK instead
---
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/NodeRefresher.java | 39 ++++++++++++++-------------------------
1 files changed, 14 insertions(+), 25 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/NodeRefresher.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/NodeRefresher.java
index f28f19d..37d01c0 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/NodeRefresher.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/NodeRefresher.java
@@ -30,12 +30,7 @@
import javax.naming.InterruptedNamingException;
import javax.naming.NameNotFoundException;
-import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
-import javax.naming.SizeLimitExceededException;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import javax.naming.ldap.LdapName;
import javax.swing.SwingUtilities;
import javax.swing.tree.TreeNode;
@@ -345,42 +340,36 @@
* Performs the search in the case the user specified a custom filter.
* @param dn the parent DN we perform the search from.
* @param conn the connection to be used.
- * @throws NamingException if a problem occurred.
+ * @throws IOException if a problem occurred.
*/
- private void searchForCustomFilter(String dn, ConnectionWrapper conn)
- throws NamingException
+ private void searchForCustomFilter(String dn, ConnectionWrapper conn) throws IOException
{
- SearchControls ctls = controller.getBasicSearchControls();
- ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
- ctls.setReturningAttributes(new String[]{});
- ctls.setCountLimit(1);
- NamingEnumeration<SearchResult> s = conn.getLdapContext().search(new LdapName(dn),
- controller.getFilter(),
- ctls);
- try
+ SearchRequest request = newSearchRequest(dn, WHOLE_SUBTREE, controller.getFilter())
+ .setSizeLimit(1);
+ try (ConnectionEntryReader entryReader = conn.getConnection().search(request))
{
- if (!s.hasMore())
+ if (!entryReader.hasNext())
{
- throw new NameNotFoundException("Entry "+dn+
+ throw LdapException.newLdapException(ResultCode.NO_SUCH_OBJECT, "Entry " + dn +
" does not verify filter "+controller.getFilter());
}
- while (s.hasMore())
+ while (entryReader.hasNext())
{
- s.next();
+ entryReader.readEntry();
}
}
- catch (SizeLimitExceededException slme)
+ catch (LdapException e)
{
+ if (!e.getResult().getResultCode().equals(ResultCode.SIZE_LIMIT_EXCEEDED))
+ {
+ throw e;
+ }
// We are just searching for an entry, but if there is more than one
// this exception will be thrown. We call sr.hasMore after the
// first entry has been retrieved to avoid sending a systematic
// abandon when closing the s NamingEnumeration.
// See CR 6976906.
}
- finally
- {
- s.close();
- }
}
/** Read the local entry associated to the current node. */
--
Gitblit v1.10.0