Author: nkinder
Update of /cvs/dirsec/console/src/com/netscape/management/client/ug
In directory
cvs01.phx2.fedoraproject.org:/tmp/cvs-serv5262/src/com/netscape/management/client/ug
Modified Files:
ResourceEditor.java ResourcePageObservable.java
Log Message:
Bug 229699 - objectclass without parent causes StringIndexOutOfBounds in console
The exception was occuring since the Console assumed that an entry created by
going to "New->User" would have the givenname and sn attribute present and
never checked if they were null before calling the String.substring() method.
The fix is to first check if these attributes are null.
There were other issues around this problem as well. The
ResourcePageObservable class that is used to represent the entry being edited
keeps a list of objectclasses along with the list of attributes and values for
the entry (including the objectclass attribute). The problem was that removing
an objectclass from the entry in the editor did not remove the objectclass from
the objectclass list. This causes the editor to make assumptions about the
entry, such as the presence of the givenname and sn attribute that caused the
exception. The fix is to sync the objectclass list with the actual
objectclasses that are present in the entry when a change is made.
Index: ResourceEditor.java
===================================================================
RCS file: /cvs/dirsec/console/src/com/netscape/management/client/ug/ResourceEditor.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- ResourceEditor.java 18 Jul 2005 00:34:23 -0000 1.1.1.1
+++ ResourceEditor.java 1 Mar 2011 19:24:56 -0000 1.2
@@ -799,6 +799,8 @@
String sAttrName = (String) arg;
if ((sAttrName != null) &&
(sAttrName.toLowerCase().equals("objectclass"))) {
+ // refresh the objectclass list
+ ((ResourcePageObservable)o).syncObjectClassList();
// update the plugin
setupPlugin(((ResourcePageObservable) o).get("objectclass"));
}
Index: ResourcePageObservable.java
===================================================================
RCS file:
/cvs/dirsec/console/src/com/netscape/management/client/ug/ResourcePageObservable.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ResourcePageObservable.java 7 Feb 2011 19:49:52 -0000 1.3
+++ ResourcePageObservable.java 1 Mar 2011 19:24:56 -0000 1.4
@@ -125,6 +125,17 @@
/**
+ * Synchronizes the objectclass list with the objectclass
+ * attribute values that are present in the observable.
+ *
+ * @param objectClassList vector of object classes
+ */
+ public void syncObjectClassList() {
+ _objectClassList = get("objectclass");
+ }
+
+
+ /**
* Gets the LDAPEntry for the specified DN
*
* @param DN the LDAPEntry to retrieve
@@ -293,15 +304,21 @@
} else if ( sAttribute.toLowerCase().
equalsIgnoreCase(
ID_FORMAT_FIRSTLETTER_LASTNAME)) {
- sUID = get(STRING_GIVENNAME,
- 0).substring(0, 1) +
- get(STRING_SN, 0);
+ String givenName = get(STRING_GIVENNAME, 0);
+ String sn = get(STRING_SN, 0);
+ if ((givenName != null) &&
!givenName.equals("") &&
+ (sn != null) &&
(!sn.equals(""))) {
+ sUID = givenName.substring(0, 1) + sn;
+ }
} else if ( sAttribute.toLowerCase().
equalsIgnoreCase(
ID_FORMAT_GIVENNAME_FIRSTLETTER)) {
- sUID = get(STRING_GIVENNAME,
- 0) + get(STRING_SN,
- 0).substring(0, 1);
+ String givenName = get(STRING_GIVENNAME, 0);
+ String sn = get(STRING_SN, 0);
+ if ((givenName != null) &&
!givenName.equals("") &&
+ (sn != null) &&
(!sn.equals(""))) {
+ sUID = givenName + sn.substring(0, 1);
+ }
} else if ( sAttribute.toLowerCase().
equalsIgnoreCase(
ID_FORMAT_LASTNAME_GIVENNAME)) {
@@ -366,7 +383,7 @@
_entry = newEntry;
- // Refresh so we get a copy of the entrt from the DS. This ensures
+ // Refresh so we get a copy of the entry from the DS. This ensures
// that we see any updates that the DS added to the entry.
refresh();
}