=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/importer/DefaultDhis14FileImportService.java' --- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/importer/DefaultDhis14FileImportService.java 2009-11-23 17:06:09 +0000 +++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/importer/DefaultDhis14FileImportService.java 2009-11-25 17:51:16 +0000 @@ -261,6 +261,11 @@ public void importData( ImportParams params, InputStream inputStream ) { + if ( !verifyImportFile( params ) ) + { + return; + } + NameMappingUtil.clearMapping(); if ( params.isPreview() ) @@ -915,4 +920,36 @@ return mapping; } + + /** + * Verifies that the import file is valid by checking for routine and semi + * permanent data values out of range. + */ + private boolean verifyImportFile( ImportParams params ) + { + if ( params.isDataValues() ) + { + Integer count = (Integer) queryManager.queryForObject( "getRoutineDataValuesOutOfRange", null ); + + if ( count != null && count > 0 ) + { + log.error( "Table RoutineData contains values larger than 2^31 which is out of range" ); + + return false; + } + + count = (Integer) queryManager.queryForObject( "getSemiPermanentDataValuesOutOfRange", null ); + + if ( count != null && count > 0 ) + { + log.error( "Table SemiPermanentData contains values larger than 2^31 which is out of range" ); + + return false; + } + } + + log.info( "Verified import file" ); + + return true; + } } === modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/resources/sqlmap/routineDataValue.sqlmap.xml' --- dhis-2/dhis-services/dhis-service-importexport/src/main/resources/sqlmap/routineDataValue.sqlmap.xml 2009-03-03 16:46:36 +0000 +++ dhis-2/dhis-services/dhis-service-importexport/src/main/resources/sqlmap/routineDataValue.sqlmap.xml 2009-11-25 17:51:16 +0000 @@ -35,4 +35,8 @@ SELECT DISTINCT DataPeriodID FROM RoutineData + + === modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/resources/sqlmap/semiPermanentDataValue.sqlmap.xml' --- dhis-2/dhis-services/dhis-service-importexport/src/main/resources/sqlmap/semiPermanentDataValue.sqlmap.xml 2009-03-03 16:46:36 +0000 +++ dhis-2/dhis-services/dhis-service-importexport/src/main/resources/sqlmap/semiPermanentDataValue.sqlmap.xml 2009-11-25 17:51:16 +0000 @@ -39,4 +39,8 @@ AND LastUpdated > #value# + +