From c9958277baf5f911bda401802259a4b50d9cd599 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 03 Aug 2016 16:06:26 +0000
Subject: [PATCH] BasicNode: use DN
---
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/RootNode.java | 5
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/LDAPEntryReader.java | 8
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java | 15 +-
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DuplicateEntryPanel.java | 2
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/BasicNode.java | 10
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/event/EntryReadErrorEvent.java | 10 +
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteEntryTask.java | 49 +++----
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDAPEntrySelectionPanel.java | 2
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/BrowserController.java | 51 ++++----
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/SuffixNode.java | 5
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyEntryTask.java | 2
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractBrowseEntriesPanel.java | 63 +++++-----
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDAPEntryPanel.java | 3
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/NodeRefresher.java | 25 +---
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ResetUserPasswordPanel.java | 4
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java | 2
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ResetUserPasswordTask.java | 5
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ErrorSearchingEntryPanel.java | 6
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewEntryTask.java | 61 +++------
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewGroupPanel.java | 2
20 files changed, 148 insertions(+), 182 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/BrowserController.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/BrowserController.java
index 64597f9..138d236 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/BrowserController.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/BrowserController.java
@@ -48,6 +48,7 @@
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
+import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
import org.opends.admin.ads.ADSContext;
import org.opends.admin.ads.util.ConnectionWrapper;
@@ -249,7 +250,7 @@
* @throws IllegalArgumentException if a node with the given dn exists but
* is not a suffix node.
*/
- public boolean hasSuffix(String suffixDn) throws IllegalArgumentException
+ public boolean hasSuffix(DN suffixDn) throws IllegalArgumentException
{
return findSuffixNode(suffixDn, rootNode) != null;
}
@@ -263,15 +264,13 @@
* @return the TreePath of the new node.
* @throws IllegalArgumentException if a node with the given dn exists.
*/
- public TreePath addSuffix(String suffixDn, String parentSuffixDn)
- throws IllegalArgumentException
+ public TreePath addSuffix(DN suffixDn, DN parentSuffixDn) throws IllegalArgumentException
{
SuffixNode parentNode;
if (parentSuffixDn != null) {
parentNode = findSuffixNode(parentSuffixDn, rootNode);
if (parentNode == null) {
- throw new IllegalArgumentException("Invalid suffix dn " +
- parentSuffixDn);
+ throw new IllegalArgumentException("Invalid suffix dn " + parentSuffixDn);
}
}
else {
@@ -295,7 +294,7 @@
* @param nodeDn the DN of the node to be added.
* @return the TreePath of the new node.
*/
- public TreePath addNodeUnderRoot(String nodeDn) {
+ public TreePath addNodeUnderRoot(DN nodeDn) {
SuffixNode parentNode = rootNode;
int index = findChildNode(parentNode, nodeDn);
if (index >= 0) { // A node has already this dn -> bug
@@ -530,8 +529,7 @@
* @param newEntryDn the dn of the entry to be added.
* @return the tree path associated with the new entry.
*/
- public TreePath notifyEntryAdded(BrowserNodeInfo parentInfo,
- String newEntryDn) {
+ public TreePath notifyEntryAdded(BrowserNodeInfo parentInfo, DN newEntryDn) {
BasicNode parentNode = parentInfo.getNode();
BasicNode childNode = new BasicNode(newEntryDn);
int childIndex;
@@ -916,15 +914,16 @@
}
if (node instanceof SuffixNode)
{
- String dn = node.getDN();
- return Utilities.areDnsEqual(dn, ADSContext.getAdministrationSuffixDN().toString()) ||
- Utilities.areDnsEqual(dn, ConfigConstants.DN_DEFAULT_SCHEMA_ROOT) ||
- Utilities.areDnsEqual(dn, ConfigConstants.DN_TASK_ROOT) ||
- Utilities.areDnsEqual(dn, ConfigConstants.DN_CONFIG_ROOT) ||
- Utilities.areDnsEqual(dn, ConfigConstants.DN_MONITOR_ROOT) ||
- Utilities.areDnsEqual(dn, ConfigConstants.DN_TRUST_STORE_ROOT) ||
- Utilities.areDnsEqual(dn, ConfigConstants.DN_BACKUP_ROOT) ||
- Utilities.areDnsEqual(dn, DN_EXTERNAL_CHANGELOG_ROOT);
+ DN dn = node.getDN();
+ String dnStr = dn.toString();
+ return dn.equals(ADSContext.getAdministrationSuffixDN()) ||
+ Utilities.areDnsEqual(dnStr, ConfigConstants.DN_DEFAULT_SCHEMA_ROOT) ||
+ Utilities.areDnsEqual(dnStr, ConfigConstants.DN_TASK_ROOT) ||
+ Utilities.areDnsEqual(dnStr, ConfigConstants.DN_CONFIG_ROOT) ||
+ Utilities.areDnsEqual(dnStr, ConfigConstants.DN_MONITOR_ROOT) ||
+ Utilities.areDnsEqual(dnStr, ConfigConstants.DN_TRUST_STORE_ROOT) ||
+ Utilities.areDnsEqual(dnStr, ConfigConstants.DN_BACKUP_ROOT) ||
+ Utilities.areDnsEqual(dnStr, DN_EXTERNAL_CHANGELOG_ROOT);
}
else
{
@@ -988,9 +987,9 @@
if (parent != null)
{
final LDAPURL parentUrl = findUrlForDisplayedEntry(parent);
- return LDAPConnectionPool.makeLDAPUrl(parentUrl, node.getDN());
+ return LDAPConnectionPool.makeLDAPUrl(parentUrl, node.getDN().toString());
}
- return LDAPConnectionPool.makeLDAPUrl(connConfig.getHostPort(), node.getDN(), connConfig.isLdaps());
+ return LDAPConnectionPool.makeLDAPUrl(connConfig.getHostPort(), node.getDN().toString(), connConfig.isLdaps());
}
/**
@@ -1019,7 +1018,7 @@
if (followReferrals && node.getRemoteUrl() != null) {
return node.getRemoteUrl().getRawBaseDN();
}
- return node.getDN();
+ return node.getDN().toString();
}
/**
@@ -1371,7 +1370,7 @@
// Search a child node matching the DN of the entry
int index;
if (differential) {
- index = findChildNode(parent, entry.getName().toString());
+ index = findChildNode(parent, entry.getName());
}
else {
index = - (parent.getChildCount() + 1);
@@ -1382,7 +1381,7 @@
if (index < 0) {
// -(index + 1) is the location where to insert the new node
index = -(index + 1);
- child = new BasicNode(entry.getName().toString());
+ child = new BasicNode(entry.getName());
parent.insert(child, index);
updateNodeRendering(child, entry);
insertIndex.add(index);
@@ -1614,7 +1613,7 @@
* @param childDn the DN of the entry that is being searched.
* @return the index of the node matching childDn.
*/
- public int findChildNode(BasicNode parent, String childDn) {
+ public int findChildNode(BasicNode parent, DN childDn) {
int childCount = parent.getChildCount();
int i = 0;
while (i < childCount
@@ -1704,10 +1703,10 @@
* @throws IllegalArgumentException if a node with the given dn exists but
* is not a suffix node.
*/
- private SuffixNode findSuffixNode(String suffixDn, SuffixNode suffixNode)
+ private SuffixNode findSuffixNode(DN suffixDn, SuffixNode suffixNode)
throws IllegalArgumentException
{
- if (Utilities.areDnsEqual(suffixNode.getDN(), suffixDn)) {
+ if (suffixNode.getDN().equals(suffixDn)) {
return suffixNode;
}
@@ -1722,7 +1721,7 @@
do
{
child = (BasicNode) suffixNode.getChildAt(i);
- if (Utilities.areDnsEqual(child.getDN(), suffixDn))
+ if (child.getDN().equals(suffixDn))
{
found = true;
}
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 e2de5f8..f28f19d 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
@@ -309,7 +309,8 @@
*/
private void searchForCustomFilter(BasicNode node, ConnectionWrapper conn) throws IOException
{
- SearchRequest request = newSearchRequest(node.getDN(), WHOLE_SUBTREE, controller.getFilter(), NO_ATTRIBUTES)
+ SearchRequest request =
+ newSearchRequest(node.getDN().toString(), WHOLE_SUBTREE, controller.getFilter(), NO_ATTRIBUTES)
.setSizeLimit(1);
try (ConnectionEntryReader s = conn.getConnection().search(request))
{
@@ -398,10 +399,9 @@
String filter = controller.getObjectSearchFilter();
SearchRequest request =
- newSearchRequest(node.getDN(), BASE_OBJECT, filter, controller.getAttrsForRedSearch())
+ newSearchRequest(node.getDN().toString(), BASE_OBJECT, filter, controller.getAttrsForRedSearch())
.setSizeLimit(controller.getMaxChildren());
localEntry = conn.getConnection().searchSingleEntry(request);
- localEntry.setName(node.getDN());
if (localEntry == null) {
/* Not enough rights to read the entry or the entry simply does not exist */
throw newLdapException(ResultCode.NO_SUCH_OBJECT, "Can't find entry: " + node.getDN());
@@ -798,19 +798,10 @@
for (int i=0; i<getNode().getChildCount(); i++)
{
BasicNode node = (BasicNode)getNode().getChildAt(i);
- try
+ if (node.getDN().equals(parentToAddDN))
{
- DN dn = DN.valueOf(node.getDN());
- if (dn.equals(parentToAddDN))
- {
- resultValue[0] = false;
- break;
- }
- }
- catch (Throwable t)
- {
- throw new RuntimeException("Error decoding dn: "+
- node.getDN()+" . "+t, t);
+ resultValue[0] = false;
+ break;
}
}
}
@@ -966,9 +957,7 @@
boolean checkSucceeded = true;
try
{
- DN dn1 = DN.valueOf(getNode().getDN());
- DN dn2 = url.getBaseDN();
- if (dn2.isSuperiorOrEqualTo(dn1))
+ if (url.getBaseDN().isSuperiorOrEqualTo(getNode().getDN()))
{
HostPort urlHostPort = new HostPort(url.getHost(), url.getPort());
checkSucceeded = urlHostPort.equals(controller.getConfigurationConnection().getHostPort());
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/event/EntryReadErrorEvent.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/event/EntryReadErrorEvent.java
index 1879df5..7eda72c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/event/EntryReadErrorEvent.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/event/EntryReadErrorEvent.java
@@ -12,10 +12,12 @@
* information: "Portions Copyright [year] [name of copyright owner]".
*
* Copyright 2008 Sun Microsystems, Inc.
+ * Portions Copyright 2016 ForgeRock AS.
*/
-
package org.opends.guitools.controlpanel.event;
+import org.forgerock.opendj.ldap.DN;
+
//Note: in terms of synchronization, this implementation assumes that the
//interrupt method is only called in the event thread (this class is used
//when the user selects a node in the LDAP entry browser).
@@ -27,7 +29,7 @@
{
private Object source;
private Throwable t;
- private String dn;
+ private DN dn;
/**
* Constructor for the event.
@@ -35,7 +37,7 @@
* @param dn the DN of the entry we were searching.
* @param t the throwable that we got as error.
*/
- public EntryReadErrorEvent(Object source, String dn, Throwable t)
+ public EntryReadErrorEvent(Object source, DN dn, Throwable t)
{
this.source = source;
this.t = t;
@@ -64,7 +66,7 @@
* Returns the DN of the entry we were searching.
* @return the DN of the entry we were searching.
*/
- public String getDN()
+ public DN getDN()
{
return dn;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteEntryTask.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteEntryTask.java
index 5c909d4..44d550b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteEntryTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteEntryTask.java
@@ -94,7 +94,7 @@
for (TreePath path : paths)
{
BasicNode node = (BasicNode)path.getLastPathComponent();
- entries.add(DN.valueOf(node.getDN()));
+ entries.add(node.getDN());
}
for (BackendDescriptor backend : info.getServerDescriptor().getBackends())
{
@@ -186,37 +186,20 @@
for (TreePath path : paths)
{
BasicNode node = (BasicNode)path.getLastPathComponent();
- try
+ DN dn = node.getDN();
+ if (!isAlreadyDeleted(alreadyDeleted, dn))
{
- DN dn = DN.valueOf(node.getDN());
- boolean isDnDeleted = false;
- for (DN deletedDn : alreadyDeleted)
+ ConnectionWrapper conn = controller.findConnectionForDisplayedEntry(node);
+ useAdminCtx = controller.isConfigurationNode(node);
+ if (node.hasSubOrdinates())
{
- if (dn.isSubordinateOrEqualTo(deletedDn))
- {
- isDnDeleted = true;
- break;
- }
+ deleteSubtreeWithControl(conn, dn, path, toNotify);
}
- if (!isDnDeleted)
+ else
{
- ConnectionWrapper conn = controller.findConnectionForDisplayedEntry(node);
- useAdminCtx = controller.isConfigurationNode(node);
- if (node.hasSubOrdinates())
- {
- deleteSubtreeWithControl(conn, dn, path, toNotify);
- }
- else
- {
- deleteSubtreeRecursively(conn, dn, path, toNotify);
- }
- alreadyDeleted.add(dn);
+ deleteSubtreeRecursively(conn, dn, path, toNotify);
}
- }
- catch (DirectoryException de)
- {
- throw new RuntimeException("Unexpected error parsing dn: "+
- node.getDN(), de);
+ alreadyDeleted.add(dn);
}
}
if (!toNotify.isEmpty())
@@ -247,6 +230,18 @@
}
}
+ private boolean isAlreadyDeleted(ArrayList<DN> dns, DN dnToFind)
+ {
+ for (DN dn : dns)
+ {
+ if (dnToFind.isSubordinateOrEqualTo(dn))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Notifies that some entries have been deleted. This will basically update
* the browser controller so that the tree reflects the changes that have
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyEntryTask.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyEntryTask.java
index e4c8b35..7737d2c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyEntryTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyEntryTask.java
@@ -370,7 +370,7 @@
controller.getNodeInfoFromPath(treePath));
newPath[0] = controller.notifyEntryAdded(
controller.getNodeInfoFromPath(parentPath),
- newEntry.getName().toString());
+ newEntry.getName());
}
});
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewEntryTask.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewEntryTask.java
index 03a7bfb..8279219 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewEntryTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewEntryTask.java
@@ -187,44 +187,32 @@
{
getProgressDialog().appendProgressHtml(
Utilities.getProgressDone(ColorAndFontConstants.progressFont));
+ final DN newEntryName = newEntry.getName();
boolean entryInserted = false;
if (parentNode != null)
{
- boolean isReallyParentNode = false;
- try
- {
- DN parentDN = DN.valueOf(parentNode.getDN());
- isReallyParentNode =
- parentDN.equals(newEntry.getName().parent());
- }
- catch (Throwable t)
- {
- // Bug
- t.printStackTrace();
- isReallyParentNode = false;
- }
+ boolean isReallyParentNode = parentNode.getDN().equals(newEntryName.parent());
if (isReallyParentNode)
{
- insertNode(parentNode, newEntry.getName(),
- isBaseDN(newEntry.getName()));
+ insertNode(parentNode, newEntryName, isBaseDN(newEntryName));
entryInserted = true;
}
}
if (!entryInserted)
{
BasicNode root = (BasicNode)controller.getTreeModel().getRoot();
- BasicNode realParentNode = findParentNode(newEntry.getName(), root);
+ BasicNode realParentNode = findParentNode(newEntryName, root);
if (realParentNode != null)
{
- insertNode(realParentNode, newEntry.getName(), false);
+ insertNode(realParentNode, newEntryName, false);
}
- else if (isBaseDN(newEntry.getName()))
+ else if (isBaseDN(newEntryName))
{
int nRootChildren = controller.getTreeModel().getChildCount(controller.getTreeModel().getRoot());
if (nRootChildren > 1)
{
// Insert in the root.
- insertNode(root, newEntry.getName(), true);
+ insertNode(root, newEntryName, true);
}
}
}
@@ -269,29 +257,20 @@
int nRootChildren = controller.getTreeModel().getChildCount(root);
for (int i=0; i<nRootChildren; i++)
{
- BasicNode node =
- (BasicNode)controller.getTreeModel().getChild(root, i);
- try
+ BasicNode node = (BasicNode) controller.getTreeModel().getChild(root, i);
+ DN nodeDN = node.getDN();
+ if (dn.isSubordinateOrEqualTo(nodeDN))
{
- DN nodeDN = DN.valueOf(node.getDN());
- if (dn.isSubordinateOrEqualTo(nodeDN))
+ if (dn.size() == nodeDN.size() + 1)
{
- if (dn.size() == nodeDN.size() + 1)
- {
- parentNode = node;
- break;
- }
- else
- {
- parentNode = findParentNode(dn, node);
- break;
- }
+ parentNode = node;
+ break;
}
- }
- catch (Throwable t)
- {
- // Bug
- throw new RuntimeException("Unexpected error: "+t, t);
+ else
+ {
+ parentNode = findParentNode(dn, node);
+ break;
+ }
}
}
return parentNode;
@@ -306,11 +285,11 @@
TreePath newPath;
if (isSuffix)
{
- newPath = controller.addSuffix(dn.toString(), parentNode.getDN());
+ newPath = controller.addSuffix(dn, parentNode.getDN());
}
else
{
- newPath = controller.notifyEntryAdded(controller.getNodeInfoFromPath(parentPath), dn.toString());
+ newPath = controller.notifyEntryAdded(controller.getNodeInfoFromPath(parentPath), dn);
}
if (newPath != null)
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ResetUserPasswordTask.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ResetUserPasswordTask.java
index 5a3a226..c5d63d1 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ResetUserPasswordTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ResetUserPasswordTask.java
@@ -70,7 +70,7 @@
backendSet = new HashSet<>();
this.node = node;
this.newPassword = pwd;
- dn = DN.valueOf(node.getDN());
+ dn = node.getDN();
for (BackendDescriptor backend : info.getServerDescriptor().getBackends())
{
@@ -112,8 +112,7 @@
@Override
public LocalizableMessage getTaskDescription()
{
- return INFO_CTRL_PANEL_RESET_USER_PASSWORD_TASK_DESCRIPTION.get(
- node.getDN());
+ return INFO_CTRL_PANEL_RESET_USER_PASSWORD_TASK_DESCRIPTION.get(node.getDN());
}
@Override
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractBrowseEntriesPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractBrowseEntriesPanel.java
index e38db37..43fb5ce 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractBrowseEntriesPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractBrowseEntriesPanel.java
@@ -631,7 +631,7 @@
controller.removeAllUnderRoot();
controller.setFilter(filterValue);
controller.setAutomaticExpand(!BrowserController.ALL_OBJECTS_FILTER.equals(filterValue));
- SortedSet<String> allSuffixes = new TreeSet<>();
+ SortedSet<DN> allSuffixes = new TreeSet<>();
if (controller.getConfigurationConnection() != null)
{
treePane.getTree().setRootVisible(displayAll);
@@ -639,27 +639,27 @@
boolean added = false;
for (BackendDescriptor backend : getInfo().getServerDescriptor().getBackends())
{
- for (BaseDNDescriptor baseDN : backend.getBaseDns())
+ for (BaseDNDescriptor baseDNDescriptor : backend.getBaseDns())
{
- boolean isBaseDN = baseDN.getDn().equals(theDN);
- String dn = Utilities.unescapeUtf8(baseDN.getDn().toString());
+ DN baseDN = baseDNDescriptor.getDn();
+ boolean isBaseDN = baseDN.equals(theDN);
if (displayAll)
{
- allSuffixes.add(dn);
+ allSuffixes.add(baseDN);
}
else if (isBaseDN)
{
- controller.addSuffix(dn, null);
+ controller.addSuffix(baseDN, null);
added = true;
}
}
}
if (displayAll)
{
- allSuffixes.add(ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT);
- for (String dn : allSuffixes)
+ allSuffixes.add(DN.valueOf(ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT));
+ for (DN baseDN : allSuffixes)
{
- controller.addSuffix(dn, null);
+ controller.addSuffix(baseDN, null);
}
}
else if (!added && !displayAll)
@@ -667,14 +667,14 @@
if (isChangeLog(theDN))
{
// Consider it a suffix
- controller.addSuffix(s, null);
+ controller.addSuffix(theDN, null);
}
else
{
BasicNode rootNode = (BasicNode) controller.getTree().getModel().getRoot();
- if (controller.findChildNode(rootNode, s) == -1)
+ if (controller.findChildNode(rootNode, theDN) == -1)
{
- controller.addNodeUnderRoot(s);
+ controller.addNodeUnderRoot(theDN);
}
}
}
@@ -813,29 +813,29 @@
boolean isSubordinate = false;
for (BackendDescriptor backend : ev.getBackends())
{
- for (BaseDNDescriptor baseDN : backend.getBaseDns())
+ for (BaseDNDescriptor baseDNDescriptor : backend.getBaseDns())
{
boolean isBaseDN = false;
- if (baseDN.getDn().equals(theDN))
+ DN baseDN = baseDNDescriptor.getDn();
+ if (baseDN.equals(theDN))
{
isBaseDN = true;
}
- else if (baseDN.getDn().isSuperiorOrEqualTo(theDN))
+ else if (baseDN.isSuperiorOrEqualTo(theDN))
{
isSubordinate = true;
}
- String dn = Utilities.unescapeUtf8(baseDN.getDn().toString());
if (displayAll || isBaseDN)
{
try
{
- if (!controller.hasSuffix(dn))
+ if (!controller.hasSuffix(baseDN))
{
- controller.addSuffix(dn, null);
+ controller.addSuffix(baseDN, null);
}
else
{
- int index = controller.findChildNode(rootNode, dn);
+ int index = controller.findChildNode(rootNode, baseDN);
if (index >= 0)
{
TreeNode node = rootNode.getChildAt(index);
@@ -851,14 +851,15 @@
{
// The suffix node exists but is not a suffix node. Simply log a message.
logger.warn(
- LocalizableMessage.raw("Suffix: " + dn + " added as a non suffix node. Exception: " + iae, iae));
+ LocalizableMessage.raw("Suffix: " + baseDN + " added as a non suffix node. Exception: " + iae,
+ iae));
}
}
}
}
- if (isSubordinate && controller.findChildNode(rootNode, s) == -1)
+ if (isSubordinate && controller.findChildNode(rootNode, theDN) == -1)
{
- controller.addNodeUnderRoot(s);
+ controller.addNodeUnderRoot(theDN);
}
}
}
@@ -1315,17 +1316,17 @@
boolean added = false;
for (BackendDescriptor backend : getInfo().getServerDescriptor().getBackends())
{
- for (BaseDNDescriptor baseDN : backend.getBaseDns())
+ for (BaseDNDescriptor baseDNDescriptor : backend.getBaseDns())
{
- String dn = Utilities.unescapeUtf8(baseDN.getDn().toString());
- boolean isBaseDN = baseDN.getDn().equals(theDN);
- if (baseDN.getEntries() > 0)
+ DN baseDN = baseDNDescriptor.getDn();
+ boolean isBaseDN = baseDN.equals(theDN);
+ if (baseDNDescriptor.getEntries() > 0)
{
try
{
- if ((displayAll || isBaseDN) && !controller.hasSuffix(dn))
+ if ((displayAll || isBaseDN) && !controller.hasSuffix(baseDN))
{
- controller.addSuffix(dn, null);
+ controller.addSuffix(baseDN, null);
added = true;
}
}
@@ -1333,16 +1334,16 @@
{
// The suffix node exists but is not a suffix node. Simply log a message.
logger.warn(LocalizableMessage.raw(
- "Suffix: " + dn + " added as a non suffix node. Exception: " + iae, iae));
+ "Suffix: " + baseDN + " added as a non suffix node. Exception: " + iae, iae));
}
}
}
if (!added && !displayAll)
{
BasicNode rootNode = (BasicNode) controller.getTree().getModel().getRoot();
- if (controller.findChildNode(rootNode, s) == -1)
+ if (controller.findChildNode(rootNode, theDN) == -1)
{
- controller.addNodeUnderRoot(s);
+ controller.addNodeUnderRoot(theDN);
}
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java
index bedd2d2..91e59a2 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java
@@ -335,8 +335,8 @@
{
for (TreePath p : paths)
{
- BasicNode n = (BasicNode)p.getLastPathComponent();
- if (!entryPane.canDelete(DN.valueOf(n.getDN())))
+ BasicNode n = (BasicNode) p.getLastPathComponent();
+ if (!entryPane.canDelete(n.getDN()))
{
return false;
}
@@ -502,7 +502,7 @@
}
if (node != null)
{
- String dn;
+ DN dn;
if (controller.getFollowReferrals() &&
node.getReferral() != null &&
node.getRemoteUrl() == null &&
@@ -511,13 +511,12 @@
{
// We are in the case where we are following referrals but the referral
// could not be resolved. Display an error.
- entryPane.referralSolveError(node.getDN(), node.getReferral(),
- node.getError());
+ entryPane.referralSolveError(node.getDN(), node.getReferral(), node.getError());
dn = null;
}
else if (controller.getFollowReferrals() && node.getRemoteUrl() != null)
{
- dn = node.getRemoteUrl().getRawBaseDN();
+ dn = DN.valueOf(node.getRemoteUrl().getRawBaseDN());
}
else
{
@@ -1069,8 +1068,8 @@
LinkedHashSet<DN> dns = new LinkedHashSet<>();
for (TreePath path : paths)
{
- BasicNode node = (BasicNode)path.getLastPathComponent();
- dns.add(DN.valueOf(node.getDN()));
+ BasicNode node = (BasicNode) path.getLastPathComponent();
+ dns.add(node.getDN());
}
if (addToGroupDlg == null)
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DuplicateEntryPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DuplicateEntryPanel.java
index d7f6b73..5d04d6b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DuplicateEntryPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DuplicateEntryPanel.java
@@ -116,7 +116,7 @@
DN aParentDN;
String aRdn;
- DN nodeDN = DN.valueOf(node.getDN());
+ DN nodeDN = node.getDN();
if (nodeDN.isRootDN())
{
aParentDN = nodeDN;
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ErrorSearchingEntryPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ErrorSearchingEntryPanel.java
index 683120d..e362306 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ErrorSearchingEntryPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ErrorSearchingEntryPanel.java
@@ -25,6 +25,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
+import org.forgerock.opendj.ldap.DN;
import org.opends.guitools.controlpanel.browser.BasicNodeError;
import org.opends.guitools.controlpanel.browser.ReferralLimitExceededException;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
@@ -85,7 +86,7 @@
* @param dn the DN of the entry that caused a problem.
* @param t the Throwable that occurred when searching the entry.
*/
- public void setError(String dn, Throwable t)
+ public void setError(DN dn, Throwable t)
{
LocalizableMessage title = INFO_CTRL_PANEL_ERROR_SEARCHING_ENTRY_TITLE.get();
LocalizableMessage details;
@@ -108,8 +109,7 @@
* @param referrals the list of referrals defined in the entry.
* @param error the error that occurred resolving the referral.
*/
- public void setReferralError(String dn, String[] referrals,
- BasicNodeError error)
+ public void setReferralError(DN dn, String[] referrals, BasicNodeError error)
{
LocalizableMessage title = INFO_CTRL_PANEL_ERROR_RESOLVING_REFERRAL_TITLE.get();
LocalizableMessageBuilder details = new LocalizableMessageBuilder();
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDAPEntryPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDAPEntryPanel.java
index 02274fc..1038895 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDAPEntryPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDAPEntryPanel.java
@@ -316,8 +316,7 @@
* @param referrals the list of referrals defined in the entry.
* @param error the error that occurred resolving the referral.
*/
- public void referralSolveError(String dn, String[] referrals,
- BasicNodeError error)
+ public void referralSolveError(DN dn, String[] referrals, BasicNodeError error)
{
searchResult = null;
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDAPEntrySelectionPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDAPEntrySelectionPanel.java
index 30f9242..dffcb70 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDAPEntrySelectionPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDAPEntrySelectionPanel.java
@@ -126,7 +126,7 @@
dns = new String[paths.length];
for (int i=0; i<paths.length; i++)
{
- dns[i] = ((BasicNode)paths[i].getLastPathComponent()).getDN();
+ dns[i] = ((BasicNode) paths[i].getLastPathComponent()).getDN().toString();
}
}
else
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewGroupPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewGroupPanel.java
index f9754ea..3bd5aa2 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewGroupPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewGroupPanel.java
@@ -565,7 +565,7 @@
else if (comp == referenceGroup
&& nodes.getNodes().length > 0)
{
- String dn = nodes.getNodes()[0].getNode().getDN();
+ String dn = nodes.getNodes()[0].getNode().getDN().toString();
referenceGroup.setText(dn);
referenceGroup.setCaretPosition(dn.length());
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ResetUserPasswordPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ResetUserPasswordPanel.java
index 5b1816e..0e738cb 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ResetUserPasswordPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ResetUserPasswordPanel.java
@@ -26,13 +26,13 @@
import javax.swing.JLabel;
import javax.swing.JPasswordField;
+import org.forgerock.i18n.LocalizableMessage;
import org.opends.guitools.controlpanel.browser.BrowserController;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
import org.opends.guitools.controlpanel.task.ResetUserPasswordTask;
import org.opends.guitools.controlpanel.task.Task;
import org.opends.guitools.controlpanel.ui.nodes.BasicNode;
import org.opends.guitools.controlpanel.util.Utilities;
-import org.forgerock.i18n.LocalizableMessage;
/** Panel that appears when the user wants to change the password of a user. */
public class ResetUserPasswordPanel extends StatusGenericPanel
@@ -68,7 +68,7 @@
setPrimaryValid(lPassword);
setPrimaryValid(lConfirmPassword);
- dn.setText(node.getDN());
+ dn.setText(node.getDN().toString());
name.setText(node.getDisplayName());
password.setText("");
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
index 80e74a9..68d3173 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
@@ -332,7 +332,7 @@
JTextField tf = (JTextField)comp;
if (nodes.getNodes().length > 0)
{
- String dn = nodes.getNodes()[0].getNode().getDN();
+ String dn = nodes.getNodes()[0].getNode().getDN().toString();
tf.setText(dn);
tf.setCaretPosition(dn.length());
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/BasicNode.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/BasicNode.java
index 128f649..dc9ebeb 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/BasicNode.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/BasicNode.java
@@ -28,7 +28,7 @@
public class BasicNode extends DefaultMutableTreeNode {
private static final long serialVersionUID = 5441658731908509872L;
- private String localDn;
+ private DN localDn;
private String localRdn;
private String localRdnWithAttributeName;
private LDAPURL remoteUrl;
@@ -61,10 +61,10 @@
* Constructor.
* @param dn the DN of the entry.
*/
- public BasicNode(String dn) {
+ public BasicNode(DN dn) {
localDn = dn;
- localRdn = extractRDN(localDn);
- localRdnWithAttributeName = extractRDN(localDn, true);
+ localRdn = extractRDN(localDn.toString());
+ localRdnWithAttributeName = extractRDN(localDn.toString(), true);
isLeaf = true;
refreshNeededOnExpansion = true;
numSubOrdinates = -1;
@@ -77,7 +77,7 @@
* Returns the DN of the local entry.
* @return the DN of the local entry.
*/
- public String getDN() {
+ public DN getDN() {
return localDn;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/RootNode.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/RootNode.java
index eea1a4e..099dd81 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/RootNode.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/RootNode.java
@@ -14,9 +14,10 @@
* Copyright 2008 Sun Microsystems, Inc.
* Portions Copyright 2016 ForgeRock AS.
*/
-
package org.opends.guitools.controlpanel.ui.nodes;
+import org.forgerock.opendj.ldap.DN;
+
/**
* The root node of the tree in the 'Manage Entries...' tree. It represents
* the root entry of the directory.
@@ -27,7 +28,7 @@
/** Constructor of the node. */
public RootNode() {
- super("");
+ super(DN.rootDN());
setLeaf(false);
setRefreshNeededOnExpansion(false);
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/SuffixNode.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/SuffixNode.java
index 388a70e..ca8199c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/SuffixNode.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/SuffixNode.java
@@ -14,9 +14,10 @@
* Copyright 2008 Sun Microsystems, Inc.
* Portions Copyright 2016 ForgeRock AS.
*/
-
package org.opends.guitools.controlpanel.ui.nodes;
+import org.forgerock.opendj.ldap.DN;
+
/** Represents a suffix in the tree in the 'Manage Entries...' tree. */
public class SuffixNode extends BasicNode {
@@ -26,7 +27,7 @@
* Constructor of the node.
* @param dn the DN of the suffix.
*/
- public SuffixNode(String dn) {
+ public SuffixNode(DN dn) {
super(dn);
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/LDAPEntryReader.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/LDAPEntryReader.java
index 6b8da9b..5f5445f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/LDAPEntryReader.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/LDAPEntryReader.java
@@ -22,6 +22,8 @@
import java.util.HashSet;
import java.util.Set;
+import org.forgerock.opendj.ldap.DN;
+import org.forgerock.opendj.ldap.Filter;
import org.forgerock.opendj.ldap.requests.Requests;
import org.forgerock.opendj.ldap.requests.SearchRequest;
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
@@ -38,7 +40,7 @@
*/
public class LDAPEntryReader extends BackgroundTask<CustomSearchResult>
{
- private final String dn;
+ private final DN dn;
private final ConnectionWrapper conn;
private final Set<EntryReadListener> listeners = new HashSet<>();
private boolean isOver;
@@ -49,7 +51,7 @@
* @param dn the DN of the entry.
* @param conn the connection to the server.
*/
- public LDAPEntryReader(String dn, ConnectionWrapper conn)
+ public LDAPEntryReader(DN dn, ConnectionWrapper conn)
{
this.dn = dn;
this.conn = conn;
@@ -60,7 +62,7 @@
public CustomSearchResult processBackgroundTask() throws Throwable
{
isOver = false;
- final String filter = "(|(objectclass=*)(objectclass=ldapsubentry))";
+ final Filter filter = Filter.valueOf("(|(objectclass=*)(objectclass=ldapsubentry))");
SearchRequest request = Requests.newSearchRequest(dn, BASE_OBJECT, filter, "*", "+");
SearchResultEntry sr = conn.getConnection().searchSingleEntry(request);
if (isInterrupted())
--
Gitblit v1.10.0