You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by si...@apache.org on 2009/01/02 17:23:00 UTC

svn commit: r730769 - /labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/Dispatch.java

Author: simoneg
Date: Fri Jan  2 08:23:00 2009
New Revision: 730769

URL: http://svn.apache.org/viewvc?rev=730769&view=rev
Log:
LABS-264 : magma.env in web.xml
LABS-265 : eliminate // deriving from tomcat handling

Modified:
    labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/Dispatch.java

Modified: labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/Dispatch.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/Dispatch.java?rev=730769&r1=730768&r2=730769&view=diff
==============================================================================
--- labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/Dispatch.java (original)
+++ labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/Dispatch.java Fri Jan  2 08:23:00 2009
@@ -22,6 +22,7 @@
 import org.apache.magma.website.templating.Template;
 import org.apache.magma.website.utils.Binder;
 import org.apache.magma.website.utils.URLRewritingStream;
+import org.apache.magma.settings.Settings;
 import org.apache.magma.startup.Startup;
 
 import java.io.IOException;
@@ -40,6 +41,11 @@
 	@Override
 	public void init() throws ServletException {
 		super.init();
+		String parameter = getServletConfig().getInitParameter("magma.env");
+		if (parameter != null) {
+			Settings.setEnvironment(parameter);
+			System.out.println("Magma running in " + parameter + " env");
+		}
 		Startup.start();
 	}
 	
@@ -61,6 +67,9 @@
 
 	protected void handle(HttpServletRequest req, HttpServletResponse resp) {
 		String pathInfo = req.getPathInfo();
+		while (pathInfo.indexOf("//") != -1) {
+			pathInfo = pathInfo.replaceAll("//", "/");
+		}
 		req.setAttribute("__magma_url", pathInfo);
 		RootWebHandler.getInstance().beforeRequest();
 		Producer producer = findProducer(pathInfo);
@@ -197,25 +206,9 @@
 	}
 
 	protected Producer findProducer(String pathInfo) {
-		String[] info = tokenizeRequest(pathInfo);
 		RootWebHandler root = RootWebHandler.getInstance();
-		Producer producer = root.find(info);
+		Producer producer = root.find(pathInfo);
 		return producer;
 	}
 
-	protected String[] tokenizeRequest(String pathInfo) {
-		String[] info = null;
-		if (pathInfo == null) {
-			info = new String[] { "" };
-		} else {
-			StringTokenizer stok = new StringTokenizer(pathInfo, "/-");
-			info = new String[stok.countTokens()];
-			int pos = 0;
-			while (stok.hasMoreTokens()) {
-				info[pos++] = stok.nextToken();
-			}
-		}
-		return info;
-	}
-	
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org