Revision: 3816
Author: [email protected]
Date: Fri Jul 30 08:32:41 2010
Log: NEW - bug 2917: Exceptions when editing security settings
http://trillian.sqlpower.ca/bugzilla/show_bug.cgi?id=2917

Fixed the bug where having multiple Grants within a Group that refer to an ArchitectSwingProject, and opening the GroupEditorPanel would throw an exception. This was caused by the change in definition of what a system level Grant is. A system level grant must have a null subject. The check has been changed so that only 1 system level ArchitectSwingProject Grant is allowed.

Also, added documentation to PrivilegesEditorPanel.
http://code.google.com/p/power-architect/source/detail?r=3816

Modified:
/trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/GroupEditorPanel.java /trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/PrivilegesEditorPanel.java

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/GroupEditorPanel.java Wed Jul 28 07:26:33 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/GroupEditorPanel.java Fri Jul 30 08:32:41 2010
@@ -163,9 +163,11 @@

         Grant globalGrant = null;
         for (Grant grant : baseGroup.getChildren(Grant.class)) {
- if (grant.getType() != null && grant.getType().equals(ArchitectSwingProject.class.getName())) {
+            if (grant.isSystemLevel() && grant.getType() != null &&
+ grant.getType().equals(ArchitectSwingProject.class.getName())) {
                 if (globalGrant != null) {
- throw new IllegalStateException("Multiple grants for Architect Project found");
+                    throw new IllegalStateException(
+ "Multiple grants for system level workspace under the same group found.");
                 }

                 globalGrant = grant;
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/PrivilegesEditorPanel.java Fri Jun 25 12:24:11 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/PrivilegesEditorPanel.java Fri Jul 30 08:32:41 2010
@@ -40,6 +40,10 @@
 import com.jgoodies.forms.layout.CellConstraints;
 import com.jgoodies.forms.layout.FormLayout;

+/**
+ * This {...@link DataEntryPanel} is used for modifying system level privileges on
+ * the server.
+ */
 public class PrivilegesEditorPanel implements DataEntryPanel {

     private Grant grant;
@@ -66,7 +70,30 @@
     private final ArchitectSwingProject securityWorkspace;

     private boolean hasUnsavedChanges = false;
-
+
+    /**
+     * Creates a new {...@link PrivilegesEditorPanel}.
+     *
+     * @param baseGrant
+ * The {...@link Grant} object which the privileges panel should
+     *            start off with.
+     * @param baseGroupOrUser
+     *            The {...@link Group} or {...@link User} object that the
+     *            {...@link Grant} applies to.
+     * @param subject
+ * The UUID of the object we want to grant access to. This can be
+     *            null if {...@link #type} is specified.
+     * @param type
+ * The fully qualified name of the class of object we want to
+     *            grant access to.
+     * @param username
+     *            The username of the person accessing this panel. Certain
+     *            functionality of the panel is disabled depending on what
+     *            privileges this user has.
+     * @param securityWorkspace
+ * The {...@link ArchitectSwingProject} that represents the security
+     *            workspace.
+     */
public PrivilegesEditorPanel(Grant baseGrant, SPObject baseGroupOrUser, String subject, String type, String username, ArchitectSwingProject securityWorkspace) {
         this.securityWorkspace = securityWorkspace;
         this.grant = baseGrant;
@@ -202,6 +229,10 @@
         }
     }

+    /**
+ * Disables the privilege {...@link JCheckBox}es if the user accessing this
+     * panel is authorized to modify them.
+     */
     public void disableIfNecessary() {
         User user = null;
         List<Grant> grantsForUser = new ArrayList<Grant>();

Reply via email to