dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37846
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19324: Improved error message output on failed gml import
------------------------------------------------------------
revno: 19324
committer: Halvdan Hoem Grelland <halvdanhg@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-06-09 17:19:51 +0200
message:
Improved error message output on failed gml import
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/DefaultGmlImportService.java
dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/util/ImportMetaDataGmlTask.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/gml/DefaultGmlImportService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/DefaultGmlImportService.java 2015-06-09 14:24:56 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/DefaultGmlImportService.java 2015-06-09 15:19:51 +0000
@@ -151,7 +151,6 @@
return GmlPreProcessingResult.success( metaData );
}
- @Transactional
@Override
public void importGml( MetaData metaData, String userUid, ImportOptions importOptions, TaskId taskId )
{
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/util/ImportMetaDataGmlTask.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/util/ImportMetaDataGmlTask.java 2015-06-05 12:56:34 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/util/ImportMetaDataGmlTask.java 2015-06-09 15:19:51 +0000
@@ -93,35 +93,45 @@
GmlPreProcessingResult gmlPreProcessingResult = gmlImportService.preProcessGml( inputStream );
- if ( !gmlPreProcessingResult.isSuccess() )
+ if ( gmlPreProcessingResult.isSuccess() )
+ {
+ gmlImportService.importGml( gmlPreProcessingResult.getResultMetaData(), userUid, importOptions, taskId );
+ }
+ else
{
Throwable throwable = gmlPreProcessingResult.getThrowable();
- String message = createErrorMessage( throwable );
-
- notifier.notify( taskId, NotificationLevel.ERROR, message, false );
- log.error( "GML import failed: " + message, throwable );
-
- return;
+
+ notifier.notify( taskId, NotificationLevel.ERROR, createNotifierErrorMessage( throwable ), false );
+ log.error( "GML import failed during pre-processing", throwable );
}
-
- gmlImportService.importGml( gmlPreProcessingResult.getResultMetaData(), userUid, importOptions, taskId );
}
- private String createErrorMessage( Throwable throwable )
+ private String createNotifierErrorMessage( Throwable throwable )
{
- String message = "";
+ StringBuilder sb = new StringBuilder( "GML import failed: " );
+
Throwable rootThrowable = ExceptionUtils.getRootCause( throwable );
-
if ( rootThrowable instanceof SAXParseException )
{
SAXParseException e = (SAXParseException) rootThrowable;
- message += "Syntax error on line " + e.getLineNumber() + ". " + e.getMessage();
+ sb.append( e.getMessage() );
+
+ if ( e.getLineNumber() >= 0 )
+ {
+ sb.append( " On line " ).append( e.getLineNumber() );
+
+ if ( e.getColumnNumber() >= 0 )
+ {
+ sb.append( " column " ).append( e.getColumnNumber() );
+ }
+ }
+ sb.append( "." );
}
else
{
- message += rootThrowable.getMessage();
+ sb.append( rootThrowable.getMessage() );
}
- return HtmlUtils.htmlEscape( message );
+ return HtmlUtils.htmlEscape( sb.toString() );
}
}