if (!this.isSystemRole) {
Record[] groupRecords = record.getAttributeAsRecordArray(RolesDataSource.Field.RESOURCE_GROUPS);
ListGridRecord[] groupListGridRecords = toListGridRecordArray(groupRecords);
this.resourceGroupSelector = new RoleResourceGroupSelector(groupListGridRecords,
!this.hasManageSecurityPermission);
this.resourceGroupSelector.addAssignedItemsChangedHandler(new AssignedItemsChangedHandler() {
public void onSelectionChanged(AssignedItemsChangedEvent event) {
onItemChanged();
}
});
updateTab(this.resourceGroupsTab, this.resourceGroupSelector);
Record[] bundleGroupRecords = record.getAttributeAsRecordArray(RolesDataSource.Field.BUNDLE_GROUPS);
ListGridRecord[] bundleGroupListGridRecords = toListGridRecordArray(bundleGroupRecords);
this.bundleGroupSelector = new RoleBundleGroupSelector(bundleGroupListGridRecords,
!this.hasManageSecurityPermission);
this.bundleGroupSelector.addAssignedItemsChangedHandler(new AssignedItemsChangedHandler() {
public void onSelectionChanged(AssignedItemsChangedEvent event) {
onItemChanged();
}
});
updateTab(this.bundleGroupsTab, this.bundleGroupSelector);
}
ListGridRecord[] subjectListGridRecords = toListGridRecordArray(subjectRecords);
if (getRecordId() == RolesDataSource.ID_SUPERUSER) {
// If this is the superuser role, make sure the rhqadmin record is disabled, so it cannot be removed
// from the role, and filter the overlord record out, so users don't even know it exists.
List<ListGridRecord> filteredSubjectRecords = new ArrayList<ListGridRecord>();
for (ListGridRecord subjectListGridRecord : subjectListGridRecords) {
int subjectId = subjectListGridRecord.getAttributeAsInt(UsersDataSource.Field.ID);
if (subjectId == UsersDataSource.ID_RHQADMIN) {
subjectListGridRecord.setEnabled(false);
}
if (subjectId != UsersDataSource.ID_OVERLORD) {
filteredSubjectRecords.add(subjectListGridRecord);
}
}
subjectListGridRecords = filteredSubjectRecords.toArray(new ListGridRecord[filteredSubjectRecords
.size()]);
}
this.subjectSelector = new RoleSubjectSelector(subjectListGridRecords, !this.hasManageSecurityPermission);
this.subjectSelector.addAssignedItemsChangedHandler(new AssignedItemsChangedHandler() {
public void onSelectionChanged(AssignedItemsChangedEvent event) {
onItemChanged();
}
});
updateTab(this.subjectsTab, this.subjectSelector);
if (this.isLdapConfigured) {
Record[] ldapGroupRecords = record.getAttributeAsRecordArray(RolesDataSource.Field.LDAP_GROUPS);
ListGridRecord[] ldapGroupListGridRecords = toListGridRecordArray(ldapGroupRecords);
this.ldapGroupSelector = new RoleLdapGroupSelector(ldapGroupListGridRecords,
!this.hasManageSecurityPermission);
this.ldapGroupSelector.addAssignedItemsChangedHandler(new AssignedItemsChangedHandler() {
public void onSelectionChanged(AssignedItemsChangedEvent event) {
onItemChanged();
}
});
updateTab(this.ldapGroupsTab, this.ldapGroupSelector);