dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #03303
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1129: Added check for data values out of range (2^31) for DHIS 1.4 file import.
------------------------------------------------------------
revno: 1129
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Wed 2009-11-25 18:51:16 +0100
message:
Added check for data values out of range (2^31) for DHIS 1.4 file import.
modified:
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/resources/sqlmap/routineDataValue.sqlmap.xml
dhis-2/dhis-services/dhis-service-importexport/src/main/resources/sqlmap/semiPermanentDataValue.sqlmap.xml
--
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-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
</select>
+ <select id="getRoutineDataValuesOutOfRange" resultClass="java.lang.Integer">
+ SELECT COUNT(*) FROM RoutineData WHERE EntryNumber > 2147483647
+ </select>
+
</sqlMap>
=== 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#
</select>
+ <select id="getSemiPermanentDataValuesOutOfRange" resultClass="java.lang.Integer">
+ SELECT COUNT(*) FROM SemiPermanentData WHERE EntryNumber > 2147483647
+ </select>
+
</sqlMap>