Mercurial > dive4elements > gnv-client
comparison 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 |
comparison
equal
deleted
inserted
replaced
656:b98d1adee7a6 | 723:199982e8866e |
---|---|
31 import de.intevation.gnv.geobackend.base.query.exception.QueryException; | 31 import de.intevation.gnv.geobackend.base.query.exception.QueryException; |
32 import de.intevation.gnv.raster.PaletteManager; | 32 import de.intevation.gnv.raster.PaletteManager; |
33 import de.intevation.gnv.state.InputData; | 33 import de.intevation.gnv.state.InputData; |
34 import de.intevation.gnv.state.OutputStateBase; | 34 import de.intevation.gnv.state.OutputStateBase; |
35 import de.intevation.gnv.state.exception.StateException; | 35 import de.intevation.gnv.state.exception.StateException; |
36 import de.intevation.gnv.utils.ArtifactXMLUtilities; | |
36 import de.intevation.gnv.utils.FileUtils; | 37 import de.intevation.gnv.utils.FileUtils; |
37 import de.intevation.gnv.utils.MapfileGenerator; | 38 import de.intevation.gnv.utils.MapfileGenerator; |
38 import de.intevation.gnv.utils.MetaWriter; | 39 import de.intevation.gnv.utils.MetaWriter; |
39 import de.intevation.gnv.utils.ShapeFileWriter; | 40 import de.intevation.gnv.utils.ShapeFileWriter; |
40 | 41 |
100 log.debug("LayerOutputState.out"); | 101 log.debug("LayerOutputState.out"); |
101 String outputMode = XMLUtils.xpathString( | 102 String outputMode = XMLUtils.xpathString( |
102 format, XPATH_OUTPUT_MODE, ArtifactNamespaceContext.INSTANCE); | 103 format, XPATH_OUTPUT_MODE, ArtifactNamespaceContext.INSTANCE); |
103 if (outputMode.equalsIgnoreCase("wms")) { | 104 if (outputMode.equalsIgnoreCase("wms")) { |
104 Collection<Result> data = this.fetchData(); | 105 Collection<Result> data = this.fetchData(); |
105 XMLUtils.toStream(this.getWMS(uuid, callContext, data),outputStream); | 106 if (data != null && !data.isEmpty()){ |
107 XMLUtils.toStream(this.getWMS(uuid, callContext, data), | |
108 outputStream); | |
109 }else{ | |
110 this.writeExceptionReport2Stream(outputStream); | |
111 } | |
106 }else if (outputMode.equalsIgnoreCase("zip")){ | 112 }else if (outputMode.equalsIgnoreCase("zip")){ |
107 Collection<Result> data = this.fetchData(); | 113 Collection<Result> data = this.fetchData(); |
108 this.writeZip(uuid, callContext, outputStream, data); | 114 if (data != null && !data.isEmpty()){ |
109 } | 115 this.writeZip(uuid, callContext, outputStream, data); |
116 }else{ | |
117 this.writeExceptionReport2Stream(outputStream); | |
118 } | |
119 | |
120 } | |
121 } | |
122 | |
123 /** | |
124 * @param outputStream | |
125 */ | |
126 private void writeExceptionReport2Stream(OutputStream outputStream) { | |
127 Document document = XMLUtils.newDocument(); | |
128 new ArtifactXMLUtilities(). | |
129 createExceptionReport("No Data to Export", document); | |
130 XMLUtils.toStream(document,outputStream); | |
110 } | 131 } |
111 | 132 |
112 | 133 |
113 /** | 134 /** |
114 * Fetches the Data from the Databasebackend | 135 * Fetches the Data from the Databasebackend |