← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19781: Apps, minor

 

------------------------------------------------------------
revno: 19781
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-08-18 17:24:18 -0400
message:
  Apps, minor
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AppController.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/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<App> apps = appManager.getApps();
-
+        List<App> apps = new ArrayList<App>();
+        
+        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')" )