=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java 2012-10-24 10:17:56 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java 2012-10-24 10:22:27 +0000 @@ -187,7 +187,7 @@ @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE ) @ResponseStatus( value = HttpStatus.NO_CONTENT ) @PreAuthorize( "hasRole('ALL')" ) - public void deleteObject( @PathVariable( "uid" ) String uid ) throws Exception + public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws Exception { throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() ); } === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapLegendSetController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapLegendSetController.java 2012-10-24 10:17:56 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapLegendSetController.java 2012-10-24 10:22:27 +0000 @@ -111,4 +111,29 @@ mappingService.updateMapLegendSet( legendSet ); } + + @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE ) + @ResponseStatus( value = HttpStatus.NO_CONTENT ) + @PreAuthorize( "hasRole('ALL') or hasRole('ALL')" ) + public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws Exception + { + MapLegendSet legendSet = mappingService.getMapLegendSet( uid ); + + if ( legendSet == null ) + { + ContextUtils.notFoundResponse( response, "Map legend set does not exist: " + uid ); + return; + } + + Iterator legends = legendSet.getMapLegends().iterator(); + + while ( legends.hasNext() ) + { + MapLegend legend = legends.next(); + legends.remove(); + mappingService.deleteMapLegend( legend ); + } + + mappingService.deleteMapLegendSet( legendSet ); + } }