changeset 7485:47905b570eaf

Merged
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 31 Oct 2013 18:34:10 +0100
parents 8b614d152a79 (current diff) bdb12632c5f5 (diff)
children 6b278187ed9d
files
diffstat 2 files changed, 28 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/backend/doc/documentation/de/importer-hydr-morph.tex	Thu Oct 31 18:30:46 2013 +0100
+++ b/backend/doc/documentation/de/importer-hydr-morph.tex	Thu Oct 31 18:34:10 2013 +0100
@@ -399,10 +399,14 @@
 obwohl sich das Gewässer noch nicht in der Datenbank befindet 
 (siehe Kapitel \ref{import_data}).
 
-\textbf{Stations in 'XYZ' near line \# not ordered. File rejected.}
+\textbf{WST: Stations in 'XYZ' near line \# not ordered. File rejected.}
 \\Die Stationen in einer WST-Datei sind nicht konsequent auf- oder 
 absteigend geordnet. Die Datei wird verworfen.
 
+\textbf{WST: number of columns is less than expected. File rejected.}
+\\Die Anzahl der Spalten in einer Zeile einer WST-Datei stimmt nicht
+mit der Angabe im Datei-Kopf überein. Die Datei wird verworfen.
+
 \textbf{File 'XYZ' is broken!}
 \\Die Datei XYZ ist inkonsistent und führt zu Fehlern.
 
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java	Thu Oct 31 18:30:46 2013 +0100
+++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java	Thu Oct 31 18:34:10 2013 +0100
@@ -188,8 +188,14 @@
 
                 // handle Q-lines
                 if (line.startsWith("*\u001f")) {
-                    BigDecimal [] data =
-                        parseLineAsDouble(line, columnCount, false, true);
+                    BigDecimal [] data = null;
+                    try {
+                        data = parseLineAsDouble(line, columnCount, false, true);
+                    }
+                    catch(IllegalArgumentException iae) {
+                        log.error(iae.getMessage());
+                        return;
+                    }
 
                     if (aktAbfluesse != null) { // add Q-ranges obtained from previous lines
                         if (kmHist1 != null && kmHist2 != null
@@ -329,8 +335,14 @@
                         columnHeaderChecked = true;
                     }
 
-                    BigDecimal [] data =
-                        parseLineAsDouble(line, columnCount, true, false);
+                    BigDecimal [] data = null;
+                    try {
+                        data = parseLineAsDouble(line, columnCount, true, false);
+                    }
+                    catch(IllegalArgumentException iae) {
+                        log.error(iae.getMessage());
+                        return;
+                    }
 
                     BigDecimal kaem = data[0];
 
@@ -345,7 +357,7 @@
                     // check consistence of station ordering in file
                     if (kmHist2 != null && 
                         kmHist2.compareTo(kmHist1) != kmHist1.compareTo(kaem)) {
-                        throw new ParseException("Stations in " + file + 
+                        throw new ParseException("WST: Stations in " + file + 
                             " near line " + in.getLineNumber() + 
                             " not ordered. File rejected.");
                     }
@@ -529,11 +541,15 @@
             strings.add(line.substring(0, 8));
         }
 
-        int pos = 9;
+        int pos = 0;
         for (int i = 0; i < tokenCount; ++i) {
+            pos += 9;
+            if (pos >= line.length()) {
+                throw new IllegalArgumentException(
+                    "WST: number of columns is less than expected. File rejected.");
+            }
             strings.add(line.substring(pos, 
                 Math.min(pos + 8, line.length())));
-            pos += 9;
         }
 
         return strings.toArray(new String[strings.size()]);

http://dive4elements.wald.intevation.org