Undeprecate user node methods
[gpl/argeo-suite.git] / org.argeo.app.core / src / org / argeo / app / core / SuiteUtils.java
index b766aca268f7941daf2b613a6d271fbd9d308266..ad4e2ac5e6caf3c7e9e5f90d8c5b2ef546e4b469 100644 (file)
@@ -1,7 +1,6 @@
 package org.argeo.app.core;
 
 import java.util.HashSet;
-import java.util.Optional;
 import java.util.Set;
 
 import javax.jcr.Node;
@@ -13,24 +12,22 @@ 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;
-import org.argeo.cms.auth.RoleNameUtils;
+import org.argeo.cms.RoleNameUtils;
 import org.argeo.jcr.JcrException;
 import org.argeo.jcr.JcrUtils;
 
 /** Utilities around the Argeo Suite APIs. */
 public class SuiteUtils {
-       @Deprecated
        public static String getUserNodePath(String userDn) {
                String uid = RoleNameUtils.getLastRdnValue(userDn);
                return EntityType.user.basePath() + '/' + uid;
        }
 
-       @Deprecated
        private static Node getOrCreateUserNode(Session adminSession, String userDn) {
                try {
                        Node usersBase = adminSession.getNode(EntityType.user.basePath());
@@ -40,8 +37,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.get(), userDn.toString());
+                               userNode.setProperty(LdapAttr.uid.get(), uid);
                                adminSession.save();
 //                             JackrabbitSecurityUtils.denyPrivilege(adminSession, userNode.getPath(), SuiteRole.coworker.dn(),
 //                                             Privilege.JCR_READ);
@@ -58,7 +55,6 @@ public class SuiteUtils {
                }
        }
 
-       @Deprecated
        public static Node getCmsSessionNode(Session session, CmsSession cmsSession) {
                try {
                        return session.getNode(getUserNodePath(cmsSession.getUserDn()) + '/' + cmsSession.getUuid().toString());
@@ -67,7 +63,6 @@ public class SuiteUtils {
                }
        }
 
-       @Deprecated
        public static Node getOrCreateCmsSessionNode(Session adminSession, CmsSession cmsSession) {
                try {
                        String userDn = cmsSession.getUserDn();
@@ -121,20 +116,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;
                                        }