diff backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java @ 7339:40e5ad76103c

WST Import: Added parse error exception to WST parser.
author Sascha L. Teichmann <teichmann@intevation.de>
date Tue, 15 Oct 2013 18:31:59 +0200
parents c894b7b45c4c
children 2ce7bacc940f
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java	Tue Oct 15 17:39:04 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java	Tue Oct 15 18:31:59 2013 +0200
@@ -356,12 +356,17 @@
                 continue;
             }
             log.info("found file '" + file.getName() + "'");
-            WstParser wstParser = new WstParser();
-            wstParser.parse(file);
-            ImportWst iw = wstParser.getWst();
-            iw.setKind(5);
-            iw.setDescription(FLOOD_PROTECTION + "/" + iw.getDescription());
-            floodProtection.add(iw);
+            try {
+                WstParser wstParser = new WstParser();
+                wstParser.parse(file);
+                ImportWst iw = wstParser.getWst();
+                iw.setKind(5);
+                iw.setDescription(FLOOD_PROTECTION + "/" + iw.getDescription());
+                floodProtection.add(iw);
+            }
+            catch (WstParser.ParseException e) {
+                log.error(e);
+            }
         }
     }
 
@@ -768,12 +773,17 @@
                 continue;
             }
             log.info("found file '" + file.getName() + "'");
-            WstParser wstParser = new WstParser();
-            wstParser.parse(file);
-            ImportWst iw = wstParser.getWst();
-            iw.setKind(4);
-            iw.setDescription(FLOOD_WATER + "/" + iw.getDescription());
-            floodWater.add(iw);
+            try {
+                WstParser wstParser = new WstParser();
+                wstParser.parse(file);
+                ImportWst iw = wstParser.getWst();
+                iw.setKind(4);
+                iw.setDescription(FLOOD_WATER + "/" + iw.getDescription());
+                floodWater.add(iw);
+            }
+            catch (WstParser.ParseException e) {
+                log.error(e);
+            }
         }
     }
 
@@ -805,7 +815,14 @@
             ImportWst iw = new ImportWst(ImportOfficialWstColumn.COLUMN_FACTORY);
 
             WstParser wstParser = new WstParser(iw);
-            wstParser.parse(file);
+            try {
+                wstParser.parse(file);
+            }
+            catch (WstParser.ParseException e) {
+                log.error(e);
+                continue;
+            }
+
             iw.setKind(3);
             iw.setDescription(folder + "/" + iw.getDescription());
 
@@ -878,12 +895,17 @@
             }
             log.debug("Found WST file: " + file);
 
-            WstParser wstParser = new WstParser();
-            wstParser.parse(file);
-            ImportWst iw = wstParser.getWst();
-            iw.setKind(2);
-            iw.setDescription(FIXATIONS+ "/" + iw.getDescription());
-            fixations.add(iw);
+            try {
+                WstParser wstParser = new WstParser();
+                wstParser.parse(file);
+                ImportWst iw = wstParser.getWst();
+                iw.setKind(2);
+                iw.setDescription(FIXATIONS+ "/" + iw.getDescription());
+                fixations.add(iw);
+            }
+            catch (WstParser.ParseException e) {
+                log.error(e);
+            }
         }
     }
 
@@ -922,12 +944,17 @@
             }
             log.debug("Found WST file: " + file);
 
-            WstParser wstParser = new WstParser();
-            wstParser.parse(file);
-            ImportWst iw = wstParser.getWst();
-            iw.setKind(1);
-            iw.setDescription(EXTRA_LONGITUDINALS + "/" + iw.getDescription());
-            extraWsts.add(iw);
+            try {
+                WstParser wstParser = new WstParser();
+                wstParser.parse(file);
+                ImportWst iw = wstParser.getWst();
+                iw.setKind(1);
+                iw.setDescription(EXTRA_LONGITUDINALS + "/" + iw.getDescription());
+                extraWsts.add(iw);
+            }
+            catch (WstParser.ParseException e) {
+                log.error(e);
+            }
         }
 
     }
@@ -939,9 +966,14 @@
         }
 
         WstParser wstParser = new WstParser();
-        wstParser.parse(wstFile);
-        wst = wstParser.getWst();
-        wst.setKmUp(wst.guessWaterLevelIncreasing());
+        try {
+            wstParser.parse(wstFile);
+            wst = wstParser.getWst();
+            wst.setKmUp(wst.guessWaterLevelIncreasing());
+        }
+        catch (WstParser.ParseException e) {
+            log.error(e);
+        }
     }
 
     public void parseGauges() throws IOException {

http://dive4elements.wald.intevation.org