dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #26201
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12974: fixed potential concurrency issues in api/me/programs
------------------------------------------------------------
revno: 12974
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-11-19 15:33:28 +0100
message:
fixed potential concurrency issues in api/me/programs
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-10-15 13:18:44 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.java 2013-11-19 14:33:28 +0000
@@ -81,7 +81,7 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping(value = { CurrentUserController.RESOURCE_PATH, "/me" }, method = RequestMethod.GET)
+@RequestMapping( value = { CurrentUserController.RESOURCE_PATH, "/me" }, method = RequestMethod.GET )
public class CurrentUserController
{
public static final String RESOURCE_PATH = "/currentUser";
@@ -120,7 +120,7 @@
@Autowired
private I18nService i18nService;
- @RequestMapping(produces = { "application/json", "text/*" })
+ @RequestMapping( produces = { "application/json", "text/*" } )
public void getCurrentUser( HttpServletResponse response ) throws Exception
{
User currentUser = currentUserService.getCurrentUser();
@@ -133,7 +133,7 @@
JacksonUtils.toJsonWithView( response.getOutputStream(), currentUser, DetailedView.class );
}
- @RequestMapping(value = "/inbox", produces = { "application/json", "text/*" })
+ @RequestMapping( value = "/inbox", produces = { "application/json", "text/*" } )
public void getInbox( HttpServletResponse response ) throws Exception
{
User currentUser = currentUserService.getCurrentUser();
@@ -150,7 +150,7 @@
JacksonUtils.toJson( response.getOutputStream(), inbox );
}
- @RequestMapping(value = "/dashboard", produces = { "application/json", "text/*" })
+ @RequestMapping( value = "/dashboard", produces = { "application/json", "text/*" } )
public void getDashboard( HttpServletResponse response ) throws Exception
{
User currentUser = currentUserService.getCurrentUser();
@@ -167,7 +167,7 @@
JacksonUtils.toJson( response.getOutputStream(), dashboard );
}
- @RequestMapping(value = { "/profile", "/user-account" }, produces = { "application/json", "text/*" })
+ @RequestMapping( value = { "/profile", "/user-account" }, produces = { "application/json", "text/*" } )
public void getUserAccount( HttpServletResponse response ) throws Exception
{
User currentUser = currentUserService.getCurrentUser();
@@ -204,7 +204,7 @@
JacksonUtils.toJson( response.getOutputStream(), userAccount );
}
- @RequestMapping(value = { "/profile", "/user-account" }, method = RequestMethod.POST, consumes = "application/json")
+ @RequestMapping( value = { "/profile", "/user-account" }, method = RequestMethod.POST, consumes = "application/json" )
public void postUserAccountJson( HttpServletResponse response, HttpServletRequest request ) throws Exception
{
UserAccount userAccount = JacksonUtils.fromJson( request.getInputStream(), UserAccount.class );
@@ -240,9 +240,9 @@
userService.updateUser( currentUser );
}
- @RequestMapping(value = "/recipients", produces = { "application/json", "text/*" })
+ @RequestMapping( value = "/recipients", produces = { "application/json", "text/*" } )
public void recipientsJson( HttpServletResponse response,
- @RequestParam(value = "filter") String filter ) throws IOException, NotAuthenticatedException, FilterTooShortException
+ @RequestParam( value = "filter" ) String filter ) throws IOException, NotAuthenticatedException, FilterTooShortException
{
User currentUser = currentUserService.getCurrentUser();
@@ -267,7 +267,7 @@
JacksonUtils.toJson( response.getOutputStream(), recipients );
}
- @RequestMapping(value = { "/assignedOrganisationUnits", "/organisationUnits" }, produces = { "application/json", "text/*" })
+ @RequestMapping( value = { "/assignedOrganisationUnits", "/organisationUnits" }, produces = { "application/json", "text/*" } )
public void getAssignedOrganisationUnits( HttpServletResponse response, @RequestParam Map<String, String> parameters ) throws IOException, NotAuthenticatedException
{
User currentUser = currentUserService.getCurrentUser();
@@ -282,17 +282,25 @@
if ( parameters.containsKey( "includeChildren" ) && Boolean.parseBoolean( parameters.get( "includeChildren" ) ) )
{
+ List<OrganisationUnit> children = new ArrayList<OrganisationUnit>();
+
for ( OrganisationUnit organisationUnit : userOrganisationUnits )
{
- userOrganisationUnits.addAll( organisationUnit.getChildren() );
+ children.addAll( organisationUnit.getChildren() );
}
+
+ userOrganisationUnits.addAll( children );
}
else if ( parameters.containsKey( "includeDescendants" ) && Boolean.parseBoolean( parameters.get( "includeDescendants" ) ) )
{
+ List<OrganisationUnit> children = new ArrayList<OrganisationUnit>();
+
for ( OrganisationUnit organisationUnit : userOrganisationUnits )
{
- userOrganisationUnits.addAll( organisationUnitService.getOrganisationUnitsWithChildren( organisationUnit.getUid() ) );
+ children.addAll( organisationUnitService.getOrganisationUnitsWithChildren( organisationUnit.getUid() ) );
}
+
+ userOrganisationUnits.addAll( children );
}
String viewName = parameters.get( "viewClass" );
@@ -307,9 +315,9 @@
JacksonUtils.toJsonWithView( response.getOutputStream(), userOrganisationUnits, viewClass );
}
- @RequestMapping(value = { "/assignedPrograms", "/programs" }, produces = { "application/json", "text/*" })
+ @RequestMapping( value = { "/assignedPrograms", "/programs" }, produces = { "application/json", "text/*" } )
public void getPrograms( HttpServletResponse response, @RequestParam Map<String, String> parameters,
- @RequestParam(required = false) Integer type )
+ @RequestParam( required = false ) Integer type )
throws IOException, NotAuthenticatedException
{
User currentUser = currentUserService.getCurrentUser();
@@ -345,17 +353,25 @@
if ( parameters.containsKey( "includeDescendants" ) && Boolean.parseBoolean( parameters.get( "includeDescendants" ) ) )
{
+ List<OrganisationUnit> children = new ArrayList<OrganisationUnit>();
+
for ( OrganisationUnit organisationUnit : userOrganisationUnits )
{
- userOrganisationUnits.addAll( organisationUnitService.getOrganisationUnitsWithChildren( organisationUnit.getUid() ) );
+ children.addAll( organisationUnitService.getOrganisationUnitsWithChildren( organisationUnit.getUid() ) );
}
+
+ userOrganisationUnits.addAll( children );
}
else
{
+ List<OrganisationUnit> children = new ArrayList<OrganisationUnit>();
+
for ( OrganisationUnit organisationUnit : userOrganisationUnits )
{
- userOrganisationUnits.addAll( organisationUnit.getChildren() );
+ children.addAll( organisationUnit.getChildren() );
}
+
+ userOrganisationUnits.addAll( children );
}
for ( OrganisationUnit organisationUnit : userOrganisationUnits )
@@ -418,8 +434,8 @@
JacksonUtils.toJson( response.getOutputStream(), forms );
}
- @SuppressWarnings("unchecked")
- @RequestMapping(value = { "/assignedDataSets", "/dataSets" }, produces = { "application/json", "text/*" })
+ @SuppressWarnings( "unchecked" )
+ @RequestMapping( value = { "/assignedDataSets", "/dataSets" }, produces = { "application/json", "text/*" } )
public void getDataSets( HttpServletResponse response, @RequestParam Map<String, String> parameters ) throws IOException, NotAuthenticatedException
{
User currentUser = currentUserService.getCurrentUser();