? src/com/redhat/rhdb/admin/PrivilegesCheckBoxPanel.java Index: ChangeLog =================================================================== RCS file: /cvs/rhdb/src/rhdb/guitools/rhdb-admin/ChangeLog,v retrieving revision 1.8 diff -c -r1.8 ChangeLog *** ChangeLog 4 May 2004 16:57:14 -0000 1.8 --- ChangeLog 9 Jun 2004 05:39:20 -0000 *************** *** 1,3 **** --- 1,108 ---- + 2004-06-09 Deepak Bhole + + * src/com/redhat/rhdb/admin/CheckBoxPanel.java: Added intialization + code for checkbox/boolean arrays to prevent NullPointerException's. + * src/com/redhat/rhdb/admin/EditPrivilegesDialog.form: Changed by the + IDE. + * src/com/redhat/rhdb/admin/EditPrivilegesDialog.java: Added + code to get the GRANT OPTION string (OPTION GRANT WITH), so that the + appropriate checkboxes show up in 7.4.x versions. Changed jpPrivileges + to be of type PrivilegesCheckBoxPanel which is more suited, given the + changes to the Privileges structure in 7.4.x. + (jcbPublicActionPerformed): New scaffolding function. Updates status + of the OPTION GRANT WITH checkbox to ensure that only "users" can be + given that privilege option. + (jlGroupsValueChanged): Ditto. + (jlUsersValueChanged): Ditto. + (adjustGrantWithBoxes): New function .Updates status of the OPTION + GRANT WITH checkbox to ensure that only "users" can begiven that + privilege option. + (doApplyAction): Change function to work with the new WITH GRANT + OPTION option for 7.4.x backends. + (getPrivileges): Ditto. + (updatePrivileges): Ditto. Based on the privilege, the WITH GRANT + OPTION checkbox is checked as needed. + * src/com/redhat/rhdb/admin/ManagePrivilegesDialog.form: Changed by the + IDE. + * src/com/redhat/rhdb/admin/ManagePrivilegesDialog.java: Changed + constructor to initialize the grantOptionString so that the WITH GRANT + OPTION checkboxes show up. Changed jpDatabasePriv, jpSchemaPriv, + jpTablePriv, jpViewPriv, jpSequencesPriv, jpLanguagesPriv and + jpFunctionPriv to be PrivilegesCheckBoxPanel which is more suited for + the new privileges functionality in 7.4.x. + (languagePrivilegeChange): Fix bug in function that caused apply to be + disabled if multiple items were selected (it should be enabled since a + mass change is about to happen, and the user should be aware of what + is about to happen whether even if in the end, nothing may really + change). + (functionPrivilegeChange): Ditto. + (sequencePrivilegeChange): Ditto. + (viewPrivilegeChange): Ditto. + (tablePrivilegeChange): Ditto. + (schemaPrivilegeChange): Ditto. + (databasePrivilegeChange): Ditto. + (schemaSelected): Change function to work with the new WITH GRANT + OPTION option for 7.4.x backends. Based on the privilege, the WITH + GRANT OPTION checkbox is checked as needed. + (databaseSelected): Ditto. + (functionSelected): Ditto. + (languageSelected): Ditto. + (sequenceSelected): Ditto. + (viewSelected): Ditto. + (tableSelected): Ditto. + (updatePrivileges): Change function to work with the new WITH GRANT + OPTION in 7.4.x backends. + * src/com/redhat/rhdb/admin/ObjectUpdate.java: Added new tokens + pertaining to the WITH GRANT OPTION option. + * src/com/redhat/rhdb/admin/PrivilegesCheckBoxPanel.java: New file. A + more complex extension of CheckBoxPanel (not inherited due to too many + differences). This panel allows "secondary" checkboxes which behave in + a manner required by the privilege dialogs for the WITH GRANT OPTION + option. + * src/com/redhat/rhdb/admin/PrivilegesUpdate.java + (getUpdateFunctionPrivString): Change function to work with the new + WITH GRANT OPTION option. + (getUpdateLanguagePrivString): Ditto. + (getUpdateViewPrivString): Ditto. + (getUpdateSequencePrivString): Ditto. + (getUpdateDatabasePrivString): Ditto. + (getUpdateSchemaPrivString): Ditto. + (getUpdateTablePrivString): Ditto. + * src/com/redhat/rhdb/admin/pgsql/AbstractRhdb73DatabaseMetaData.java + (getDatabasePrivileges): Change function to return 2 more fields, + GRANTOR and IS_GRANTABLE (as defined in JDBC specs for + getTablePrivileges()). + (getFunctionPrivileges): Ditto. + (getGrantOptionString): New function. Returns the grant option + string. Emmpty string for 7.3.x and lower backends. + (getLanguagePrivileges): Change function to return 2 more fields, + GRANTOR and IS_GRANTABLE (as defined in JDBC specs for + getTablePrivileges()). + (getSchemaPrivileges): Ditto. + (getSequencePrivileges): Ditto. + (getTablePrivileges): Ditto. + (getViewPrivileges): Ditto. + (getACLComponents): New function. Takes in ACL in format as per 7.4.x + docs, and breaks it down into components. + (parseACLArray): Overloaded helper function from PostgreSQL JDBC. + (addACLPrivileges): Ditto. + (parseACL): Ditto. + * src/com/redhat/rhdb/admin/pgsql/AbstractRhdb74DatabaseMetaData.java: + (getGrantOptionString): New function. Returns the grant option + string for 7.4.x and higher backends. + * src/com/redhat/rhdb/admin/pgsql/AdminDatabaseMetaData.java + (getGrantOptionString): New function added to interface. + * src/com/redhat/rhdb/admin/tree/DatabaseNode.java (raiseView): Change + function to show IS_GRANTABLE and GRANTOR in the privileges row for + the view. + * src/com/redhat/rhdb/admin/tree/FunctionNode.java: Ditto. + * src/com/redhat/rhdb/admin/tree/LanguageNode.java: Ditto. + * src/com/redhat/rhdb/admin/tree/SchemaNode.java: Ditto. + * src/com/redhat/rhdb/admin/tree/SequenceNode.java: Ditto. + * src/com/redhat/rhdb/admin/tree/TableNode.java: Ditto. + * src/com/redhat/rhdb/admin/tree/ViewNode.java: Ditto. + + 2004-05-04 Deepak Bhole * src/com/redhat/rhdb/admin/AddColumnDialog.java: Added support for Index: src/com/redhat/rhdb/admin/Administrator.java =================================================================== RCS file: /cvs/rhdb/src/rhdb/guitools/rhdb-admin/src/com/redhat/rhdb/admin/Administrator.java,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 Administrator.java *** src/com/redhat/rhdb/admin/Administrator.java 21 Nov 2003 18:30:20 -0000 1.1.1.1 --- src/com/redhat/rhdb/admin/Administrator.java 9 Jun 2004 05:39:20 -0000 *************** *** 33,37 **** MetalLookAndFeel.setCurrentTheme(new AdminLookAndFeel()); new MainWindow().show(); } ! } --- 33,37 ---- MetalLookAndFeel.setCurrentTheme(new AdminLookAndFeel()); new MainWindow().show(); } ! } Index: src/com/redhat/rhdb/admin/CheckBoxPanel.java =================================================================== RCS file: /cvs/rhdb/src/rhdb/guitools/rhdb-admin/src/com/redhat/rhdb/admin/CheckBoxPanel.java,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 CheckBoxPanel.java *** src/com/redhat/rhdb/admin/CheckBoxPanel.java 21 Nov 2003 18:30:21 -0000 1.1.1.1 --- src/com/redhat/rhdb/admin/CheckBoxPanel.java 9 Jun 2004 05:39:20 -0000 *************** *** 1,5 **** /* ! * Copyright (c) 2003 Red Hat, Inc. All rights reserved. * * This software may be freely redistributed under the terms of the * GNU General Public License. --- 1,5 ---- /* ! * Copyright (c) 2003, 2004 Red Hat, Inc. All rights reserved. * * This software may be freely redistributed under the terms of the * GNU General Public License. *************** *** 313,320 **** firePropertyChange(SELECTION_MADE, !hasChanged[0], hasChanged[0]); } ! private javax.swing.JCheckBox[] jchButtons; ! private boolean[] hasChanged; /** Static Layout Value - Displays Buttons Horizontally */ public static final int HORIZONTAL = 1; --- 313,320 ---- firePropertyChange(SELECTION_MADE, !hasChanged[0], hasChanged[0]); } ! protected javax.swing.JCheckBox[] jchButtons = new javax.swing.JCheckBox[0]; ! protected boolean[] hasChanged = new boolean[0]; /** Static Layout Value - Displays Buttons Horizontally */ public static final int HORIZONTAL = 1; Index: src/com/redhat/rhdb/admin/EditPrivilegesDialog.form =================================================================== RCS file: /cvs/rhdb/src/rhdb/guitools/rhdb-admin/src/com/redhat/rhdb/admin/EditPrivilegesDialog.form,v retrieving revision 1.1 diff -c -r1.1 EditPrivilegesDialog.form *** src/com/redhat/rhdb/admin/EditPrivilegesDialog.form 14 Jan 2004 00:53:50 -0000 1.1 --- src/com/redhat/rhdb/admin/EditPrivilegesDialog.form 9 Jun 2004 05:39:20 -0000 *************** *** 37,42 **** --- 37,45 ---- + + + *************** *** 80,85 **** --- 83,91 ---- + + + *************** *** 96,118 **** ! ! ! ! --- 102,126 ---- + + + ! ! ! Index: src/com/redhat/rhdb/admin/EditPrivilegesDialog.java =================================================================== RCS file: /cvs/rhdb/src/rhdb/guitools/rhdb-admin/src/com/redhat/rhdb/admin/EditPrivilegesDialog.java,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 EditPrivilegesDialog.java *** src/com/redhat/rhdb/admin/EditPrivilegesDialog.java 21 Nov 2003 18:30:22 -0000 1.1.1.1 --- src/com/redhat/rhdb/admin/EditPrivilegesDialog.java 9 Jun 2004 05:39:21 -0000 *************** *** 1,5 **** /** ! * Copyright (c) 2003 Red Hat, Inc. All rights reserved. * This software may be freely redistributed under the terms of the * GNU General Public License. * --- 1,5 ---- /** ! * Copyright (c) 2003, 2004 Red Hat, Inc. All rights reserved. * This software may be freely redistributed under the terms of the * GNU General Public License. * *************** *** 74,80 **** privileges = dbmd.getValidSchemaPrivileges(); else if (invocationNode instanceof DatabaseNode) privileges = dbmd.getValidDatabasePrivileges(); ! initComponents(); // update title --- 74,82 ---- privileges = dbmd.getValidSchemaPrivileges(); else if (invocationNode instanceof DatabaseNode) privileges = dbmd.getValidDatabasePrivileges(); ! ! grantOptionString = dbmd.getGrantOptionString(); ! initComponents(); // update title *************** *** 124,130 **** jlUsers = new com.redhat.rhdb.admin.AdminList(); jspGroups = new javax.swing.JScrollPane(); jlGroups = new com.redhat.rhdb.admin.AdminList(); ! jpPrivileges = new CheckBoxPanel (privileges, CheckBoxPanel.VERTICAL, AdminResources.getString(AdminResources.DLG_EDIT_PRIVILEGES_PRIVILEGES)); jpButtons = new javax.swing.JPanel(); jbOK = okAction.getButton(); jbApply = applyAction.getButton(); --- 126,132 ---- jlUsers = new com.redhat.rhdb.admin.AdminList(); jspGroups = new javax.swing.JScrollPane(); jlGroups = new com.redhat.rhdb.admin.AdminList(); ! jpPrivileges = new PrivilegesCheckBoxPanel (privileges, AdminResources.getString(AdminResources.DLG_EDIT_PRIVILEGES_PRIVILEGES), grantOptionString); jpButtons = new javax.swing.JPanel(); jbOK = okAction.getButton(); jbApply = applyAction.getButton(); *************** *** 145,150 **** --- 147,158 ---- updatePrivileges(); } }); + jcbPublic.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcbPublicActionPerformed(evt); + } + }); + gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; *************** *** 174,179 **** --- 182,193 ---- updatePrivileges(); } }); + jlUsers.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + jlUsersValueChanged(evt); + } + }); + jspUsers.setViewportView(jlUsers); gridBagConstraints = new java.awt.GridBagConstraints(); *************** *** 190,195 **** --- 204,215 ---- updatePrivileges(); } }); + jlGroups.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + jlGroupsValueChanged(evt); + } + }); + jspGroups.setViewportView(jlGroups); gridBagConstraints = new java.awt.GridBagConstraints(); *************** *** 201,207 **** gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 3); jpOptions.add(jspGroups, gridBagConstraints); - jpPrivileges.setEnabled(false); jpPrivileges.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent evt) { checkPrivilegeChange(evt); --- 221,226 ---- *************** *** 210,216 **** gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; ! gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 0.5; --- 229,235 ---- gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; ! gridBagConstraints.gridy = 2; gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 0.5; *************** *** 233,243 **** setSize(new java.awt.Dimension(500, 300)); }//GEN-END:initComponents ! private void checkPrivilegeChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_checkPrivilegeChange ! // Add your handling code here: // get number of selected items in the lists int numSelected = jlUsers.getSelectedValues().length + jlGroups.getSelectedValues().length; // Disable apply button, if none of the priveleges are changed during single selection // In all other cases enable it. --- 252,287 ---- setSize(new java.awt.Dimension(500, 300)); }//GEN-END:initComponents ! private void jcbPublicActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbPublicActionPerformed ! adjustGrantWithBoxes(); ! }//GEN-LAST:event_jcbPublicActionPerformed ! ! private void jlGroupsValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jlGroupsValueChanged ! adjustGrantWithBoxes(); ! }//GEN-LAST:event_jlGroupsValueChanged ! ! private void jlUsersValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jlUsersValueChanged ! adjustGrantWithBoxes(); ! }//GEN-LAST:event_jlUsersValueChanged ! ! /** ! * Enabled the GRANT WITH OPTION only if applicable ! */ ! ! private void adjustGrantWithBoxes() { ! if (jlGroups.getSelectedValues().length > 0 || jcbPublic.isSelected()) { ! jpPrivileges.setSecondaryCBEnabled(false); ! } else { ! jpPrivileges.setSecondaryCBEnabled(true); ! } ! } ! ! private void checkPrivilegeChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_checkPrivilegeChange ! // Add your handling code here: // get number of selected items in the lists int numSelected = jlUsers.getSelectedValues().length + jlGroups.getSelectedValues().length; + numSelected += this.jcbPublic.isSelected() ? numSelected+1 : numSelected; // Disable apply button, if none of the priveleges are changed during single selection // In all other cases enable it. *************** *** 246,252 **** jbApply.setEnabled(false); else jbApply.setEnabled(true); ! }//GEN-LAST:event_checkPrivilegeChange /** Closes the dialog */ private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog --- 290,297 ---- jbApply.setEnabled(false); else jbApply.setEnabled(true); ! ! }//GEN-LAST:event_checkPrivilegeChange /** Closes the dialog */ private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog *************** *** 293,300 **** Hashtable parameters = new Hashtable(); Object[] users = jlUsers.getSelectedValues(); Object[] groups = jlGroups.getSelectedValues(); ! String[] privileges = jpPrivileges.getSelectedBoxes(); ! // Add the entries into the hash table if (jcbPublic.isSelected()) --- 338,346 ---- Hashtable parameters = new Hashtable(); Object[] users = jlUsers.getSelectedValues(); Object[] groups = jlGroups.getSelectedValues(); ! String[] privileges = jpPrivileges.getPrimaryOnlySelectedBoxes(); ! String[] privilegesWithGrant = jpPrivileges.getSelectedSecondaryBoxes(); ! // Add the entries into the hash table if (jcbPublic.isSelected()) *************** *** 322,328 **** for (int i = 0; i < privileges.length; i++) privilegeSet.put(privileges[i], privileges[i]); ! // Add calling object Hashtable objectSet = new Hashtable(); objectSet.put(invocationNode.toString(), invocationNode.toString()); --- 368,380 ---- for (int i = 0; i < privileges.length; i++) privilegeSet.put(privileges[i], privileges[i]); ! // Add privileges ! Hashtable privilegeWithGrantSet = new Hashtable(); ! ! for (int i = 0; i < privilegesWithGrant.length; i++) ! privilegeWithGrantSet.put(privilegesWithGrant[i], privilegesWithGrant[i]); ! ! // Add calling object Hashtable objectSet = new Hashtable(); objectSet.put(invocationNode.toString(), invocationNode.toString()); *************** *** 337,342 **** --- 389,395 ---- parameters.put(ObjectUpdate.PARAM_SCHEMA_NAME, ((FunctionNode) invocationNode).getParentSchemaName()); parameters.put(ObjectUpdate.PARAM_FUNCTIONS, objectSet); parameters.put(ObjectUpdate.PARAM_FUNCTION_PRIVILEGES, privilegeSet); + parameters.put(ObjectUpdate.PARAM_FUNCTION_PRIVILEGES_WITH_GRANT, privilegeWithGrantSet); PrivilegesUpdate.updatePrivileges(backendClient, parameters); } else if (invocationNode instanceof LanguageNode) { *************** *** 345,351 **** parameters.put(ObjectUpdate.PARAM_DB_NAME, ((LanguageNode) invocationNode).getParentDatabaseName()); parameters.put(ObjectUpdate.PARAM_LANGUAGES, objectSet); parameters.put(ObjectUpdate.PARAM_LANGUAGE_PRIVILEGES, privilegeSet); ! PrivilegesUpdate.updatePrivileges(backendClient, parameters); } else if (invocationNode instanceof SequenceNode) { // Sequences --- 398,405 ---- parameters.put(ObjectUpdate.PARAM_DB_NAME, ((LanguageNode) invocationNode).getParentDatabaseName()); parameters.put(ObjectUpdate.PARAM_LANGUAGES, objectSet); parameters.put(ObjectUpdate.PARAM_LANGUAGE_PRIVILEGES, privilegeSet); ! parameters.put(ObjectUpdate.PARAM_LANGUAGE_PRIVILEGES_WITH_GRANT, privilegeWithGrantSet); ! PrivilegesUpdate.updatePrivileges(backendClient, parameters); } else if (invocationNode instanceof SequenceNode) { // Sequences *************** *** 354,360 **** parameters.put(ObjectUpdate.PARAM_SCHEMA_NAME, ((SequenceNode) invocationNode).getParentSchemaName()); parameters.put(ObjectUpdate.PARAM_SEQUENCES, objectSet); parameters.put(ObjectUpdate.PARAM_SEQUENCE_PRIVILEGES, privilegeSet); ! PrivilegesUpdate.updatePrivileges(backendClient, parameters); } else if (invocationNode instanceof TableNode) { // Tables --- 408,415 ---- parameters.put(ObjectUpdate.PARAM_SCHEMA_NAME, ((SequenceNode) invocationNode).getParentSchemaName()); parameters.put(ObjectUpdate.PARAM_SEQUENCES, objectSet); parameters.put(ObjectUpdate.PARAM_SEQUENCE_PRIVILEGES, privilegeSet); ! parameters.put(ObjectUpdate.PARAM_SEQUENCE_PRIVILEGES_WITH_GRANT, privilegeWithGrantSet); ! PrivilegesUpdate.updatePrivileges(backendClient, parameters); } else if (invocationNode instanceof TableNode) { // Tables *************** *** 363,369 **** parameters.put(ObjectUpdate.PARAM_SCHEMA_NAME, ((TableNode) invocationNode).getParentSchemaName()); parameters.put(ObjectUpdate.PARAM_TABLES, objectSet); parameters.put(ObjectUpdate.PARAM_TABLE_PRIVILEGES, privilegeSet); ! PrivilegesUpdate.updatePrivileges(backendClient, parameters); } else if (invocationNode instanceof ViewNode) { // Views --- 418,425 ---- parameters.put(ObjectUpdate.PARAM_SCHEMA_NAME, ((TableNode) invocationNode).getParentSchemaName()); parameters.put(ObjectUpdate.PARAM_TABLES, objectSet); parameters.put(ObjectUpdate.PARAM_TABLE_PRIVILEGES, privilegeSet); ! parameters.put(ObjectUpdate.PARAM_TABLE_PRIVILEGES_WITH_GRANT, privilegeWithGrantSet); ! PrivilegesUpdate.updatePrivileges(backendClient, parameters); } else if (invocationNode instanceof ViewNode) { // Views *************** *** 372,400 **** parameters.put(ObjectUpdate.PARAM_SCHEMA_NAME, ((ViewNode) invocationNode).getParentSchemaName()); parameters.put(ObjectUpdate.PARAM_VIEWS, objectSet); parameters.put(ObjectUpdate.PARAM_VIEW_PRIVILEGES, privilegeSet); ! PrivilegesUpdate.updatePrivileges(backendClient, parameters); } else if (invocationNode instanceof SchemaNode) { // Schemas parameters.put(ObjectUpdate.PARAM_CLUSTER_NAME, ((SchemaNode) invocationNode).getParentClusterName()); parameters.put(ObjectUpdate.PARAM_DB_NAME, ((SchemaNode) invocationNode).getParentDatabaseName()); parameters.put(ObjectUpdate.PARAM_SCHEMAS, objectSet); parameters.put(ObjectUpdate.PARAM_SCHEMA_PRIVILEGES, privilegeSet); ! PrivilegesUpdate.updatePrivileges(backendClient, parameters); } else if (invocationNode instanceof DatabaseNode) { // Databases parameters.put(ObjectUpdate.PARAM_CLUSTER_NAME, ((DatabaseNode) invocationNode).getParentClusterName()); parameters.put(ObjectUpdate.PARAM_DB_NAME, invocationNode.toString()); parameters.put(ObjectUpdate.PARAM_DATABASES, objectSet); parameters.put(ObjectUpdate.PARAM_DATABASE_PRIVILEGES, privilegeSet); ! PrivilegesUpdate.updatePrivileges(backendClient, parameters); } invocationNode.reloadView(backendClient); // Reset the privileges panel. int[] justApplied = jpPrivileges.getSelectedIndexes(); jpPrivileges.reset(); jpPrivileges.setSelectedBoxes(justApplied, true); } catch (ObjectUpdateException e) { e.printStackTrace(); --- 428,461 ---- parameters.put(ObjectUpdate.PARAM_SCHEMA_NAME, ((ViewNode) invocationNode).getParentSchemaName()); parameters.put(ObjectUpdate.PARAM_VIEWS, objectSet); parameters.put(ObjectUpdate.PARAM_VIEW_PRIVILEGES, privilegeSet); ! parameters.put(ObjectUpdate.PARAM_VIEW_PRIVILEGES_WITH_GRANT, privilegeWithGrantSet); ! PrivilegesUpdate.updatePrivileges(backendClient, parameters); } else if (invocationNode instanceof SchemaNode) { // Schemas parameters.put(ObjectUpdate.PARAM_CLUSTER_NAME, ((SchemaNode) invocationNode).getParentClusterName()); parameters.put(ObjectUpdate.PARAM_DB_NAME, ((SchemaNode) invocationNode).getParentDatabaseName()); parameters.put(ObjectUpdate.PARAM_SCHEMAS, objectSet); parameters.put(ObjectUpdate.PARAM_SCHEMA_PRIVILEGES, privilegeSet); ! parameters.put(ObjectUpdate.PARAM_SCHEMA_PRIVILEGES_WITH_GRANT, privilegeWithGrantSet); ! PrivilegesUpdate.updatePrivileges(backendClient, parameters); } else if (invocationNode instanceof DatabaseNode) { // Databases parameters.put(ObjectUpdate.PARAM_CLUSTER_NAME, ((DatabaseNode) invocationNode).getParentClusterName()); parameters.put(ObjectUpdate.PARAM_DB_NAME, invocationNode.toString()); parameters.put(ObjectUpdate.PARAM_DATABASES, objectSet); parameters.put(ObjectUpdate.PARAM_DATABASE_PRIVILEGES, privilegeSet); ! parameters.put(ObjectUpdate.PARAM_DATABASE_PRIVILEGES_WITH_GRANT, privilegeWithGrantSet); ! PrivilegesUpdate.updatePrivileges(backendClient, parameters); } invocationNode.reloadView(backendClient); // Reset the privileges panel. int[] justApplied = jpPrivileges.getSelectedIndexes(); + int[] justAppliedOptions = jpPrivileges.getSelectedSecondaryIndexes(); jpPrivileges.reset(); jpPrivileges.setSelectedBoxes(justApplied, true); + jpPrivileges.setSelectedSecondaryBoxes(justAppliedOptions, true); } catch (ObjectUpdateException e) { e.printStackTrace(); *************** *** 434,444 **** } else if (invocationNode instanceof TableNode) { dbmd = this.backendClient.getAdminDatabaseMetaData(((TableNode) invocationNode).getParentClusterName(), ((TableNode) invocationNode).getParentDatabaseName()); String[][] tablePrivileges = backendClient.resultSetToStringArray(dbmd.getTablePrivileges(null, ((TableNode) invocationNode).getParentSchemaName(), invocationNode.toString()), (new ProcessLease())); ! objPrivileges = new String[tablePrivileges.length][2]; for (int i=0; i < tablePrivileges.length; i++) { objPrivileges[i][0] = tablePrivileges[i][4]; objPrivileges[i][1] = tablePrivileges[i][5]; } } else if (invocationNode instanceof ViewNode) { --- 495,509 ---- } else if (invocationNode instanceof TableNode) { dbmd = this.backendClient.getAdminDatabaseMetaData(((TableNode) invocationNode).getParentClusterName(), ((TableNode) invocationNode).getParentDatabaseName()); String[][] tablePrivileges = backendClient.resultSetToStringArray(dbmd.getTablePrivileges(null, ((TableNode) invocationNode).getParentSchemaName(), invocationNode.toString()), (new ProcessLease())); ! objPrivileges = new String[tablePrivileges.length][4]; for (int i=0; i < tablePrivileges.length; i++) { objPrivileges[i][0] = tablePrivileges[i][4]; objPrivileges[i][1] = tablePrivileges[i][5]; + + // [i][2] would be GRANTOR.. we don't care about that here, skip it + + objPrivileges[i][3] = tablePrivileges[i][6]; } } else if (invocationNode instanceof ViewNode) { *************** *** 494,506 **** jpPrivileges.reset(); if (selectedUsers.length == 1) { for (int i = 0; i < objPriv.length; i++) { ! if (objPriv[i][0].equals(selectedUsers[0].toString())) jpPrivileges.setSelectedBox(objPriv[i][1], true); } } else { for (int i = 0; i < objPriv.length; i++) ! if (objPriv[i][0].equals("group " + selectedGroups[0].toString())) jpPrivileges.setSelectedBox(objPriv[i][1], true); } jbApply.setEnabled(false); } --- 559,579 ---- jpPrivileges.reset(); if (selectedUsers.length == 1) { for (int i = 0; i < objPriv.length; i++) { ! if (objPriv[i][0].equals(selectedUsers[0].toString())) { jpPrivileges.setSelectedBox(objPriv[i][1], true); + + if (objPriv[i][3].equals("YES")) + jpPrivileges.setSelectedSecondaryBox(objPriv[i][1], true); + } } } else { for (int i = 0; i < objPriv.length; i++) ! if (objPriv[i][0].equals("group " + selectedGroups[0].toString())) { jpPrivileges.setSelectedBox(objPriv[i][1], true); + + if (objPriv[i][3].equals("YES")) + jpPrivileges.setSelectedSecondaryBox(objPriv[i][1], true); + } } jbApply.setEnabled(false); } *************** *** 516,530 **** String[][] objPriv = getPrivileges(); jpPrivileges.reset(); for (int i = 0; i < objPriv.length; i++) ! if (objPriv[i][0].equals("PUBLIC")) jpPrivileges.setSelectedBox(objPriv[i][1], true); jbApply.setEnabled(false); } else { // PUBLIC and list selection jpPrivileges.setEnabled(true); jpPrivileges.reset(); } - } private AdminBackendClient backendClient; --- 589,606 ---- String[][] objPriv = getPrivileges(); jpPrivileges.reset(); for (int i = 0; i < objPriv.length; i++) ! if (objPriv[i][0].equals("PUBLIC")) { jpPrivileges.setSelectedBox(objPriv[i][1], true); + + if (objPriv[i][3].equals("YES")) + jpPrivileges.setSelectedSecondaryBox(objPriv[i][1], true); + } jbApply.setEnabled(false); } else { // PUBLIC and list selection jpPrivileges.setEnabled(true); jpPrivileges.reset(); } } private AdminBackendClient backendClient; *************** *** 533,539 **** private GenericAction applyAction; private GenericAction cancelAction; private String[] privileges = new String[0]; ! // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jbApply; private javax.swing.JButton jbCancel; --- 609,616 ---- private GenericAction applyAction; private GenericAction cancelAction; private String[] privileges = new String[0]; ! private String grantOptionString = ""; ! // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jbApply; private javax.swing.JButton jbCancel; *************** *** 545,551 **** private javax.swing.JLabel jlbUsers; private javax.swing.JPanel jpButtons; private javax.swing.JPanel jpOptions; ! private com.redhat.rhdb.admin.CheckBoxPanel jpPrivileges; private javax.swing.JScrollPane jspGroups; private javax.swing.JScrollPane jspUsers; // End of variables declaration//GEN-END:variables --- 622,628 ---- private javax.swing.JLabel jlbUsers; private javax.swing.JPanel jpButtons; private javax.swing.JPanel jpOptions; ! private com.redhat.rhdb.admin.PrivilegesCheckBoxPanel jpPrivileges; private javax.swing.JScrollPane jspGroups; private javax.swing.JScrollPane jspUsers; // End of variables declaration//GEN-END:variables Index: src/com/redhat/rhdb/admin/ManagePrivilegesDialog.form =================================================================== RCS file: /cvs/rhdb/src/rhdb/guitools/rhdb-admin/src/com/redhat/rhdb/admin/ManagePrivilegesDialog.form,v retrieving revision 1.1 diff -c -r1.1 ManagePrivilegesDialog.form *** src/com/redhat/rhdb/admin/ManagePrivilegesDialog.form 14 Jan 2004 00:53:50 -0000 1.1 --- src/com/redhat/rhdb/admin/ManagePrivilegesDialog.form 9 Jun 2004 05:39:22 -0000 *************** *** 48,60 **** ! ! --- 48,60 ---- ! ! *************** *** 97,109 **** ! ! --- 97,109 ---- ! ! *************** *** 166,178 **** ! ! --- 166,178 ---- ! ! *************** *** 226,238 **** ! ! --- 226,238 ---- ! ! *************** *** 286,298 **** ! ! --- 286,298 ---- ! ! *************** *** 346,358 **** ! ! --- 346,358 ---- ! ! *************** *** 406,418 **** ! ! --- 406,418 ---- ! ! Index: src/com/redhat/rhdb/admin/ManagePrivilegesDialog.java =================================================================== RCS file: /cvs/rhdb/src/rhdb/guitools/rhdb-admin/src/com/redhat/rhdb/admin/ManagePrivilegesDialog.java,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 ManagePrivilegesDialog.java *** src/com/redhat/rhdb/admin/ManagePrivilegesDialog.java 21 Nov 2003 18:30:23 -0000 1.1.1.1 --- src/com/redhat/rhdb/admin/ManagePrivilegesDialog.java 9 Jun 2004 05:39:23 -0000 *************** *** 1,5 **** /** ! * Copyright (c) 2003 Red Hat, Inc. All rights reserved. * This software may be freely redistributed under the terms of the * GNU General Public License. * --- 1,5 ---- /** ! * Copyright (c) 2003, 2004 Red Hat, Inc. All rights reserved. * This software may be freely redistributed under the terms of the * GNU General Public License. * *************** *** 72,77 **** --- 72,82 ---- cancelAction = af.getAction(ActionFactory.ACTION_CANCEL); applyAction = af.getAction(ActionFactory.ACTION_APPLY); + // Only MANAGE USERS should have WITH GRANT OPTION option.. + + if (invocationNode instanceof UserNode) + grantOptionString = dbmd.getGrantOptionString(); + initComponents(); // Add databases to combo box *************** *** 107,137 **** jpDatabase = new javax.swing.JPanel(); jcbDatabase = new com.redhat.rhdb.admin.AdminComboBox(); ! jpDatabasePriv = new CheckBoxPanel(dbOptions, CheckBoxPanel.VERTICAL); jpSchema = new javax.swing.JPanel(); jcbSchema = new com.redhat.rhdb.admin.AdminComboBox(); ! jpSchemaPriv = new CheckBoxPanel(schOptions, CheckBoxPanel.VERTICAL); jtpObjects = new javax.swing.JTabbedPane(); jspTables = new javax.swing.JSplitPane(); jscTables = new javax.swing.JScrollPane(); jlTables = new javax.swing.JList(); ! jpTablePriv = new CheckBoxPanel(options, CheckBoxPanel.VERTICAL, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_PRIVILEGES)); jspViews = new javax.swing.JSplitPane(); jscViews = new javax.swing.JScrollPane(); jlViews = new javax.swing.JList(); ! jpViewPriv = new CheckBoxPanel(options, CheckBoxPanel.VERTICAL, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_PRIVILEGES)); jspSequences = new javax.swing.JSplitPane(); jscSequences = new javax.swing.JScrollPane(); jlSequences = new javax.swing.JList(); ! jpSequencesPriv = new CheckBoxPanel(options, CheckBoxPanel.VERTICAL, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_PRIVILEGES)); jspLanguages = new javax.swing.JSplitPane(); jscLanguages = new javax.swing.JScrollPane(); jlLanguages = new javax.swing.JList(); ! jpLanguagesPriv = new CheckBoxPanel(langOptions, CheckBoxPanel.VERTICAL, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_PRIVILEGES)); jspFunctions = new javax.swing.JSplitPane(); jscFunctions = new javax.swing.JScrollPane(); jlFunctions = new javax.swing.JList(); ! jpFunctionPriv = new CheckBoxPanel(funcOptions, CheckBoxPanel.VERTICAL, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_PRIVILEGES)); jpButtons = new javax.swing.JPanel(); jbOK = okAction.getButton(); jbApply = applyAction.getButton(); --- 112,142 ---- jpDatabase = new javax.swing.JPanel(); jcbDatabase = new com.redhat.rhdb.admin.AdminComboBox(); ! jpDatabasePriv = new PrivilegesCheckBoxPanel(dbOptions, "", grantOptionString); jpSchema = new javax.swing.JPanel(); jcbSchema = new com.redhat.rhdb.admin.AdminComboBox(); ! jpSchemaPriv = new PrivilegesCheckBoxPanel(schOptions, "", grantOptionString); jtpObjects = new javax.swing.JTabbedPane(); jspTables = new javax.swing.JSplitPane(); jscTables = new javax.swing.JScrollPane(); jlTables = new javax.swing.JList(); ! jpTablePriv = new PrivilegesCheckBoxPanel(options, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_PRIVILEGES), grantOptionString); jspViews = new javax.swing.JSplitPane(); jscViews = new javax.swing.JScrollPane(); jlViews = new javax.swing.JList(); ! jpViewPriv = new PrivilegesCheckBoxPanel(options, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_PRIVILEGES), grantOptionString); jspSequences = new javax.swing.JSplitPane(); jscSequences = new javax.swing.JScrollPane(); jlSequences = new javax.swing.JList(); ! jpSequencesPriv = new PrivilegesCheckBoxPanel(options, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_PRIVILEGES), grantOptionString); jspLanguages = new javax.swing.JSplitPane(); jscLanguages = new javax.swing.JScrollPane(); jlLanguages = new javax.swing.JList(); ! jpLanguagesPriv = new PrivilegesCheckBoxPanel(langOptions, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_PRIVILEGES), grantOptionString); jspFunctions = new javax.swing.JSplitPane(); jscFunctions = new javax.swing.JScrollPane(); jlFunctions = new javax.swing.JList(); ! jpFunctionPriv = new PrivilegesCheckBoxPanel(funcOptions, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_PRIVILEGES), grantOptionString); jpButtons = new javax.swing.JPanel(); jbOK = okAction.getButton(); jbApply = applyAction.getButton(); *************** *** 380,387 **** private void languagePrivilegeChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_languagePrivilegeChange // Add your handling code here: ! if (evt.getPropertyName() == CheckBoxPanel.SELECTION_MADE) { ! if (jpLanguagesPriv.getChangedIndexes().length != 0 || jlLanguages.getSelectedIndices().length > 0) { jtpObjects.setTitleAt(3, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_LANGUAGES) + " *"); jbApply.setEnabled(true); langPrivChanged = true; --- 385,392 ---- private void languagePrivilegeChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_languagePrivilegeChange // Add your handling code here: ! if (evt.getPropertyName() == PrivilegesCheckBoxPanel.SELECTION_MADE) { ! if (jpLanguagesPriv.getChangedIndexes().length != 0 || jlLanguages.getSelectedIndices().length > 1) { jtpObjects.setTitleAt(3, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_LANGUAGES) + " *"); jbApply.setEnabled(true); langPrivChanged = true; *************** *** 395,402 **** private void functionPrivilegeChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_functionPrivilegeChange // Add your handling code here: ! if (evt.getPropertyName() == CheckBoxPanel.SELECTION_MADE) { ! if (jpFunctionPriv.getChangedIndexes().length != 0 || jlFunctions.getSelectedIndices().length > 0) { jtpObjects.setTitleAt(4, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_FUNCTIONS) + " *"); jbApply.setEnabled(true); funcPrivChanged = true; --- 400,407 ---- private void functionPrivilegeChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_functionPrivilegeChange // Add your handling code here: ! if (evt.getPropertyName() == PrivilegesCheckBoxPanel.SELECTION_MADE) { ! if (jpFunctionPriv.getChangedIndexes().length != 0 || jlFunctions.getSelectedIndices().length > 1) { jtpObjects.setTitleAt(4, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_FUNCTIONS) + " *"); jbApply.setEnabled(true); funcPrivChanged = true; *************** *** 410,417 **** private void sequencePrivilegeChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_sequencePrivilegeChange // Add your handling code here: ! if (evt.getPropertyName() == CheckBoxPanel.SELECTION_MADE) { ! if (jpSequencesPriv.getChangedIndexes().length != 0 || jlSequences.getSelectedIndices().length > 0) { jtpObjects.setTitleAt(2, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_SEQUENCES) + " *"); jbApply.setEnabled(true); seqPrivChanged = true; --- 415,422 ---- private void sequencePrivilegeChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_sequencePrivilegeChange // Add your handling code here: ! if (evt.getPropertyName() == PrivilegesCheckBoxPanel.SELECTION_MADE) { ! if (jpSequencesPriv.getChangedIndexes().length != 0 || jlSequences.getSelectedIndices().length > 1) { jtpObjects.setTitleAt(2, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_SEQUENCES) + " *"); jbApply.setEnabled(true); seqPrivChanged = true; *************** *** 425,432 **** private void viewPrivilegeChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_viewPrivilegeChange // Add your handling code here: ! if (evt.getPropertyName() == CheckBoxPanel.SELECTION_MADE) { ! if (jpViewPriv.getChangedIndexes().length != 0 || jlViews.getSelectedIndices().length > 0) { jtpObjects.setTitleAt(1, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_VIEWS) + " *"); jbApply.setEnabled(true); viewPrivChanged = true; --- 430,437 ---- private void viewPrivilegeChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_viewPrivilegeChange // Add your handling code here: ! if (evt.getPropertyName() == PrivilegesCheckBoxPanel.SELECTION_MADE) { ! if (jpViewPriv.getChangedIndexes().length != 0 || jlViews.getSelectedIndices().length > 1) { jtpObjects.setTitleAt(1, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_VIEWS) + " *"); jbApply.setEnabled(true); viewPrivChanged = true; *************** *** 440,447 **** private void tablePrivilegeChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_tablePrivilegeChange // Add your handling code here: ! if (evt.getPropertyName() == CheckBoxPanel.SELECTION_MADE) { ! if (jpTablePriv.getChangedIndexes().length != 0 || jlTables.getSelectedIndices().length > 0) { jtpObjects.setTitleAt(0, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_TABLES) + " *"); jbApply.setEnabled(true); tablePrivChanged = true; --- 445,452 ---- private void tablePrivilegeChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_tablePrivilegeChange // Add your handling code here: ! if (evt.getPropertyName() == PrivilegesCheckBoxPanel.SELECTION_MADE) { ! if (jpTablePriv.getChangedIndexes().length != 0 || jlTables.getSelectedIndices().length > 1) { jtpObjects.setTitleAt(0, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_TABLES) + " *"); jbApply.setEnabled(true); tablePrivChanged = true; *************** *** 455,461 **** private void schemaPrivilegeChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_schemaPrivilegeChange // Add your handling code here: ! if (evt.getPropertyName() == CheckBoxPanel.SELECTION_MADE) { if (jpSchemaPriv.getChangedIndexes().length != 0) { jpSchema.setBorder(new javax.swing.border.TitledBorder(AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_SCHEMA) + " *")); jbApply.setEnabled(true); --- 460,466 ---- private void schemaPrivilegeChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_schemaPrivilegeChange // Add your handling code here: ! if (evt.getPropertyName() == PrivilegesCheckBoxPanel.SELECTION_MADE) { if (jpSchemaPriv.getChangedIndexes().length != 0) { jpSchema.setBorder(new javax.swing.border.TitledBorder(AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_SCHEMA) + " *")); jbApply.setEnabled(true); *************** *** 470,476 **** private void databasePrivilegeChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_databasePrivilegeChange // Add your handling code here: ! if (evt.getPropertyName() == CheckBoxPanel.SELECTION_MADE) { if (jpDatabasePriv.getChangedIndexes().length != 0) { jpDatabase.setBorder(new javax.swing.border.TitledBorder(AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_DATABASE) + " *")); jbApply.setEnabled(true); --- 475,481 ---- private void databasePrivilegeChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_databasePrivilegeChange // Add your handling code here: ! if (evt.getPropertyName() == PrivilegesCheckBoxPanel.SELECTION_MADE) { if (jpDatabasePriv.getChangedIndexes().length != 0) { jpDatabase.setBorder(new javax.swing.border.TitledBorder(AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_DATABASE) + " *")); jbApply.setEnabled(true); *************** *** 562,570 **** for (int i=0; i < privOfSelectedSchema.length; i++) { if (name.compareTo( privOfSelectedSchema[i][0]) == 0) { ! for (int j=1; j 1) { jtpObjects.setTitleAt(2, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_SEQUENCES) + " *"); ! jbApply.setEnabled(true); ! seqPrivChanged = true; } ! } else { ! jpSequencesPriv.setEnabled(false); ! jpSequencesPriv.reset(); ! seqPrivChanged = false; ! jtpObjects.setTitleAt(2, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_SEQUENCES)); ! updateApplyStatus(); ! } }//GEN-LAST:event_sequenceSelected private void viewSelected(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_viewSelected --- 895,912 ---- displayError(e.getMessage()); } ! } else if (jlSequences.getSelectedIndices().length > 1) { jtpObjects.setTitleAt(2, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_SEQUENCES) + " *"); ! jbApply.setEnabled(true); ! seqPrivChanged = true; } ! } else { ! jpSequencesPriv.setEnabled(false); ! jpSequencesPriv.reset(); ! seqPrivChanged = false; ! jtpObjects.setTitleAt(2, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_SEQUENCES)); ! updateApplyStatus(); ! } }//GEN-LAST:event_sequenceSelected private void viewSelected(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_viewSelected *************** *** 922,957 **** try { AdminDatabaseMetaData dbmd = this.backendClient.getAdminDatabaseMetaData(cluster,database); ! String[][] privOfSelectedView = backendClient.resultSetToStringArray(dbmd.getViewPrivileges(schema,view), (new ProcessLease())); ! ! ! for (int i=0; i < privOfSelectedView.length; i++) { if (name.compareTo( privOfSelectedView[i][0]) == 0) { ! for (int j=1; j 1) { jtpObjects.setTitleAt(1, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_VIEWS) + " *"); ! jbApply.setEnabled(true); ! viewPrivChanged = true; } ! } else { ! jpViewPriv.setEnabled(false); ! jpViewPriv.reset(); ! viewPrivChanged = false; ! jtpObjects.setTitleAt(1, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_VIEWS)); ! updateApplyStatus(); ! } }//GEN-LAST:event_viewSelected private void tableSelected(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_tableSelected --- 942,976 ---- try { AdminDatabaseMetaData dbmd = this.backendClient.getAdminDatabaseMetaData(cluster,database); ! String[][] privOfSelectedView = backendClient.resultSetToStringArray(dbmd.getViewPrivileges(schema,view), (new ProcessLease())); ! for (int i=0; i < privOfSelectedView.length; i++) { if (name.compareTo( privOfSelectedView[i][0]) == 0) { ! jpViewPriv.setSelectedBox(privOfSelectedView[i][1], true); ! ! if (privOfSelectedView[i][3].equals("YES")) { ! jpViewPriv.setSelectedSecondaryBox(privOfSelectedView[i][1], true); } ! } } } catch (Exception e) { e.printStackTrace(); displayError(e.getMessage()); } ! ! } else if (jlViews.getSelectedIndices().length > 1) { jtpObjects.setTitleAt(1, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_VIEWS) + " *"); ! jbApply.setEnabled(true); ! viewPrivChanged = true; } ! } else { ! jpViewPriv.setEnabled(false); ! jpViewPriv.reset(); ! viewPrivChanged = false; ! jtpObjects.setTitleAt(1, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_VIEWS)); ! updateApplyStatus(); ! } }//GEN-LAST:event_viewSelected private void tableSelected(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_tableSelected *************** *** 987,1006 **** try { AdminDatabaseMetaData dbmd = this.backendClient.getAdminDatabaseMetaData(cluster,database); ! String[][] privOfSelectedTable = backendClient.resultSetToStringArray(dbmd.getTablePrivileges(null, schema, table), (new ProcessLease())); for (int i=0; i < privOfSelectedTable.length; i++) { ! ! if (privOfSelectedTable[i][4] == null) ! continue; ! ! for (int k=i+1; k < privOfSelectedTable.length; k++) { ! if (privOfSelectedTable[k][4] != null && privOfSelectedTable[k][4].equals(name)) { ! jpTablePriv.setSelectedBox(privOfSelectedTable[k][5], true); } } - } --- 1006,1021 ---- try { AdminDatabaseMetaData dbmd = this.backendClient.getAdminDatabaseMetaData(cluster,database); ! String[][] privOfSelectedTable = backendClient.resultSetToStringArray(dbmd.getTablePrivileges(null, schema, table), (new ProcessLease())); for (int i=0; i < privOfSelectedTable.length; i++) { ! if (name.compareTo( privOfSelectedTable[i][4]) == 0) { ! jpTablePriv.setSelectedBox(privOfSelectedTable[i][5], true); ! if (privOfSelectedTable[i][6].equals("YES")) { ! jpTablePriv.setSelectedSecondaryBox(privOfSelectedTable[i][5], true); } } } *************** *** 1115,1132 **** if (dbPrivChanged) { ! String[] effectedPriveleges = jpDatabasePriv.getSelectedBoxes(); // Create new set including the privileges that were effected Hashtable privSet = new Hashtable(); ! for (int i = 0; i < effectedPriveleges.length; i++) { ! privSet.put(effectedPriveleges[i], effectedPriveleges[i]); } parameters.put(ObjectUpdate.PARAM_DATABASE_PRIVILEGES, privSet); - // Create new set including database that was effected Hashtable databaseSet = new Hashtable(); --- 1130,1154 ---- if (dbPrivChanged) { ! String[] effectedPriveleges = jpDatabasePriv.getPrimaryOnlySelectedBoxes(); ! String[] effectedWithGrantPrivileges = jpDatabasePriv.getSelectedSecondaryBoxes(); // Create new set including the privileges that were effected Hashtable privSet = new Hashtable(); ! for (int i = 0; i < effectedPriveleges.length; i++) { ! privSet.put(effectedPriveleges[i], effectedPriveleges[i]); ! } ! ! Hashtable withGrantPrivSet = new Hashtable(); ! ! for (int i = 0; i < effectedWithGrantPrivileges.length; i++) { ! withGrantPrivSet.put(effectedWithGrantPrivileges[i], effectedWithGrantPrivileges[i]); } parameters.put(ObjectUpdate.PARAM_DATABASE_PRIVILEGES, privSet); + parameters.put(ObjectUpdate.PARAM_DATABASE_PRIVILEGES_WITH_GRANT, withGrantPrivSet); // Create new set including database that was effected Hashtable databaseSet = new Hashtable(); *************** *** 1141,1147 **** if (schemaPrivChanged) { ! String[] effectedPriveleges = jpSchemaPriv.getSelectedBoxes(); // Create new set including the privileges that were effected --- 1163,1170 ---- if (schemaPrivChanged) { ! String[] effectedPriveleges = jpSchemaPriv.getPrimaryOnlySelectedBoxes(); ! String[] effectedWithGrantPrivileges = jpSchemaPriv.getSelectedSecondaryBoxes(); // Create new set including the privileges that were effected *************** *** 1150,1156 **** --- 1173,1186 ---- privSet.put(effectedPriveleges[i], effectedPriveleges[i]); } + Hashtable withGrantPrivSet = new Hashtable(); + + for (int i = 0; i < effectedWithGrantPrivileges.length; i++) { + withGrantPrivSet.put(effectedWithGrantPrivileges[i], effectedWithGrantPrivileges[i]); + } + parameters.put(ObjectUpdate.PARAM_SCHEMA_PRIVILEGES, privSet); + parameters.put(ObjectUpdate.PARAM_SCHEMA_PRIVILEGES_WITH_GRANT, withGrantPrivSet); // Create new set including schema that were effected *************** *** 1167,1174 **** if (tablePrivChanged) { ! String[] effectedPriveleges = jpTablePriv.getSelectedBoxes(); ! // Create new set including the privileges that were effected Hashtable privSet = new Hashtable(); --- 1197,1205 ---- if (tablePrivChanged) { ! String[] effectedPriveleges = jpTablePriv.getPrimaryOnlySelectedBoxes(); ! String[] effectedWithGrantPrivileges = jpTablePriv.getSelectedSecondaryBoxes(); ! // Create new set including the privileges that were effected Hashtable privSet = new Hashtable(); *************** *** 1176,1183 **** privSet.put(effectedPriveleges[i], effectedPriveleges[i]); } parameters.put(ObjectUpdate.PARAM_TABLE_PRIVILEGES, privSet); ! // Create new set including tables that were effected --- 1207,1220 ---- privSet.put(effectedPriveleges[i], effectedPriveleges[i]); } + Hashtable withGrantPrivSet = new Hashtable(); + + for (int i = 0; i < effectedWithGrantPrivileges.length; i++) { + withGrantPrivSet.put(effectedWithGrantPrivileges[i], effectedWithGrantPrivileges[i]); + } + parameters.put(ObjectUpdate.PARAM_TABLE_PRIVILEGES, privSet); ! parameters.put(ObjectUpdate.PARAM_TABLE_PRIVILEGES_WITH_GRANT, withGrantPrivSet); // Create new set including tables that were effected *************** *** 1196,1203 **** if (viewPrivChanged) { ! String[] effectedPriveleges = jpViewPriv.getSelectedBoxes(); ! // Create new set including the privileges that were effected Hashtable privSet = new Hashtable(); --- 1233,1241 ---- if (viewPrivChanged) { ! String[] effectedPriveleges = jpViewPriv.getPrimaryOnlySelectedBoxes(); ! String[] effectedWithGrantPrivileges = jpViewPriv.getSelectedSecondaryBoxes(); ! // Create new set including the privileges that were effected Hashtable privSet = new Hashtable(); *************** *** 1205,1212 **** privSet.put(effectedPriveleges[i], effectedPriveleges[i]); } parameters.put(ObjectUpdate.PARAM_VIEW_PRIVILEGES, privSet); ! // Create new set including views that were effected --- 1243,1256 ---- privSet.put(effectedPriveleges[i], effectedPriveleges[i]); } + Hashtable withGrantPrivSet = new Hashtable(); + + for (int i = 0; i < effectedWithGrantPrivileges.length; i++) { + withGrantPrivSet.put(effectedWithGrantPrivileges[i], effectedWithGrantPrivileges[i]); + } + parameters.put(ObjectUpdate.PARAM_VIEW_PRIVILEGES, privSet); ! parameters.put(ObjectUpdate.PARAM_VIEW_PRIVILEGES_WITH_GRANT, withGrantPrivSet); // Create new set including views that were effected *************** *** 1226,1233 **** if (seqPrivChanged) { ! String[] effectedPriveleges = jpSequencesPriv.getSelectedBoxes(); ! // Create new set including the privileges that were effected Hashtable privSet = new Hashtable(); --- 1270,1278 ---- if (seqPrivChanged) { ! String[] effectedPriveleges = jpSequencesPriv.getPrimaryOnlySelectedBoxes(); ! String[] effectedWithGrantPrivileges = jpSequencesPriv.getSelectedSecondaryBoxes(); ! // Create new set including the privileges that were effected Hashtable privSet = new Hashtable(); *************** *** 1236,1243 **** privSet.put(effectedPriveleges[i], effectedPriveleges[i]); } parameters.put(ObjectUpdate.PARAM_SEQUENCE_PRIVILEGES, privSet); ! // Get all the selected sequences --- 1281,1294 ---- privSet.put(effectedPriveleges[i], effectedPriveleges[i]); } + Hashtable withGrantPrivSet = new Hashtable(); + + for (int i = 0; i < effectedWithGrantPrivileges.length; i++) { + withGrantPrivSet.put(effectedWithGrantPrivileges[i], effectedWithGrantPrivileges[i]); + } + parameters.put(ObjectUpdate.PARAM_SEQUENCE_PRIVILEGES, privSet); ! parameters.put(ObjectUpdate.PARAM_SEQUENCE_PRIVILEGES_WITH_GRANT, withGrantPrivSet); // Get all the selected sequences *************** *** 1257,1263 **** if (langPrivChanged) { ! String[] effectedPriveleges = jpLanguagesPriv.getSelectedBoxes(); // Create new set including the privileges that were effected --- 1308,1315 ---- if (langPrivChanged) { ! String[] effectedPriveleges = jpLanguagesPriv.getPrimaryOnlySelectedBoxes(); ! String[] effectedWithGrantPrivileges = jpLanguagesPriv.getSelectedSecondaryBoxes(); // Create new set including the privileges that were effected *************** *** 1267,1274 **** privSet.put(effectedPriveleges[i], effectedPriveleges[i]); } parameters.put(ObjectUpdate.PARAM_LANGUAGE_PRIVILEGES, privSet); ! // Get all the selected items s --- 1319,1332 ---- privSet.put(effectedPriveleges[i], effectedPriveleges[i]); } + Hashtable withGrantPrivSet = new Hashtable(); + + for (int i = 0; i < effectedWithGrantPrivileges.length; i++) { + withGrantPrivSet.put(effectedWithGrantPrivileges[i], effectedWithGrantPrivileges[i]); + } + parameters.put(ObjectUpdate.PARAM_LANGUAGE_PRIVILEGES, privSet); ! parameters.put(ObjectUpdate.PARAM_LANGUAGE_PRIVILEGES_WITH_GRANT, withGrantPrivSet); // Get all the selected items s *************** *** 1287,1294 **** if (funcPrivChanged) { ! String[] effectedPriveleges = jpFunctionPriv.getSelectedBoxes(); ! // Create new set including the privileges that were effected --- 1345,1352 ---- if (funcPrivChanged) { ! String[] effectedPriveleges = jpFunctionPriv.getPrimaryOnlySelectedBoxes(); ! String[] effectedWithGrantPrivileges = jpFunctionPriv.getSelectedSecondaryBoxes(); // Create new set including the privileges that were effected *************** *** 1298,1305 **** privSet.put(effectedPriveleges[i], effectedPriveleges[i]); } parameters.put(ObjectUpdate.PARAM_FUNCTION_PRIVILEGES, privSet); ! // Get all the selected items s --- 1356,1370 ---- privSet.put(effectedPriveleges[i], effectedPriveleges[i]); } + Hashtable withGrantPrivSet = new Hashtable(); + + for (int i = 0; i < effectedWithGrantPrivileges.length; i++) { + withGrantPrivSet.put(effectedWithGrantPrivileges[i], effectedWithGrantPrivileges[i]); + } + parameters.put(ObjectUpdate.PARAM_FUNCTION_PRIVILEGES, privSet); ! parameters.put(ObjectUpdate.PARAM_FUNCTION_PRIVILEGES_WITH_GRANT, withGrantPrivSet); ! // Get all the selected items s *************** *** 1323,1354 **** jbApply.setEnabled(false); jtpObjects.setTitleAt(0, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_TABLES)); int[] justApplied = jpTablePriv.getSelectedIndexes(); jpTablePriv.reset(); jpTablePriv.setSelectedBoxes(justApplied, true); jtpObjects.setTitleAt(1, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_VIEWS)); justApplied = jpViewPriv.getSelectedIndexes(); jpViewPriv.reset(); jpViewPriv.setSelectedBoxes(justApplied, true); jtpObjects.setTitleAt(2, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_SEQUENCES)); justApplied = jpSequencesPriv.getSelectedIndexes(); jpSequencesPriv.reset(); jpSequencesPriv.setSelectedBoxes(justApplied, true); jtpObjects.setTitleAt(3, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_LANGUAGES)); justApplied = jpLanguagesPriv.getSelectedIndexes(); jpLanguagesPriv.reset(); jpLanguagesPriv.setSelectedBoxes(justApplied, true); jtpObjects.setTitleAt(4, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_FUNCTIONS)); justApplied = jpFunctionPriv.getSelectedIndexes(); ! jpFunctionPriv.reset(); jpFunctionPriv.setSelectedBoxes(justApplied, true); jpDatabase.setBorder(new javax.swing.border.TitledBorder(AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_DATABASE))); justApplied = jpDatabasePriv.getSelectedIndexes(); ! jpDatabasePriv.reset(); jpDatabasePriv.setSelectedBoxes(justApplied, true); jpSchema.setBorder(new javax.swing.border.TitledBorder(AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_SCHEMA))); justApplied = jpSchemaPriv.getSelectedIndexes(); ! jpSchemaPriv.reset(); jpSchemaPriv.setSelectedBoxes(justApplied, true); } catch (ObjectUpdateException e) { e.printStackTrace(); --- 1388,1433 ---- jbApply.setEnabled(false); jtpObjects.setTitleAt(0, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_TABLES)); int[] justApplied = jpTablePriv.getSelectedIndexes(); + int[] justAppliedOptions = jpTablePriv.getSelectedSecondaryIndexes(); jpTablePriv.reset(); jpTablePriv.setSelectedBoxes(justApplied, true); + jpTablePriv.setSelectedSecondaryBoxes(justAppliedOptions, true); jtpObjects.setTitleAt(1, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_VIEWS)); justApplied = jpViewPriv.getSelectedIndexes(); + justAppliedOptions = jpViewPriv.getSelectedSecondaryIndexes(); jpViewPriv.reset(); jpViewPriv.setSelectedBoxes(justApplied, true); + jpViewPriv.setSelectedSecondaryBoxes(justAppliedOptions, true); jtpObjects.setTitleAt(2, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_SEQUENCES)); justApplied = jpSequencesPriv.getSelectedIndexes(); + justAppliedOptions = jpSequencesPriv.getSelectedSecondaryIndexes(); jpSequencesPriv.reset(); jpSequencesPriv.setSelectedBoxes(justApplied, true); + jpSequencesPriv.setSelectedSecondaryBoxes(justAppliedOptions, true); jtpObjects.setTitleAt(3, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_LANGUAGES)); justApplied = jpLanguagesPriv.getSelectedIndexes(); + justAppliedOptions = jpLanguagesPriv.getSelectedSecondaryIndexes(); jpLanguagesPriv.reset(); jpLanguagesPriv.setSelectedBoxes(justApplied, true); + jpLanguagesPriv.setSelectedSecondaryBoxes(justAppliedOptions, true); jtpObjects.setTitleAt(4, AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_FUNCTIONS)); justApplied = jpFunctionPriv.getSelectedIndexes(); ! justAppliedOptions = jpFunctionPriv.getSelectedSecondaryIndexes(); ! jpFunctionPriv.reset(); jpFunctionPriv.setSelectedBoxes(justApplied, true); + jpFunctionPriv.setSelectedSecondaryBoxes(justAppliedOptions, true); jpDatabase.setBorder(new javax.swing.border.TitledBorder(AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_DATABASE))); justApplied = jpDatabasePriv.getSelectedIndexes(); ! justAppliedOptions = jpDatabasePriv.getSelectedSecondaryIndexes(); ! jpDatabasePriv.reset(); jpDatabasePriv.setSelectedBoxes(justApplied, true); + jpDatabasePriv.setSelectedSecondaryBoxes(justAppliedOptions, true); jpSchema.setBorder(new javax.swing.border.TitledBorder(AdminResources.getString(AdminResources.DLG_MANAGE_PRIVILEGES_SCHEMA))); justApplied = jpSchemaPriv.getSelectedIndexes(); ! justAppliedOptions = jpSchemaPriv.getSelectedSecondaryIndexes(); ! jpSchemaPriv.reset(); jpSchemaPriv.setSelectedBoxes(justApplied, true); + jpSchemaPriv.setSelectedSecondaryBoxes(justAppliedOptions, true); } catch (ObjectUpdateException e) { e.printStackTrace(); *************** *** 1386,1391 **** --- 1465,1472 ---- private static String[] funcOptions; private static String[] langOptions; private static String[] options; + + private String grantOptionString = ""; // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jbApply; *************** *** 1400,1413 **** private javax.swing.JList jlViews; private javax.swing.JPanel jpButtons; private javax.swing.JPanel jpDatabase; ! private com.redhat.rhdb.admin.CheckBoxPanel jpDatabasePriv; ! private com.redhat.rhdb.admin.CheckBoxPanel jpFunctionPriv; ! private com.redhat.rhdb.admin.CheckBoxPanel jpLanguagesPriv; private javax.swing.JPanel jpSchema; ! private com.redhat.rhdb.admin.CheckBoxPanel jpSchemaPriv; ! private com.redhat.rhdb.admin.CheckBoxPanel jpSequencesPriv; ! private com.redhat.rhdb.admin.CheckBoxPanel jpTablePriv; ! private com.redhat.rhdb.admin.CheckBoxPanel jpViewPriv; private javax.swing.JScrollPane jscFunctions; private javax.swing.JScrollPane jscLanguages; private javax.swing.JScrollPane jscSequences; --- 1481,1494 ---- private javax.swing.JList jlViews; private javax.swing.JPanel jpButtons; private javax.swing.JPanel jpDatabase; ! private com.redhat.rhdb.admin.PrivilegesCheckBoxPanel jpDatabasePriv; ! private com.redhat.rhdb.admin.PrivilegesCheckBoxPanel jpFunctionPriv; ! private com.redhat.rhdb.admin.PrivilegesCheckBoxPanel jpLanguagesPriv; private javax.swing.JPanel jpSchema; ! private com.redhat.rhdb.admin.PrivilegesCheckBoxPanel jpSchemaPriv; ! private com.redhat.rhdb.admin.PrivilegesCheckBoxPanel jpSequencesPriv; ! private com.redhat.rhdb.admin.PrivilegesCheckBoxPanel jpTablePriv; ! private com.redhat.rhdb.admin.PrivilegesCheckBoxPanel jpViewPriv; private javax.swing.JScrollPane jscFunctions; private javax.swing.JScrollPane jscLanguages; private javax.swing.JScrollPane jscSequences; Index: src/com/redhat/rhdb/admin/ObjectUpdate.java =================================================================== RCS file: /cvs/rhdb/src/rhdb/guitools/rhdb-admin/src/com/redhat/rhdb/admin/ObjectUpdate.java,v retrieving revision 1.2 diff -c -r1.2 ObjectUpdate.java *** src/com/redhat/rhdb/admin/ObjectUpdate.java 4 May 2004 16:57:15 -0000 1.2 --- src/com/redhat/rhdb/admin/ObjectUpdate.java 9 Jun 2004 05:39:23 -0000 *************** *** 220,231 **** --- 220,238 ---- public static final String PARAM_PUBLIC = "public"; public static final String PARAM_DATABASE_PRIVILEGES = "database.privileges"; + public static final String PARAM_DATABASE_PRIVILEGES_WITH_GRANT = "database.privileges.with.grant"; public static final String PARAM_SCHEMA_PRIVILEGES = "schema.privileges"; + public static final String PARAM_SCHEMA_PRIVILEGES_WITH_GRANT = "schema.privileges.with.grant"; public static final String PARAM_TABLE_PRIVILEGES = "table.privileges"; + public static final String PARAM_TABLE_PRIVILEGES_WITH_GRANT = "table.privileges.with.grant"; public static final String PARAM_VIEW_PRIVILEGES = "view.privileges"; + public static final String PARAM_VIEW_PRIVILEGES_WITH_GRANT = "view.privileges.with.grant"; public static final String PARAM_SEQUENCE_PRIVILEGES = "sequence.privileges"; + public static final String PARAM_SEQUENCE_PRIVILEGES_WITH_GRANT = "sequence.privileges.with.grant"; public static final String PARAM_LANGUAGE_PRIVILEGES = "language.privileges"; + public static final String PARAM_LANGUAGE_PRIVILEGES_WITH_GRANT = "language.privileges.with.grant"; public static final String PARAM_FUNCTION_PRIVILEGES = "function.privileges"; + public static final String PARAM_FUNCTION_PRIVILEGES_WITH_GRANT = "function.privileges.with.grant"; public static final String PARAM_RULE_NAME = "rule.name"; public static final String PARAM_RELATION_NAME = "relation.name"; Index: src/com/redhat/rhdb/admin/PrivilegesUpdate.java =================================================================== RCS file: /cvs/rhdb/src/rhdb/guitools/rhdb-admin/src/com/redhat/rhdb/admin/PrivilegesUpdate.java,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 PrivilegesUpdate.java *** src/com/redhat/rhdb/admin/PrivilegesUpdate.java 21 Nov 2003 18:30:23 -0000 1.1.1.1 --- src/com/redhat/rhdb/admin/PrivilegesUpdate.java 9 Jun 2004 05:39:24 -0000 *************** *** 1,5 **** /** ! * Copyright (c) 2003 Red Hat, Inc. All rights reserved. * This software may be freely redistributed under the terms of the * GNU General Public License. * --- 1,5 ---- /** ! * Copyright (c) 2003, 2004 Red Hat, Inc. All rights reserved. * This software may be freely redistributed under the terms of the * GNU General Public License. * *************** *** 149,155 **** // that the dialog always gives the non-optional parameters before its // too late. ! String[] requiredParameters = {PARAM_CLUSTER_NAME, PARAM_DB_NAME, PARAM_FUNCTIONS, PARAM_SCHEMA_NAME, PARAM_USERS, PARAM_GROUPS, PARAM_FUNCTION_PRIVILEGES}; String[] optionalParameters = {PARAM_PUBLIC}; String updateString = ""; String functionList = ""; --- 149,155 ---- // that the dialog always gives the non-optional parameters before its // too late. ! String[] requiredParameters = {PARAM_CLUSTER_NAME, PARAM_DB_NAME, PARAM_FUNCTIONS, PARAM_SCHEMA_NAME, PARAM_USERS, PARAM_GROUPS, PARAM_FUNCTION_PRIVILEGES, PARAM_FUNCTION_PRIVILEGES_WITH_GRANT }; String[] optionalParameters = {PARAM_PUBLIC}; String updateString = ""; String functionList = ""; *************** *** 235,240 **** --- 235,260 ---- } + Object[] privilegesWithGrant = ((Hashtable) parameters.get(PARAM_FUNCTION_PRIVILEGES_WITH_GRANT)).values().toArray(); + + if (privilegesWithGrant.length != 0) { + + // Add grant call + updateString += "GRANT "; + + for (int i = 0; i < privilegesWithGrant.length; i++) { + + updateString += privilegesWithGrant[i]; + + if (i < privilegesWithGrant.length - 1) + updateString += ", "; + + } + + updateString += " ON FUNCTION " + functionList + " TO " + userList + " WITH GRANT OPTION; "; + + } + return updateString; *************** *** 343,348 **** --- 363,388 ---- } + Object[] privilegesWithGrant = ((Hashtable) parameters.get(PARAM_LANGUAGE_PRIVILEGES_WITH_GRANT)).values().toArray(); + + if (privilegesWithGrant.length != 0) { + + // Add grant call + updateString += "GRANT "; + + for (int i = 0; i < privilegesWithGrant.length; i++) { + + updateString += privilegesWithGrant[i]; + + if (i < privilegesWithGrant.length - 1) + updateString += ", "; + + } + + updateString += " ON LANGUAGE " + languageList + " TO " + userList + " WITH GRANT OPTION; "; + + } + return updateString; } *************** *** 362,368 **** // that the dialog always gives the non-optional parameters before its // too late. ! String[] requiredParameters = {PARAM_CLUSTER_NAME, PARAM_DB_NAME, PARAM_VIEWS, PARAM_SCHEMA_NAME, PARAM_USERS, PARAM_GROUPS, PARAM_VIEW_PRIVILEGES}; String[] optionalParameters = {PARAM_PUBLIC}; String updateString = ""; String viewList = ""; --- 402,408 ---- // that the dialog always gives the non-optional parameters before its // too late. ! String[] requiredParameters = {PARAM_CLUSTER_NAME, PARAM_DB_NAME, PARAM_VIEWS, PARAM_SCHEMA_NAME, PARAM_USERS, PARAM_GROUPS, PARAM_VIEW_PRIVILEGES, PARAM_VIEW_PRIVILEGES_WITH_GRANT }; String[] optionalParameters = {PARAM_PUBLIC}; String updateString = ""; String viewList = ""; *************** *** 451,457 **** } ! return updateString; } --- 491,517 ---- } ! Object[] privilegesWithGrant = ((Hashtable) parameters.get(PARAM_VIEW_PRIVILEGES_WITH_GRANT)).values().toArray(); ! ! if (privilegesWithGrant.length != 0) { ! ! // Add grant call ! updateString += "GRANT "; ! ! for (int i = 0; i < privilegesWithGrant.length; i++) { ! ! updateString += privilegesWithGrant[i]; ! ! if (i < privilegesWithGrant.length - 1) ! updateString += ", "; ! ! } ! ! updateString += " ON TABLE " + viewList + " TO " + userList + " WITH GRANT OPTION; "; ! ! } ! ! return updateString; } *************** *** 469,475 **** // that the dialog always gives the non-optional parameters before its // too late. ! String[] requiredParameters = {PARAM_CLUSTER_NAME, PARAM_DB_NAME, PARAM_SEQUENCES, PARAM_SCHEMA_NAME, PARAM_USERS, PARAM_GROUPS, PARAM_SEQUENCE_PRIVILEGES}; String[] optionalParameters = {PARAM_PUBLIC}; String updateString = ""; String sequenceList = ""; --- 529,535 ---- // that the dialog always gives the non-optional parameters before its // too late. ! String[] requiredParameters = {PARAM_CLUSTER_NAME, PARAM_DB_NAME, PARAM_SEQUENCES, PARAM_SCHEMA_NAME, PARAM_USERS, PARAM_GROUPS, PARAM_SEQUENCE_PRIVILEGES, PARAM_SEQUENCE_PRIVILEGES_WITH_GRANT }; String[] optionalParameters = {PARAM_PUBLIC}; String updateString = ""; String sequenceList = ""; *************** *** 555,561 **** } ! return updateString; } --- 615,641 ---- } ! Object[] privilegesWithGrant = ((Hashtable) parameters.get(PARAM_SEQUENCE_PRIVILEGES_WITH_GRANT)).values().toArray(); ! ! if (privilegesWithGrant.length != 0) { ! ! // Add grant call ! updateString += "GRANT "; ! ! for (int i = 0; i < privilegesWithGrant.length; i++) { ! ! updateString += privilegesWithGrant[i]; ! ! if (i < privilegesWithGrant.length - 1) ! updateString += ", "; ! ! } ! ! updateString += " ON TABLE " + sequenceList + " TO " + userList + " WITH GRANT OPTION; "; ! ! } ! ! return updateString; } *************** *** 573,579 **** // that the dialog always gives the non-optional parameters before its // too late. ! String[] requiredParameters = {PARAM_CLUSTER_NAME, PARAM_DB_NAME, PARAM_DATABASES, PARAM_USERS, PARAM_GROUPS, PARAM_DATABASE_PRIVILEGES}; String[] optionalParameters = {PARAM_PUBLIC}; String updateString = ""; String databaseList = ""; --- 653,659 ---- // that the dialog always gives the non-optional parameters before its // too late. ! String[] requiredParameters = {PARAM_CLUSTER_NAME, PARAM_DB_NAME, PARAM_DATABASES, PARAM_USERS, PARAM_GROUPS, PARAM_DATABASE_PRIVILEGES, PARAM_DATABASE_PRIVILEGES_WITH_GRANT }; String[] optionalParameters = {PARAM_PUBLIC}; String updateString = ""; String databaseList = ""; *************** *** 658,663 **** --- 738,762 ---- } + Object[] privilegesWithGrant = ((Hashtable) parameters.get(PARAM_DATABASE_PRIVILEGES_WITH_GRANT)).values().toArray(); + + if (privilegesWithGrant.length != 0) { + + // Add grant call + updateString += "GRANT "; + + for (int i = 0; i < privilegesWithGrant.length; i++) { + + updateString += privilegesWithGrant[i]; + + if (i < privilegesWithGrant.length - 1) + updateString += ", "; + + } + + updateString += " ON DATABASE " + databaseList + " TO " + userList + " WITH GRANT OPTION; "; + } + return updateString; } *************** *** 675,681 **** // that the dialog always gives the non-optional parameters before its // too late. ! String[] requiredParameters = {PARAM_CLUSTER_NAME, PARAM_DB_NAME, PARAM_SCHEMAS, PARAM_USERS, PARAM_GROUPS, PARAM_SCHEMA_PRIVILEGES}; String[] optionalParameters = {PARAM_PUBLIC}; String updateString = ""; String schemaList = ""; --- 774,780 ---- // that the dialog always gives the non-optional parameters before its // too late. ! String[] requiredParameters = {PARAM_CLUSTER_NAME, PARAM_DB_NAME, PARAM_SCHEMAS, PARAM_USERS, PARAM_GROUPS, PARAM_SCHEMA_PRIVILEGES, PARAM_SCHEMA_PRIVILEGES_WITH_GRANT }; String[] optionalParameters = {PARAM_PUBLIC}; String updateString = ""; String schemaList = ""; *************** *** 760,765 **** --- 859,884 ---- } + Object[] privilegesWithGrant = ((Hashtable) parameters.get(PARAM_SCHEMA_PRIVILEGES_WITH_GRANT)).values().toArray(); + + if (privilegesWithGrant.length != 0) { + + // Add grant call + updateString += "GRANT "; + + for (int i = 0; i < privilegesWithGrant.length; i++) { + + updateString += privilegesWithGrant[i]; + + if (i < privilegesWithGrant.length - 1) + updateString += ", "; + + } + + updateString += " ON SCHEMA " + schemaList + " TO " + userList + " WITH GRANT OPTION; "; + + } + return updateString; } *************** *** 777,783 **** // that the dialog always gives the non-optional parameters before its // too late. ! String[] requiredParameters = {PARAM_CLUSTER_NAME, PARAM_DB_NAME, PARAM_TABLES, PARAM_SCHEMA_NAME, PARAM_USERS, PARAM_GROUPS, PARAM_TABLE_PRIVILEGES}; String[] optionalParameters = {PARAM_PUBLIC}; String updateString = ""; String tableList = ""; --- 896,902 ---- // that the dialog always gives the non-optional parameters before its // too late. ! String[] requiredParameters = {PARAM_CLUSTER_NAME, PARAM_DB_NAME, PARAM_TABLES, PARAM_SCHEMA_NAME, PARAM_USERS, PARAM_GROUPS, PARAM_TABLE_PRIVILEGES, PARAM_TABLE_PRIVILEGES_WITH_GRANT }; String[] optionalParameters = {PARAM_PUBLIC}; String updateString = ""; String tableList = ""; *************** *** 863,868 **** --- 982,1007 ---- } + Object[] privilegesWithGrant = ((Hashtable) parameters.get(PARAM_TABLE_PRIVILEGES_WITH_GRANT)).values().toArray(); + + if (privilegesWithGrant.length != 0) { + + // Add grant call + updateString += "GRANT "; + + for (int i = 0; i < privilegesWithGrant.length; i++) { + + updateString += privilegesWithGrant[i]; + + if (i < privilegesWithGrant.length - 1) + updateString += ", "; + + } + + updateString += " ON TABLE " + tableList + " TO " + userList + " WITH GRANT OPTION; "; + + } + return updateString; } } Index: src/com/redhat/rhdb/admin/pgsql/AbstractRhdb73DatabaseMetaData.java =================================================================== RCS file: /cvs/rhdb/src/rhdb/guitools/rhdb-admin/src/com/redhat/rhdb/admin/pgsql/AbstractRhdb73DatabaseMetaData.java,v retrieving revision 1.2 diff -c -r1.2 AbstractRhdb73DatabaseMetaData.java *** src/com/redhat/rhdb/admin/pgsql/AbstractRhdb73DatabaseMetaData.java 4 May 2004 16:57:15 -0000 1.2 --- src/com/redhat/rhdb/admin/pgsql/AbstractRhdb73DatabaseMetaData.java 9 Jun 2004 05:39:28 -0000 *************** *** 15,21 **** import java.sql.*; import java.util.*; import org.postgresql.jdbc3.*; ! import org.postgresql.Field; import com.redhat.rhdb.admin.utils.AdminNamedObject; --- 15,21 ---- import java.sql.*; import java.util.*; import org.postgresql.jdbc3.*; ! import org.postgresql.core.*; import com.redhat.rhdb.admin.utils.AdminNamedObject; *************** *** 982,996 **** public ResultSet getDatabasePrivileges(String dbName) throws SQLException { String sql; ! Field f[] = new Field[2]; Vector v = new Vector(); f[0] = new Field(connection, "GRANTEE", iVarcharOid, getMaxNameLength()); f[1] = new Field(connection, "PRIVILEGE", iVarcharOid, getMaxNameLength()); - sql = "SELECT d.datacl from pg_database d WHERE datname='" + escapeQuotes(dbName) + "' "; - ResultSet rs = connection.createStatement().executeQuery(sql); while (rs.next()) { --- 982,999 ---- public ResultSet getDatabasePrivileges(String dbName) throws SQLException { String sql; ! Field f[] = new Field[4]; Vector v = new Vector(); f[0] = new Field(connection, "GRANTEE", iVarcharOid, getMaxNameLength()); f[1] = new Field(connection, "PRIVILEGE", iVarcharOid, getMaxNameLength()); + f[2] = new Field(connection, "GRANTOR", iVarcharOid, getMaxNameLength()); + f[3] = new Field(connection, "IS_GRANTABLE", iVarcharOid, getMaxNameLength()); + + sql = "SELECT d.datacl, u.usename from pg_database d, pg_user u " + + " WHERE datname='" + escapeQuotes(dbName) + "' AND u.usesysid=d.datdba"; ResultSet rs = connection.createStatement().executeQuery(sql); while (rs.next()) { *************** *** 999,1005 **** //get the values of array String acl = rs.getString(1); ! //parse acl array and put its values into a hashtable that has //keys as the privileges names and values are the grantee of the privileges --- 1002,1009 ---- //get the values of array String acl = rs.getString(1); ! String owner = rs.getString(2); ! //parse acl array and put its values into a hashtable that has //keys as the privileges names and values are the grantee of the privileges *************** *** 1019,1040 **** i++; } //for every permission get the user or group name for (i=0; iOnly privileges matching the schema and table name + * criteria are returned. They are ordered by TABLE_SCHEM, + * TABLE_NAME, and PRIVILEGE. + * + *

Each privilige description has the following columns: + *

    + *
  1. TABLE_CAT String => table catalog (may be null) + *
  2. TABLE_SCHEM String => table schema (may be null) + *
  3. TABLE_NAME String => table name + *
  4. GRANTOR => grantor of access (may be null) + *
  5. GRANTEE String => grantee of access + *
  6. PRIVILEGE String => name of access (SELECT, + * INSERT, UPDATE, REFRENCES, ...) + *
  7. IS_GRANTABLE String => "YES" if grantee is permitted + * to grant to others; "NO" if not; null if unknown + *
+ * + * @param catalog a catalog name; "" retrieves those without a catalog + * @param schemaPattern a schema name pattern; "" retrieves those + * without a schema + * @param tableNamePattern a table name pattern + * @return ResultSet each row is a table privilege description + * @see #getSearchStringEscape + */ + public java.sql.ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) throws SQLException + { + Field f[] = new Field[7]; + Vector v = new Vector(); + + f[0] = new Field(connection, "TABLE_CAT", iVarcharOid, getMaxNameLength()); + f[1] = new Field(connection, "TABLE_SCHEM", iVarcharOid, getMaxNameLength()); + f[2] = new Field(connection, "TABLE_NAME", iVarcharOid, getMaxNameLength()); + f[3] = new Field(connection, "GRANTOR", iVarcharOid, getMaxNameLength()); + f[4] = new Field(connection, "GRANTEE", iVarcharOid, getMaxNameLength()); + f[5] = new Field(connection, "PRIVILEGE", iVarcharOid, getMaxNameLength()); + f[6] = new Field(connection, "IS_GRANTABLE", iVarcharOid, getMaxNameLength()); + + String sql; + if (connection.haveMinimumServerVersion("7.3")) { + sql = "SELECT n.nspname,c.relname,u.usename,c.relacl "+ + " FROM pg_catalog.pg_namespace n, pg_catalog.pg_class c, pg_catalog.pg_user u "+ + " WHERE c.relnamespace = n.oid "+ + " AND u.usesysid = c.relowner "+ + " AND c.relkind = 'r' "; + if (schemaPattern != null && !"".equals(schemaPattern)) { + sql += " AND n.nspname LIKE '"+escapeQuotes(schemaPattern)+"' "; + } + } else { + sql = "SELECT NULL::text AS nspname,c.relname,u.usename,c.relacl "+ + "FROM pg_class c, pg_user u "+ + " WHERE u.usesysid = c.relowner "+ + " AND c.relkind = 'r' "; + } + + if (tableNamePattern != null && !"".equals(tableNamePattern)) { + sql += " AND c.relname LIKE '"+escapeQuotes(tableNamePattern)+"' "; + } + sql += " ORDER BY nspname, relname "; + + ResultSet rs = connection.createStatement().executeQuery(sql); + while (rs.next()) { + byte schema[] = rs.getBytes("nspname"); + byte table[] = rs.getBytes("relname"); + String owner = rs.getString("usename"); + String acl = rs.getString("relacl"); + Hashtable permissions = parseACL(acl, owner); + String permNames[] = new String[permissions.size()]; + Enumeration e = permissions.keys(); + int i=0; + while (e.hasMoreElements()) { + permNames[i++] = (String)e.nextElement(); + } + Arrays.sort(permNames); + for (i=0; iString array containing the components of the ACL string. ! */ ! ! private static String[] getACLComponents(String aclString) { ! ! ! if (aclString.startsWith("\"") && aclString.endsWith("\"")) { ! aclString = aclString.substring(1,aclString.length()-1); ! } ! ! boolean permissionsProcessed = false; ! boolean passedEqualSign = false; ! String[] aclComponents = {"", "", ""}; ! ! boolean inQuotes = false; ! // start at 1 because of leading "{" ! int beginIndex = 0; ! char prevChar = ' '; ! ! for (int i=beginIndex; i GRANTOR ends here ! ! aclComponents[0]=aclString.substring(beginIndex, i); ! ! beginIndex = i+1; ! ! passedEqualSign = true; ! ! } else if (c == '/' && !inQuotes && passedEqualSign) { ! ! // '/' and not in quotes AND equal sign passed => ! // permissions end here. ! ! // We need a check for equal sign passed because in 7.3 ! // and lower, user names with "=" are in quotes, but ! // user names with "/" aren't, which will cause a check ! // without 'passedEqualSign' to go through, even though it ! // is wrong! ! ! aclComponents[1]=aclString.substring(beginIndex, i); ! ! beginIndex = i+1; ! ! permissionsProcessed = true; ! ! } else if (i == aclString.length()-1) { ! ! // If permissions have already been encountered, this is ! // the grantor (7.4+).. else it's permissions (7.3-) ! ! if (permissionsProcessed) { ! aclComponents[2]=aclString.substring(beginIndex); ! } else { ! aclComponents[1]=aclString.substring(beginIndex); ! ! // GRANTOR unknown.. most likely means owner is ! // grantor.. but let caller make that decision ! ! aclComponents[2] = ""; ! } ! ! } ! ! prevChar = c; ! } ! ! return aclComponents; ! ! } ! ! /** ! * Parse an String of ACLs into a Vector of ACLs. ! */ ! private static Vector parseACLArray(String aclString) { ! Vector acls = new Vector(); ! if (aclString == null || aclString.length() == 0) { ! return acls; ! } ! boolean inQuotes = false; ! // start at 1 because of leading "{" ! int beginIndex = 1; ! char prevChar = ' '; ! for (int i=beginIndex; i