=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventChartController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventChartController.java 2015-06-15 13:44:20 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventChartController.java 2015-07-08 08:21:49 +0000 @@ -30,8 +30,10 @@ import org.hisp.dhis.chart.ChartService; import org.hisp.dhis.common.DimensionService; +import org.hisp.dhis.commons.util.CodecUtils; 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.eventchart.EventChart; import org.hisp.dhis.eventchart.EventChartService; import org.hisp.dhis.i18n.I18nFormat; @@ -42,10 +44,10 @@ import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.program.ProgramStageService; import org.hisp.dhis.schema.descriptors.EventChartSchemaDescriptor; -import org.hisp.dhis.commons.util.CodecUtils; import org.hisp.dhis.webapi.controller.AbstractCrudController; import org.hisp.dhis.webapi.utils.ContextUtils; import org.hisp.dhis.webapi.utils.ContextUtils.CacheStrategy; +import org.hisp.dhis.webapi.utils.WebMessageUtils; import org.jfree.chart.ChartUtilities; import org.jfree.chart.JFreeChart; import org.springframework.beans.factory.annotation.Autowired; @@ -109,7 +111,8 @@ eventChartService.saveEventChart( eventChart ); - ContextUtils.createdResponse( response, "Event chart created", EventChartSchemaDescriptor.API_ENDPOINT + "/" + eventChart.getUid() ); + response.addHeader( "Location", EventChartSchemaDescriptor.API_ENDPOINT + "/" + eventChart.getUid() ); + webMessageService.send( WebMessageUtils.created( "Event chart created" ), response, request ); } @Override @@ -120,8 +123,7 @@ if ( eventChart == null ) { - ContextUtils.notFoundResponse( response, "Event chart does not exist: " + uid ); - return; + throw new WebMessageException( WebMessageUtils.notFound( "Event chart does not exist: " + uid ) ); } EventChart newEventChart = JacksonUtils.fromJson( request.getInputStream(), EventChart.class ); @@ -141,8 +143,7 @@ if ( eventChart == null ) { - ContextUtils.notFoundResponse( response, "Event report does not exist: " + uid ); - return; + throw new WebMessageException( WebMessageUtils.notFound( "Event chart does not exist: " + uid ) ); } eventChartService.deleteEventChart( eventChart ); @@ -160,14 +161,13 @@ @RequestParam( value = "width", defaultValue = "800", required = false ) int width, @RequestParam( value = "height", defaultValue = "500", required = false ) int height, @RequestParam( value = "attachment", required = false ) boolean attachment, - HttpServletResponse response ) throws IOException + HttpServletResponse response ) throws IOException, WebMessageException { EventChart chart = eventChartService.getEventChart( uid ); // TODO no acl? if ( chart == null ) { - ContextUtils.notFoundResponse( response, "Chart does not exist: " + uid ); - return; + throw new WebMessageException( WebMessageUtils.notFound( "Event chart does not exist: " + uid ) ); } OrganisationUnit unit = ou != null ? organisationUnitService.getOrganisationUnit( ou ) : null; === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventReportController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventReportController.java 2015-02-25 06:51:55 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventReportController.java 2015-07-08 08:21:49 +0000 @@ -31,6 +31,7 @@ import org.hisp.dhis.common.DimensionService; 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.eventreport.EventReport; import org.hisp.dhis.eventreport.EventReportService; import org.hisp.dhis.i18n.I18nFormat; @@ -41,7 +42,7 @@ import org.hisp.dhis.program.ProgramStageService; import org.hisp.dhis.schema.descriptors.EventReportSchemaDescriptor; 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.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; @@ -91,7 +92,8 @@ eventReportService.saveEventReport( report ); - ContextUtils.createdResponse( response, "Event report created", EventReportSchemaDescriptor.API_ENDPOINT + "/" + report.getUid() ); + response.addHeader( "Location", EventReportSchemaDescriptor.API_ENDPOINT + "/" + report.getUid() ); + webMessageService.send( WebMessageUtils.created( "Event report created" ), response, request ); } @Override @@ -102,8 +104,7 @@ if ( report == null ) { - ContextUtils.notFoundResponse( response, "Event report does not exist: " + uid ); - return; + throw new WebMessageException( WebMessageUtils.notFound( "Event report does not exist: " + uid ) ); } EventReport newReport = JacksonUtils.fromJson( request.getInputStream(), EventReport.class ); @@ -123,8 +124,7 @@ if ( report == null ) { - ContextUtils.notFoundResponse( response, "Event report does not exist: " + uid ); - return; + throw new WebMessageException( WebMessageUtils.notFound( "Event report does not exist: " + uid ) ); } eventReportService.deleteEventReport( report ); === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityAttributeController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityAttributeController.java 2015-02-20 09:14:02 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityAttributeController.java 2015-07-08 08:21:49 +0000 @@ -50,7 +50,7 @@ * @author Morten Olav Hansen */ @Controller -@RequestMapping(value = TrackedEntityAttributeSchemaDescriptor.API_ENDPOINT) +@RequestMapping( value = TrackedEntityAttributeSchemaDescriptor.API_ENDPOINT ) public class TrackedEntityAttributeController extends AbstractCrudController { @@ -70,8 +70,7 @@ if ( withoutPrograms ) { - entityList = new ArrayList<>( - trackedEntityAttributeService.getTrackedEntityAttributesWithoutProgram() ); + entityList = new ArrayList<>( trackedEntityAttributeService.getTrackedEntityAttributesWithoutProgram() ); } else if ( options.getOptions().containsKey( "query" ) ) {