This commit is contained in:
Keith Donald
2008-09-12 17:18:08 +00:00
parent ed32b4f1ba
commit 47f7fe1133
2 changed files with 16 additions and 3 deletions

View File

@@ -22,6 +22,7 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.util.WebUtils;
import org.springframework.webflow.core.collection.AttributeMap;
/**
@@ -66,10 +67,13 @@ public class DefaultFlowUrlHandler implements FlowUrlHandler {
public String getFlowId(HttpServletRequest request) {
String pathInfo = request.getPathInfo();
if (pathInfo == null) {
throw new IllegalStateException("The HttpServletRequest pathInfo is null; unable to extract flowId");
if (pathInfo != null) {
return pathInfo.substring(1);
} else {
String servletPath = request.getServletPath();
int lastSlash = servletPath.lastIndexOf("/");
return WebUtils.extractFilenameFromUrlPath(servletPath.substring(lastSlash));
}
return request.getPathInfo().substring(1);
}
public String createFlowExecutionUrl(String flowId, String flowExecutionKey, HttpServletRequest request) {

View File

@@ -10,6 +10,7 @@ import org.springframework.webflow.core.collection.LocalAttributeMap;
public class DefaultFlowUrlHandlerTests extends TestCase {
private DefaultFlowUrlHandler urlHandler = new DefaultFlowUrlHandler();
private MockHttpServletRequest request = new MockHttpServletRequest();
public void testGetFlowId() {
@@ -20,6 +21,14 @@ public class DefaultFlowUrlHandlerTests extends TestCase {
assertEquals("foo", urlHandler.getFlowId(request));
}
public void testGetFlowIdNoPathInfo() {
request.setContextPath("/springtravel");
request.setServletPath("/app/foo.htm");
request.setPathInfo(null);
request.setRequestURI("/springtravel/app/foo.htm");
assertEquals("foo", urlHandler.getFlowId(request));
}
public void testGetFlowExecutionKey() {
request.setContextPath("/springtravel");
request.setServletPath("/app");