001 package railo.runtime.functions.cache; 002 003 import railo.runtime.PageContext; 004 import railo.runtime.cache.CacheConnection; 005 import railo.runtime.config.ConfigImpl; 006 import railo.runtime.exp.ExpressionException; 007 import railo.runtime.exp.FunctionException; 008 import railo.runtime.exp.PageException; 009 import railo.runtime.ext.function.Function; 010 011 /** 012 * 013 */ 014 public final class CacheGetDefaultCacheName implements Function { 015 016 private static final long serialVersionUID = 6115589794465960484L; 017 018 public static String call(PageContext pc, String strType) throws PageException { 019 int type = Util.toType(strType,ConfigImpl.CACHE_DEFAULT_NONE); 020 if(type==ConfigImpl.CACHE_DEFAULT_NONE) 021 throw new FunctionException(pc,"CacheGetDefaultCacheName",1,"type","invalid type defintion ["+strType+"], valid types are [object,resource,template,query]"); 022 023 ConfigImpl config=(ConfigImpl) pc.getConfig(); 024 CacheConnection conn = config.getCacheDefaultConnection(type); 025 if(conn==null) 026 throw new ExpressionException("there is no default cache defined for type ["+strType+"]"); 027 028 return conn.getName(); 029 } 030 }