annotate flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java @ 5676:f8409fbe3b88

Request maps from osm.intevation.de by another url and fix dpi handling
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 12 Apr 2013 12:57:57 +0200
parents b28a6d05e969
children 413798463dfe
rev   line source
2502
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.server;
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
2504
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
3 import de.intevation.artifacts.common.ArtifactNamespaceContext;
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
4 import de.intevation.artifacts.common.utils.ClientProtocolUtils;
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
5 import de.intevation.artifacts.common.utils.JSON;
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
6 import de.intevation.artifacts.common.utils.StringUtils;
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
7 import de.intevation.artifacts.common.utils.XMLUtils;
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
8 import de.intevation.artifacts.httpclient.exceptions.ConnectionException;
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
9 import de.intevation.artifacts.httpclient.http.HttpClient;
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
10 import de.intevation.artifacts.httpclient.http.HttpClientImpl;
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
11 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler;
4436
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
12 import de.intevation.flys.client.shared.MapUtils;
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
13 import de.intevation.flys.client.shared.model.MapConfig;
4433
5b8919ef601d Backed out changeset e8a4d2fd25cc
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4424
diff changeset
14
4436
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
15 import java.io.IOException;
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
16 import java.io.InputStream;
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
17 import java.io.OutputStream;
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
18 import java.io.UnsupportedEncodingException;
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
19 import java.net.URLEncoder;
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
20 import java.util.ArrayList;
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
21 import java.util.Collections;
4474
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
22 import java.util.Enumeration;
4473
6db783627137 Map print does now submit additional parameters to MapPrintServiceImpl.
Christian Lins <christian.lins@intevation.de>
parents: 4472
diff changeset
23 import java.util.HashMap;
4436
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
24 import java.util.LinkedHashMap;
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
25 import java.util.List;
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
26 import java.util.Map;
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
27
4436
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
28 import javax.servlet.ServletException;
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
29 import javax.servlet.http.HttpServlet;
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
30 import javax.servlet.http.HttpServletRequest;
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
31 import javax.servlet.http.HttpServletResponse;
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
32
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
33 import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
34 import org.apache.commons.httpclient.methods.GetMethod;
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
35 import org.apache.log4j.Logger;
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
36 import org.w3c.dom.Document;
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
37 import org.w3c.dom.Element;
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
38 import org.w3c.dom.NodeList;
4433
5b8919ef601d Backed out changeset e8a4d2fd25cc
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4424
diff changeset
39 /*
5b8919ef601d Backed out changeset e8a4d2fd25cc
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4424
diff changeset
40 import java.io.BufferedInputStream;
5b8919ef601d Backed out changeset e8a4d2fd25cc
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4424
diff changeset
41 import java.io.BufferedOutputStream;
5b8919ef601d Backed out changeset e8a4d2fd25cc
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4424
diff changeset
42 import java.io.File;
5b8919ef601d Backed out changeset e8a4d2fd25cc
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4424
diff changeset
43 import java.io.FileInputStream;
5b8919ef601d Backed out changeset e8a4d2fd25cc
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4424
diff changeset
44 import java.io.FileOutputStream;
5b8919ef601d Backed out changeset e8a4d2fd25cc
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4424
diff changeset
45 */
2519
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
46 /* Used by direct API call. -> Enforce GPLv3
2502
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 import org.mapfish.print.MapPrinter;
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 import org.mapfish.print.output.OutputFactory;
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 import org.mapfish.print.output.OutputFormat;
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 import org.mapfish.print.utils.PJsonObject;
2905
51ed89b754ae FLYS client: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2519
diff changeset
52 */
2502
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 public class MapPrintServiceImpl
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 extends HttpServlet
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 {
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 private static final Logger log =
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 Logger.getLogger(MapPrintServiceImpl.class);
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
60 protected static class Layer implements Comparable<Layer> {
2504
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
61
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
62 protected int pos;
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
63 protected String url;
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
64 protected String layers;
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
65 protected String description;
2504
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
66
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
67 public Layer() {
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
68 }
2504
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
69
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
70 public boolean setup(Element element) {
2504
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
71
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
72 Element parent = (Element)element.getParentNode();
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
73 String parentName = parent.getAttribute("name");
2905
51ed89b754ae FLYS client: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2519
diff changeset
74 if (!(parentName.equals("map")
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
75 || parentName.equals("floodmap"))) {
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
76 return false;
2504
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
77 }
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
78
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
79 String ns = ArtifactNamespaceContext.NAMESPACE_URI;
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
80
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
81 String visible = element.getAttributeNS(ns, "visible");
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
82 String active = element.getAttributeNS(ns, "active");
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
83
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
84 if (visible.equals("0") || active.equals("0")) {
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
85 return false;
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
86 }
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
87
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
88 url = element.getAttributeNS(ns, "url");
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
89 layers = element.getAttributeNS(ns, "layers");
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
90 description = element.getAttributeNS(ns, "description");
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
91
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
92 try {
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
93 pos = Integer.parseInt(element.getAttributeNS(ns, "pos"));
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
94 }
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
95 catch (NumberFormatException nfe) {
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
96 return false;
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
97 }
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
98
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
99 return true;
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
100 }
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
101
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
102 public Map<String, Object> toMap() {
2504
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
103 Map<String, Object> layer = new LinkedHashMap<String, Object>();
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
104
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
105 layer.put("type", "WMS");
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
106 List<Object> subLayers = new ArrayList<Object>(1);
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
107 subLayers.add(layers);
2504
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
108 layer.put("layers", subLayers);
5676
f8409fbe3b88 Request maps from osm.intevation.de by another url and fix dpi handling
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
109 // XXX: osm.intevation.de mapache only offers low dpi maps
f8409fbe3b88 Request maps from osm.intevation.de by another url and fix dpi handling
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
110 // so we need to use the uncached service
f8409fbe3b88 Request maps from osm.intevation.de by another url and fix dpi handling
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
111 layer.put("baseURL", url.replace("http://osm.intevation.de/mapcache/?",
f8409fbe3b88 Request maps from osm.intevation.de by another url and fix dpi handling
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
112 "http://osm.intevation.de/cgi-bin/germany.fcgi?"));
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
113 layer.put("format", "image/png"); // TODO: Make configurable.
2504
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
114
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
115 return layer;
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
116 }
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
117
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
118 @Override
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
119 public int compareTo(Layer other) {
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
120 int d = pos - other.pos;
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
121 if (d < 0) return -1;
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
122 return d > 0 ? +1 : 0;
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
123 }
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
124 } // class Layer
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
125
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
126 protected static String generateSpec(
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
127 Document descDocument,
2508
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
128 MapConfig mapConfig,
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
129 Double minX, Double minY,
4473
6db783627137 Map print does now submit additional parameters to MapPrintServiceImpl.
Christian Lins <christian.lins@intevation.de>
parents: 4472
diff changeset
130 Double maxX, Double maxY,
4474
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
131 Map<String, Object> pageSpecs
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
132 ) {
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
133 Map<String, Object> spec = new LinkedHashMap<String, Object>();
5676
f8409fbe3b88 Request maps from osm.intevation.de by another url and fix dpi handling
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
134 int dpi = 254;
4969
555fa2774d3c Map printing in landscape mode. Layout still buggy.
Christian Lins <christian.lins@intevation.de>
parents: 4525
diff changeset
135 spec.put("layout", "A4 landscape");
4474
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
136 spec.put("pageSize", "A4");
5676
f8409fbe3b88 Request maps from osm.intevation.de by another url and fix dpi handling
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
137 spec.put("landscape", "true");
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
138 spec.put("srs", "EPSG:" + mapConfig.getSrid());
5676
f8409fbe3b88 Request maps from osm.intevation.de by another url and fix dpi handling
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
139 spec.put("dpi", dpi);
2508
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
140 spec.put("units", "m");
2510
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
141 spec.put("geodaetic", "true");
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
142 spec.put("outputFormat", "pdf");
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
143
4474
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
144 spec.putAll(pageSpecs);
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
145
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
146 String ns = ArtifactNamespaceContext.NAMESPACE_URI;
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
147
2510
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
148 List<Layer> ls = new ArrayList<Layer>();
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents: 4436
diff changeset
149 Layer l = new Layer();
2510
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
150
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents: 4436
diff changeset
151 NodeList facets = descDocument.getElementsByTagNameNS(ns, "facet");
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents: 4436
diff changeset
152
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents: 4436
diff changeset
153 for (int i = 0, N = facets.getLength(); i < N; ++i) {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents: 4436
diff changeset
154 Element element = (Element)facets.item(i);
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents: 4436
diff changeset
155 if (l.setup(element)) {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents: 4436
diff changeset
156 ls.add(l);
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents: 4436
diff changeset
157 l = new Layer();
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
158 }
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
159 }
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
160
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
161 // Establish Z order.
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
162 Collections.sort(ls);
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
163
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
164 List<Object> layers = new ArrayList<Object>(ls.size());
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
165
2510
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
166 for (int i = ls.size()-1; i >= 0; --i) {
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
167 layers.add(ls.get(i).toMap());
2504
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
168 }
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
169
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
170 spec.put("layers", layers);
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
171 spec.put("name", "Name");
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
172
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
173 List<Object> pages = new ArrayList<Object>(1);
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
174
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
175
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
176 Map<String, Object> page = new LinkedHashMap<String, Object>();
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
177
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
178 List<Object> bounds = new ArrayList<Object>(4);
2510
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
179 bounds.add(minX);
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
180 bounds.add(minY);
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
181 bounds.add(maxX);
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
182 bounds.add(maxY);
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
183 page.put("bbox", bounds);
2504
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
184
2510
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
185 /*
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
186 bounds.add(Double.valueOf((minX+maxX)*0.5));
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
187 bounds.add(Double.valueOf((minY+maxY)*0.5));
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
188
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
189 page.put("center", bounds);
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
190 page.put("scale", Integer.valueOf(50000));
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
191 */
2504
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
192
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
193 page.put("rotation", Integer.valueOf(0));
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
194
4473
6db783627137 Map print does now submit additional parameters to MapPrintServiceImpl.
Christian Lins <christian.lins@intevation.de>
parents: 4472
diff changeset
195 // This may overwrite default settings above
4474
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
196 page.putAll(pageSpecs);
4473
6db783627137 Map print does now submit additional parameters to MapPrintServiceImpl.
Christian Lins <christian.lins@intevation.de>
parents: 4472
diff changeset
197
2504
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
198 pages.add(page);
2510
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
199 spec.put("pages", pages);
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
200
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
201 List<Object> legends = new ArrayList<Object>(layers.size());
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
202
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
203 for (Layer layer: ls) {
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
204 Map<String, Object> legend = new LinkedHashMap<String, Object>();
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
205 List<Object> classes = new ArrayList<Object>(1);
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
206 Map<String, Object> clazz = new LinkedHashMap<String, Object>();
5676
f8409fbe3b88 Request maps from osm.intevation.de by another url and fix dpi handling
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
207 String lgu = MapUtils.getLegendGraphicUrl(layer.url, layer.layers, dpi);
2510
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
208 clazz.put("icon", lgu);
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
209 clazz.put("name", layer.description);
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
210 classes.add(clazz);
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
211 legend.put("classes", classes);
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
212 legend.put("name", layer.description);
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
213 legends.add(legend);
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
214 }
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
215
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
216 spec.put("legends", legends);
2504
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
217
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
218 return JSON.toJSONString(spec);
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
219 }
2502
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
220
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
221
2503
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
222 @Override
2905
51ed89b754ae FLYS client: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2519
diff changeset
223 public void doGet(HttpServletRequest req, HttpServletResponse resp)
2503
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
224 throws ServletException, IOException
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
225 {
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
226 log.info("MapPrintServiceImpl.doGet");
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
227
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
228 String uuid = req.getParameter("uuid");
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
229
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
230 if (uuid == null || !StringUtils.checkUUID(uuid)) {
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
231 throw new ServletException("Missing or misspelled UUID");
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
232 }
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
233
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
234 String minXS = req.getParameter("minx");
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
235 String maxXS = req.getParameter("maxx");
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
236 String minYS = req.getParameter("miny");
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
237 String maxYS = req.getParameter("maxy");
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
238
2508
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
239 Double minX = null;
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
240 Double maxX = null;
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
241 Double minY = null;
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
242 Double maxY = null;
2503
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
243
2508
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
244 if (minXS != null && maxXS != null
2515
532c590beb3e Fixed problem with selecting the wrong map scale for printing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2510
diff changeset
245 && minYS != null && maxYS != null) {
532c590beb3e Fixed problem with selecting the wrong map scale for printing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2510
diff changeset
246 log.debug("all parameters found -> parsing");
2508
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
247 try {
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
248 minX = Double.parseDouble(minXS);
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
249 minY = Double.parseDouble(minYS);
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
250 maxX = Double.parseDouble(maxXS);
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
251 maxY = Double.parseDouble(maxYS);
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
252 }
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
253 catch (NumberFormatException nfe) {
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
254 throw new ServletException("Misspelled minX, minY, maxX or maxY");
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
255 }
2503
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
256 }
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
257
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
258 String mapType = req.getParameter("maptype");
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
259
2508
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
260 if (mapType == null || !mapType.equals("floodmap")) {
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
261 mapType = "map";
2503
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
262 }
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
263
4473
6db783627137 Map print does now submit additional parameters to MapPrintServiceImpl.
Christian Lins <christian.lins@intevation.de>
parents: 4472
diff changeset
264 // Retrieve print settings from request
4474
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
265 Map<String, Object> pageSpecs = new HashMap<String, Object>();
5622
b28a6d05e969 Add a new mechanism in mapfish print call to add arbitary data maps
Andre Heinecke <aheinecke@intevation.de>
parents: 5620
diff changeset
266 Map<String, Object> data = new HashMap<String, Object>();
b28a6d05e969 Add a new mechanism in mapfish print call to add arbitary data maps
Andre Heinecke <aheinecke@intevation.de>
parents: 5620
diff changeset
267 List<Object> payload = new ArrayList<Object>();
b28a6d05e969 Add a new mechanism in mapfish print call to add arbitary data maps
Andre Heinecke <aheinecke@intevation.de>
parents: 5620
diff changeset
268 data.put("data", payload);
4474
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
269 Enumeration<String> paramNames = req.getParameterNames();
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
270 while (paramNames.hasMoreElements()) {
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
271 String paramName = paramNames.nextElement();
5622
b28a6d05e969 Add a new mechanism in mapfish print call to add arbitary data maps
Andre Heinecke <aheinecke@intevation.de>
parents: 5620
diff changeset
272 if (paramName.startsWith("mapfish-data-")) {
b28a6d05e969 Add a new mechanism in mapfish print call to add arbitary data maps
Andre Heinecke <aheinecke@intevation.de>
parents: 5620
diff changeset
273 // You can add mapfish-data variables that will be mapped
b28a6d05e969 Add a new mechanism in mapfish print call to add arbitary data maps
Andre Heinecke <aheinecke@intevation.de>
parents: 5620
diff changeset
274 // to a info value pairs to provide meta data for the map
b28a6d05e969 Add a new mechanism in mapfish print call to add arbitary data maps
Andre Heinecke <aheinecke@intevation.de>
parents: 5620
diff changeset
275 String paramValue = req.getParameter(paramName);
b28a6d05e969 Add a new mechanism in mapfish print call to add arbitary data maps
Andre Heinecke <aheinecke@intevation.de>
parents: 5620
diff changeset
276 if (paramValue != null && !paramValue.isEmpty()) {
b28a6d05e969 Add a new mechanism in mapfish print call to add arbitary data maps
Andre Heinecke <aheinecke@intevation.de>
parents: 5620
diff changeset
277 Map<String, Object> data3 = new HashMap<String, Object>();
b28a6d05e969 Add a new mechanism in mapfish print call to add arbitary data maps
Andre Heinecke <aheinecke@intevation.de>
parents: 5620
diff changeset
278 data3.put("info", paramName.substring(13));
b28a6d05e969 Add a new mechanism in mapfish print call to add arbitary data maps
Andre Heinecke <aheinecke@intevation.de>
parents: 5620
diff changeset
279 data3.put("value", paramValue);
b28a6d05e969 Add a new mechanism in mapfish print call to add arbitary data maps
Andre Heinecke <aheinecke@intevation.de>
parents: 5620
diff changeset
280 payload.add(data3);
b28a6d05e969 Add a new mechanism in mapfish print call to add arbitary data maps
Andre Heinecke <aheinecke@intevation.de>
parents: 5620
diff changeset
281 }
b28a6d05e969 Add a new mechanism in mapfish print call to add arbitary data maps
Andre Heinecke <aheinecke@intevation.de>
parents: 5620
diff changeset
282 } else if (paramName.startsWith("mapfish-")) {
4474
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
283 String paramValue = req.getParameter(paramName);
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
284 pageSpecs.put(paramName.substring(8), paramValue);
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
285 }
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
286 }
5622
b28a6d05e969 Add a new mechanism in mapfish print call to add arbitary data maps
Andre Heinecke <aheinecke@intevation.de>
parents: 5620
diff changeset
287 if (!payload.isEmpty()) {
b28a6d05e969 Add a new mechanism in mapfish print call to add arbitary data maps
Andre Heinecke <aheinecke@intevation.de>
parents: 5620
diff changeset
288 pageSpecs.put("data", data);
b28a6d05e969 Add a new mechanism in mapfish print call to add arbitary data maps
Andre Heinecke <aheinecke@intevation.de>
parents: 5620
diff changeset
289 List<Object> columns = new ArrayList<Object>();
b28a6d05e969 Add a new mechanism in mapfish print call to add arbitary data maps
Andre Heinecke <aheinecke@intevation.de>
parents: 5620
diff changeset
290 columns.add("info");
b28a6d05e969 Add a new mechanism in mapfish print call to add arbitary data maps
Andre Heinecke <aheinecke@intevation.de>
parents: 5620
diff changeset
291 columns.add("value");
b28a6d05e969 Add a new mechanism in mapfish print call to add arbitary data maps
Andre Heinecke <aheinecke@intevation.de>
parents: 5620
diff changeset
292 data.put("columns", columns);
b28a6d05e969 Add a new mechanism in mapfish print call to add arbitary data maps
Andre Heinecke <aheinecke@intevation.de>
parents: 5620
diff changeset
293 }
4473
6db783627137 Map print does now submit additional parameters to MapPrintServiceImpl.
Christian Lins <christian.lins@intevation.de>
parents: 4472
diff changeset
294
2503
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
295 String url = getURL();
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
296
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
297 Document requestOut =
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
298 ClientProtocolUtils.newOutCollectionDocument(
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
299 uuid, mapType, mapType);
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
300 Document requestDesc =
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
301 ClientProtocolUtils.newDescribeCollectionDocument(uuid);
2503
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
302
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
303 Document outDocument;
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
304 Document descDocument;
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
305
2503
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
306 try {
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
307 HttpClient client = new HttpClientImpl(url);
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
308
2508
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
309 descDocument = (Document)client.doCollectionAction(
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
310 requestDesc, uuid, new DocumentResponseHandler());
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
311
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
312 InputStream is = client.collectionOut(
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
313 requestOut, uuid, mapType);
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
314
2503
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
315 try {
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
316 outDocument = XMLUtils.parseDocument(is);
2503
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
317 }
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
318 finally {
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
319 is.close();
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
320 is = null;
2503
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
321 }
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
322
2503
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
323 }
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
324 catch (ConnectionException ce) {
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
325 log.error(ce);
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
326 throw new ServletException(ce);
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
327 }
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
328
2508
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
329 MapConfig mapConfig = MapHelper.parseConfig(outDocument);
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
330
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
331 if (minX == null) {
2515
532c590beb3e Fixed problem with selecting the wrong map scale for printing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2510
diff changeset
332 log.debug("parameters missing -> fallback to max extent");
2508
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
333 String [] parts = mapConfig.getMaxExtent().split("\\s+");
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
334 if (parts.length < 4) {
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
335 throw new ServletException(
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
336 "Max extent has less than 4 values");
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
337 }
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
338 try {
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
339 minX = Double.valueOf(parts[0]);
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
340 minY = Double.valueOf(parts[1]);
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
341 maxX = Double.valueOf(parts[2]);
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
342 maxY = Double.valueOf(parts[3]);
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
343 }
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
344 catch (NumberFormatException nfe) {
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
345 throw new ServletException(nfe);
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
346 }
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
347 }
2510
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
348 if (log.isDebugEnabled()) {
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
349 log.debug("minX: " + minX);
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
350 log.debug("maxX: " + maxX);
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
351 log.debug("minY: " + minY);
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
352 log.debug("maxY: " + maxY);
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
353 }
2508
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
354
2504
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
355 String spec = generateSpec(
2506
47d07709ba09 Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2504
diff changeset
356 descDocument,
2508
4aa70825bde1 map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2506
diff changeset
357 mapConfig,
2504
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
358 minX, minY,
4473
6db783627137 Map print does now submit additional parameters to MapPrintServiceImpl.
Christian Lins <christian.lins@intevation.de>
parents: 4472
diff changeset
359 maxX, maxY,
4474
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
360 pageSpecs);
2503
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
361
2504
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
362 if (log.isDebugEnabled()) {
2510
4861ab2c28d2 map print: add legend
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2508
diff changeset
363 log.debug("Generated spec:");
2504
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
364 log.debug(spec);
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
365 //System.err.println(spec);
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
366 }
2503
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
367
2504
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
368 producePDF(spec, resp);
2503
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
369 }
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
370
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
371 protected String getURL() throws ServletException {
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
372 String url = getServletContext().getInitParameter("server-url");
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
373 if (url == null) {
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
374 throw new ServletException("Missing server-url");
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
375 }
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
376 return url;
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
377 }
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
378
2519
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
379 private static final String encode(String s) {
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
380 try {
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
381 return URLEncoder.encode(s, "UTF-8");
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
382 }
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
383 catch (UnsupportedEncodingException usee) {
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
384 // Should not happen.
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
385 return s;
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
386 }
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
387 }
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
388
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
389 protected void producePDF(String json, HttpServletResponse resp)
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
390 throws ServletException, IOException
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
391 {
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
392 String printUrl = getInitParameter("print-url");
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
393
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
394 if (printUrl == null) {
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
395 throw new ServletException("Missing 'print-url' in web.xml");
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
396 }
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
397
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
398 String url = printUrl + "/print.pdf?spec=" + encode(json);
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
399
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
400 org.apache.commons.httpclient.HttpClient client =
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
401 new org.apache.commons.httpclient.HttpClient(
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
402 new MultiThreadedHttpConnectionManager());
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
403
4436
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
404 // FIXME: The request is not authenticated.
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
405 // Currently this is not a problem because /flys/map-print
9fca4d60fb7c Reintroduce wrongly outbacked changes (rev 4418-4425).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
406 // is whitelisted in GGInAFilter.
2519
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
407 GetMethod get = new GetMethod(url);
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
408 int result = client.executeMethod(get);
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
409 InputStream in = get.getResponseBodyAsStream();
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
410
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
411 if (in != null) {
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
412 try {
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
413 OutputStream out = resp.getOutputStream();
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
414 try {
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
415 byte [] buf = new byte[4096];
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
416 int r;
5600
8128622e4b28 Set filename for the response
Andre Heinecke <aheinecke@intevation.de>
parents: 4969
diff changeset
417 resp.setHeader("Content-Disposition",
8128622e4b28 Set filename for the response
Andre Heinecke <aheinecke@intevation.de>
parents: 4969
diff changeset
418 "attachment;filename=flys-karte.pdf");
5607
6e0d122904f9 Explicitly set the content type for the pdf download.
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
419 resp.setContentType("application/pdf");
2519
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
420 while ((r = in.read(buf)) >= 0) {
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
421 out.write(buf, 0, r);
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
422 }
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
423 out.flush();
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
424 }
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
425 finally {
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
426 out.close();
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
427 }
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
428 }
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
429 finally {
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
430 in.close();
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
431 }
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
432 }
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
433 }
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
434
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
435 /* Use this if you want directly call the MapPrinter. Enforces GPLv3!
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
436
2503
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
437 protected MapPrinter getMapPrinter() throws ServletException, IOException {
2502
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
438 String configPath = getInitParameter("config");
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
439 if (configPath == null) {
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
440 throw new ServletException("Missing configuration in web.xml");
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
441 }
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
442
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
443 File configFile = new File(configPath);
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
444 if (!configFile.isAbsolute()) {
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
445 configFile = new File(getServletContext().getRealPath(configPath));
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
446 }
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
447
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
448 if (!configFile.isFile() || !configFile.canRead()) {
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
449 throw new ServletException("Cannot read '" + configFile + "'");
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
450 }
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
451
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
452 return new MapPrinter(configFile);
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
453 }
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
454
2503
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
455 protected void producePDF(String json, HttpServletResponse resp)
e3bd1f412421 Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2502
diff changeset
456 throws ServletException, IOException
2502
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
457 {
2504
425bc486a40f Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2503
diff changeset
458 PJsonObject jsonSpec = MapPrinter.parseSpec(json);
2502
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
459
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
460 MapPrinter printer = getMapPrinter();
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
461
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
462 OutputFormat outputFormat = OutputFactory.create(
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
463 printer.getConfig(), jsonSpec);
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
464
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
465 resp.setHeader("Content-Disposition", "attachment;filename=print.pdf");
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
466 resp.setHeader("Content-Type", "application/pdf");
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
467
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
468 // XXX: Streaming the generated PDF directly
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
469 // to the request out does not work. :-/
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
470 File tmpFile = File.createTempFile("map-printing", null);
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
471
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
472 try {
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
473 OutputStream out =
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
474 new BufferedOutputStream(
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
475 new FileOutputStream(tmpFile));
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
476 try {
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
477 outputFormat.print(printer, jsonSpec, out, "");
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
478 out.flush();
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
479 }
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
480 catch (Exception e) {
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
481 log.error(e);
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
482 throw new ServletException(e);
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
483 }
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
484 finally {
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
485 printer.stop();
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
486 out.close();
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
487 }
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
488 InputStream in =
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
489 new BufferedInputStream(
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
490 new FileInputStream(tmpFile));
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
491 out = resp.getOutputStream();
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
492 try {
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
493 byte [] buf = new byte[4096];
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
494 int r;
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
495 while ((r = in.read(buf)) >= 0) {
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
496 out.write(buf, 0, r);
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
497 }
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
498 out.flush();
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
499 }
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
500 finally {
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
501 in.close();
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
502 out.close();
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
503 }
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
504 }
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
505 finally {
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
506 if (tmpFile.exists()) {
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
507 tmpFile.delete();
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
508 }
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
509 }
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
510 }
2519
427df4e81af0 Call MapFish Printer via servlet to evade viral GPLv3.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2515
diff changeset
511 */
2502
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
512 }
328aa273ef3b Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
513 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org