Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/utils/MetaWriter.java @ 730:452fad121560
Implemented code for changing the title of a wms layer (issue198).
gnv-artifacts/trunk@768 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 15 Mar 2010 11:13:21 +0000 |
parents | 6eccb68a8b99 |
children | cd64ab8a46a7 |
comparison
equal
deleted
inserted
replaced
729:d23ad22bcfe7 | 730:452fad121560 |
---|---|
29 | 29 |
30 public static final String META_FILE_NAME = "meta.xml"; | 30 public static final String META_FILE_NAME = "meta.xml"; |
31 public static final String ISOLINES_NAME = "isolines.shp"; | 31 public static final String ISOLINES_NAME = "isolines.shp"; |
32 public static final String POLYGON_NAME = "polygons.shp"; | 32 public static final String POLYGON_NAME = "polygons.shp"; |
33 public static final String LAYER_DATA_NAME = "data.shp"; | 33 public static final String LAYER_DATA_NAME = "data.shp"; |
34 | |
35 public static final String CONTEXT_LAYER_TITLE = "wms.title"; | |
34 | 36 |
35 private MetaWriter() { | 37 private MetaWriter() { |
36 } | 38 } |
37 | 39 |
38 public static Document writeLayerMeta(CallContext context, | 40 public static Document writeLayerMeta(CallContext context, |
93 */ | 95 */ |
94 private static boolean writeMetaFile(String path, Document meta) { | 96 private static boolean writeMetaFile(String path, Document meta) { |
95 try { | 97 try { |
96 File metaFile = new File(path, META_FILE_NAME); | 98 File metaFile = new File(path, META_FILE_NAME); |
97 | 99 |
100 if (metaFile.exists()) { | |
101 logger.info("Delete old meta information file."); | |
102 metaFile.delete(); | |
103 } | |
104 | |
98 if (!metaFile.createNewFile() || !metaFile.canWrite()) { | 105 if (!metaFile.createNewFile() || !metaFile.canWrite()) { |
99 logger.error("Error while writing meta file: "+metaFile.toString()); | 106 logger.error("Error while writing meta file: "+metaFile.toString()); |
100 return false; | 107 return false; |
101 } | 108 } |
102 | 109 |
196 layer.appendChild(status); | 203 layer.appendChild(status); |
197 layer.appendChild(data); | 204 layer.appendChild(data); |
198 | 205 |
199 meta.appendChild(layer); | 206 meta.appendChild(layer); |
200 } | 207 } |
201 | |
202 | |
203 | 208 |
204 | 209 |
205 public static void writePolygonMeta( | 210 public static void writePolygonMeta( |
206 CallContext context, | 211 CallContext context, |
207 Document document, | 212 Document document, |
216 ArtifactNamespaceContext.NAMESPACE_PREFIX); | 221 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
217 | 222 |
218 Element layer = creator.create(LayerInfo.LAYER); | 223 Element layer = creator.create(LayerInfo.LAYER); |
219 Element model = creator.create(LayerInfo.LAYER_MODEL); | 224 Element model = creator.create(LayerInfo.LAYER_MODEL); |
220 Element name = creator.create(LayerInfo.LAYER_NAME); | 225 Element name = creator.create(LayerInfo.LAYER_NAME); |
226 Element title = creator.create(LayerInfo.LAYER_TITLE); | |
221 Element type = creator.create(LayerInfo.LAYER_TYPE); | 227 Element type = creator.create(LayerInfo.LAYER_TYPE); |
222 Element status = creator.create(LayerInfo.LAYER_STATUS); | 228 Element status = creator.create(LayerInfo.LAYER_STATUS); |
223 Element data = creator.create(LayerInfo.LAYER_DATA); | 229 Element data = creator.create(LayerInfo.LAYER_DATA); |
224 | 230 |
225 model.setTextContent(paramType); | 231 model.setTextContent(paramType); |
226 name.setTextContent(uuid); | 232 name.setTextContent(uuid); |
233 title.setTextContent( | |
234 (String) context.getContextValue(CONTEXT_LAYER_TITLE)); | |
227 type.setTextContent("POLYGON"); | 235 type.setTextContent("POLYGON"); |
228 status.setTextContent("OFF"); | 236 status.setTextContent("OFF"); |
229 data.setTextContent(POLYGON_NAME); | 237 data.setTextContent(POLYGON_NAME); |
230 | 238 |
231 layer.appendChild(model); | 239 layer.appendChild(model); |
232 layer.appendChild(name); | 240 layer.appendChild(name); |
241 layer.appendChild(title); | |
233 layer.appendChild(type); | 242 layer.appendChild(type); |
234 layer.appendChild(status); | 243 layer.appendChild(status); |
235 layer.appendChild(data); | 244 layer.appendChild(data); |
236 | 245 |
237 meta.appendChild(layer); | 246 meta.appendChild(layer); |
252 ArtifactNamespaceContext.NAMESPACE_PREFIX); | 261 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
253 | 262 |
254 Element layer = creator.create(LayerInfo.LAYER); | 263 Element layer = creator.create(LayerInfo.LAYER); |
255 Element model = creator.create(LayerInfo.LAYER_MODEL); | 264 Element model = creator.create(LayerInfo.LAYER_MODEL); |
256 Element name = creator.create(LayerInfo.LAYER_NAME); | 265 Element name = creator.create(LayerInfo.LAYER_NAME); |
266 Element title = creator.create(LayerInfo.LAYER_TITLE); | |
257 Element type = creator.create(LayerInfo.LAYER_TYPE); | 267 Element type = creator.create(LayerInfo.LAYER_TYPE); |
258 Element status = creator.create(LayerInfo.LAYER_STATUS); | 268 Element status = creator.create(LayerInfo.LAYER_STATUS); |
259 Element data = creator.create(LayerInfo.LAYER_DATA); | 269 Element data = creator.create(LayerInfo.LAYER_DATA); |
260 | 270 |
261 model.setTextContent(paramType+"_isolines"); | 271 model.setTextContent(paramType+"_isolines"); |
262 name.setTextContent(uuid); | 272 name.setTextContent(uuid); |
273 title.setTextContent( | |
274 (String) context.getContextValue(CONTEXT_LAYER_TITLE)); | |
263 type.setTextContent("LINE"); | 275 type.setTextContent("LINE"); |
264 status.setTextContent("OFF"); | 276 status.setTextContent("OFF"); |
265 data.setTextContent(ISOLINES_NAME); | 277 data.setTextContent(ISOLINES_NAME); |
266 | 278 |
267 layer.appendChild(model); | 279 layer.appendChild(model); |
268 layer.appendChild(name); | 280 layer.appendChild(name); |
281 layer.appendChild(title); | |
269 layer.appendChild(type); | 282 layer.appendChild(type); |
270 layer.appendChild(status); | 283 layer.appendChild(status); |
271 layer.appendChild(data); | 284 layer.appendChild(data); |
272 | 285 |
273 meta.appendChild(layer); | 286 meta.appendChild(layer); |