Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java @ 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 | 6eccb68a8b99 |
children | 9ba6bb85d6dd |
line wrap: on
line diff
--- 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); + } /**