001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.gateway; 020 021import java.util.Iterator; 022import java.util.List; 023import java.util.ListIterator; 024import java.util.Map; 025import java.util.Map.Entry; 026 027public class GatewayUtil { 028 029 030 public static String toRequestURI(String cfcPath) { 031 String requestURI = cfcPath.replace('.','/'); 032 if(!requestURI.startsWith("/"))requestURI="/"+requestURI+".cfc"; 033 return requestURI; 034 } 035 036 public static Object toCFML(Object obj) { 037 if(obj instanceof Map) return toCFML((Map)obj); 038 if(obj instanceof List) return toCFML((List)obj); 039 return obj; 040 } 041 042 public static Map toCFML(Map map) { 043 Iterator it = map.entrySet().iterator(); 044 Map.Entry entry; 045 while(it.hasNext()){ 046 entry=(Entry) it.next(); 047 entry.setValue(toCFML(entry.getValue())); 048 } 049 return map; 050 } 051 052 public static Object toCFML(List list) { 053 ListIterator it = list.listIterator(); 054 int index; 055 while(it.hasNext()){ 056 index=it.nextIndex(); 057 list.set(index, toCFML(it.next())); 058 059 } 060 return list; 061 } 062 063 public static int getState(GatewayEntry ge){ // this method only exists to make sure the Gateway interface must not be used outsite the gateway package 064 return ge.getGateway().getState(); 065 } 066 067}