# HG changeset patch # User Christian Lins # Date 1342176896 0 # Node ID 96daa8a4c48f463d7fba7dd4e16e489c16cdbd20 # Parent 453d2d0c4258cc3c4c4c329a0fd8e19334d100ff Fix and workaround NullPointerExceptions flys-artifacts/trunk@4988 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 453d2d0c4258 -r 96daa8a4c48f flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Fri Jul 13 10:44:18 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Jul 13 10:54:56 2012 +0000 @@ -1,3 +1,9 @@ +2012-07-13 Christian Lins + + * src/main/java/de/intevation/flys/utils/MapfileGenerator.java, + src/main/java/de/intevation/flys/utils/GeometryUtils.java: + Fix and workaround NullPointerExceptions. + 2012-07-13 Ingo Weinzierl * src/main/java/de/intevation/flys/wsplgen/WSPLGENCallable.java, @@ -10,8 +16,8 @@ src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java, src/main/java/de/intevation/flys/artifacts/MapArtifact.java, src/main/java/de/intevation/flys/utils/MapfileGenerator.java, - src/main/java/de/intevation/flys/exports/MapGenerator.java: Organized - and added missing imports. + src/main/java/de/intevation/flys/exports/MapGenerator.java: + Organized and added missing imports. 2012-07-13 Ingo Weinzierl diff -r 453d2d0c4258 -r 96daa8a4c48f flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java --- a/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java Fri Jul 13 10:44:18 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java Fri Jul 13 10:54:56 2012 +0000 @@ -76,7 +76,7 @@ public static String getRiverBounds(String rivername) { Envelope env = getRiverBoundary(rivername); - if (env == null) { + if (env != null) { return jtsBoundsToOLBounds(env); } @@ -91,11 +91,12 @@ * @return the OpenLayers boundary of env. */ public static String jtsBoundsToOLBounds(Envelope env) { - return "" + - env.getMinX() + " " + - env.getMinY() + " " + - env.getMaxX() + " " + - env.getMaxY(); + StringBuilder buf = new StringBuilder(); + buf.append(env.getMinX()); buf.append(' '); + buf.append(env.getMinY()); buf.append(' '); + buf.append(env.getMaxX()); buf.append(' '); + buf.append(env.getMaxY()); + return buf.toString(); } public static String createOLBounds(Geometry a, Geometry b) { diff -r 453d2d0c4258 -r 96daa8a4c48f flys-artifacts/src/main/java/de/intevation/flys/utils/MapfileGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/utils/MapfileGenerator.java Fri Jul 13 10:44:18 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/MapfileGenerator.java Fri Jul 13 10:54:56 2012 +0000 @@ -1,5 +1,14 @@ package de.intevation.flys.utils; +import de.intevation.artifacts.CallContext; +import de.intevation.artifacts.common.utils.Config; +import de.intevation.flys.artifacts.FLYSArtifact; +import de.intevation.flys.artifacts.model.LayerInfo; +import de.intevation.flys.artifacts.model.map.WMSDBLayerFacet; +import de.intevation.flys.artifacts.model.map.WMSLayerFacet; +import de.intevation.flys.artifacts.model.map.WSPLGENLayerFacet; +import de.intevation.flys.artifacts.resources.Resources; + import java.io.File; import java.io.FileNotFoundException; import java.io.FileWriter; @@ -18,15 +27,6 @@ import org.geotools.data.shapefile.shp.ShapefileHeader; import org.geotools.data.shapefile.shp.ShapefileReader; -import de.intevation.artifacts.CallContext; -import de.intevation.artifacts.common.utils.Config; -import de.intevation.flys.artifacts.FLYSArtifact; -import de.intevation.flys.artifacts.model.LayerInfo; -import de.intevation.flys.artifacts.model.map.WMSDBLayerFacet; -import de.intevation.flys.artifacts.model.map.WMSLayerFacet; -import de.intevation.flys.artifacts.model.map.WSPLGENLayerFacet; -import de.intevation.flys.artifacts.resources.Resources; - /** * This class iterates over a bunch of directories, searches for meta * information coresponding to shapefiles and creates a mapfile which is used by @@ -67,7 +67,7 @@ private String velocityLogfile; private VelocityEngine velocityEngine; - private boolean lock[]; + private final boolean lock[]; @@ -610,7 +610,9 @@ layerinfo.setData(wms.getData()); layerinfo.setTitle(wms.getDescription()); layerinfo.setStyle(style); - layerinfo.setExtent(GeometryUtils.jtsBoundsToOLBounds(wms.getExtent())); + if(wms.getExtent() != null) { + layerinfo.setExtent(GeometryUtils.jtsBoundsToOLBounds(wms.getExtent())); + } layerinfo.setConnection(wms.getConnection()); layerinfo.setConnectionType(wms.getConnectionType()); layerinfo.setLabelItem(wms.getLabelItem());