001 package railo.runtime.functions.cache; 002 003 import java.io.IOException; 004 005 import railo.commons.lang.StringUtil; 006 import railo.runtime.PageContext; 007 import railo.runtime.config.ConfigImpl; 008 import railo.runtime.exp.PageException; 009 import railo.runtime.ext.function.Function; 010 import railo.runtime.op.Caster; 011 import railo.runtime.type.Array; 012 import railo.runtime.type.ArrayImpl; 013 import railo.runtime.type.List; 014 015 /** 016 * 017 */ 018 public final class CacheGetProperties implements Function { 019 020 private static final long serialVersionUID = -8665995702411192700L; 021 022 public static Array call(PageContext pc) throws PageException { 023 return call(pc, null); 024 } 025 026 public static Array call(PageContext pc, String cacheName) throws PageException { 027 Array arr = new ArrayImpl(); 028 try { 029 if(StringUtil.isEmpty(cacheName)){ 030 addDefault(pc,ConfigImpl.CACHE_DEFAULT_OBJECT,arr); 031 addDefault(pc,ConfigImpl.CACHE_DEFAULT_TEMPLATE,arr); 032 addDefault(pc,ConfigImpl.CACHE_DEFAULT_QUERY,arr); 033 addDefault(pc,ConfigImpl.CACHE_DEFAULT_RESOURCE,arr); 034 //arr.appendEL(Util.getDefault(pc,ConfigImpl.CACHE_DEFAULT_TEMPLATE).getCustomInfo()); 035 //arr.appendEL(Util.getDefault(pc,ConfigImpl.CACHE_DEFAULT_QUERY).getCustomInfo()); 036 //arr.appendEL(Util.getDefault(pc,ConfigImpl.CACHE_DEFAULT_RESOURCE).getCustomInfo()); 037 // MUST welcher muss zuers sein 038 } 039 else{ 040 String name; 041 String[] names=List.listToStringArray(cacheName, ','); 042 for(int i=0;i<names.length;i++){ 043 name=names[i].trim(); 044 if(name.equalsIgnoreCase("template")) 045 arr.appendEL(Util.getDefault(pc,ConfigImpl.CACHE_DEFAULT_TEMPLATE).getCustomInfo()); 046 else if(name.equalsIgnoreCase("object")) 047 arr.appendEL(Util.getDefault(pc,ConfigImpl.CACHE_DEFAULT_OBJECT).getCustomInfo()); 048 else if(name.equalsIgnoreCase("query")) 049 arr.appendEL(Util.getDefault(pc,ConfigImpl.CACHE_DEFAULT_QUERY).getCustomInfo()); 050 else if(name.equalsIgnoreCase("resource")) 051 arr.appendEL(Util.getDefault(pc,ConfigImpl.CACHE_DEFAULT_RESOURCE).getCustomInfo()); 052 else 053 arr.appendEL(Util.getCache(pc.getConfig(),name).getCustomInfo()); 054 } 055 } 056 057 058 return arr; 059 } catch (IOException e) { 060 throw Caster.toPageException(e); 061 } 062 } 063 064 private static void addDefault(PageContext pc, int type, Array arr) { 065 try { 066 arr.appendEL(Util.getDefault(pc,type).getCustomInfo()); 067 } catch (IOException e) {} 068 } 069 }