Author: nhosoi
Update of /cvs/dirsec/console/src/com/netscape/management/client/topology In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv32522/src/com/netscape/management/client/topology
Modified Files: ServerNode.java Log Message: Bug 521108 - Customer is unable to add a new Role within RHDS 8.1.0.
https://bugzilla.redhat.com/show_bug.cgi?id=521108
Fix Description: The console uses resource editor extensions which are registered under cn=ResourceEditorExtension, ou=1.1, ou=admin, ou=Global Preferences, ou=example.com, o=NetscapeRoot in the admin server. Some extensions are provided by idm-console-framework, but some others are provided by 389-ds-console.
Currently the console will load all extensions during console initialization. However, when a user uses the console for the first time it doesn't have the 389-ds-console jar file yet. The jar file will only be downloaded when the user clicks the server node, but at that point the console will not try to load the extensions again.
This problem can be reproduced by removing ~/.389-console/jars folder and then restarting the console.
The patch will change the behaviour such that during initialization the console will only load the extensions from idm-console-framework (without @ sign). When the user clicks on the server node it will load the extensions from the 389-ds-console jar file (ending with @ + jar file name) .
Note: Committing the change on behalf of Endi Sukma Dewata (edewata@redhat.com).
Index: ServerNode.java =================================================================== RCS file: /cvs/dirsec/console/src/com/netscape/management/client/topology/ServerNode.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ServerNode.java 29 Jan 2009 21:23:59 -0000 1.5 +++ ServerNode.java 17 Mar 2010 17:37:51 -0000 1.6 @@ -31,6 +31,7 @@ import com.netscape.management.client.console.*; import com.netscape.management.client.components.*; import com.netscape.management.client.ace.*; +import com.netscape.management.client.ug.*; import com.netscape.management.client.util.*; import netscape.ldap.*; import netscape.ldap.controls.*; @@ -1288,6 +1289,7 @@ } } so.initialize(ci); + loadResourceEditorExtension(ci, jarName); if (so instanceof ResourceObject) { ((ResourceObject) so).setName(serverID); @@ -1308,6 +1310,111 @@ } }
+ public void loadResourceEditorExtension(ConsoleInfo ci, String jarName) { + + LDAPConnection ldc = ci.getLDAPConnection(); + if (ldc == null) return; + + String ldapLocation = ""; + LDAPSearchConstraints cons; + LDAPSearchResults result; + LDAPAttribute attribute; + + try { + cons = ldc.getSearchConstraints(); + cons.setBatchSize(1); + // then get the resource editor extension + ldapLocation = "cn=ResourceEditorExtension,"+ + LDAPUtil.getAdminGlobalParameterEntry(); + result = ldc.search(ldapLocation, + LDAPConnection.SCOPE_ONE, "(Objectclass=nsAdminResourceEditorExtension)", + null, false, cons); + Hashtable hResourceEditorExtension = ResourceEditor.getResourceEditorExtension(); + Hashtable deleteResourceEditorExtension = ResourceEditor.getDeleteResourceEditorExtension(); + + if (result != null) { + while (result.hasMoreElements()) { + LDAPEntry ExtensionEntry; + try { + ExtensionEntry = (LDAPEntry) result.next(); + } catch (Exception e) { + // ldap exception + continue; + } + + attribute = ExtensionEntry.getAttribute("cn", + LDAPUtil.getLDAPAttributeLocale()); + Enumeration eValues = attribute.getStringValues(); + String sCN = ""; + while (eValues.hasMoreElements()) { + sCN = (String) eValues.nextElement(); // Take the first CN + break; + } + + attribute = + ExtensionEntry.getAttribute("nsClassname", + LDAPUtil.getLDAPAttributeLocale()); + if (attribute != null) { + eValues = attribute.getStringValues(); + + Vector vClass = (Vector)hResourceEditorExtension.get( + sCN.toLowerCase()); + if (vClass == null) { + vClass = new Vector(); + hResourceEditorExtension.put( + sCN.toLowerCase(), vClass); + } + + while (eValues.hasMoreElements()) { + String sJarClassName = + (String) eValues.nextElement(); + if (!sJarClassName.endsWith("@"+jarName)) continue; + + Class c = ClassLoaderUtil.getClass( + ci, sJarClassName); + + if (c != null) { + vClass.addElement(c); + } + } + } + + attribute = + ExtensionEntry.getAttribute("nsDeleteClassname", + LDAPUtil.getLDAPAttributeLocale()); + if (attribute != null) { + Enumeration deleteClasses = + attribute.getStringValues(); + + Vector deleteClassesVector = (Vector)deleteResourceEditorExtension.get( + sCN.toLowerCase()); + if (deleteClassesVector == null) { + deleteClassesVector = new Vector(); + deleteResourceEditorExtension.put( + sCN.toLowerCase(), deleteClassesVector); + } + + while (deleteClasses.hasMoreElements()) { + String jarClassname = (String) + deleteClasses.nextElement(); + if (!jarClassname.endsWith("@"+jarName)) continue; + + Class c = ClassLoaderUtil.getClass( + ci, jarClassname); + if (c != null) { + deleteClassesVector.addElement(c); + } + } + } + } + } + + } + catch (LDAPException e) { + Debug.println("Console: Cannot open "+ldapLocation); + } + } + /** * Inner class for opening a server console in a separate thread. */
389-commits@lists.fedoraproject.org