1 13 package info.magnolia.cms.security; 14 15 import info.magnolia.cms.beans.config.ContentRepository; 16 import info.magnolia.cms.core.Content; 17 import info.magnolia.cms.core.HierarchyManager; 18 import info.magnolia.cms.core.ItemType; 19 import info.magnolia.context.MgnlContext; 20 21 import org.slf4j.Logger; 22 import org.slf4j.LoggerFactory; 23 24 25 28 public class MgnlGroupManager implements GroupManager { 29 30 public static Logger log = LoggerFactory.getLogger(MgnlRoleManager.class); 31 32 39 public Group createGroup(String name) throws UnsupportedOperationException , AccessDeniedException { 40 try { 41 Content node = getHierarchyManager().createContent("/", name, ItemType.GROUP.getSystemName()); 42 getHierarchyManager().save(); 43 return new MgnlGroup(node); 44 } 45 catch (Exception e) { 46 log.error("can't create role [" + name + "]", e); 47 return null; 48 } 49 } 50 51 58 public Group getGroup(String name) throws UnsupportedOperationException , AccessDeniedException { 59 try { 60 return new MgnlGroup(getHierarchyManager().getContent(name)); 61 } 62 catch (Exception e) { 63 log.info("can't find group [" + name + "]", e); 64 return null; 65 } 66 } 67 68 71 protected HierarchyManager getHierarchyManager() { 72 return MgnlContext.getHierarchyManager(ContentRepository.USER_GROUPS); 73 } 74 } 75 | Popular Tags |