diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java @ 1121:66783d957201

Close open shapefile transactions properly. flys-artifacts/trunk@2628 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 01 Sep 2011 07:27:44 +0000
parents fb3947027e92
children be9bb260b835
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java	Thu Sep 01 07:06:14 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java	Thu Sep 01 07:27:44 2011 +0000
@@ -4,7 +4,6 @@
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.net.MalformedURLException;
 import java.util.List;
 
 import javax.xml.xpath.XPathConstants;
@@ -300,25 +299,23 @@
         File shapeLines = new File(dir, WSPLGEN_BARRIERS_LINES);
         File shapePolys = new File(dir, WSPLGEN_BARRIERS_POLY);
 
-        try {
-            GeometryUtils.writeShapefile(
-                shapeLines,
-                GeometryUtils.buildFeatureType("lines", srs, LineString.class),
-                fcs[0]);
-            job.addLin(shapeLines.getAbsolutePath());
+        boolean l = GeometryUtils.writeShapefile(
+            shapeLines,
+            GeometryUtils.buildFeatureType("lines", srs, LineString.class),
+            fcs[0]);
 
-            GeometryUtils.writeShapefile(
-                shapePolys,
-                GeometryUtils.buildFeatureType("polygons", srs, Polygon.class),
-                fcs[1]);
+        if (l) {
+            job.addLin(shapeLines.getAbsolutePath());
+        }
+
+        boolean p = GeometryUtils.writeShapefile(
+            shapePolys,
+            GeometryUtils.buildFeatureType("polygons", srs, Polygon.class),
+            fcs[1]);
+
+        if (p) {
             job.addLin(shapePolys.getAbsolutePath());
         }
-        catch (MalformedURLException mue) {
-            logger.error("Error while writing shapefile: " + mue.getMessage());
-        }
-        catch (IOException ioe) {
-            logger.error("Error while writing shapefile: " + ioe.getMessage());
-        }
     }
 
 
@@ -379,19 +376,14 @@
 
         File axisShape = new File(dir, WSPLGEN_AXIS);
 
-        try {
-            GeometryUtils.writeShapefile(
-                axisShape,
-                GeometryUtils.buildFeatureType("axis", srs, LineString.class),
-                collection);
+        boolean a = GeometryUtils.writeShapefile(
+            axisShape,
+            GeometryUtils.buildFeatureType("axis", srs, LineString.class),
+            collection);
+
+        if (a) {
             job.setAxis(axisShape.getAbsolutePath());
         }
-        catch (MalformedURLException mue) {
-            logger.error("Error while writing shapefile: " + mue.getMessage());
-        }
-        catch (IOException ioe) {
-            logger.error("Error while writing shapefile: " + ioe.getMessage());
-        }
     }
 
 
@@ -427,20 +419,14 @@
 
         File qpsShape = new File(dir, WSPLGEN_QPS);
 
-        try {
-            GeometryUtils.writeShapefile(
-                qpsShape,
-                GeometryUtils.buildFeatureType(
-                    "qps", srs, LineString.class, attrs),
-                collection);
+        boolean q = GeometryUtils.writeShapefile(
+            qpsShape,
+            GeometryUtils.buildFeatureType("qps", srs, LineString.class, attrs),
+            collection);
+
+        if (q) {
             job.setPro(qpsShape.getAbsolutePath());
         }
-        catch (MalformedURLException mue) {
-            logger.error("Error while writing shapefile: " + mue.getMessage());
-        }
-        catch (IOException ioe) {
-            logger.error("Error while writing shapefile: " + ioe.getMessage());
-        }
     }
 
 
@@ -480,20 +466,14 @@
 
         File talaueShape = new File(dir, WSPLGEN_FLOODPLAIN);
 
-        try {
-            GeometryUtils.writeShapefile(
-                talaueShape,
-                GeometryUtils.buildFeatureType(
-                    "talaue", srs, MultiPolygon.class),
-                collection);
+        boolean t = GeometryUtils.writeShapefile(
+            talaueShape,
+            GeometryUtils.buildFeatureType("talaue", srs, MultiPolygon.class),
+            collection);
+
+        if (t) {
             job.setArea(talaueShape.getAbsolutePath());
         }
-        catch (MalformedURLException mue) {
-            logger.error("Error while writing shapefile: " + mue.getMessage());
-        }
-        catch (IOException ioe) {
-            logger.error("Error while writing shapefile: " + ioe.getMessage());
-        }
     }
 
 

http://dive4elements.wald.intevation.org