← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19584: updated LegendSetController to use WebMessage

 

------------------------------------------------------------
revno: 19584
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-07-08 15:24:28 +0700
message:
  updated LegendSetController to use WebMessage
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/legend/LegendSetController.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/legend/LegendSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/legend/LegendSetController.java	2015-02-25 06:51:55 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/legend/LegendSetController.java	2015-07-08 08:24:28 +0000
@@ -30,12 +30,13 @@
 
 import org.hisp.dhis.dxf2.common.ImportOptions;
 import org.hisp.dhis.dxf2.common.JacksonUtils;
+import org.hisp.dhis.dxf2.webmessage.WebMessageException;
 import org.hisp.dhis.legend.Legend;
 import org.hisp.dhis.legend.LegendService;
 import org.hisp.dhis.legend.LegendSet;
 import org.hisp.dhis.schema.descriptors.LegendSetSchemaDescriptor;
 import org.hisp.dhis.webapi.controller.AbstractCrudController;
-import org.hisp.dhis.webapi.utils.ContextUtils;
+import org.hisp.dhis.webapi.utils.WebMessageUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Controller;
@@ -72,7 +73,8 @@
 
         legendService.addLegendSet( legendSet );
 
-        ContextUtils.createdResponse( response, "Legend set created", LegendSetSchemaDescriptor.API_ENDPOINT + "/" + legendSet.getUid() );
+        response.addHeader( "Location", LegendSetSchemaDescriptor.API_ENDPOINT + "/" + legendSet.getUid() );
+        webMessageService.send( WebMessageUtils.created( "Legend set created" ), response, request );
     }
 
     @Override
@@ -84,8 +86,7 @@
 
         if ( legendSet == null )
         {
-            ContextUtils.notFoundResponse( response, "Legend set does not exist: " + uid );
-            return;
+            throw new WebMessageException( WebMessageUtils.notFound( "Legend set does not exist: " + uid ) );
         }
 
         Iterator<Legend> legends = legendSet.getLegends().iterator();
@@ -118,8 +119,7 @@
 
         if ( legendSet == null )
         {
-            ContextUtils.notFoundResponse( response, "Legend set does not exist: " + uid );
-            return;
+            throw new WebMessageException( WebMessageUtils.notFound( "Legend set does not exist: " + uid ) );
         }
 
         Iterator<Legend> legends = legendSet.getLegends().iterator();