Commits

Joseph Walton committed f6bca07

Remove handling of 'redirect:' and 'redirect-action:'.

Backport the fix for WW-4140 from
https://svn.apache.org/viewvc?view=revision&revision=1503127 .

Comments (0)

Files changed (2)

src/java/com/opensymphony/webwork/dispatcher/mapper/DefaultActionMapper.java

 import com.opensymphony.webwork.RequestUtils;
 import com.opensymphony.webwork.WebWorkConstants;
 import com.opensymphony.webwork.config.Configuration;
-import com.opensymphony.webwork.dispatcher.ServletRedirectResult;
 import com.opensymphony.webwork.util.PrefixTrie;
 
 import javax.servlet.http.HttpServletRequest;
 
     static final String METHOD_PREFIX = "method:";
     static final String ACTION_PREFIX = "action:";
-    static final String REDIRECT_PREFIX = "redirect:";
-    static final String REDIRECT_ACTION_PREFIX = "redirect-action:";
 
     static PrefixTrie prefixTrie = new PrefixTrie() {
         {
                         mapping.setMethod(method);
                         name = name.substring(0, bang);
                     }
-                    
-                    mapping.setName(name);
-                }
-            });
-
-            put(REDIRECT_PREFIX, new ParameterAction() {
-                public void execute(String key, ActionMapping mapping) {
-                    ServletRedirectResult redirect = new ServletRedirectResult();
-                    redirect.setLocation(key.substring(REDIRECT_PREFIX.length()));
-                    mapping.setResult(redirect);
-                }
-            });
 
-            put(REDIRECT_ACTION_PREFIX, new ParameterAction() {
-                public void execute(String key, ActionMapping mapping) {
-                    String location = key.substring(REDIRECT_ACTION_PREFIX.length());
-                    ServletRedirectResult redirect = new ServletRedirectResult();
-                    String extension = getDefaultExtension();
-                    if (extension != null) {
-                        location += "." + extension;
-                    }
-                    redirect.setLocation(location);
-                    mapping.setResult(redirect);
+                    mapping.setName(name);
                 }
             });
         }

src/test/com/opensymphony/webwork/dispatcher/mapper/DefaultActionMapperTest.java

 import java.util.HashMap;
 import java.util.Map;
 
-import com.opensymphony.webwork.dispatcher.ServletRedirectResult;
 import com.opensymphony.webwork.views.jsp.WebWorkMockHttpServletRequest;
 import com.opensymphony.xwork.Result;
 
 	
 	public void testRedirectPrefix() throws Exception {
 		Map parameterMap = new HashMap();
-		parameterMap.put(DefaultActionMapper.REDIRECT_PREFIX+"www.google.com", "");
-		
+		parameterMap.put("redirect:" + "www.google.com", "");
+
 		WebWorkMockHttpServletRequest request = new WebWorkMockHttpServletRequest();
 		request.setupGetServletPath("/someServletPath.action");
 		request.setParameterMap(parameterMap);
 		ActionMapping actionMapping = defaultActionMapper.getMapping(request);
 		
 		Result result = actionMapping.getResult();
-		assertNotNull(result);
-		assertTrue(result instanceof ServletRedirectResult);
-		
-		//TODO: need to test location but there's noaccess to the property/method, unless we use reflection
+		assertNull(result);
 	}
 	
 	public void testRedirectActionPrefix() throws Exception {
 		Map parameterMap = new HashMap();
-		parameterMap.put(DefaultActionMapper.REDIRECT_ACTION_PREFIX+"myAction", "");
-		
+		parameterMap.put("redirectAction:" + "myAction", "");
+
 		WebWorkMockHttpServletRequest request = new WebWorkMockHttpServletRequest();
 		request.setupGetServletPath("/someServletPath.action");
 		request.setParameterMap(parameterMap);
 		ActionMapping actionMapping = defaultActionMapper.getMapping(request);
 		
 		Result result = actionMapping.getResult();
-		assertNotNull(result);
-		assertTrue(result instanceof ServletRedirectResult);
-		
-		// TODO: need to test location but there's noaccess to the property/method, unless we use reflection
+		assertNull(result);
 	}
 	
 	
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.