← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15424: minor redirect fix in IndexController

 

------------------------------------------------------------
revno: 15424
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-05-27 10:46:50 +0200
message:
  minor redirect fix in IndexController
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/IndexController.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/IndexController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/IndexController.java	2014-05-26 09:06:51 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/IndexController.java	2014-05-27 08:46:50 +0000
@@ -28,10 +28,12 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hisp.dhis.webapi.utils.ContextUtils;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 
@@ -46,14 +48,16 @@
     //--------------------------------------------------------------------------
 
     @RequestMapping( value = "/api", method = RequestMethod.GET )
-    public void getIndex( HttpServletResponse response ) throws IOException
+    public void getIndex( HttpServletRequest request, HttpServletResponse response ) throws IOException
     {
-        response.sendRedirect( "/api/resources" );
+        String location = response.encodeRedirectURL( "/resources" );
+        response.sendRedirect( ContextUtils.getRootPath( request ) + location );
     }
 
     @RequestMapping( value = "/", method = RequestMethod.GET )
-    public void getIndexWithSlash( HttpServletResponse response ) throws IOException
+    public void getIndexWithSlash( HttpServletRequest request, HttpServletResponse response ) throws IOException
     {
-        response.sendRedirect( "/api/resources" );
+        String location = response.encodeRedirectURL( "/resources" );
+        response.sendRedirect( ContextUtils.getRootPath( request ) + location );
     }
 }