diff src/java/de/intevation/mxd/reader/SimpleRendererReader.java @ 116:c8a1361ddd38

Improved exceptionhandlin for renderer reader.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 15 Jun 2011 18:37:27 +0200
parents 59e06c405a9a
children a4ab239509f1
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/reader/SimpleRendererReader.java	Wed Jun 15 16:48:42 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/SimpleRendererReader.java	Wed Jun 15 18:37:27 2011 +0200
@@ -7,6 +7,7 @@
 import com.esri.arcgis.carto.SimpleRenderer;
 
 import org.w3c.dom.Element;
+import java.io.IOException;
 
 import de.intevation.mxd.utils.MapToXMLUtils;
 
@@ -67,39 +68,65 @@
      *
      * @return The XML node.
      */
-    public Element read()
-    throws Exception {
+    public Element read() {
         logger.debug("read()");
         Element rendererElement;
         rendererElement = util.addRenderer(layer);
 
-        rendererElement.setAttribute("label", renderer.getLabel());
-        rendererElement.setAttribute("description", renderer.getDescription());
-        symbol = renderer.getSymbol();
-
-        MarkerSymbolReader markerReader = new MarkerSymbolReader();
-        LineSymbolReader lineReader = new LineSymbolReader();
-        FillSymbolReader fillReader = new FillSymbolReader();
-        if(markerReader.canRead(symbol)) {
-            markerReader.setSymbol(symbol);
-            markerReader.setUtil(util);
-            markerReader.setParent(rendererElement);
-            markerReader.read();
+        try {
+            rendererElement.setAttribute("label", renderer.getLabel());
         }
-        else if(lineReader.canRead(symbol)) {
-            lineReader.setSymbol(symbol);
-            lineReader.setUtil(util);
-            lineReader.setParent(rendererElement);
-            lineReader.read();
+        catch(IOException ioe) {
+            logger.warn(
+                "Could not read label name." +
+                "Setting label name to \"default-label\"");
+            rendererElement.setAttribute("label", "default-label");
         }
-        else if(fillReader.canRead(symbol)) {
-            fillReader.setSymbol(symbol);
-            fillReader.setUtil(util);
-            fillReader.setParent(rendererElement);
-            fillReader.read();
+
+        try {
+            rendererElement.setAttribute(
+                "description",
+                renderer.getDescription());
         }
-        else {
-            logger.debug("No known Symbol type: " + symbol.getClass().toString());
+        catch(IOException ioe) {
+            logger.warn(
+                "Could not read description." +
+                " Setting empty description.");
+            rendererElement.setAttribute("description", "");
+        }
+
+        try {
+            symbol = renderer.getSymbol();
+
+            MarkerSymbolReader markerReader = new MarkerSymbolReader();
+            LineSymbolReader lineReader = new LineSymbolReader();
+            FillSymbolReader fillReader = new FillSymbolReader();
+            if(markerReader.canRead(symbol)) {
+                markerReader.setSymbol(symbol);
+                markerReader.setUtil(util);
+                markerReader.setParent(rendererElement);
+                markerReader.read();
+            }
+            else if(lineReader.canRead(symbol)) {
+                lineReader.setSymbol(symbol);
+                lineReader.setUtil(util);
+                lineReader.setParent(rendererElement);
+                lineReader.read();
+            }
+            else if(fillReader.canRead(symbol)) {
+                fillReader.setSymbol(symbol);
+                fillReader.setUtil(util);
+                fillReader.setParent(rendererElement);
+                fillReader.read();
+            }
+            else {
+                logger.debug(
+                    "No known Symbol type: " +
+                    symbol.getClass().toString());
+            }
+        }
+        catch(Exception e) {
+            logger.error("Could not read symbol. Stopped reading renderer.");
         }
         return layer;
     }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)