1 23 24 package org.infoglue.deliver.applications.filters; 25 26 import org.infoglue.deliver.util.CacheController; 27 28 29 36 37 public class URIMapperCache 38 { 39 private static URIMapperCache instance = null; 40 41 final String CACHE_NAME = "NavigationCache"; 42 43 public URIMapperCache() 44 { 45 } 46 47 public synchronized static URIMapperCache getInstance() 48 { 49 if (instance == null) { 50 instance = new URIMapperCache(); 51 } 52 return instance; 53 } 54 55 public void clear() 56 { 57 } 58 59 public Integer getCachedSiteNodeId(Integer repositoryId, String [] path, int upToIndex) 60 { 61 if (repositoryId == null || path == null) 62 return null; 63 String cacheKey = createCacheKey(repositoryId, path, upToIndex); 64 return (Integer )CacheController.getCachedObject(CACHE_NAME, cacheKey); 65 } 66 67 public boolean addCachedSiteNodeId(Integer repositoryId, String [] path, int upToIndex, Integer siteNodeId) 68 { 69 if (repositoryId == null || path == null || siteNodeId == null) 70 return false; 71 String cacheKey = createCacheKey(repositoryId, path, upToIndex); 72 CacheController.cacheObject(CACHE_NAME, cacheKey, siteNodeId); 73 return true; 74 } 75 76 private String createCacheKey(Integer repositoryId, String [] path, int upToIndex) 77 { 78 StringBuffer sb = new StringBuffer (128); 79 sb.append(String.valueOf(repositoryId)).append(":/"); 80 for (int i=0;i < path.length && i < upToIndex ;i++) { 81 sb.append(path[i].toLowerCase()).append("/"); 82 } 83 return sb.toString(); 84 } 85 } | Popular Tags |