001    package railo.runtime.gateway;
002    
003    import java.util.Iterator;
004    import java.util.List;
005    import java.util.ListIterator;
006    import java.util.Map;
007    import java.util.Map.Entry;
008    
009    public class GatewayUtil {
010    
011            
012            public static String toRequestURI(String cfcPath) {
013                    String requestURI = cfcPath.replace('.','/');
014                    if(!requestURI.startsWith("/"))requestURI="/"+requestURI+".cfc";
015                    return requestURI;
016            }
017    
018            public static Object toCFML(Object obj) {
019                    if(obj instanceof Map) return toCFML((Map)obj);
020                    if(obj instanceof List) return toCFML((List)obj);
021                    return obj;
022            }
023            
024            public static Map toCFML(Map map) {
025                    Iterator it = map.entrySet().iterator();
026                    Map.Entry entry;
027                    while(it.hasNext()){
028                            entry=(Entry) it.next();
029                            entry.setValue(toCFML(entry.getValue()));
030                    }
031                    return map;
032            }
033    
034            public static Object toCFML(List list) {
035                    ListIterator it = list.listIterator();
036                    int index;
037                    while(it.hasNext()){
038                            index=it.nextIndex();
039                            list.set(index, toCFML(it.next()));
040                            
041                    }
042                    return list;
043            }
044            
045            public static int getState(GatewayEntry ge){ // this method only exists to make sure the Gateway interface must not be used outsite the gateway package
046                    return ge.getGateway().getState();
047            }
048    
049    }