=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AppController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AppController.java 2015-08-18 20:08:20 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AppController.java 2015-08-18 21:24:18 +0000 @@ -30,6 +30,7 @@ import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; @@ -89,28 +90,31 @@ private ResourceLoader resourceLoader = new DefaultResourceLoader(); @RequestMapping( method = RequestMethod.GET, produces = ContextUtils.CONTENT_TYPE_JSON ) - public void getApps( HttpServletResponse response ) + public void getApps( @RequestParam(required=false) String key, HttpServletResponse response ) throws IOException { - List apps = appManager.getApps(); - + List apps = new ArrayList(); + + if ( key != null ) + { + App app = appManager.getApp( key ); + + if ( app == null ) + { + response.sendError( HttpServletResponse.SC_NOT_FOUND ); + return; + } + + apps.add( app ); + } + else + { + apps = appManager.getApps(); + } + renderService.toJson( response.getOutputStream(), apps ); } - @RequestMapping( method = RequestMethod.GET ) - public void getAppByKey( @RequestParam String key, HttpServletRequest request, HttpServletResponse response ) throws IOException - { - App app = appManager.getApp( key ); - - if ( app == null ) - { - response.sendError( HttpServletResponse.SC_NOT_FOUND ); - return; - } - - renderService.toJson( response.getOutputStream(), app ); - } - @RequestMapping( method = RequestMethod.POST ) @ResponseStatus( HttpStatus.NO_CONTENT ) @PreAuthorize( "hasRole('ALL') or hasRole('M_dhis-web-maintenance-appmanager')" )