← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14042: Nullpointer check

 

------------------------------------------------------------
revno: 14042
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-02-16 11:45:20 +0100
message:
  Nullpointer check
modified:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataSetsAction.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-commons/src/main/java/org/hisp/dhis/commons/action/GetDataSetsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataSetsAction.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataSetsAction.java	2014-02-16 10:45:20 +0000
@@ -41,6 +41,7 @@
 import org.hisp.dhis.paging.ActionPagingSupport;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
 import org.hisp.dhis.user.UserAuthorityGroup;
 import org.hisp.dhis.user.UserService;
 import org.hisp.dhis.util.ContextUtils;
@@ -140,13 +141,17 @@
         {
             Set<DataSet> accessibleDataSets = new HashSet<DataSet>();
 
-            for ( UserAuthorityGroup u : userService.getUserCredentials( currentUserService.getCurrentUser() )
-                .getUserAuthorityGroups() )
+            User user = currentUserService.getCurrentUser();
+            
+            if ( user != null )
             {
-                accessibleDataSets.addAll( u.getDataSets() );
-            }
-
-            dataSets.retainAll( accessibleDataSets );
+                for ( UserAuthorityGroup u : userService.getUserCredentials( user ).getUserAuthorityGroups() )
+                {
+                    accessibleDataSets.addAll( u.getDataSets() );
+                }
+                
+                dataSets.retainAll( accessibleDataSets );
+            }            
         }
 
         Collections.sort( dataSets, IdentifiableObjectNameComparator.INSTANCE );