Author: mrdon Date: Wed Jan 10 14:55:44 2007 New Revision: 495026 URL: http://svn.apache.org/viewvc?view=rev&rev=495026 Log: Fixed restful action mapper (switched role of put/get) WW-1475
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapper.java struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapperTest.java Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapper.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapper.java?view=diff&rev=495026&r1=495025&r2=495026 ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapper.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapper.java Wed Jan 10 14:55:44 2007 @@ -63,8 +63,8 @@ * <li><code>GET: /movie/Thrillers => method="view", id="Thrillers"</code></li> * <li><code>GET: /movie/Thrillers!edit => method="edit", id="Thrillers"</code></li> * <li><code>GET: /movie/new => method="editNew"</code></li> - * <li><code>POST: /movie/Thrillers => method="update"</code></li> - * <li><code>PUT: /movie/ => method="create"</code></li> + * <li><code>POST: /movie/Thrillers => method="create"</code></li> + * <li><code>PUT: /movie/ => method="update"</code></li> * <li><code>DELETE: /movie/Thrillers => method="remove"</code></li> * </ul> * <p> @@ -108,9 +108,9 @@ // Index e.g. foo/ if (isGet(request)) { mapping.setMethod("index"); - + // Creating a new entry on POST e.g. foo/ - } else if (isPost(request)) { + } else if (isPut(request)) { mapping.setMethod("create"); } @@ -126,7 +126,7 @@ mapping.setMethod("view"); // Updating an item e.g. foo/1 - } else if (isPut(request)) { + } else if (isPost(request)) { mapping.setMethod("update"); // Removing an item e.g. foo/1 @@ -173,7 +173,6 @@ mapping.setName(actionName.substring(actionSlashPos+1)); } } - return mapping; } Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapperTest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapperTest.java?view=diff&rev=495026&r1=495025&r2=495026 ============================================================================== --- struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapperTest.java (original) +++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/Restful2ActionMapperTest.java Wed Jan 10 14:55:44 2007 @@ -88,12 +88,12 @@ assertEquals("1", mapping.getParams().get("bar")); } - public void testPostCreate() throws Exception { + public void testPutCreate() throws Exception { req.setupGetRequestURI("/my/namespace/foo/"); req.setupGetServletPath("/my/namespace/foo/"); req.setupGetAttribute(null); req.addExpectedGetAttributeName("javax.servlet.include.servlet_path"); - req.setupGetMethod("POST"); + req.setupGetMethod("PUT"); ActionMapping mapping = mapper.getMapping(req, configManager);