From eaee3f6a42c1a129f07e2364a4c32c59b9e03e19 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 09 Feb 2016 15:22:22 +0000
Subject: [PATCH] Prep work for OPENDJ-1342: align APIs for RDNs
---
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyEntryTask.java | 50 +++++++++++++++++++++++++-------------------------
1 files changed, 25 insertions(+), 25 deletions(-)
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 397ec4a..271fb5c 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
@@ -22,7 +22,7 @@
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
- * Portions Copyright 2014-2015 ForgeRock AS
+ * Portions Copyright 2014-2016 ForgeRock AS
*/
package org.opends.guitools.controlpanel.task;
@@ -47,7 +47,10 @@
import javax.swing.tree.TreePath;
import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.ldap.AVA;
+import org.forgerock.opendj.ldap.AttributeDescription;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.guitools.controlpanel.browser.BrowserController;
import org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor;
@@ -120,9 +123,9 @@
}
mustRename = !newDn.equals(oldDn);
}
- catch (OpenDsException ode)
+ catch (OpenDsException e)
{
- throw new RuntimeException("Could not parse DN: " + oldEntry.getDN(), ode);
+ throw new RuntimeException("Could not parse DN: " + oldEntry.getDN(), e);
}
modifications = getModifications(newEntry, oldEntry, getInfo());
// Find password modifications
@@ -422,14 +425,14 @@
private boolean rdnTypeChanged(RDN oldRDN, RDN newRDN)
{
- if (newRDN.getNumValues() != oldRDN.getNumValues())
+ if (newRDN.size() != oldRDN.size())
{
return true;
}
- for (int i = 0; i < newRDN.getNumValues(); i++)
+ for (AVA ava : newRDN)
{
- if (!find(oldRDN, newRDN.getAttributeName(i)))
+ if (!find(oldRDN, ava.getAttributeType()))
{
return true;
}
@@ -437,11 +440,11 @@
return false;
}
- private boolean find(RDN rdn, String attrName)
+ private boolean find(RDN rdn, AttributeType attrType)
{
- for (int j = 0; j < rdn.getNumValues(); j++)
+ for (AVA ava : rdn)
{
- if (attrName.equalsIgnoreCase(rdn.getAttributeName(j)))
+ if (attrType.equals(ava.getAttributeType()))
{
return true;
}
@@ -463,9 +466,9 @@
private boolean entryContainsRdnTypes(CustomSearchResult entry, RDN rdn)
{
- for (int i = 0; i < rdn.getNumValues(); i++)
+ for (AVA ava : rdn)
{
- List<Object> values = entry.getAttributeValues(rdn.getAttributeName(i));
+ List<Object> values = entry.getAttributeValues(ava.getAttributeName());
if (values.isEmpty())
{
return false;
@@ -490,7 +493,8 @@
newAttrs.add(newEntry.getObjectClassAttribute());
for (org.opends.server.types.Attribute attr : newAttrs)
{
- String attrName = attr.getNameWithOptions();
+ AttributeDescription attrDesc = attr.getAttributeDescription();
+ String attrName = attrDesc.toString();
if (!ViewEntryPanel.isEditable(attrName, schema))
{
continue;
@@ -503,18 +507,15 @@
}
List<Object> oldValues = oldEntry.getAttributeValues(attrName);
- boolean isAttributeInNewRdn = false;
ByteString rdnValue = null;
- RDN rdn = newEntry.getName().rdn();
- for (int i=0; i<rdn.getNumValues() && !isAttributeInNewRdn; i++)
+ for (AVA ava : newEntry.getName().rdn())
{
- isAttributeInNewRdn =
- rdn.getAttributeName(i).equalsIgnoreCase(attrName);
- if (isAttributeInNewRdn)
+ if (ava.getAttributeType().equals(attrDesc.getAttributeType()))
{
- rdnValue = rdn.getAttributeValue(i);
+ rdnValue = ava.getAttributeValue();
}
}
+ boolean isAttributeInNewRdn = rdnValue != null;
/* Check the attributes of the old DN. If we are renaming them they
* will be deleted. Check that they are on the new entry but not in
@@ -532,16 +533,15 @@
{
oldRDN = DN.valueOf(oldEntry.getDN()).rdn();
}
- catch (DirectoryException de)
+ catch (DirectoryException unexpected)
{
- throw new RuntimeException("Unexpected error parsing DN: "+
- oldEntry.getDN(), de);
+ throw new RuntimeException("Unexpected error parsing DN: " + oldEntry.getDN(), unexpected);
}
- for (int i=0; i<oldRDN.getNumValues(); i++)
+ for (AVA ava : oldRDN)
{
- if (oldRDN.getAttributeName(i).equalsIgnoreCase(attrName))
+ if (ava.getAttributeType().equals(attrDesc.getAttributeType()))
{
- ByteString value = oldRDN.getAttributeValue(i);
+ ByteString value = ava.getAttributeValue();
if (attr.contains(value))
{
if (rdnValue == null || !rdnValue.equals(value))
--
Gitblit v1.10.0