=== modified file 'dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java' --- dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java 2013-03-06 04:25:38 +0000 +++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java 2013-03-07 07:59:41 +0000 @@ -51,9 +51,33 @@ return orgUnits; } + @RequestMapping( method = RequestMethod.GET, value = "/{version}" ) + @ResponseBody + public OrgUnits getOrgUnitsForUser( HttpServletRequest request, @PathVariable String version ) + throws NotAllowedException + { + User user = currentUserService.getCurrentUser(); + + if ( user == null ) + { + throw NotAllowedException.NO_USER; + } + + Collection units = user.getOrganisationUnits(); + + List unitList = new ArrayList(); + for ( OrganisationUnit unit : units ) + { + unitList.add( getOrgUnit( unit, request ) ); + } + OrgUnits orgUnits = new OrgUnits( unitList ); + orgUnits.setClientVersion( version ); + return orgUnits; + } + @RequestMapping( method = RequestMethod.GET, value = "/{version}/" ) @ResponseBody - public OrgUnits getOrgUnitsForUser( HttpServletRequest request, @PathVariable String version ) + public OrgUnits getOrgUnitsForUserLWUIT( HttpServletRequest request, @PathVariable String version ) throws NotAllowedException { User user = currentUserService.getCurrentUser();