Author: rmeggins
Update of /cvs/dirsec/console/src/com/netscape/management/client/ug
In directory
cvs01.phx2.fedoraproject.org:/tmp/cvs-serv8170/src/com/netscape/management/client/ug
Modified Files:
ResourcePageObservable.java
Log Message:
Bug 586571 - DS Console shows escaped DNs
https://bugzilla.redhat.com/show_bug.cgi?id=586571
Resolves: bug 586571
Bug Description: DS Console shows escaped DNs
Reviewed by: nkinder (Thanks!)
Branch: HEAD
Fix Description: Was not working correctly in the property and advanced
editor for editing some DNs that contained other DNs as RDN values.
I also moved a lot of the DN handling code into the main console package
into the LDAPUtil class. This will allow the main console to handle DN
escapes as well. Unfortunately, if managing a new DS on a machine which
only has the old console framework, these methods will be missing.
So, use the new methods if available, otherwise, fallback on the DSUtil
implementation.
Platforms tested: RHEL5 x86_64
Flag Day: no
Doc impact: no
Index: ResourcePageObservable.java
===================================================================
RCS file:
/cvs/dirsec/console/src/com/netscape/management/client/ug/ResourcePageObservable.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- ResourcePageObservable.java 18 Jul 2005 00:34:24 -0000 1.1.1.1
+++ ResourcePageObservable.java 3 May 2010 20:37:56 -0000 1.2
@@ -24,7 +24,10 @@
import java.util.*;
import com.netscape.management.client.console.ConsoleInfo;
-import com.netscape.management.client.util.*;
+import com.netscape.management.client.util.Debug;
+import com.netscape.management.client.util.KingpinLDAPConnection;
+import com.netscape.management.client.util.LDAPUtil;
+import com.netscape.management.client.util.ResourceSet;
import netscape.ldap.*;
import netscape.ldap.util.*;
@@ -428,12 +431,15 @@
LDAPConnection ldapConnection = _info.getUserLDAPConnection();
try {
String DN = _entry.getDN();
+ String unescDN = LDAPUtil.unEscapeDN(DN);
+ boolean needesc = !unescDN.equals(DN);
String newRdnValue = get(_sIndexAttribute, 0);
if (newRdnValue == null || newRdnValue.trim().equals("")) {
_sIndexAttribute = "cn";
newRdnValue = get(_sIndexAttribute, 0);
- }
+ }
String newRDN = _sIndexAttribute + "=" + newRdnValue;
+ String newRDNEsc = _sIndexAttribute + "=" +
LDAPUtil.escapeDNVal(newRdnValue);
//for a group there is no ou so we have to check
String[] rdns = LDAPDN.explodeDN(DN, false);
@@ -448,11 +454,18 @@
Debug.println(6, "ResourcePageObservable.save: RDN=" +
RDN);
Debug.println(6, "ResourcePageObservable.save: newRDN=" +
newRDN);
- if (DN.length() > 0 && (new RDN(newRDN)).equals(new
RDN(RDN)) == false) {
+ Debug.println(6, "ResourcePageObservable.save: newRDNEsc="
+ newRDNEsc);
+ if (DN.length() > 0 &&
+ ((new RDN(newRDN)).equals(new RDN(RDN)) == false) &&
+ ((new RDN(newRDNEsc)).equals(new RDN(RDN)) == false)) {
Debug.println("ResourcePageObservable.save: rename " +
DN + " --> new rdn=" + newRDN);
ldapConnection.rename(DN, newRDN, true); // Cannot rename same
RDN.
}
- sDN = newRDN + newBaseDN.toString();
+ if (needesc) {
+ sDN = newRDNEsc + newBaseDN.toString();
+ } else {
+ sDN = newRDN + newBaseDN.toString();
+ }
} else {
sDN = _entry.getDN();
}