- DefaultTabularPart<HierarchyUnit, Content> usersPart = new DefaultTabularPart<>() {
-
- @Override
- protected List<Content> asList(HierarchyUnit hu) {
- List<Content> roles = new ArrayList<>();
- UserDirectory ud = (UserDirectory) hu.getDirectory();
- if (ud.getRealm().isPresent()) {
- for (Role r : ud.getHierarchyUnitRoles(ud, null, true)) {
- Content content = ContentUtils.roleToContent(cmsUserManager, contentSession, r);
- if (content.hasContentClass(LdapObjs.inetOrgPerson, LdapObjs.organization))
- roles.add(content);
- }
-
- } else {
- for (HierarchyUnit directChild : hu.getDirectHierarchyUnits(false)) {
- if (!(directChild.isType(HierarchyUnit.Type.FUNCTIONAL)
- || directChild.isType(HierarchyUnit.Type.ROLES))) {
- for (Role r : ud.getHierarchyUnitRoles(directChild, null, false)) {
- Content content = ContentUtils.roleToContent(cmsUserManager, contentSession, r);
- if (content.hasContentClass(LdapObjs.inetOrgPerson, LdapObjs.organization,
- LdapObjs.groupOfNames))
- roles.add(content);
- }
- }
- }
- }
- return roles;
- }
- };
- usersPart.addColumn(new Column<Content>() {
-
- @Override
- public String getText(Content role) {
- if (role.hasContentClass(LdapObjs.inetOrgPerson))
- return UserAdminUtils.getUserDisplayName(role.adapt(User.class));
- else if (role.hasContentClass(LdapObjs.organization))
- return role.attr(LdapAttrs.o);
- else if (role.hasContentClass(LdapObjs.groupOfNames))
- return role.attr(LdapAttrs.cn);
- else
- return null;
- }
-
- @Override
- public CmsIcon getIcon(Content role) {
- if (role.hasContentClass(LdapObjs.posixAccount))
- return SuiteIcon.user;
- else if (role.hasContentClass(LdapObjs.inetOrgPerson))
- return SuiteIcon.person;
- else if (role.hasContentClass(LdapObjs.organization))
- return SuiteIcon.organisationContact;
- else if (role.hasContentClass(LdapObjs.groupOfNames))
- return SuiteIcon.group;
- else
- return null;
- }
-
- @Override
- public int getWidth() {
- return 300;
- }
-
- });
-// usersPart.addColumn((Column<Content>) (role) -> role.attr(LdapAttrs.mail));