← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22121: minor, don't validate object is mode is delete

 

------------------------------------------------------------
revno: 22121
committer: Morten Olav Hansen <morten@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2016-03-03 09:23:39 +0700
message:
  minor, don't validate object is mode is delete
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/DefaultObjectBundleService.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-03 02:03:29 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/DefaultObjectBundleService.java	2016-03-03 02:23:39 +0000
@@ -192,17 +192,21 @@
 
             List<List<PreheatErrorReport>> referenceErrors = preheatService.checkReferences( bundle.getObjects().get( klass ), bundle.getPreheat(), bundle.getPreheatIdentifier() );
             referenceErrors.forEach( objectBundleValidation::addErrorReports ); // collapsing for now, we might want to give pr object ref list
-            Iterator<IdentifiableObject> iterator = bundle.getObjects().get( klass ).iterator();
 
-            while ( iterator.hasNext() )
+            if ( !bundle.getImportMode().isDelete() )
             {
-                IdentifiableObject object = iterator.next();
-                List<ErrorReport> objectValidation = schemaValidator.validate( object );
+                Iterator<IdentifiableObject> iterator = bundle.getObjects().get( klass ).iterator();
 
-                if ( !objectValidation.isEmpty() )
+                while ( iterator.hasNext() )
                 {
-                    objectBundleValidation.addErrorReports( objectValidation );
-                    iterator.remove();
+                    IdentifiableObject object = iterator.next();
+                    List<ErrorReport> objectValidation = schemaValidator.validate( object );
+
+                    if ( !objectValidation.isEmpty() )
+                    {
+                        objectBundleValidation.addErrorReports( objectValidation );
+                        iterator.remove();
+                    }
                 }
             }
         }