changeset 723:199982e8866e

Integrated ExceptionHandling if no Data was found for the given Layer. gnv-artifacts/trunk@753 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Tue, 09 Mar 2010 11:42:57 +0000
parents b98d1adee7a6
children 9ba6bb85d6dd
files gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java
diffstat 2 files changed, 30 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Mon Mar 08 15:15:08 2010 +0000
+++ b/gnv-artifacts/ChangeLog	Tue Mar 09 11:42:57 2010 +0000
@@ -1,3 +1,10 @@
+2010-03-09  Tim Englich  <tim.englich@intevation.de>
+
+	* src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java (out): 
+	  Integrated ExceptionHandling if no Data was found for the given Layer.
+	  If no data couuld be retrieved from the Database an XMl-Exceptionreport 
+	  will be generated which must be analized by the Clients.
+
 2010-03-08  Ingo Weinzierl <ingo.weinzierl@intevation.de>
 
 	  Issue186
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java	Mon Mar 08 15:15:08 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java	Tue Mar 09 11:42:57 2010 +0000
@@ -33,6 +33,7 @@
 import de.intevation.gnv.state.InputData;
 import de.intevation.gnv.state.OutputStateBase;
 import de.intevation.gnv.state.exception.StateException;
+import de.intevation.gnv.utils.ArtifactXMLUtilities;
 import de.intevation.gnv.utils.FileUtils;
 import de.intevation.gnv.utils.MapfileGenerator;
 import de.intevation.gnv.utils.MetaWriter;
@@ -102,12 +103,32 @@
                 format, XPATH_OUTPUT_MODE, ArtifactNamespaceContext.INSTANCE);
         if (outputMode.equalsIgnoreCase("wms")) {
             Collection<Result> data = this.fetchData();
-            XMLUtils.toStream(this.getWMS(uuid, callContext, data),outputStream);
+            if (data != null && !data.isEmpty()){
+                XMLUtils.toStream(this.getWMS(uuid, callContext, data),
+                                  outputStream);
+            }else{
+                this.writeExceptionReport2Stream(outputStream);
+            }
         }else if (outputMode.equalsIgnoreCase("zip")){
             Collection<Result> data = this.fetchData();
-            this.writeZip(uuid, callContext, outputStream, data);
+            if (data != null && !data.isEmpty()){
+                this.writeZip(uuid, callContext, outputStream, data);
+            }else{
+                this.writeExceptionReport2Stream(outputStream);
+            }
+            
         }
     }
+
+    /**
+     * @param outputStream
+     */
+    private void writeExceptionReport2Stream(OutputStream outputStream) {
+        Document document = XMLUtils.newDocument();
+        new ArtifactXMLUtilities().
+        createExceptionReport("No Data to Export", document);
+        XMLUtils.toStream(document,outputStream);
+    }
     
     
     /**

http://dive4elements.wald.intevation.org