- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 06 Aug 2009 11:37:33 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3/unicorn/route
In directory hutz:/tmp/cvs-serv29717/src/org/w3/unicorn/route
Modified Files:
Tag: dev2
RouteParser.java
Log Message:
getters/setters + new logs
Index: RouteParser.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3/unicorn/route/Attic/RouteParser.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -d -r1.1.2.2 -r1.1.2.3
--- RouteParser.java 6 Aug 2009 10:13:27 -0000 1.1.2.2
+++ RouteParser.java 6 Aug 2009 11:37:31 -0000 1.1.2.3
@@ -1,65 +1,67 @@
package org.w3.unicorn.route;
-import java.io.File;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
-import org.w3.unicorn.util.Property;
public class RouteParser {
private static Logger logger = Logger.getLogger("RouteParser");
- private static List<Route> routeList;
+ private static List<Route> routeList = new ArrayList<Route>();
private static Route index;
private static Route error404;
-
- public static void init() throws Exception {
- File routesXML = new File(Property.get("PATH_TO_CONF_FILES", "ROUTE_XML"));
-
- RoutesDocument docXML = RoutesDocument.Factory.parse(routesXML);
-
- List<Route> tempRouteList = docXML.getRoutes().getRouteList();
- routeList = new ArrayList<Route>();
-
- for(Route route : tempRouteList) {
- logger.info("Route found: " + route.toString());
-
- if (route.isSetType() && route.getType().equals("index")) {
- index = route;
- routeList.add(index);
- } else if (route.isSetType() && route.getType().equals("404")) {
- error404 = route;
- } else {
- routeList.add(route);
- }
- }
- }
-
public static Route getRoute(HttpServletRequest request) throws MalformedURLException {
- logger.debug("PathInfo: "+request.getPathInfo());
+ logger.debug("Received request: " + request.getPathInfo());
String pathInfo = request.getPathInfo();
if(pathInfo.equals("") || pathInfo.equals("/")) {
- logger.debug("Coresponding action: " + index.getAction());
+ logger.debug("Found coresponding action: " + index.getAction());
return index;
}
for(Route route : routeList) {
for (String patternString : route.getPatternList()) {
Pattern pattern = Pattern.compile(patternString);
+ logger.debug("Trying to match with pattern: " + patternString);
if (pattern.matcher(pathInfo).matches()) {
- logger.debug("Coresponding action: " + route.getAction());
+ logger.debug("> Matched.");
+ logger.debug("Found coresponding action: " + route.getAction());
return route;
}
}
}
- logger.debug("Coresponding action: " + error404.getAction());
+
+ logger.debug("Found coresponding action: " + error404.getAction());
return error404;
}
+
+ public static List<Route> getRouteList() {
+ return routeList;
+ }
+
+ public static void setRouteList(List<Route> routeList) {
+ RouteParser.routeList = routeList;
+ }
+
+ public static Route getIndex() {
+ return index;
+ }
+
+ public static void setIndex(Route index) {
+ RouteParser.index = index;
+ }
+
+ public static Route getError404() {
+ return error404;
+ }
+
+ public static void setError404(Route error404) {
+ RouteParser.error404 = error404;
+ }
}
Received on Thursday, 6 August 2009 11:37:49 UTC