dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24317
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11899: fixed bug in assignedPrograms, was returning programs it couldn't access
------------------------------------------------------------
revno: 11899
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-09-04 09:49:25 +0200
message:
fixed bug in assignedPrograms, was returning programs it couldn't access
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.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/api/controller/user/CurrentUserController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.java 2013-09-03 15:24:51 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.java 2013-09-04 07:49:25 +0000
@@ -306,9 +306,9 @@
JacksonUtils.toJsonWithView( response.getOutputStream(), userOrganisationUnits, viewClass );
}
- @RequestMapping( value = { "/assignedPrograms" }, produces = { "application/json", "text/*" } )
+ @RequestMapping(value = { "/assignedPrograms" }, produces = { "application/json", "text/*" })
public void getPrograms( HttpServletResponse response, @RequestParam Map<String, String> parameters,
- @RequestParam( defaultValue = "1" ) Integer type )
+ @RequestParam(defaultValue = "1") Integer type )
throws IOException, NotAuthenticatedException
{
User currentUser = currentUserService.getCurrentUser();
@@ -321,6 +321,7 @@
Set<OrganisationUnit> userOrganisationUnits = new HashSet<OrganisationUnit>();
Set<OrganisationUnit> organisationUnits = new HashSet<OrganisationUnit>();
Set<Program> programs = new HashSet<Program>();
+ List<Program> userPrograms = new ArrayList<Program>( programService.getProgramsByCurrentUser( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) );
Map<String, List<Program>> programAssociations = new HashMap<String, List<Program>>();
if ( currentUser.getOrganisationUnits().isEmpty() && currentUser.getUserCredentials().getAllAuthorities().contains( "ALL" ) )
@@ -354,9 +355,15 @@
if ( !ouPrograms.isEmpty() )
{
- organisationUnits.add( organisationUnit );
- programs.addAll( ouPrograms );
- programAssociations.put( organisationUnit.getUid(), ouPrograms );
+ for ( Program program : ouPrograms )
+ {
+ if ( userPrograms.contains( program ) )
+ {
+ organisationUnits.add( organisationUnit );
+ programs.addAll( ouPrograms );
+ programAssociations.put( organisationUnit.getUid(), ouPrograms );
+ }
+ }
}
}