← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14773: Event analytics, fixed NPE vulnerability

 

------------------------------------------------------------
revno: 14773
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-04-10 17:05:15 +0200
message:
  Event analytics, fixed NPE vulnerability
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.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-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java	2014-03-27 11:13:02 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java	2014-04-10 15:05:15 +0000
@@ -43,6 +43,7 @@
 import org.hisp.dhis.analytics.event.EventQueryParams;
 import org.hisp.dhis.analytics.event.EventQueryPlanner;
 import org.hisp.dhis.analytics.table.PartitionUtils;
+import org.hisp.dhis.common.DimensionalObject;
 import org.hisp.dhis.common.IllegalQueryException;
 import org.hisp.dhis.common.ListMap;
 import org.hisp.dhis.common.NameableObject;
@@ -161,10 +162,13 @@
             params.setPartitions( PartitionUtils.getPartitions( queryPeriod, TABLE_PREFIX, tableSuffix, validPartitions ) );
         }
         
-        for ( NameableObject object : params.getOrganisationUnits() )
+        if ( params.hasDimensionOrFilter( DimensionalObject.ORGUNIT_DIM_ID ) )
         {
-            OrganisationUnit unit = (OrganisationUnit) object; 
-            unit.setLevel( organisationUnitService.getLevelOfOrganisationUnit( unit.getUid() ) );
+            for ( NameableObject object : params.getDimensionOrFilter( DimensionalObject.ORGUNIT_DIM_ID ) )
+            {
+                OrganisationUnit unit = (OrganisationUnit) object; 
+                unit.setLevel( organisationUnitService.getLevelOfOrganisationUnit( unit.getUid() ) );
+            }
         }
         
         //TODO periods, convert to start/end dates