[PATCH 4 of 4] Merged
Wald Commits
scm-commit at wald.intevation.org
Thu Oct 31 18:34:18 CET 2013
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1383240850 -3600
# Node ID 47905b570eaf84e290df2dccd4482b38c07b9f19
# Parent 8b614d152a79439c6eb51c1ca83dd2e8fa87e224
# Parent bdb12632c5f58182a2b79fcc1949b9d7854f6896
Merged
diff -r 8b614d152a79 -r 47905b570eaf backend/doc/documentation/de/importer-hydr-morph.tex
--- 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.
diff -r 8b614d152a79 -r 47905b570eaf backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java
--- 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()]);
More information about the Dive4elements-commits
mailing list