------------------------------------------------------------ revno: 19585 committer: Morten Olav Hansen <morte...@gmail.com> branch nick: dhis2 timestamp: Wed 2015-07-08 15:27:27 +0700 message: updated MapController and MapViewController to use WebMessage modified: dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/GeoFeatureController.java dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapController.java dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapViewController.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/mapping/GeoFeatureController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/GeoFeatureController.java 2015-06-16 10:36:25 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/GeoFeatureController.java 2015-07-08 08:27:27 +0000 @@ -34,13 +34,13 @@ import org.hisp.dhis.common.DimensionalObject; import org.hisp.dhis.common.DisplayProperty; import org.hisp.dhis.common.NameableObjectUtils; +import org.hisp.dhis.commons.filter.FilterUtils; import org.hisp.dhis.dxf2.render.RenderService; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroup; import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet; import org.hisp.dhis.system.filter.OrganisationUnitWithValidCoordinatesFilter; -import org.hisp.dhis.commons.filter.FilterUtils; import org.hisp.dhis.user.CurrentUserService; import org.hisp.dhis.webapi.utils.ContextUtils; import org.hisp.dhis.webapi.webdomain.GeoFeature; === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapController.java 2015-05-11 06:02:29 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapController.java 2015-07-08 08:27:27 +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.i18n.I18nFormat; import org.hisp.dhis.i18n.I18nManager; import org.hisp.dhis.legend.LegendService; @@ -48,6 +49,7 @@ 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.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; @@ -126,7 +128,8 @@ mappingService.addMap( map ); - ContextUtils.createdResponse( response, "Map created", MapSchemaDescriptor.API_ENDPOINT + "/" + map.getUid() ); + response.addHeader( "Location", MapSchemaDescriptor.API_ENDPOINT + "/" + map.getUid() ); + webMessageService.send( WebMessageUtils.created( "Map created" ), response, request ); } @Override @@ -137,8 +140,7 @@ if ( map == null ) { - ContextUtils.notFoundResponse( response, "Map does not exist: " + uid ); - return; + throw new WebMessageException( WebMessageUtils.notFound( "Map does not exist: " + uid ) ); } Iterator<MapView> views = map.getMapViews().iterator(); @@ -179,8 +181,7 @@ if ( map == null ) { - ContextUtils.notFoundResponse( response, "Map does not exist: " + uid ); - return; + throw new WebMessageException( WebMessageUtils.notFound( "Map does not exist: " + uid ) ); } mappingService.deleteMap( map ); @@ -203,20 +204,17 @@ if ( map == null ) { - ContextUtils.notFoundResponse( response, "Map does not exist: " + uid ); - return; + throw new WebMessageException( WebMessageUtils.notFound( "Map does not exist: " + uid ) ); } if ( width != null && width < MAP_MIN_WIDTH ) { - ContextUtils.conflictResponse( response, "Min map width is " + MAP_MIN_WIDTH + ": " + width ); - return; + throw new WebMessageException( WebMessageUtils.conflict( "Min map width is " + MAP_MIN_WIDTH + ": " + width ) ); } if ( height != null && height < MAP_MIN_HEIGHT ) { - ContextUtils.conflictResponse( response, "Min map height is " + MAP_MIN_HEIGHT + ": " + height ); - return; + throw new WebMessageException( WebMessageUtils.conflict( "Min map height is " + MAP_MIN_HEIGHT + ": " + height ) ); } 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/mapping/MapViewController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapViewController.java 2015-02-20 09:14:02 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapViewController.java 2015-07-08 08:27:27 +0000 @@ -29,6 +29,7 @@ */ import com.google.common.collect.Lists; +import org.hisp.dhis.dxf2.webmessage.WebMessageException; import org.hisp.dhis.mapgeneration.MapGenerationService; import org.hisp.dhis.mapping.MapView; import org.hisp.dhis.mapping.MappingService; @@ -37,10 +38,11 @@ import org.hisp.dhis.query.Order; import org.hisp.dhis.schema.descriptors.MapViewSchemaDescriptor; 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.hisp.dhis.webapi.webdomain.WebMetaData; import org.hisp.dhis.webapi.webdomain.WebOptions; -import org.hisp.dhis.webapi.utils.ContextUtils; -import org.hisp.dhis.webapi.utils.ContextUtils.CacheStrategy; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -86,8 +88,7 @@ if ( mapView == null ) { - ContextUtils.notFoundResponse( response, "Map view does not exist: " + uid ); - return; + throw new WebMessageException( WebMessageUtils.notFound( "Map view does not exist: " + uid ) ); } renderMapViewPng( mapView, response );
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp