1 13 package info.magnolia.cms.beans.config; 14 15 import info.magnolia.cms.core.Content; 16 import info.magnolia.cms.core.HierarchyManager; 17 18 import javax.jcr.PathNotFoundException; 19 import javax.jcr.RepositoryException; 20 21 import org.apache.log4j.Logger; 22 23 24 28 public class LocalStore { 29 30 private static Logger log = Logger.getLogger(LocalStore.class); 31 32 private Content localStore; 33 34 private String configPath; 35 36 protected static LocalStore getInstance(String path) { 37 LocalStore store = new LocalStore(); 38 store.configPath = path; 39 store.init(); 40 return store; 41 } 42 43 private void init() { 44 log.info("Config : Initializing LocalStore for - " + configPath); HierarchyManager configHierarchyManager = ContentRepository.getHierarchyManager(ContentRepository.CONFIG); 46 try { 47 localStore = configHierarchyManager.getContent(configPath); 48 log.info("Config : LocalStore initialized for -" + configPath); } 50 catch (PathNotFoundException e) { 51 log.error("Config : No LocalStore defined for - " + configPath); } 53 catch (RepositoryException re) { 54 log.error("Config : Failed to initialize LocalStore for - " + configPath); log.error(re.getMessage(), re); 56 } 57 } 58 59 protected Content getStore() { 60 return localStore; 61 } 62 } 63 | Popular Tags |