← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11085: Web api, made sure links and access are put on objects for the query resource

 

------------------------------------------------------------
revno: 11085
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-05-29 17:31:28 +0200
message:
  Web api, made sure links and access are put on objects for the query resource
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.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/AbstractCrudController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java	2013-03-19 17:09:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java	2013-05-29 15:31:28 +0000
@@ -87,18 +87,7 @@
 
         ReflectionUtils.invokeSetterMethod( ExchangeClasses.getAllExportMap().get( getEntityClass() ), metaData, entityList );
 
-        if ( options.hasLinks() )
-        {
-            WebUtils.generateLinks( metaData );
-        }
-
-        if ( SharingUtils.isSupported( getEntityClass() ) )
-        {
-            for ( T object : entityList )
-            {
-                addAccessProperties( object );
-            }
-        }
+        handleLinksAndAccess( options, metaData, entityList );
 
         postProcessEntities( entityList );
         postProcessEntities( entityList, parameters );
@@ -118,10 +107,7 @@
 
         ReflectionUtils.invokeSetterMethod( ExchangeClasses.getAllExportMap().get( getEntityClass() ), metaData, entityList );
 
-        if ( options.hasLinks() )
-        {
-            WebUtils.generateLinks( metaData );
-        }
+        handleLinksAndAccess( options, metaData, entityList );
 
         postProcessEntities( entityList );
         postProcessEntities( entityList, parameters );
@@ -344,6 +330,22 @@
         ((BaseIdentifiableObject) object).setAccess( access );
     }
 
+    protected void handleLinksAndAccess( WebOptions options, WebMetaData metaData, List<T> entityList )
+    {
+        if ( options != null && options.hasLinks() )
+        {
+            WebUtils.generateLinks( metaData );
+        }
+
+        if ( entityList != null && SharingUtils.isSupported( getEntityClass() ) )
+        {
+            for ( T object : entityList )
+            {
+                addAccessProperties( object );
+            }
+        }
+    }
+    
     //--------------------------------------------------------------------------
     // Reflection helpers
     //--------------------------------------------------------------------------