X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.app.core%2Fsrc%2Forg%2Fargeo%2Fapp%2Fcore%2FSuiteUtils.java;h=2b211423a145200eef6b67ad3969cfa58bb6081a;hb=99a029d144e7aab7f8b5a9ac3a2c4383cae4a6f5;hp=cc0e3bfffc63b858c91ce44d5035f59b84051d43;hpb=ca5ab3a2e58b3607ea8920fd94e0a936c55cf99d;p=gpl%2Fargeo-suite.git diff --git a/org.argeo.app.core/src/org/argeo/app/core/SuiteUtils.java b/org.argeo.app.core/src/org/argeo/app/core/SuiteUtils.java index cc0e3bf..2b21142 100644 --- a/org.argeo.app.core/src/org/argeo/app/core/SuiteUtils.java +++ b/org.argeo.app.core/src/org/argeo/app/core/SuiteUtils.java @@ -1,5 +1,7 @@ package org.argeo.app.core; +import static org.argeo.cms.acr.ContentUtils.SLASH; + import java.util.HashSet; import java.util.Set; @@ -11,18 +13,32 @@ import javax.jcr.security.Privilege; import javax.naming.ldap.LdapName; import javax.security.auth.x500.X500Principal; +import org.argeo.api.acr.Content; +import org.argeo.api.acr.ContentSession; import org.argeo.api.cms.CmsConstants; import org.argeo.api.cms.CmsSession; import org.argeo.app.api.EntityType; import org.argeo.app.api.SuiteRole; +import org.argeo.cms.CmsUserManager; +import org.argeo.cms.acr.CmsContentRepository; import org.argeo.jackrabbit.security.JackrabbitSecurityUtils; import org.argeo.jcr.JcrException; import org.argeo.jcr.JcrUtils; +import org.argeo.osgi.useradmin.UserDirectory; import org.argeo.util.naming.LdapAttrs; +import org.osgi.service.useradmin.Role; /** Utilities around the Argeo Suite APIs. */ public class SuiteUtils { + public static Content roleToContent(CmsUserManager userManager, ContentSession contentSession, Role role) { + UserDirectory userDirectory = userManager.getDirectory(role); + String path = CmsContentRepository.DIRECTORY_BASE + SLASH + userDirectory.getName() + SLASH + + userDirectory.getRolePath(role); + Content content = contentSession.get(path); + return content; + } + @Deprecated public static String getUserNodePath(LdapName userDn) { String uid = userDn.getRdn(userDn.size() - 1).getValue().toString(); return EntityType.user.basePath() + '/' + uid; @@ -55,6 +71,7 @@ public class SuiteUtils { } } + @Deprecated public static Node getCmsSessionNode(Session session, CmsSession cmsSession) { try { return session.getNode(getUserNodePath(cmsSession.getUserDn()) + '/' + cmsSession.getUuid().toString()); @@ -63,6 +80,7 @@ public class SuiteUtils { } } + @Deprecated public static Node getOrCreateCmsSessionNode(Session adminSession, CmsSession cmsSession) { try { LdapName userDn = cmsSession.getUserDn();