1 13 package info.magnolia.context; 14 15 import info.magnolia.cms.beans.config.ContentRepository; 16 import info.magnolia.cms.core.HierarchyManager; 17 import info.magnolia.cms.core.search.QueryManager; 18 import info.magnolia.cms.security.AccessManager; 19 import info.magnolia.cms.security.Security; 20 import info.magnolia.cms.security.User; 21 22 import org.slf4j.Logger; 23 import org.slf4j.LoggerFactory; 24 25 26 31 public class SystemContextImpl extends AbstractMapBasedContext implements SystemContext { 32 33 36 private static Logger log = LoggerFactory.getLogger(SystemContextImpl.class); 37 38 41 private static final long serialVersionUID = 222L; 42 43 46 public SystemContextImpl() { 47 } 48 49 public HierarchyManager getHierarchyManager(String repositoryId, String workspaceId) { 50 return ContentRepository.getHierarchyManager(repositoryId, workspaceId); 51 } 52 53 public AccessManager getAccessManager(String repositoryId, String workspaceId) { 54 return ContentRepository.getAccessManager(); 55 } 56 57 public QueryManager getQueryManager(String repositoryId, String workspaceId) { 58 return this.getHierarchyManager(repositoryId, workspaceId).getQueryManager(); 59 } 60 61 public void setAttribute(String name, Object value, int scope) { 62 if (scope == Context.LOCAL_SCOPE || scope == Context.SESSION_SCOPE) { 63 log 64 .warn( 65 "you should not set an attribute in the system context in request or session scope. You are setting {}={}", 66 name, 67 value); 68 } 69 super.setAttribute(name, value, scope); 70 } 71 72 public void removeAttribute(String name, Object value, int scope) { 73 if (scope == Context.LOCAL_SCOPE || scope == Context.SESSION_SCOPE) { 74 log 75 .warn( 76 "you should not manipulate an attribute in the system context in request or session scope. You are setting {}={}", 77 name, 78 value); 79 } 80 super.removeAttribute(name, scope); 81 } 82 83 88 public User getUser() { 89 if (this.user == null) { 90 log.debug("JAAS Subject is null, returning Anonymous user"); 91 this.user = Security.getUserManager().getSystemUser(); 92 } 93 return this.user; 94 } 95 } 96 | Popular Tags |