modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java | 25 ++-------- modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleGroup.java | 6 +- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java | 1 3 files changed, 10 insertions(+), 22 deletions(-)
New commits: commit 3b6937932d7b9eadcad387a44bad1adeacea1a7a Author: Jay Shaughnessy jshaughn@redhat.com Date: Mon Aug 19 10:34:48 2013 -0400
reverse the inverse relationship setting because as is Role.setBundleGroups would fail when trying to deserialize a bundle group update. (when calling updateRole)
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java index 3f4c136..ed72d5f 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java @@ -190,7 +190,6 @@ public class Role implements Serializable { }
public void addPermission(Permission permission) { - // permission.setRole(this); this.permissions.add(permission); }
@@ -229,7 +228,6 @@ public class Role implements Serializable { this.subjects = subjects; for (Subject subject : subjects) { subject.addRole(this); - this.subjects.add(subject); } } } @@ -286,37 +284,25 @@ public class Role implements Serializable { }
/** - * This also updates the inverse relations (add this role to bundle groups) - * @param bundleGroups + * This *does not* update the inverse relation. You may want {@link BundleGroup#addRole(Role)} */ public void setBundleGroups(Set<BundleGroup> bundleGroups) { - if (bundleGroups == null) { - this.bundleGroups = new HashSet<BundleGroup>(); - } else { - this.bundleGroups = bundleGroups; - for (BundleGroup bundleGroup : this.bundleGroups) { - bundleGroup.addRole(this); - this.bundleGroups.add(bundleGroup); - } - } + this.bundleGroups = bundleGroups; }
/** - * This also updates the inverse relation (add this role to bundle group) - * @param bundleGroup + * This *does not* update the inverse relation. You may want {@link BundleGroup#addRole(Role)} */ + public void addBundleGroup(BundleGroup bundleGroup) { getBundleGroups().add(bundleGroup); - bundleGroup.addRole(this); }
/** - * This also updates the inverse relation (remove this role from bundle group) - * @param bundleGroup + * This *does not* update the inverse relation. You may want {@link BundleGroup#removeRole(Role)} */ public void removeBundleGroup(BundleGroup bundleGroup) { getBundleGroups().remove(bundleGroup); - bundleGroup.removeRole(this); }
public Set<ResourceGroup> getResourceGroups() { @@ -330,7 +316,6 @@ public class Role implements Serializable { this.resourceGroups = resourceGroups; for (ResourceGroup resourceGroup : this.resourceGroups) { resourceGroup.addRole(this); - this.resourceGroups.add(resourceGroup); } } } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleGroup.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleGroup.java index dd6a824..e290f46 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleGroup.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleGroup.java @@ -165,18 +165,20 @@ public class BundleGroup implements Serializable { }
/** - * This *does not* update the inverse relation. You may want {@link Role#addBundleGroup(BundleGroup)} + * This also updates the inverse relation (add this bundle group to role) * @param role */ public void addRole(Role role) { getRoles().add(role); + role.addBundleGroup(this); }
/** - * This *does not* update the inverse relation. You may want {@link Role#removeBundleGroup(BundleGroup)} + * This also updates the inverse relation (remove this bundle group from role) * @param role */ public boolean removeRole(Role role) { + role.removeBundleGroup(this); return getRoles().remove(role); }
commit ef1a138b14ce0742576c9ff886f62b3feae82f8d Author: Jay Shaughnessy jshaughn@redhat.com Date: Mon Aug 19 10:33:19 2013 -0400
Make sure to fetch the bundle groups so the selector is correctly seeded.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java index 047dacc..3e1fed4 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java @@ -320,6 +320,7 @@ public class RolesDataSource extends RPCDataSource<Role, RoleCriteria> { criteria.fetchSubjects(true); criteria.fetchResourceGroups(true); criteria.fetchLdapGroups(true); + criteria.fetchBundleGroups(true); }
// TODO: instead of fetching subjects and resource groups, use a composite object that will pull the subject
rhq-commits@lists.fedorahosted.org