comparison artifacts/src/main/java/org/dive4elements/river/utils/MapfileGenerator.java @ 8202:e4606eae8ea5

sed src/**/*.java 's/logger/log/g'
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 05 Sep 2014 12:58:17 +0200
parents 81ae2a4873f2
children e9d912c97fa8
comparison
equal deleted inserted replaced
8201:4b8c5a08de04 8202:e4606eae8ea5
51 public static final String MS_LINE_PREFIX = "lines-"; 51 public static final String MS_LINE_PREFIX = "lines-";
52 public static final String MS_POLYGONS_PREFIX = "polygons-"; 52 public static final String MS_POLYGONS_PREFIX = "polygons-";
53 public static final String MS_LAYER_PREFIX = "ms_layer-"; 53 public static final String MS_LAYER_PREFIX = "ms_layer-";
54 public static final String MS_USERSHAPE_PREFIX = "user-"; 54 public static final String MS_USERSHAPE_PREFIX = "user-";
55 55
56 private static Logger logger = Logger.getLogger(MapfileGenerator.class); 56 private static Logger log = Logger.getLogger(MapfileGenerator.class);
57 57
58 private File shapefileDirectory; 58 private File shapefileDirectory;
59 59
60 private VelocityEngine velocityEngine; 60 private VelocityEngine velocityEngine;
61 61
89 velocityEngine = new VelocityEngine(); 89 velocityEngine = new VelocityEngine();
90 try { 90 try {
91 setupVelocity(velocityEngine); 91 setupVelocity(velocityEngine);
92 } 92 }
93 catch (Exception e) { 93 catch (Exception e) {
94 logger.error(e, e); 94 log.error(e, e);
95 return null; 95 return null;
96 } 96 }
97 } 97 }
98 return velocityEngine; 98 return velocityEngine;
99 } 99 }
144 context.put("CONFIGDIR", 144 context.put("CONFIGDIR",
145 Config.getConfigDirectory().getCanonicalPath()); 145 Config.getConfigDirectory().getCanonicalPath());
146 } 146 }
147 catch (FileNotFoundException fnfe) { 147 catch (FileNotFoundException fnfe) {
148 // this is bad 148 // this is bad
149 logger.warn(fnfe, fnfe); 149 log.warn(fnfe, fnfe);
150 } 150 }
151 catch (IOException ioe) { 151 catch (IOException ioe) {
152 // this is also bad 152 // this is also bad
153 logger.warn(ioe, ioe); 153 log.warn(ioe, ioe);
154 } 154 }
155 155
156 return context; 156 return context;
157 } 157 }
158 158
169 } 169 }
170 170
171 try { 171 try {
172 VelocityEngine engine = getVelocityEngine(); 172 VelocityEngine engine = getVelocityEngine();
173 if (engine == null) { 173 if (engine == null) {
174 logger.error("Error while fetching VelocityEngine."); 174 log.error("Error while fetching VelocityEngine.");
175 return null; 175 return null;
176 } 176 }
177 177
178 return engine.getTemplate(model); 178 return engine.getTemplate(model);
179 } 179 }
180 catch (Exception e) { 180 catch (Exception e) {
181 logger.warn(e, e); 181 log.warn(e, e);
182 } 182 }
183 183
184 return null; 184 return null;
185 } 185 }
186 186
266 for (File layer: layerFiles) { 266 for (File layer: layerFiles) {
267 try { 267 try {
268 layers.add(layer.getCanonicalPath()); 268 layers.add(layer.getCanonicalPath());
269 } 269 }
270 catch (IOException ioe) { 270 catch (IOException ioe) {
271 logger.warn(ioe, ioe); 271 log.warn(ioe, ioe);
272 } 272 }
273 } 273 }
274 } 274 }
275 275
276 return layers; 276 return layers;
294 File layerFile, 294 File layerFile,
295 Template tpl 295 Template tpl
296 ) 296 )
297 throws FileNotFoundException 297 throws FileNotFoundException
298 { 298 {
299 if (logger.isDebugEnabled()) { 299 if (log.isDebugEnabled()) {
300 logger.debug("Write layer for:"); 300 log.debug("Write layer for:");
301 logger.debug(" directory/file: " + layerFile.getName()); 301 log.debug(" directory/file: " + layerFile.getName());
302 } 302 }
303 303
304 Writer writer = null; 304 Writer writer = null;
305 305
306 try { 306 try {
310 context.put("LAYER", layerInfo); 310 context.put("LAYER", layerInfo);
311 311
312 tpl.merge(context, writer); 312 tpl.merge(context, writer);
313 } 313 }
314 catch (FileNotFoundException fnfe) { 314 catch (FileNotFoundException fnfe) {
315 logger.error(fnfe, fnfe); 315 log.error(fnfe, fnfe);
316 } 316 }
317 catch (IOException ioe) { 317 catch (IOException ioe) {
318 logger.error(ioe, ioe); 318 log.error(ioe, ioe);
319 } 319 }
320 catch (Exception e) { 320 catch (Exception e) {
321 logger.error(e, e); 321 log.error(e, e);
322 } 322 }
323 finally { 323 finally {
324 try { 324 try {
325 if (writer != null) { 325 if (writer != null) {
326 writer.close(); 326 writer.close();
327 } 327 }
328 } 328 }
329 catch (IOException ioe) { 329 catch (IOException ioe) {
330 logger.debug(ioe, ioe); 330 log.debug(ioe, ioe);
331 } 331 }
332 } 332 }
333 } 333 }
334 334
335 335
355 VelocityContext context = getVelocityContext(); 355 VelocityContext context = getVelocityContext();
356 context.put("LAYERS", layers); 356 context.put("LAYERS", layers);
357 357
358 Template mapTemplate = getMapfileTemplateObj(); 358 Template mapTemplate = getMapfileTemplateObj();
359 if (mapTemplate == null) { 359 if (mapTemplate == null) {
360 logger.warn("No mapfile template found."); 360 log.warn("No mapfile template found.");
361 return; 361 return;
362 } 362 }
363 363
364 mapTemplate.merge(context, writer); 364 mapTemplate.merge(context, writer);
365 365
367 // real mapfile because we don't run into race conditions on this 367 // real mapfile because we don't run into race conditions on this
368 // way. (iw) 368 // way. (iw)
369 tmp.renameTo(mapfile); 369 tmp.renameTo(mapfile);
370 } 370 }
371 catch (FileNotFoundException fnfe) { 371 catch (FileNotFoundException fnfe) {
372 logger.error(fnfe, fnfe); 372 log.error(fnfe, fnfe);
373 } 373 }
374 catch (IOException ioe) { 374 catch (IOException ioe) {
375 logger.error(ioe, ioe); 375 log.error(ioe, ioe);
376 } 376 }
377 catch (Exception e) { 377 catch (Exception e) {
378 logger.error(e, e); 378 log.error(e, e);
379 } 379 }
380 finally { 380 finally {
381 try { 381 try {
382 if (writer != null) { 382 if (writer != null) {
383 writer.close(); 383 writer.close();
386 if (tmp.exists()) { 386 if (tmp.exists()) {
387 tmp.delete(); 387 tmp.delete();
388 } 388 }
389 } 389 }
390 catch (IOException ioe) { 390 catch (IOException ioe) {
391 logger.debug(ioe, ioe); 391 log.debug(ioe, ioe);
392 } 392 }
393 } 393 }
394 } 394 }
395 } 395 }
396 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 396 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org