Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java @ 2509:3952429cc41b
Added zoom listener a adjust the print link bbox.
flys-client/trunk@4364 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 09 May 2012 13:15:26 +0000 |
parents | 4aa70825bde1 |
children | 4861ab2c28d2 |
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 |
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.ClientProtocolUtils; |
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.JSON; |
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.StringUtils; |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
8 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
|
9 |
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.exceptions.ConnectionException; |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
11 |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
12 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
|
13 import de.intevation.artifacts.httpclient.http.HttpClientImpl; |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
14 |
2506
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
15 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
16 |
2504
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
17 import de.intevation.flys.client.shared.model.MapConfig; |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
18 |
2506
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
19 import java.io.BufferedInputStream; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
20 import java.io.BufferedOutputStream; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
21 import java.io.File; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
22 import java.io.FileInputStream; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
23 import java.io.FileOutputStream; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
24 import java.io.IOException; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
25 import java.io.InputStream; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
26 import java.io.OutputStream; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
27 |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
28 import java.util.ArrayList; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
29 import java.util.Collections; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
30 import java.util.LinkedHashMap; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
31 import java.util.List; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
32 import java.util.Map; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
33 |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
34 import javax.servlet.ServletException; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
35 |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
36 import javax.servlet.http.HttpServlet; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
37 import javax.servlet.http.HttpServletRequest; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
38 import javax.servlet.http.HttpServletResponse; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
39 |
2502
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 import org.apache.log4j.Logger; |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 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
|
43 |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 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
|
45 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
|
46 |
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.utils.PJsonObject; |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 |
2503
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
49 import org.w3c.dom.Document; |
2504
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
50 import org.w3c.dom.Element; |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
51 import org.w3c.dom.NodeList; |
2503
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
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 public class MapPrintServiceImpl |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 extends HttpServlet |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 { |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 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
|
57 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
|
58 |
2506
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
59 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
|
60 |
2506
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
61 protected int pos; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
62 protected String url; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
63 protected String layers; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
64 protected String description; |
2504
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
65 |
2506
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
66 public Layer() { |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
67 } |
2504
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
68 |
2506
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
69 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
|
70 |
2506
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
71 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
|
72 String parentName = parent.getAttribute("name"); |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
73 if (!(parentName.equals("map") |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
74 || parentName.equals("floodmap"))) { |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
75 return false; |
2504
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
76 } |
2506
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
77 |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
78 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
|
79 |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
80 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
|
81 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
|
82 |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
83 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
|
84 return false; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
85 } |
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 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
|
88 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
|
89 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
|
90 |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
91 try { |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
92 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
|
93 } |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
94 catch (NumberFormatException nfe) { |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
95 return false; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
96 } |
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 return true; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
99 } |
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 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
|
102 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
|
103 |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
104 layer.put("type", "WMS"); |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
105 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
|
106 subLayers.add(layers); |
2504
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
107 layer.put("layers", subLayers); |
2506
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
108 layer.put("baseURL", url); |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
109 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
|
110 |
2506
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
111 return layer; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
112 } |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
113 |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
114 @Override |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
115 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
|
116 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
|
117 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
|
118 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
|
119 } |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
120 } // class Layer |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
121 |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
122 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
|
123 Document descDocument, |
2508
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
124 MapConfig mapConfig, |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
125 Double minX, Double minY, |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
126 Double maxX, Double maxY |
2506
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
127 ) { |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
128 Map<String, Object> spec = new LinkedHashMap<String, Object>(); |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
129 spec.put("layout", "A4 portrait"); |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
130 spec.put("title", "FLYS Druck"); |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
131 spec.put("srs", "EPSG:" + mapConfig.getSrid()); |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
132 spec.put("dpi", Integer.valueOf(254)); |
2508
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
133 spec.put("units", "m"); |
2506
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
134 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
|
135 |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
136 |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
137 List<Layer> ls = new ArrayList<Layer>(); |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
138 Layer l = new Layer(); |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
139 |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
140 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
|
141 NodeList facets = descDocument.getElementsByTagNameNS(ns, "facet"); |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
142 |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
143 for (int i = 0, N = facets.getLength(); i < N; ++i) { |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
144 Element element = (Element)facets.item(i); |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
145 if (l.setup(element)) { |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
146 ls.add(l); |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
147 l = new Layer(); |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
148 } |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
149 } |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
150 |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
151 // Establish Z order. |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
152 Collections.sort(ls); |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
153 |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
154 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
|
155 |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
156 for (Layer layer: ls) { |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
157 layers.add(layer.toMap()); |
2504
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
158 } |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
159 |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
160 spec.put("layers", layers); |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
161 spec.put("name", "Name"); |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
162 |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
163 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
|
164 |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
165 spec.put("pages", pages); |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
166 |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
167 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
|
168 |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
169 List<Object> bounds = new ArrayList<Object>(4); |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
170 bounds.add(Double.valueOf(minX)); |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
171 bounds.add(Double.valueOf(minY)); |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
172 bounds.add(Double.valueOf(maxX)); |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
173 bounds.add(Double.valueOf(maxY)); |
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 page.put("bbox", bounds); |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
176 |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
177 page.put("mapTitle", "FLYS Karte"); |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
178 page.put("comment", "Eine mit FLYS gedruckte Karte."); |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
179 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
|
180 |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
181 pages.add(page); |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
182 |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
183 return JSON.toJSONString(spec); |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
184 } |
2502
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
185 |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
186 |
2503
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
187 @Override |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
188 public void doGet(HttpServletRequest req, HttpServletResponse resp) |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
189 throws ServletException, IOException |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
190 { |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
191 log.info("MapPrintServiceImpl.doGet"); |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
192 |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
193 String uuid = req.getParameter("uuid"); |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
194 |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
195 if (uuid == null || !StringUtils.checkUUID(uuid)) { |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
196 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
|
197 } |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
198 |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
199 String minXS = req.getParameter("minx"); |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
200 String maxXS = req.getParameter("maxx"); |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
201 String minYS = req.getParameter("miny"); |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
202 String maxYS = req.getParameter("maxy"); |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
203 |
2508
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
204 Double minX = null; |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
205 Double maxX = null; |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
206 Double minY = null; |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
207 Double maxY = null; |
2503
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
208 |
2508
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
209 if (minXS != null && maxXS != null |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
210 && minYS != null && maxYS == null) { |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
211 try { |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
212 minX = Double.parseDouble(minXS); |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
213 minY = Double.parseDouble(minYS); |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
214 maxX = Double.parseDouble(maxXS); |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
215 maxY = Double.parseDouble(maxYS); |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
216 } |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
217 catch (NumberFormatException nfe) { |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
218 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
|
219 } |
2503
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
220 } |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
221 |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
222 String mapType = req.getParameter("maptype"); |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
223 |
2508
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
224 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
|
225 mapType = "map"; |
2503
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
226 } |
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 url = getURL(); |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
229 |
2506
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
230 Document requestOut = |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
231 ClientProtocolUtils.newOutCollectionDocument( |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
232 uuid, mapType, mapType); |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
233 Document requestDesc = |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
234 ClientProtocolUtils.newDescribeCollectionDocument(uuid); |
2503
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
235 |
2506
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
236 Document outDocument; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
237 Document descDocument; |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
238 |
2503
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
239 try { |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
240 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
|
241 |
2508
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
242 descDocument = (Document)client.doCollectionAction( |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
243 requestDesc, uuid, new DocumentResponseHandler()); |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
244 |
2506
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
245 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
|
246 requestOut, uuid, mapType); |
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
247 |
2503
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
248 try { |
2506
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
249 outDocument = XMLUtils.parseDocument(is); |
2503
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
250 } |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
251 finally { |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
252 is.close(); |
2506
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
diff
changeset
|
253 is = null; |
2503
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
254 } |
2506
47d07709ba09
Printing: extract layer order and visibility from collections describe.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2504
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 catch (ConnectionException ce) { |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
258 log.error(ce); |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
259 throw new ServletException(ce); |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
260 } |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
261 |
2508
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
262 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
|
263 |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
264 if (minX == null) { |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
265 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
|
266 if (parts.length < 4) { |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
267 throw new ServletException( |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
268 "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
|
269 } |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
270 try { |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
271 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
|
272 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
|
273 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
|
274 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
|
275 } |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
276 catch (NumberFormatException nfe) { |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
277 throw new ServletException(nfe); |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
278 } |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
279 } |
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
280 |
2504
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
281 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
|
282 descDocument, |
2508
4aa70825bde1
map print: generate valid url to access service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2506
diff
changeset
|
283 mapConfig, |
2504
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
284 minX, minY, |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
285 maxX, maxY); |
2503
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
286 |
2504
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
287 if (log.isDebugEnabled()) { |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
288 log.debug(spec); |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
289 //System.err.println(spec); |
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
290 } |
2503
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
291 |
2504
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
292 producePDF(spec, resp); |
2503
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
293 } |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
294 |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
295 protected String getURL() throws ServletException { |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
296 String url = getServletContext().getInitParameter("server-url"); |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
297 if (url == null) { |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
298 throw new ServletException("Missing server-url"); |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
299 } |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
300 return url; |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
301 } |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
302 |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
303 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
|
304 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
|
305 if (configPath == null) { |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
306 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
|
307 } |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
308 |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
309 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
|
310 if (!configFile.isAbsolute()) { |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
311 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
|
312 } |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
313 |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
314 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
|
315 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
|
316 } |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
317 |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
318 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
|
319 } |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
320 |
2503
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
321 |
e3bd1f412421
Added GET parameters to map printer
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2502
diff
changeset
|
322 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
|
323 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
|
324 { |
2504
425bc486a40f
Generate map print spec dynamically from artifact
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2503
diff
changeset
|
325 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
|
326 |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
327 MapPrinter printer = getMapPrinter(); |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
328 |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
329 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
|
330 printer.getConfig(), jsonSpec); |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
331 |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
332 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
|
333 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
|
334 |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
335 // 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
|
336 // 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
|
337 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
|
338 |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
339 try { |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
340 OutputStream out = |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
341 new BufferedOutputStream( |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
342 new FileOutputStream(tmpFile)); |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
343 try { |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
344 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
|
345 out.flush(); |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
346 } |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
347 catch (Exception e) { |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
348 log.error(e); |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
349 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
|
350 } |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
351 finally { |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
352 printer.stop(); |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
353 out.close(); |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
354 } |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
355 InputStream in = |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
356 new BufferedInputStream( |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
357 new FileInputStream(tmpFile)); |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
358 out = resp.getOutputStream(); |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
359 try { |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
360 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
|
361 int r; |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
362 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
|
363 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
|
364 } |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
365 out.flush(); |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
366 } |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
367 finally { |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
368 in.close(); |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
369 out.close(); |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
370 } |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
371 } |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
372 finally { |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
373 if (tmpFile.exists()) { |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
374 tmpFile.delete(); |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
375 } |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
376 } |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
377 } |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
378 } |
328aa273ef3b
Call MapPrinter directly and not via the MapFish Print servlet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
379 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |