← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19300: Identifiable object, generic store, null checks

 

------------------------------------------------------------
revno: 19300
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2015-06-07 14:42:33 +0200
message:
  Identifiable object, generic store, null checks
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java
  dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.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-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java	2015-03-03 13:43:52 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java	2015-06-07 12:42:33 +0000
@@ -463,7 +463,11 @@
 
         publicAccess = AccessStringHelper.DEFAULT;
         externalAccess = false;
-        userGroupAccesses.clear();
+        
+        if ( userGroupAccesses != null )
+        {
+            userGroupAccesses.clear();
+        }
     }
 
     /**
@@ -496,6 +500,7 @@
     public static Map<String, Integer> getCodeMap( Collection<? extends BaseIdentifiableObject> objects )
     {
         Map<String, Integer> map = new HashMap<>();
+        
         for ( BaseIdentifiableObject object : objects )
         {
             String code = object.getCode();
@@ -503,6 +508,7 @@
 
             map.put( code, internalId );
         }
+        
         return map;
     }
 
@@ -515,6 +521,7 @@
     public static Map<String, Integer> getNameMap( Collection<? extends BaseIdentifiableObject> objects )
     {
         Map<String, Integer> map = new HashMap<>();
+        
         for ( BaseIdentifiableObject object : objects )
         {
             String name = object.getName();
@@ -522,6 +529,7 @@
 
             map.put( name, internalId );
         }
+        
         return map;
     }
 
@@ -574,7 +582,10 @@
         publicAccess = other.getPublicAccess() == null ? publicAccess : other.getPublicAccess();
         externalAccess = other.getExternalAccess();
 
-        userGroupAccesses.clear();
-        userGroupAccesses.addAll( other.getUserGroupAccesses() );
+        if ( userGroupAccesses != null )
+        {
+            userGroupAccesses.clear();
+            userGroupAccesses.addAll( other.getUserGroupAccesses() );
+        }
     }
 }

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java	2015-05-15 07:32:28 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java	2015-06-07 12:42:33 +0000
@@ -93,7 +93,7 @@
     protected CurrentUserService currentUserService;
 
     /**
-     * Allows rewiring (e.g. by a unit test)
+     * Allows injection (e.g. by a unit test)
      */
     public void setCurrentUserService( CurrentUserService currentUserService )
     {
@@ -338,7 +338,11 @@
             if ( clearSharing )
             {
                 identifiableObject.setPublicAccess( AccessStringHelper.DEFAULT );
-                identifiableObject.getUserGroupAccesses().clear();
+                
+                if ( identifiableObject.getUserGroupAccesses() != null )
+                {
+                    identifiableObject.getUserGroupAccesses().clear();
+                }
             }
 
             if ( identifiableObject.getUser() == null )