polish
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user