Refactor naming packages
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / acr / ContentUtils.java
index eeec4fcfc9aa66ac537560581db37d6392194768..5ea79662a387341f5d902c58f0fdc5c95de74f3b 100644 (file)
@@ -9,6 +9,10 @@ import java.util.function.BiConsumer;
 import javax.xml.namespace.QName;
 
 import org.argeo.api.acr.Content;
+import org.argeo.api.acr.ContentSession;
+import org.argeo.cms.CmsUserManager;
+import org.argeo.osgi.useradmin.UserDirectory;
+import org.osgi.service.useradmin.Role;
 
 /** Utilities and routines around {@link Content}. */
 public class ContentUtils {
@@ -114,4 +118,12 @@ public class ContentUtils {
 
        }
 
+       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;
+       }
+
 }