Adapt to changes in Argeo Commons
authorMathieu <mbaudier@argeo.org>
Sun, 13 Nov 2022 07:23:05 +0000 (08:23 +0100)
committerMathieu <mbaudier@argeo.org>
Sun, 13 Nov 2022 07:23:05 +0000 (08:23 +0100)
org.argeo.app.api/src/org/argeo/app/api/EntityNames.java
org.argeo.app.api/src/org/argeo/app/api/SuiteRole.java
org.argeo.app.core/src/org/argeo/app/core/SuiteUtils.java
swt/org.argeo.app.ui/src/org/argeo/app/ui/people/GroupUiProvider.java
swt/org.argeo.app.ui/src/org/argeo/app/ui/people/HierarchyUnitPart.java
swt/org.argeo.app.ui/src/org/argeo/app/ui/people/NewUserForm.java
swt/org.argeo.app.ui/src/org/argeo/app/ui/people/PeopleEntryArea.java
swt/org.argeo.app.ui/src/org/argeo/app/ui/people/PersonUiProvider.java
swt/org.argeo.app.ui/src/org/argeo/app/ui/people/UsersPart.java

index 01569c1c1ae726f7c19dab0b65847eeac25d8219..b60a436d28b4f333affa6015140ffaccc0e9c7de 100644 (file)
@@ -1,6 +1,6 @@
 package org.argeo.app.api;
 
