← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7313: Improved response status codes for interpretation controller

 

Merge authors:
  Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 7313 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-06-15 20:19:58 +0200
message:
  Improved response status codes for interpretation controller
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.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/api/controller/InterpretationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java	2012-05-31 22:31:59 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java	2012-06-15 10:19:42 +0000
@@ -124,8 +124,9 @@
         Interpretation interpretation = new Interpretation( chart, text );
         
         interpretationService.saveInterpretation( interpretation );
-        
-        ContextUtils.okResponse( response, "Chart interpretation created" );
+
+        response.setStatus( HttpServletResponse.SC_CREATED );
+        response.setHeader( "Location", InterpretationController.RESOURCE_PATH + "/" + interpretation.getUid() );
     }
 
     @RequestMapping( value = "/map/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } )
@@ -144,8 +145,9 @@
         Interpretation interpretation = new Interpretation( mapView, text );
         
         interpretationService.saveInterpretation( interpretation );
-        
-        ContextUtils.okResponse( response, "Map view interpretation created" );
+
+        response.setStatus( HttpServletResponse.SC_CREATED );
+        response.setHeader( "Location", InterpretationController.RESOURCE_PATH + "/" + interpretation.getUid() );
     }
 
     @RequestMapping( value = "/reportTable/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } )
@@ -178,8 +180,9 @@
         Interpretation interpretation = new Interpretation( reportTable, orgUnit, text );
         
         interpretationService.saveInterpretation( interpretation );
-        
-        ContextUtils.okResponse( response, "Report table interpretation created" );
+
+        response.setStatus( HttpServletResponse.SC_CREATED );
+        response.setHeader( "Location", InterpretationController.RESOURCE_PATH + "/" + interpretation.getUid() );
     }
     
     @RequestMapping( value = "/{uid}/comment", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } )
@@ -189,6 +192,7 @@
     {
         interpretationService.addInterpretationComment( uid, text );
 
-        ContextUtils.okResponse( response, "Comment created" );
+        response.setStatus( HttpServletResponse.SC_CREATED );
+        response.setHeader( "Location", InterpretationController.RESOURCE_PATH + "/" + uid );
     }
 }