← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22258: more user fixes, make sure to update userCredentials from persisted user object, since the one in...

 

------------------------------------------------------------
revno: 22258
committer: Morten Olav Hansen <morten@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2016-03-12 14:09:23 +0700
message:
  more user fixes, make sure to update userCredentials from persisted user object, since the one in the preheater might be stale
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/DefaultObjectBundleService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/hooks/UserObjectBundleHook.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-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/DefaultObjectBundleService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/DefaultObjectBundleService.java	2016-03-10 11:35:51 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/DefaultObjectBundleService.java	2016-03-12 07:09:23 +0000
@@ -315,11 +315,7 @@
         }
 
         objectBundleHooks.forEach( hook -> hook.postImport( bundle ) );
-
-        if ( FlushMode.DONE == bundle.getFlushMode() )
-        {
-            session.flush();
-        }
+        session.flush();
 
         dbmsManager.clearSession();
         bundle.setObjectBundleStatus( ObjectBundleStatus.COMMITTED );

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/hooks/UserObjectBundleHook.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/hooks/UserObjectBundleHook.java	2016-03-12 06:43:22 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/hooks/UserObjectBundleHook.java	2016-03-12 07:09:23 +0000
@@ -115,7 +115,9 @@
             }
 
             User user = (User) identifiableObject;
-            Map<String, Object> userCredentialsReferenceMap = userCredentialsReferences.get( user.getUserCredentials().getUid() );
+            UserCredentials userCredentials = user.getUserCredentials();
+
+            Map<String, Object> userCredentialsReferenceMap = userCredentialsReferences.get( userCredentials.getUid() );
 
             if ( userCredentialsReferenceMap == null || userCredentialsReferenceMap.isEmpty() )
             {
@@ -124,13 +126,13 @@
 
             user.setOrganisationUnits( (Set<OrganisationUnit>) userReferenceMap.get( "organisationUnits" ) );
             user.setDataViewOrganisationUnits( (Set<OrganisationUnit>) userReferenceMap.get( "dataViewOrganisationUnits" ) );
-
-            user.getUserCredentials().setUser( (User) userCredentialsReferenceMap.get( "user" ) );
+            userCredentials.setUser( (User) userCredentialsReferenceMap.get( "user" ) );
+            userCredentials.setUserInfo( user );
 
             preheatService.connectReferences( user, objectBundle.getPreheat(), objectBundle.getPreheatIdentifier() );
-            preheatService.connectReferences( user.getUserCredentials(), objectBundle.getPreheat(), objectBundle.getPreheatIdentifier() );
+            preheatService.connectReferences( userCredentials, objectBundle.getPreheat(), objectBundle.getPreheatIdentifier() );
 
-            sessionFactory.getCurrentSession().update( user.getUserCredentials() );
+            user.setUserCredentials( userCredentials );
             sessionFactory.getCurrentSession().update( user );
         }
     }