-import org.argeo.api.acr.ldap.LdapAttrs;
+import org.argeo.api.acr.ldap.LdapAttr;
 
 /** Constants used to name entity structures. */
 public interface EntityNames {
@@ -35,16 +35,16 @@ public interface EntityNames {
 
        // LDAP-LIKE ENTITIES
        @Deprecated
-       final String DISPLAY_NAME = LdapAttrs.displayName.property();
+       final String DISPLAY_NAME = LdapAttr.displayName.property();
        // Persons
        @Deprecated
-       final String GIVEN_NAME = LdapAttrs.givenName.property();
+       final String GIVEN_NAME = LdapAttr.givenName.property();
        @Deprecated
-       final String SURNAME = LdapAttrs.sn.property();
+       final String SURNAME = LdapAttr.sn.property();
        @Deprecated
-       final String EMAIL = LdapAttrs.mail.property();
+       final String EMAIL = LdapAttr.mail.property();
        @Deprecated
-       final String OU = LdapAttrs.ou.property();
+       final String OU = LdapAttr.ou.property();
 
        // WGS84
        final String GEO_LAT = "geo:lat";
index 086f93193157dde79c76d93cb2b36ffc2ef20d5b..e8207074705895de0d15e26988bd7691f54e112a 100644 (file)
@@ -4,7 +4,7 @@ import javax.xml.namespace.QName;
 
 import org.argeo.api.acr.ArgeoNamespace;
 import org.argeo.api.acr.ContentName;
-import org.argeo.api.acr.ldap.LdapAttrs;
+import org.argeo.api.acr.ldap.LdapAttr;
 import org.argeo.api.cms.CmsConstants;
 import org.argeo.cms.SystemRole;
 
@@ -41,7 +41,7 @@ public enum SuiteRole implements SystemRole {
 
        @Deprecated
        public String dn() {
-               return new StringBuilder(LdapAttrs.cn.name()).append("=").append(getRolePrefix()).append(".").append(name())
+               return new StringBuilder(LdapAttr.cn.name()).append("=").append(getRolePrefix()).append(".").append(name())
                                .append(",").append(CmsConstants.SYSTEM_ROLES_BASEDN).toString();
        }
 }
index 6453b88b4c2c2d12133a1dd94923a818a668b0e1..da794cb0cd424aa74412a3b9a3d00102833d6bb3 100644 (file)
@@ -13,8 +13,8 @@ import javax.security.auth.x500.X500Principal;
 import javax.xml.namespace.QName;
 
 import org.argeo.api.acr.Content;
-import org.argeo.api.acr.ldap.LdapAttrs;
-import org.argeo.api.acr.ldap.LdapObjs;
+import org.argeo.api.acr.ldap.LdapAttr;
+import org.argeo.api.acr.ldap.LdapObj;
 import org.argeo.api.cms.CmsConstants;
 import org.argeo.api.cms.CmsSession;
 import org.argeo.app.api.EntityType;
@@ -40,8 +40,8 @@ public class SuiteUtils {
                                userNode = usersBase.addNode(uid, NodeType.NT_UNSTRUCTURED);
                                userNode.addMixin(EntityType.user.get());
                                userNode.addMixin(NodeType.MIX_CREATED);
-                               userNode.setProperty(LdapAttrs.distinguishedName.property(), userDn.toString());
-                               userNode.setProperty(LdapAttrs.uid.property(), uid);
+                               userNode.setProperty(LdapAttr.distinguishedName.property(), userDn.toString());
+                               userNode.setProperty(LdapAttr.uid.property(), uid);
                                adminSession.save();
 //                             JackrabbitSecurityUtils.denyPrivilege(adminSession, userNode.getPath(), SuiteRole.coworker.dn(),
 //                                             Privilege.JCR_READ);
@@ -121,20 +121,20 @@ public class SuiteUtils {
        }
 
        synchronized static public long findNextId(Content hierarchyUnit, QName cclass) {
-               if (!hierarchyUnit.hasContentClass(LdapObjs.posixGroup.qName())) 
+               if (!hierarchyUnit.hasContentClass(LdapObj.posixGroup.qName())) 
                        throw new IllegalArgumentException(hierarchyUnit + " is not a POSIX group");
                
-               long min = hierarchyUnit.get(LdapAttrs.gidNumber.qName(), Long.class).orElseThrow();
+               long min = hierarchyUnit.get(LdapAttr.gidNumber.qName(), Long.class).orElseThrow();
                long currentMax = 0l;
                for (Content childHu : hierarchyUnit) {
-                       if (!childHu.hasContentClass(LdapObjs.organizationalUnit.qName()))
+                       if (!childHu.hasContentClass(LdapObj.organizationalUnit.qName()))
                                continue;
                        // FIXME filter out functional hierarchy unit
                        for (Content role : childHu) {
                                if (role.hasContentClass(cclass)) {
 
-                                       if (LdapObjs.posixAccount.qName().equals(cclass)) {
-                                               Long id = role.get(LdapAttrs.uidNumber.qName(), Long.class).orElseThrow();
+                                       if (LdapObj.posixAccount.qName().equals(cclass)) {
+                                               Long id = role.get(LdapAttr.uidNumber.qName(), Long.class).orElseThrow();
                                                if (id > currentMax)
                                                        currentMax = id;
                                        }
index 755821ac17831506a7056710b92aaf4e0165f308..f0a5b38a90dbe6a442632f93b830b51280159932 100644 (file)
@@ -1,8 +1,8 @@
 package org.argeo.app.ui.people;
 
 import org.argeo.api.acr.Content;
-import org.argeo.api.acr.ldap.LdapAttrs;
-import org.argeo.api.acr.ldap.LdapObjs;
+import org.argeo.api.acr.ldap.LdapAttr;
+import org.argeo.api.acr.ldap.LdapObj;
 import org.argeo.api.cms.directory.CmsGroup;
 import org.argeo.api.cms.directory.CmsUserManager;
 import org.argeo.api.cms.directory.HierarchyUnit;
@@ -26,11 +26,11 @@ public class GroupUiProvider implements SwtUiProvider {
 
                // TODO localise at content level
                String title;
-               if (context.hasContentClass(LdapObjs.organization))
-                       title = SuiteMsg.org.lead() + " " + context.attr(LdapAttrs.cn) + " ("
+               if (context.hasContentClass(LdapObj.organization))
+                       title = SuiteMsg.org.lead() + " " + context.attr(LdapAttr.cn) + " ("
                                        + hierarchyUnit.getHierarchyUnitLabel(CurrentUser.locale()) + ")";
                else
-                       title = SuiteMsg.group.lead() + " " + context.attr(LdapAttrs.cn) + " ("
+                       title = SuiteMsg.group.lead() + " " + context.attr(LdapAttr.cn) + " ("
                                        + hierarchyUnit.getHierarchyUnitLabel(CurrentUser.locale()) + ")";
                SuiteUiUtils.addFormLabel(parent, title);
 
index 9ad3457664a948c23eedec60615573cc2fd6982f..33160315871f7793c33d9167c390259a46030e68 100644 (file)
@@ -5,7 +5,7 @@ import java.util.List;
 
 import org.argeo.api.acr.Content;
 import org.argeo.api.acr.ContentSession;
-import org.argeo.api.acr.ldap.LdapObjs;
+import org.argeo.api.acr.ldap.LdapObj;
 import org.argeo.api.cms.directory.CmsDirectory;
 import org.argeo.api.cms.directory.CmsUserManager;
 import org.argeo.api.cms.directory.HierarchyUnit;
@@ -36,9 +36,9 @@ public class HierarchyUnitPart extends AbstractHierarchicalPart<HierarchyUnit> {
                        @Override
                        public CmsIcon getIcon(HierarchyUnit model) {
                                Content content = ContentUtils.hierarchyUnitToContent(contentSession, model);
-                               if (content.hasContentClass(LdapObjs.organization))
+                               if (content.hasContentClass(LdapObj.organization))
                                        return SuiteIcon.organisation;
-                               else if (content.hasContentClass(LdapObjs.posixGroup))
+                               else if (content.hasContentClass(LdapObj.posixGroup))
                                        return SuiteIcon.users;
                                else
                                        return SuiteIcon.addressBook;
index e8ba541589fa447b6dda29e2c858be24bfa925f3..e45197323d4e5c6d72464617b55b6831d9abc734 100644 (file)
@@ -9,8 +9,8 @@ import java.util.Set;
 import java.util.UUID;
 
 import org.argeo.api.acr.Content;
-import org.argeo.api.acr.ldap.LdapAttrs;
-import org.argeo.api.acr.ldap.LdapObjs;
+import org.argeo.api.acr.ldap.LdapAttr;
+import org.argeo.api.acr.ldap.LdapObj;
 import org.argeo.api.cms.directory.CmsUserManager;
 import org.argeo.api.cms.directory.HierarchyUnit;
 import org.argeo.app.core.SuiteUtils;
@@ -40,7 +40,7 @@ public class NewUserForm extends AbstractGuidedForm {
 
        public NewUserForm(CmsUserManager cmsUserManager, Content hierarchyUnit) {
                this.hierarchyUnit = hierarchyUnit;
-               if (!hierarchyUnit.hasContentClass(LdapObjs.posixGroup.qName()))
+               if (!hierarchyUnit.hasContentClass(LdapObj.posixGroup.qName()))
                        throw new IllegalArgumentException(hierarchyUnit + " is not a POSIX group");
                this.cmsUserManager = cmsUserManager;
        }
@@ -76,25 +76,25 @@ public class NewUserForm extends AbstractGuidedForm {
                        String username = "uid=" + uid + ",ou=People," + hu.getBase();
 
                        Map<String, Object> properties = new HashMap<>();
-                       properties.put(LdapAttrs.givenName.name(), firstName);
-                       properties.put(LdapAttrs.sn.name(), lastName);
-                       properties.put(LdapAttrs.mail.name(), email);
-                       properties.put(LdapAttrs.cn.name(), firstName + " " + lastName);
-                       properties.put(LdapAttrs.employeeNumber.name(), uuid.toString());
+                       properties.put(LdapAttr.givenName.name(), firstName);
+                       properties.put(LdapAttr.sn.name(), lastName);
+                       properties.put(LdapAttr.mail.name(), email);
+                       properties.put(LdapAttr.cn.name(), firstName + " " + lastName);
+                       properties.put(LdapAttr.employeeNumber.name(), uuid.toString());
 
                        Map<String, Object> credentials = new HashMap<>();
                        User user = cmsUserManager.createUser(username, properties, credentials);
 
-                       Long huGidNumber = hierarchyUnit.get(LdapAttrs.gidNumber.qName(), Long.class).orElseThrow();
-                       Long nextUserId = SuiteUtils.findNextId(hierarchyUnit, LdapObjs.posixAccount.qName());
+                       Long huGidNumber = hierarchyUnit.get(LdapAttr.gidNumber.qName(), Long.class).orElseThrow();
+                       Long nextUserId = SuiteUtils.findNextId(hierarchyUnit, LdapObj.posixAccount.qName());
                        String homeDirectory = "/home/" + uid;
                        Map<String, Object> additionalProperties = new HashMap<>();
-                       additionalProperties.put(LdapAttrs.uidNumber.name(), nextUserId.toString());
-                       additionalProperties.put(LdapAttrs.gidNumber.name(), huGidNumber.toString());
-                       additionalProperties.put(LdapAttrs.homeDirectory.name(), homeDirectory);
+                       additionalProperties.put(LdapAttr.uidNumber.name(), nextUserId.toString());
+                       additionalProperties.put(LdapAttr.gidNumber.name(), huGidNumber.toString());
+                       additionalProperties.put(LdapAttr.homeDirectory.name(), homeDirectory);
 
                        Set<String> objectClasses = new HashSet<>();
-                       objectClasses.add(LdapObjs.posixAccount.name());
+                       objectClasses.add(LdapObj.posixAccount.name());
                        cmsUserManager.addObjectClasses(user, objectClasses, additionalProperties);
                        return true;
                }
index 41310aa8c6e8f36a0c46f918526169653e81334e..1cbd9be76759f04be480510522b0733b47cfb4f8 100644 (file)
@@ -6,7 +6,7 @@ import javax.jcr.RepositoryException;
 import org.argeo.api.acr.Content;
 import org.argeo.api.acr.ContentRepository;
 import org.argeo.api.acr.ContentSession;
-import org.argeo.api.acr.ldap.LdapAttrs;
+import org.argeo.api.acr.ldap.LdapAttr;
 import org.argeo.api.cms.directory.CmsUserManager;
 import org.argeo.api.cms.directory.HierarchyUnit;
 import org.argeo.api.cms.ux.CmsView;
@@ -66,7 +66,7 @@ public class PeopleEntryArea implements SwtUiProvider, CmsUiProvider {
 
                        @Override
                        public String getText(Content role) {
-                               return role.attr(LdapAttrs.mail);
+                               return role.attr(LdapAttr.mail);
                        }
 
                        @Override
index 5ff00a7d124e53a5420d9edfe3f46f58d0151efc..6930b4e2a8cdcc5d0ad0eea2eac7ddc74b8a2cb4 100644 (file)
@@ -6,8 +6,8 @@ import java.util.Map;
 
 import org.argeo.api.acr.Content;
 import org.argeo.api.acr.QNamed;
-import org.argeo.api.acr.ldap.LdapAttrs;
-import org.argeo.api.acr.ldap.LdapObjs;
+import org.argeo.api.acr.ldap.LdapAttr;
+import org.argeo.api.acr.ldap.LdapObj;
 import org.argeo.api.cms.directory.CmsUser;
 import org.argeo.api.cms.directory.CmsUserManager;
 import org.argeo.app.api.SuiteRole;
@@ -56,15 +56,15 @@ public class PersonUiProvider implements SwtUiProvider {
 
                String roleContext = RoleNameUtils.getContext(user.getName());
 
-               if (context.hasContentClass(LdapObjs.person.qName())) {
+               if (context.hasContentClass(LdapObj.person.qName())) {
 
-                       addFormLine(main, SuiteMsg.firstName, context, LdapAttrs.givenName);
-                       addFormLine(main, SuiteMsg.lastName, context, LdapAttrs.sn);
-                       addFormLine(main, SuiteMsg.email, context, LdapAttrs.mail);
+                       addFormLine(main, SuiteMsg.firstName, context, LdapAttr.givenName);
+                       addFormLine(main, SuiteMsg.lastName, context, LdapAttr.sn);
+                       addFormLine(main, SuiteMsg.email, context, LdapAttr.mail);
                }
 
-               if (context.hasContentClass(LdapObjs.posixAccount.qName())) {
-                       if (hierarchyUnitContent.hasContentClass(LdapObjs.organization)) {
+               if (context.hasContentClass(LdapObj.posixAccount.qName())) {
+                       if (hierarchyUnitContent.hasContentClass(LdapObj.organization)) {
                                SwtSection rolesSection = new SwtSection(main, SWT.NONE);
                                rolesSection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
                                rolesSection.setLayout(new GridLayout(2, false));
index d82b227d709887e9441e2c348679ca2cbcb22145..96e24444cfe2a2c60c7910bf173daa0f10a5df80 100644 (file)
@@ -5,8 +5,8 @@ import java.util.List;
 
 import org.argeo.api.acr.Content;
 import org.argeo.api.acr.ContentSession;
-import org.argeo.api.acr.ldap.LdapAttrs;
-import org.argeo.api.acr.ldap.LdapObjs;
+import org.argeo.api.acr.ldap.LdapAttr;
+import org.argeo.api.acr.ldap.LdapObj;
 import org.argeo.api.cms.directory.CmsUserManager;
 import org.argeo.api.cms.directory.HierarchyUnit;
 import org.argeo.api.cms.directory.UserDirectory;
@@ -30,25 +30,25 @@ public class UsersPart extends DefaultTabularPart<HierarchyUnit, Content> {
 
                        @Override
                        public String getText(Content role) {
-                               if (role.hasContentClass(LdapObjs.inetOrgPerson))
+                               if (role.hasContentClass(LdapObj.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 if (role.hasContentClass(LdapObj.organization))
+                                       return role.attr(LdapAttr.o);
+                               else if (role.hasContentClass(LdapObj.groupOfNames))
+                                       return role.attr(LdapAttr.cn);
                                else
                                        return null;
                        }
 
                        @Override
                        public CmsIcon getIcon(Content role) {
-                               if (role.hasContentClass(LdapObjs.posixAccount))
+                               if (role.hasContentClass(LdapObj.posixAccount))
                                        return SuiteIcon.user;
-                               else if (role.hasContentClass(LdapObjs.inetOrgPerson))
+                               else if (role.hasContentClass(LdapObj.inetOrgPerson))
                                        return SuiteIcon.person;
-                               else if (role.hasContentClass(LdapObjs.organization))
+                               else if (role.hasContentClass(LdapObj.organization))
                                        return SuiteIcon.organisationContact;
-                               else if (role.hasContentClass(LdapObjs.groupOfNames))
+                               else if (role.hasContentClass(LdapObj.groupOfNames))
                                        return SuiteIcon.group;
                                else
                                        return null;
@@ -69,7 +69,7 @@ public class UsersPart extends DefaultTabularPart<HierarchyUnit, Content> {
                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))
+                               if (content.hasContentClass(LdapObj.inetOrgPerson, LdapObj.organization))
                                        roles.add(content);
                        }
 
@@ -79,8 +79,8 @@ public class UsersPart extends DefaultTabularPart<HierarchyUnit, Content> {
                                                || 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))
+                                               if (content.hasContentClass(LdapObj.inetOrgPerson, LdapObj.organization,
+                                                               LdapObj.groupOfNames))
                                                        roles.add(content);
                                        }
                                }